deviceDetail.vue 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  1. <template>
  2. <!-- 设备详情 -->
  3. <view class="content">
  4. <view class="name_box">
  5. <view class="name_content">{{ devInfo.devName }}</view>
  6. </view>
  7. <view class="radar-box">
  8. <view
  9. :style="{
  10. width: `${length / 200}px`,
  11. height: `${width / 200}px`,
  12. position: 'relative',
  13. left: `${xOffset / 100}rpx`,
  14. top: `${yOffset / 100}rpx`,
  15. overflow: 'hidden',
  16. }"
  17. :class="[
  18. width < 25500 && length < 25000 ? 'tranStyle' : 'center',
  19. ]"
  20. >
  21. <view
  22. v-for="(item, index) in modules"
  23. :key="index"
  24. class="moduleContent"
  25. >
  26. <view
  27. :class="item.type"
  28. :style="{
  29. width: `${item.width / 2}px`,
  30. height: `${item.length / 2}px`,
  31. top: `${item.top / 2}px`,
  32. left: `${item.left / 2}px`,
  33. transform: `rotate(${item.rotate}deg)`,
  34. 'transform-origin': 'center center',
  35. }"
  36. >
  37. <image
  38. class="module-img"
  39. :src="`../../static/furnitures/${item.type}.png`"
  40. mode=""
  41. />
  42. </view>
  43. </view>
  44. <template v-if="devType == 'LNB'">
  45. <view v-for="(item, index) in targetPoints" :key="index">
  46. <image
  47. class="action-icon-M"
  48. :style="{
  49. position: 'absolute',
  50. transform: `translate3d(${
  51. item.displayX / 2 + 100
  52. }px, ${
  53. -item.displayY / 2 + 100
  54. }px, 0) translate(-50%, -50%)`,
  55. zIndex: 9999,
  56. transition: 'transform 1s linear',
  57. willChange: 'transform',
  58. }"
  59. :src="`../../static/${lnbAction}.png`"
  60. mode=""
  61. />
  62. </view>
  63. </template>
  64. <template v-else>
  65. <image
  66. v-if="actionName"
  67. class="action-icon-G"
  68. :style="{
  69. top: `${top / 200}px`,
  70. left: `${left / 200}px`,
  71. }"
  72. :src="`../../images/furnitures/${actionName}.png`"
  73. mode=""
  74. />
  75. </template>
  76. </view>
  77. </view>
  78. <view class="switchBox">
  79. <text class="name">呼吸灯</text>
  80. <switch
  81. :value="statusLight"
  82. @change="handleLightChange"
  83. :active-value="1"
  84. :inactive-value="0"
  85. size="24px"
  86. active-color="#07c160"
  87. inactive-color="#eeeff1"
  88. style="transform: scale(0.8)"
  89. />
  90. </view>
  91. <view class="notice-info">
  92. <text style="color: #95a4b3; font-size: 28rpx">{{
  93. todayDate
  94. }}</text>
  95. <view class="title" v-if="devInfo.installPosition == 'Toilet'">
  96. <view class="title-text" style="color: #22dea7"
  97. >今日卫生间使用频次</view
  98. >
  99. <view class="title-btn" style="color: #22dea7"
  100. >{{ endArr.length == "" ? "0" : endArr.length }}次</view
  101. >
  102. </view>
  103. <view class="title" v-if="devInfo.installPosition != 'Toilet'">
  104. <view class="title-text" style="color: #22dea7"
  105. >今日进出频次</view
  106. >
  107. <view class="title-btn" style="color: #22dea7"
  108. >{{ endArr.length == "" ? "0" : endArr.length }}次</view
  109. >
  110. </view>
  111. <view
  112. class="stayDetail"
  113. v-if="endArr.length > 0 && endArr.length == 1"
  114. >
  115. <view v-for="item in endArr" :key="item.id">
  116. <view class="stayDetail-item">
  117. <view class="stayDetail-text"
  118. >{{ item.enterTime }}目标进入</view
  119. >
  120. <view class="stayDetail-btn"
  121. >{{ item.leaveTime }}目标离开</view
  122. >
  123. </view>
  124. </view>
  125. </view>
  126. <view
  127. class="stayDetail"
  128. v-if="endArr.length > 0 && endArr.length > 1"
  129. >
  130. <swiper
  131. class="auto-scroll-swiper"
  132. :indicator-dots="false"
  133. :autoplay="false"
  134. :interval="3000"
  135. :circular="true"
  136. :display-multiple-items="1"
  137. :vertical="false"
  138. :current="currentIndex"
  139. @change="onSwiperChange"
  140. >
  141. <swiper-item
  142. v-for="item in endArr"
  143. :key="item.id"
  144. class="stayDetail-item"
  145. >
  146. <view class="stayDetail-text"
  147. >{{ item.enterTime }}目标进入</view
  148. >
  149. <view class="stayDetail-btn"
  150. >{{ item.leaveTime }}目标离开</view
  151. >
  152. </swiper-item>
  153. </swiper>
  154. </view>
  155. <view class="title" v-if="devInfo.installPosition == 'Toilet'">
  156. <view class="title-text" style="color: #ff976a"
  157. >昨日卫生间使用频次</view
  158. >
  159. <view class="title-btn" style="color: #ff976a"
  160. >{{ endArr.length == "" ? "0" : endArr.length }}次</view
  161. >
  162. </view>
  163. <view class="title" v-else>
  164. <view class="title-text" style="color: #ff976a"
  165. >昨日进出频次</view
  166. >
  167. <view class="title-btn" style="color: #ff976a"
  168. >{{ endArr.length == "" ? "0" : endArr.length }}次</view
  169. >
  170. </view>
  171. </view>
  172. <view class="box">
  173. <view class="handle-btn">
  174. <view class="btn1" @click="shareDevice">分享</view>
  175. <view class="btn1" @click="gotoSetting">设置</view>
  176. <view class="btn2" @click="healthAlarm"> 健康闹钟 </view>
  177. </view>
  178. </view>
  179. <!-- 遮罩层 -->
  180. <view class="mask" v-if="shareModel" @click="shareModel = false"></view>
  181. <!-- 弹窗内容 -->
  182. <view class="share-modal" v-if="shareModel">
  183. <view class="modal-header">
  184. <text class="cancel-btn" @click="shareModel = false">取消</text>
  185. <text class="modal-title">分享</text>
  186. <text class="confirm-btn" @click="onShareConfirm()">确认</text>
  187. </view>
  188. <view class="modal-body">
  189. <view class="info-row">
  190. <view class="label">设备序列号:</view>
  191. <view class="value">{{ devInfo.clientId }}</view>
  192. </view>
  193. <view class="info-row">
  194. <view class="label">设备名称:</view>
  195. <view class="value">{{ devInfo.devName }}</view>
  196. </view>
  197. <view class="input-row phoneInfo">
  198. <view>被分享人</view>
  199. <input
  200. class="input"
  201. placeholder="请输入手机号"
  202. type="number"
  203. v-model="sharedPhone"
  204. />
  205. </view>
  206. <view class="funChoice">
  207. <view class="funItem" @click="smChange()">
  208. <label class="simple-radio"
  209. ><radio
  210. :value="messageFlag"
  211. color="#7c5345"
  212. :checked="messageFlag == true"
  213. class="hide-original"
  214. />
  215. <text>短信权限</text></label
  216. >
  217. </view>
  218. <view class="funItem">
  219. <label class="simple-radio" @click="snChange()"
  220. ><radio
  221. :value="serviceNumberFlag"
  222. color="#7c5345"
  223. :checked="serviceNumberFlag == true"
  224. class="hide-original"
  225. />
  226. <text>服务号通知</text></label
  227. >
  228. </view>
  229. <view class="funItem">
  230. <label class="simple-radio" @click="vfChange()"
  231. ><radio
  232. :value="voipFlag"
  233. color="#7c5345"
  234. :checked="voipFlag == true"
  235. class="hide-original"
  236. />
  237. <text>语音通话</text></label
  238. ></view
  239. >
  240. </view>
  241. </view>
  242. </view>
  243. <view class="modal-mask" v-if="choiceVisible" @click="closeChoice">
  244. <view class="modal-container">
  245. <view class="modal-header">
  246. <text class="title">请选择分享方式</text>
  247. </view>
  248. <view class="modal-buttons">
  249. <!-- 手机号分析按钮 -->
  250. <button class="btn phone-btn" @click="handlePhoneAnalysis">
  251. <text>手机号分享</text>
  252. </button>
  253. <!-- 链接分享按钮 -->
  254. <button class="btn link-btn" @click="handleLinkShare">
  255. <text>链接分享</text>
  256. </button>
  257. </view>
  258. </view>
  259. </view>
  260. <alarModel />
  261. </view>
  262. </template>
  263. <script>
  264. import mqtt from "../../utils/mqtt";
  265. export default {
  266. data() {
  267. return {
  268. width: 0, //检测区域宽度
  269. length: 0, //检测区域长度
  270. xOffset: 0,
  271. yOffset: 0,
  272. devInfo: "",
  273. actionName: "",
  274. startDate: "",
  275. endDate: "",
  276. softWare: "",
  277. targetPoints: [],
  278. statusLight: 0,
  279. currentDate: new Date().getTime(),
  280. lnbAction: "action8",
  281. wsj: false,
  282. todayWcTimes: "",
  283. stayDetail: "",
  284. todayDate: "",
  285. dev_id: "",
  286. nowTime: "",
  287. devName: "",
  288. devType: "",
  289. localPhone: uni.getStorageSync("phone"),
  290. startArr: [],
  291. endArr: [],
  292. // mqtt相关
  293. mqttClient: "",
  294. // voip相关
  295. // isWmpf: isWmpf,
  296. name: "用户",
  297. voipDevices: [],
  298. authorizeFlag: "",
  299. sn: "",
  300. isShowPopUp: false,
  301. contactList: [],
  302. // isWmpf,
  303. // envVersion,
  304. // apiTypesValid: (isWmpf ? apiTypesWMPF : apiTypesWechat).map(
  305. // (id) => apiTypes[id]
  306. // ),
  307. apiTypeIndex: 0,
  308. currentIndex: 0,
  309. modules: [],
  310. autoPlayinterval: "",
  311. choiceVisible: "",
  312. // 手机号分享授权模块
  313. shareModel: false,
  314. alarmModel: false,
  315. sharedPhone: "",
  316. messageFlag: true,
  317. serviceNumberFlag: true,
  318. voipFlag: true,
  319. inactivityTimer: "",
  320. };
  321. },
  322. computed: {},
  323. methods: {
  324. getdevInfo(devId) {
  325. this.$http
  326. .get(`wap/device/queryDeviceInfoById/${devId}`, {})
  327. .then((res) => {
  328. if (res.data.data) {
  329. this.devInfo = res.data.data;
  330. this.devType = this.devInfo.devType;
  331. this.width =
  332. Math.abs(
  333. this.devInfo.yyEnd - this.devInfo.yyStart
  334. ) * 100;
  335. this.length =
  336. Math.abs(
  337. this.devInfo.xxEnd - this.devInfo.xxStart
  338. ) * 100;
  339. this.xOffset =
  340. (this.devInfo.xxStart + this.devInfo.xxEnd) * 50;
  341. this.yOffset =
  342. -(this.devInfo.yyStart + this.devInfo.yyEnd) * 50;
  343. this.statusLight = this.devInfo.statusLight;
  344. }
  345. })
  346. .catch((err) => {});
  347. },
  348. getdevRoomInfo(devId) {
  349. this.$http
  350. .get(`wap/room/readRoom`, {
  351. devId: devId,
  352. })
  353. .then((res) => {
  354. if (res.data.data) {
  355. this.modules = res.data.data.furnitures;
  356. }
  357. });
  358. },
  359. handleLightChange(e) {
  360. let newValue = e.detail.value == true ? 1 : 0;
  361. this.$http
  362. .post(`wap/device/statusLight`, {
  363. statusLight: newValue,
  364. devId: this.devInfo.devId,
  365. })
  366. .then((res) => {
  367. if (res.data.code == 200) {
  368. uni.showToast({
  369. title: "操作成功",
  370. icon: "success",
  371. });
  372. this.statusLight = newValue;
  373. } else {
  374. wx.showToast({
  375. title: res.data.message,
  376. icon: "none",
  377. });
  378. }
  379. });
  380. },
  381. connectMQTT(clientId, devId) {
  382. const THRESHOLD = 2;
  383. const params = {
  384. keepalive: 60,
  385. clean: true,
  386. connectTimeout: 30 * 1000,
  387. clientId:
  388. "wx_mqtt_" + Math.random().toString(16).substring(2, 8),
  389. username: "admin",
  390. password: "public",
  391. // 微信小程序特定配置
  392. wsOptions: {
  393. WebSocket: function (url) {
  394. return wx.connectSocket({
  395. url: url,
  396. header: {
  397. "content-type": "application/json",
  398. },
  399. protocols: ["mqtt"],
  400. });
  401. },
  402. },
  403. rejectUnauthorized: false, // 仅开发环境使用,生产环境应设为true或移除
  404. };
  405. let client = "";
  406. let selectedService = uni.getStorageSync("sercviceChoice");
  407. if (!selectedService || selectedService == "aloneServe") {
  408. client = mqtt.connect("wxs://radar-power.cn:8084/mqtt", params);
  409. }
  410. // 存储client引用以便后续操作
  411. this.mqttClient = client;
  412. client.on("connect", () => {
  413. console.log("MQTT连接成功");
  414. client.subscribe(`/mps/${clientId}/realtime_pos`, (err) => {
  415. if (err) {
  416. console.error("订阅失败", err);
  417. } else {
  418. console.log(`成功订阅设备主题: device/${clientId}`);
  419. }
  420. });
  421. });
  422. client.on("disconnect", () => {
  423. console.log("MQTT不在连接");
  424. });
  425. client.on("error", (err) => {
  426. // console.error("MQTT连接错误", err);
  427. setTimeout(() => {
  428. // console.log("尝试重新连接MQTT...");
  429. this.connectMQTT(clientId, devId);
  430. }, 5000);
  431. });
  432. client.on("reconnect", () => {
  433. // console.log("MQTT正在重新连接...");
  434. });
  435. client.on("close", () => {
  436. // console.log("MQTT连接已关闭");
  437. });
  438. client.on("message", (topic, message) => {
  439. clearTimeout(this.inactivityTimer);
  440. this.inactivityTimer = setTimeout(() => {
  441. this.targetPoints = {};
  442. console.log("长时间没有点位,消除");
  443. }, 1500);
  444. const match = topic.match(/^\/mps\/(.+)\/realtime_pos$/);
  445. if (!match) return;
  446. const msgDevId = match[1];
  447. if (msgDevId !== clientId) return; // 只处理当前设备
  448. try {
  449. const data = JSON.parse(message.toString());
  450. // console.log(data, 9999);
  451. const arr = data.targetPoints;
  452. this.left = arr[0];
  453. this.top = arr[1];
  454. if (arr.length > 0) {
  455. const currentIds = new Set();
  456. arr.forEach((item) => {
  457. if (item.length < 4) return;
  458. const [x, y, z, id] = item;
  459. currentIds.add(id);
  460. if (!(id in this.targetPoints)) {
  461. this.targetPoints[id] = {
  462. x,
  463. y,
  464. z,
  465. id,
  466. displayX: x,
  467. displayY: y,
  468. lastX: x,
  469. lastY: y,
  470. };
  471. }
  472. // 去抖动
  473. const dx = x - this.targetPoints[id].lastX;
  474. const dy = y - this.targetPoints[id].lastY;
  475. if (Math.sqrt(dx * dx + dy * dy) > THRESHOLD) {
  476. this.targetPoints[id].x = x;
  477. this.targetPoints[id].y = y;
  478. this.targetPoints[id].z = z;
  479. this.targetPoints[id].lastX = x;
  480. this.targetPoints[id].lastY = y;
  481. this.targetPoints[id].displayX = x;
  482. this.targetPoints[id].displayY = y;
  483. }
  484. });
  485. console.log("🚀🚀🚀🚀targets", this.targetPoints);
  486. }
  487. } catch (e) {
  488. // console.error("MQTT消息解析失败", e);
  489. }
  490. });
  491. },
  492. parseDeviceItem(devItemStr) {
  493. try {
  494. const devItem = JSON.parse(devItemStr);
  495. if (!devItem || !devItem.devId || !devItem.clientId) {
  496. throw new Error("设备信息不完整");
  497. }
  498. return devItem;
  499. } catch (e) {
  500. throw new Error("设备信息解析失败: " + e.message);
  501. }
  502. },
  503. // 分享功能模块
  504. shareDevice() {
  505. this.choiceVisible = true;
  506. },
  507. onShareConfirm() {
  508. if (!this.sharedPhone) {
  509. uni.showModal({
  510. content: "请填写手机号!",
  511. showCancel: false,
  512. });
  513. return;
  514. }
  515. let reg_tel =
  516. /^(13[0-9]|14[01456879]|15[0-3,5-9]|16[2567]|17[0-8]|18[0-9]|19[0-3,5-9])\d{8}$/;
  517. if (!reg_tel.test(this.sharedPhone)) {
  518. uni.showModal({
  519. content: "请填写正确手机号!",
  520. showCancel: false,
  521. });
  522. return;
  523. }
  524. let shareParam = {
  525. sharerUserId: uni.getStorageSync("userId"),
  526. devId: this.devInfo.devId,
  527. sharerPhone: uni.getStorageSync("phone"),
  528. sharedUserId: "",
  529. sharedPhone: this.sharedPhone,
  530. messageFlag: this.messageFlag == true ? 0 : 1,
  531. serviceNumberFlag: this.serviceNumberFlag == true ? 0 : 1,
  532. voipFlag: this.voipFlag == true ? 0 : 1,
  533. };
  534. this.$http
  535. .post("wap/share/deviceShare", shareParam, {
  536. header: {
  537. "Content-Type": "application/json;charset=UTF-8",
  538. },
  539. })
  540. .then((res) => {
  541. if (res.data.code == 200) {
  542. uni.showToast({
  543. title: "分享成功",
  544. icon: "success",
  545. duration: 1500,
  546. });
  547. } else {
  548. uni.showToast({
  549. title: res.data.message,
  550. icon: "none",
  551. duration: 1500,
  552. });
  553. }
  554. });
  555. this.shareModel = false;
  556. },
  557. closeChoice() {
  558. this.choiceVisible = false;
  559. },
  560. handlePhoneAnalysis() {
  561. this.choiceVisible = false;
  562. this.shareModel = true;
  563. },
  564. handleLinkShare() {
  565. this.choiceVisible = false;
  566. uni.navigateTo({
  567. url:
  568. "/pagesA/linkShare/linkShare?devInfo=" +
  569. JSON.stringify(this.devInfo),
  570. });
  571. },
  572. smChange() {
  573. this.messageFlag = !this.messageFlag;
  574. },
  575. snChange() {
  576. this.serviceNumberFlag = !this.serviceNumberFlag;
  577. },
  578. vfChange() {
  579. this.voipFlag = !this.voipFlag;
  580. },
  581. gotoSetting() {
  582. uni.navigateTo({
  583. url:
  584. "/pagesA/deviceSetting/deviceSetting?devInfo=" +
  585. JSON.stringify(this.devInfo),
  586. });
  587. },
  588. getFrequency(devId) {
  589. let now = new Date();
  590. let startDate = this.timestampToTime(
  591. new Date(
  592. now.getFullYear(),
  593. now.getMonth(),
  594. now.getDate() - 1
  595. ).getTime()
  596. );
  597. let endDate = this.timestampToTime(
  598. new Date(
  599. now.getFullYear(),
  600. now.getMonth(),
  601. now.getDate()
  602. ).getTime()
  603. );
  604. this.$http
  605. .post(`wap/device/getUsedInfo`, {
  606. devId: devId,
  607. startDate: startDate,
  608. endDate: endDate,
  609. })
  610. .then((res) => {
  611. if (res.data.code == 200) {
  612. if (
  613. res.data.data.stayTimes &&
  614. res.data.data.stayTimes.length > 0
  615. ) {
  616. this.startArr = res.data.data.stayTimes.filter(
  617. (item) => item.enterTime.startsWith(startDate)
  618. );
  619. this.endArr = res.data.data.stayTimes.filter(
  620. (item) => item.enterTime.startsWith(endDate)
  621. );
  622. }
  623. if (this.startArr.length > 0) {
  624. this.startArr.forEach((item) => {
  625. item.enterTime = item.enterTime
  626. .slice(11)
  627. .slice(0, 5);
  628. item.leaveTime = item.leaveTime
  629. .slice(11)
  630. .slice(0, 5);
  631. });
  632. }
  633. if (this.endArr.length > 0) {
  634. this.endArr.forEach((item) => {
  635. item.enterTime = item.enterTime
  636. .slice(11)
  637. .slice(0, 5);
  638. item.leaveTime = item.leaveTime
  639. .slice(11)
  640. .slice(0, 5);
  641. });
  642. }
  643. } else {
  644. wx.showToast({
  645. title: res.data.message,
  646. icon: "none",
  647. });
  648. }
  649. });
  650. },
  651. // 健康闹钟方法
  652. healthAlarm() {
  653. uni.showToast({
  654. title: "该功能正在开发中,敬请期待",
  655. icon: "none",
  656. duration: 1500,
  657. });
  658. },
  659. // 循环播放进出
  660. timestampToTime(value, type = 0) {
  661. var time = new Date(value);
  662. var year = time.getFullYear();
  663. var month = time.getMonth() + 1;
  664. var date = time.getDate();
  665. var hour = time.getHours();
  666. var minute = time.getMinutes();
  667. var second = time.getSeconds();
  668. month = month < 10 ? "0" + month : month;
  669. date = date < 10 ? "0" + date : date;
  670. hour = hour < 10 ? "0" + hour : hour;
  671. minute = minute < 10 ? "0" + minute : minute;
  672. second = second < 10 ? "0" + second : second;
  673. var arr = [
  674. year + "-" + month + "-" + date,
  675. year +
  676. "-" +
  677. month +
  678. "-" +
  679. date +
  680. " " +
  681. hour +
  682. ":" +
  683. minute +
  684. ":" +
  685. second,
  686. year + "年" + month + "月" + date + "日",
  687. year +
  688. "年" +
  689. month +
  690. "月" +
  691. date +
  692. " " +
  693. hour +
  694. ":" +
  695. minute +
  696. ":" +
  697. second,
  698. hour + ":" + minute + ":" + second,
  699. year + "-" + month + "-" + date + " " + hour + ":" + minute,
  700. month + "月" + date + "日" + hour + ":" + minute,
  701. ];
  702. return arr[type];
  703. },
  704. onSwiperChange(event) {
  705. const current = event.detail.current;
  706. const totalItems = this.endArr.length;
  707. if (current === totalItems - 1) {
  708. this.autoplay = false;
  709. }
  710. this.currentIndex = current;
  711. },
  712. autoSwipe() {
  713. if (this.endArr && this.endArr.length > 0) {
  714. setInterval(() => {
  715. let nextIndex = this.currentIndex + 1;
  716. if (nextIndex >= this.endArr.length) {
  717. nextIndex = 0; // 循环到第一个项目
  718. }
  719. this.currentIndex = nextIndex;
  720. }, 3000); // 每3秒自动滚动一次
  721. }
  722. },
  723. },
  724. onLoad(options) {
  725. try {
  726. const devItem = this.parseDeviceItem(options.devItem);
  727. const { devId, clientId } = devItem;
  728. Promise.all([this.getdevInfo(devId), this.getdevRoomInfo(devId)])
  729. .then(() => {
  730. this.connectMQTT(clientId, devId);
  731. this.getFrequency(devId);
  732. })
  733. .catch((error) => {
  734. // console.error("初始化失败:", error);
  735. uni.showToast({
  736. title: "初始化设备信息失败",
  737. icon: "none",
  738. });
  739. });
  740. } catch (error) {
  741. uni.showToast({
  742. title: "设备信息格式错误",
  743. icon: "none",
  744. });
  745. }
  746. this.autoPlayinterval = setTimeout(() => {
  747. this.autoSwipe();
  748. }, 3000);
  749. },
  750. onUnload() {
  751. if (this.mqttClient) this.mqttClient.end(true);
  752. clearInterval(this.autoPlayinterval);
  753. clearInterval(this.inactivityTimer);
  754. },
  755. onHide() {
  756. if (this.mqttClient) this.mqttClient.end(true);
  757. },
  758. onShow() {},
  759. // onShareAppMessage() {},
  760. };
  761. </script>
  762. <style lang="less" scoped>
  763. .content {
  764. height: 100vh;
  765. background: linear-gradient(180deg, #faede2 0%, #f4f4f4 100%);
  766. box-sizing: border-box;
  767. padding-top: 20rpx;
  768. .name_box {
  769. display: flex;
  770. justify-content: center;
  771. align-items: center;
  772. margin: 0 auto 37rpx 0;
  773. .name_content {
  774. display: inline-flex;
  775. background: rgba(255, 255, 255, 0.65);
  776. border-radius: 37rpx;
  777. padding: 6rpx 18rpx;
  778. }
  779. }
  780. .radar-box {
  781. margin: 0 auto;
  782. position: relative;
  783. display: flex;
  784. align-items: center;
  785. justify-content: center;
  786. width: 710rpx;
  787. height: 710rpx;
  788. background: #ffffff;
  789. border-radius: 37.5rpx;
  790. box-sizing: border-box;
  791. .center {
  792. position: absolute;
  793. background-color: #fff;
  794. border: 14rpx solid #333333;
  795. background-image: url("http://jkld.radar-power.com//uploadFiles/framework/file/20250620/toilet_bg.png");
  796. background-repeat: no-repeat;
  797. background-position: center;
  798. transform: scale(1.3);
  799. .moduleContent {
  800. position: relative;
  801. view {
  802. position: absolute;
  803. }
  804. .module-img {
  805. width: 100%;
  806. height: 100%;
  807. display: block;
  808. }
  809. }
  810. }
  811. .tranStyle {
  812. position: absolute;
  813. background-color: #fff;
  814. border: 9rpx solid #333333;
  815. background-image: url("http://jkld.radar-power.com//uploadFiles/framework/file/20250620/toilet_bg.png");
  816. background-repeat: no-repeat;
  817. background-position: center;
  818. transform: scale(2.5);
  819. .moduleContent {
  820. overflow: hidden;
  821. position: relative;
  822. view {
  823. position: absolute;
  824. }
  825. .module-img {
  826. width: 100%;
  827. height: 100%;
  828. display: block;
  829. }
  830. }
  831. }
  832. .action-icon-G {
  833. position: absolute;
  834. width: 100rpx;
  835. height: 100rpx;
  836. }
  837. .action-icon-M {
  838. position: absolute;
  839. width: 50rpx;
  840. height: 50rpx;
  841. }
  842. }
  843. .switchBox {
  844. width: 710rpx;
  845. height: 94rpx;
  846. margin: 18rpx auto;
  847. padding: 0 37rpx;
  848. display: flex;
  849. align-items: center;
  850. background: #ffffff;
  851. border-radius: 37rpx;
  852. box-sizing: border-box;
  853. .name {
  854. color: #111111;
  855. font-size: 32rpx;
  856. }
  857. }
  858. .notice-info {
  859. width: 710rpx;
  860. max-height: 300rpx;
  861. overflow: hidden;
  862. padding: 30rpx 37rpx 10rpx 37rpx;
  863. background: #ffffff;
  864. border-radius: 37rpx;
  865. box-sizing: border-box;
  866. margin: 0 auto;
  867. .title {
  868. margin-top: 10rpx;
  869. margin-bottom: 10rpx;
  870. font-family: PingFang SC, PingFang SC;
  871. font-weight: 500;
  872. font-size: 34rpx;
  873. color: #1757dd;
  874. display: flex;
  875. align-items: center;
  876. justify-content: space-between;
  877. .title-text {
  878. font-size: 28rpx;
  879. font-weight: 500;
  880. color: #1757dd;
  881. }
  882. .title-btn {
  883. font-size: 28rpx;
  884. font-weight: 500;
  885. color: #5a5a5a;
  886. }
  887. }
  888. .stayDetail {
  889. height: 80rpx;
  890. overflow: hidden;
  891. margin-top: 10rpx;
  892. margin-bottom: 10rpx;
  893. padding-left: 20rpx;
  894. font-family: PingFang SC, PingFang SC;
  895. font-weight: 500;
  896. font-size: 34rpx;
  897. .stayDetail-item {
  898. display: flex;
  899. padding-bottom: 5rpx !important;
  900. padding-top: 10rpx !important;
  901. box-sizing: border-box;
  902. line-height: 60rpx;
  903. .stayDetail-text {
  904. width: 40%;
  905. font-size: 28rpx;
  906. height: 30rpx !important;
  907. }
  908. .stayDetail-btn {
  909. padding-left: 30rpx;
  910. font-size: 28rpx;
  911. height: 30rpx !important;
  912. }
  913. }
  914. }
  915. }
  916. .box {
  917. position: fixed;
  918. bottom: 0;
  919. left: 0;
  920. width: 100vw;
  921. height: 168rpx;
  922. padding: 0 37rpx;
  923. background: #ffffff;
  924. box-sizing: border-box;
  925. .handle-btn {
  926. margin-top: 40rpx;
  927. display: flex;
  928. align-items: center;
  929. justify-content: space-between;
  930. .btn1 {
  931. display: flex;
  932. align-items: center;
  933. justify-content: center;
  934. width: 155rpx;
  935. height: 94rpx;
  936. background: #ffebe4;
  937. border-radius: 28rpx;
  938. font-weight: 500;
  939. color: #111111;
  940. font-size: 32rpx;
  941. text-align: center;
  942. }
  943. .btn2 {
  944. display: flex;
  945. align-items: center;
  946. justify-content: center;
  947. width: 328rpx;
  948. height: 94rpx;
  949. background: linear-gradient(
  950. 105.95deg,
  951. #a27867 0%,
  952. #74483d 100%
  953. );
  954. border-radius: 28rpx;
  955. box-shadow: 0rpx 4.69rpx 18.75rpx rgba(72, 41, 29, 0.15),
  956. 0rpx 9.38rpx 9.38rpx rgba(154, 132, 89, 0.2),
  957. 0rpx -4.69rpx 28.13rpx 4.69rpx #a16647 inset;
  958. font-family: MiSans;
  959. font-weight: 500;
  960. color: #ffffff;
  961. font-size: 32rpx;
  962. }
  963. }
  964. }
  965. /* 弹窗部分样式 */
  966. .mask {
  967. position: fixed;
  968. left: 0;
  969. top: 0;
  970. right: 0;
  971. bottom: 0;
  972. background: rgba(0, 0, 0, 0.3);
  973. z-index: 100;
  974. }
  975. .share-modal {
  976. position: fixed;
  977. left: 0;
  978. right: 0;
  979. bottom: 0;
  980. background: #fff;
  981. border-radius: 24rpx 24rpx 0 0;
  982. z-index: 101;
  983. height: 750rpx;
  984. .modal-header {
  985. display: flex;
  986. justify-content: space-between;
  987. align-items: center;
  988. padding: 32rpx 32rpx 0 32rpx;
  989. font-size: 30rpx;
  990. .cancel-btn {
  991. color: #888;
  992. font-size: 32rpx;
  993. }
  994. .modal-title {
  995. color: #111111;
  996. font-size: 36rpx;
  997. }
  998. .confirm-btn {
  999. color: #996e5f;
  1000. font-size: 32rpx;
  1001. }
  1002. }
  1003. .modal-body {
  1004. padding: 50rpx;
  1005. .info-row {
  1006. display: flex;
  1007. margin-bottom: 24rpx;
  1008. font-size: 28rpx;
  1009. padding: 0 20rpx;
  1010. .label {
  1011. color: #111111;
  1012. width: 200rpx;
  1013. font-size: 32rpx;
  1014. text-align-last: justify;
  1015. }
  1016. .value {
  1017. text-align: right;
  1018. width: 65%;
  1019. color: #111111;
  1020. font-size: 32rpx;
  1021. }
  1022. }
  1023. .input-row {
  1024. display: flex;
  1025. align-items: center;
  1026. margin-top: 32rpx;
  1027. border-radius: 40rpx;
  1028. background: #f7f7f7;
  1029. padding: 0 24rpx;
  1030. height: 80rpx;
  1031. .input {
  1032. text-align: right;
  1033. flex: 1;
  1034. border: none;
  1035. background: transparent;
  1036. font-size: 28rpx;
  1037. color: #333;
  1038. }
  1039. }
  1040. .funChoice {
  1041. .funItem {
  1042. .simple-radio {
  1043. display: flex;
  1044. align-items: center;
  1045. padding: 20rpx 0;
  1046. }
  1047. }
  1048. }
  1049. }
  1050. }
  1051. // 分享弹窗样式
  1052. .modal-mask {
  1053. position: fixed;
  1054. top: 0;
  1055. left: 0;
  1056. right: 0;
  1057. bottom: 0;
  1058. background: rgba(0, 0, 0, 0.5);
  1059. display: flex;
  1060. justify-content: center;
  1061. align-items: center;
  1062. z-index: 999;
  1063. .modal-container {
  1064. width: 80%;
  1065. background: #fff;
  1066. border-radius: 16rpx;
  1067. overflow: hidden;
  1068. animation: fadeIn 0.3s;
  1069. .modal-header {
  1070. padding: 30rpx;
  1071. text-align: center;
  1072. border-bottom: 1rpx solid #f5f5f5;
  1073. .title {
  1074. font-size: 36rpx;
  1075. display: block;
  1076. margin-bottom: 10rpx;
  1077. }
  1078. }
  1079. .modal-buttons {
  1080. display: flex;
  1081. flex-direction: column;
  1082. padding: 20rpx;
  1083. .btn {
  1084. flex: 1;
  1085. height: 90rpx;
  1086. margin: 15rpx 0;
  1087. border-radius: 45rpx;
  1088. display: flex;
  1089. align-items: center;
  1090. justify-content: center;
  1091. font-size: 32rpx;
  1092. border: none;
  1093. background: none;
  1094. position: relative;
  1095. }
  1096. .btn-icon {
  1097. width: 40rpx;
  1098. height: 40rpx;
  1099. margin-right: 15rpx;
  1100. }
  1101. .phone-btn {
  1102. background: linear-gradient(
  1103. 105.95deg,
  1104. #ba978a 0%,
  1105. #a27867 100%
  1106. );
  1107. color: white;
  1108. }
  1109. .link-btn {
  1110. background: linear-gradient(
  1111. 105.95deg,
  1112. #a27867 0%,
  1113. #74483d 100%
  1114. );
  1115. color: white;
  1116. }
  1117. }
  1118. }
  1119. }
  1120. }
  1121. </style>