home.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. <template>
  2. <view class="home-warp">
  3. <view class="header">
  4. <view class="headerPng" @click="gotoPath('/pagesA/my/my')">
  5. <image :src="imageUrl" mode="widthFix" />
  6. </view>
  7. <view class="title">健康雷达</view>
  8. </view>
  9. <view class="leineng">
  10. <view>
  11. <image
  12. src="https://hflnxx.oss-cn-shanghai.aliyuncs.com/IMAGE/20250919/home_ln.png"
  13. mode=""
  14. />
  15. </view>
  16. <view class="right">
  17. <view
  18. class="rightItem"
  19. @click="gotoDevice('/pagesA/devices/devices')"
  20. >
  21. <view class="rightTitle">全部设备</view>
  22. <view class="rightContent"
  23. ><text>{{ devNum }}</text
  24. >台</view
  25. >
  26. </view>
  27. <view
  28. class="rightItem"
  29. @click="gotoDevice('/pagesA/homeManage/homeManage')"
  30. >
  31. <view class="rightTitle">我的家庭</view>
  32. <view class="rightContent"
  33. ><text>{{ groupNum }}</text
  34. >家</view
  35. >
  36. </view>
  37. <view class="rightItem" @click="goAbnormalInfo()">
  38. <view class="rightTitle">异常信息</view>
  39. <view class="rightContent" v-if="warnNum == 0"
  40. ><text>0</text>条</view
  41. >
  42. <view class="rightAlarm" v-else
  43. ><text>{{ warnNum }}</text
  44. >条</view
  45. >
  46. </view>
  47. </view>
  48. </view>
  49. <view class="content">
  50. <view
  51. class="card"
  52. @click="gotoPath('/pagesA/adNewDevice/adNewDevice')"
  53. >
  54. <view class="contentTitle">
  55. <text>添加设备</text>
  56. <image src="../../static/rightArrow.png" />
  57. </view>
  58. <view class="contentCenter"> 家庭陪伴探测器 </view>
  59. <view class="contentImg">
  60. <image src="../../static/smalLn.png" mode="" />
  61. </view>
  62. </view>
  63. <view
  64. class="card"
  65. @click="gotoDevice('/pagesA/homeManage/homeManage')"
  66. >
  67. <view class="contentTitle">
  68. <text>我的家庭</text>
  69. <image src="../../static/rightArrow.png" />
  70. </view>
  71. <view class="contentCenter"> 点击进入我的家 </view>
  72. <view class="contentImg">
  73. <image src="../../static/myHome.png" mode="" />
  74. </view>
  75. </view>
  76. </view>
  77. <view class="bottom">
  78. <image src="../../static/linkService.png" mode="" />
  79. <button open-type="contact">联系客服</button>
  80. </view>
  81. <!-- <movable-area class="movable-area" direction="all">
  82. <movable-view
  83. class="movable-button"
  84. :x="pos.x"
  85. :y="pos.y"
  86. direction="all"
  87. @change="onChange"
  88. @touchend="onTouchEnd"
  89. v-if="showService"
  90. >
  91. <image src="../../static/linkService.png" class="icon" />
  92. <span class="pulse"></span>
  93. <span class="pulse"></span>
  94. <button open-type="contact" class="contact-btn"></button>
  95. </movable-view>
  96. </movable-area> -->
  97. <view class="bot_version"> v3.0.17</view>
  98. <view
  99. class="shareInfo"
  100. @click="goDeviceShare()"
  101. v-if="shareNum > 0"
  102. :style="{ top: warnNum > 0 ? '280rpx' : '210rpx' }"
  103. >
  104. <image src="../../static/ln_small.png" class="shareimage"></image>
  105. <text class="sharetitle"
  106. >您有<text class="sharenum">{{ shareNum }}</text
  107. >台设备待授权</text
  108. >
  109. <image src="../../static/arrTwo.png" class="arrimage"></image>
  110. </view>
  111. <view
  112. class="warmInfo"
  113. @click="goAbnormalInfo()"
  114. v-if="alarmRetentionLists.length > 0"
  115. >
  116. <image src="../../static/warmImage.png" class="shareImage"></image>
  117. <view class="shareTitleContainer">
  118. <view
  119. class="shareTitleList"
  120. v-if="alarmRetentionLists.length > 1"
  121. >
  122. <view
  123. class="shareTitle"
  124. v-for="item in alarmRetentionLists"
  125. :key="item.clientId"
  126. >
  127. {{ item.devName }}检测到有{{
  128. getEventTypeName(item.eventType)
  129. }}
  130. </view>
  131. <view
  132. class="shareTitle"
  133. v-for="item in alarmRetentionLists"
  134. :key="item.clientId"
  135. >
  136. {{ item.devName }}检测到有{{
  137. getEventTypeName(item.eventType)
  138. }}
  139. </view>
  140. </view>
  141. <view class="shareTitleTwo" v-else>
  142. <template v-if="alarmRetentionLists.length == 1">
  143. <view class="shareTitle">
  144. {{ alarmRetentionLists[0].devName }}检测到有{{
  145. getEventTypeName(
  146. alarmRetentionLists[0].eventType
  147. )
  148. }}
  149. </view>
  150. </template>
  151. </view>
  152. </view>
  153. <image src="../../static/arrFour.png" class="warmImage"></image>
  154. </view>
  155. <tenMinutes v-if="isIniTenMinutes" />
  156. <alarModel v-if="showModle" />
  157. </view>
  158. </template>
  159. <script>
  160. export default {
  161. name: "my",
  162. data() {
  163. return {
  164. notices: [],
  165. groupNum: 0,
  166. shareNum: 0,
  167. devNum: 0,
  168. warnNum: 0,
  169. imageUrl: "../../static/headerInfo.jpg",
  170. devDevice: "",
  171. warmNum: "",
  172. warmDetail: [],
  173. alarmRetentionLists: [],
  174. warmTypeList: [],
  175. isIniTenMinutes: false,
  176. showModle: false,
  177. // 修改我的客服点位
  178. pos: { x: 0, y: 0 },
  179. selectX: 0,
  180. selectY: 0,
  181. screenWidth: 0,
  182. screenHeight: 0,
  183. btnWidth: 80,
  184. btnHeight: 80,
  185. margin: 0, // 边距
  186. windowWidth: 0,
  187. dragTimer: null,
  188. showService: false,
  189. };
  190. },
  191. computed: {},
  192. methods: {
  193. gotoPath(path) {
  194. if (uni.getStorageSync("userId")) {
  195. uni.navigateTo({
  196. url: path,
  197. });
  198. } else {
  199. uni.showToast({
  200. title: "暂未登录,请先登录",
  201. icon: "none",
  202. duration: 1500,
  203. });
  204. uni.reLaunch({
  205. url: "/pagesA/loginNew/loginNew",
  206. });
  207. }
  208. },
  209. gotoDevice(url) {
  210. if (uni.getStorageSync("userId")) {
  211. if (this.devDevice.length == 1) {
  212. uni.setStorageSync("devIdDetail", this.devDevice[0].devId);
  213. uni.setStorageSync(
  214. "clientIDetail",
  215. this.devDevice[0].clientId
  216. );
  217. uni.navigateTo({
  218. url:
  219. "/pagesA/deviceDetail/deviceDetail?devItem=" +
  220. JSON.stringify(this.devDevice[0]),
  221. });
  222. } else {
  223. uni.navigateTo({
  224. url: url,
  225. });
  226. }
  227. } else {
  228. uni.showToast({
  229. title: "暂未登录,请先登录",
  230. icon: "none",
  231. duration: 1500,
  232. });
  233. uni.reLaunch({
  234. url: "/pagesA/loginNew/loginNew",
  235. });
  236. }
  237. },
  238. goAbnormalInfo() {
  239. if (uni.getStorageSync("userId")) {
  240. if (this.warnNum <= 0) {
  241. uni.showToast({
  242. title: "暂无异常信息",
  243. icon: "none",
  244. duration: 1500,
  245. });
  246. return;
  247. }
  248. uni.navigateTo({
  249. url: "/pagesA/abnormalInfo/abnormalInfo",
  250. });
  251. return;
  252. }
  253. uni.reLaunch({
  254. url: "/pagesA/loginNew/loginNew",
  255. });
  256. },
  257. goDeviceShare() {
  258. uni.setStorageSync("shareStatus", "authorized");
  259. uni.navigateTo({
  260. url: "/pagesA/shareList/shareList",
  261. });
  262. },
  263. getperSonInfo() {
  264. this.$http
  265. .get("wap/home/homeInfo", {
  266. userId: uni.getStorageSync("userId"),
  267. })
  268. .then((res) => {
  269. if (res.data.data) {
  270. const { groupNum, devNum, warnNum } = res.data.data;
  271. this.groupNum = groupNum;
  272. this.devNum = devNum;
  273. this.warnNum = warnNum;
  274. this.devDevice = res.data.data.deviceList;
  275. }
  276. });
  277. },
  278. getShareNum() {
  279. this.$http
  280. .post("wap/share/queryDevShare", {
  281. userId: uni.getStorageSync("userId"),
  282. state: 0,
  283. })
  284. .then((res) => {
  285. this.shareNum = res.data.data?.length || 0;
  286. });
  287. },
  288. // 异常信息处理
  289. getWarnList() {
  290. this.$http
  291. .post(
  292. "wap/stats/alarmEventsQuery",
  293. {
  294. pageNo: 1,
  295. pageSize: 3,
  296. createTimeStart: this.$time(new Date()),
  297. createTimeEnd: this.$time(new Date()),
  298. },
  299. {
  300. header: {
  301. "Content-Type": "application/json;charset=UTF-8",
  302. token: uni.getStorageSync("tokenValue") || "",
  303. },
  304. }
  305. )
  306. .then((res) => {
  307. if (res.data.data) {
  308. this.alarmRetentionLists = res.data.data.rows;
  309. }
  310. });
  311. },
  312. getwarmType() {
  313. this.$http.get("wap/stats/queryEventType").then((res) => {
  314. if (res.data.data) {
  315. this.warmTypeList = res.data.data;
  316. }
  317. });
  318. },
  319. getEventTypeName(eventType) {
  320. return (
  321. this.warmTypeList.find((item) => item.eventVal == eventType)
  322. ?.eventDesc || "未知"
  323. );
  324. },
  325. onChange(e) {
  326. this.selectX = e.detail.x;
  327. this.selectY = e.detail.y;
  328. },
  329. onTouchEnd() {
  330. uni.getSystemInfo({
  331. success: (res) => {
  332. this.windowWidth = Number(res.windowWidth / 2);
  333. },
  334. });
  335. // console.log(this.selectX, this.selectY, "777777");
  336. // if (this.selectX >= this.windowWidth) {
  337. // this.selectX = 0;
  338. // } else {
  339. // this.selectX = 0;
  340. // }
  341. this.selectX = 0;
  342. this.pos.x = this.selectX;
  343. this.pos.y = this.selectY;
  344. uni.setStorageSync("posLocationX", this.pos.x);
  345. uni.setStorageSync("posLocationY", this.pos.y);
  346. },
  347. },
  348. onLoad() {
  349. // const sys = uni.getSystemInfoSync();
  350. // this.windowWidth = sys.windowWidth;
  351. // this.windowHeight = sys.windowHeight;
  352. // // 初始化位置:右下角
  353. // this.pos.x = this.windowWidth - this.btnWidth - this.margin;
  354. // this.pos.y = this.windowHeight - this.btnHeight - this.margin;
  355. // // 如果之前存储过位置,用存储覆盖
  356. // const savedX = uni.getStorageSync("posLocationX");
  357. // const savedY = uni.getStorageSync("posLocationY");
  358. // if (savedX !== "" && savedX !== undefined) this.pos.x = savedX;
  359. // if (savedY !== "" && savedY !== undefined) this.pos.y = savedY;
  360. if (
  361. !uni.getStorageSync("posLocationX") ||
  362. !uni.getStorageSync("posLocationY")
  363. ) {
  364. this.pos = { x: 0, y: 0 };
  365. }
  366. this.pos.x = uni.getStorageSync("posLocationX");
  367. this.pos.y = uni.getStorageSync("posLocationY");
  368. },
  369. onShow() {
  370. if (uni.getStorageSync("userId")) {
  371. this.getperSonInfo();
  372. this.getShareNum();
  373. this.getwarmType();
  374. this.getWarnList();
  375. this.showModle = true;
  376. this.isIniTenMinutes = true;
  377. this.showService = true;
  378. }
  379. // 配置服务器
  380. let selectedService = uni.getStorageSync("sercviceChoice");
  381. if (!selectedService) {
  382. uni.setStorageSync("sercviceChoice", "aloneServe");
  383. }
  384. },
  385. onHide() {
  386. this.showModle = false;
  387. this.isIniTenMinutes = false;
  388. },
  389. onUnload() {
  390. // this.isIniTenMinutes = false;
  391. },
  392. onShareAppMessage() {
  393. return {
  394. title: "好友向您分享雷能守护",
  395. path: "/pages/home/home",
  396. };
  397. },
  398. };
  399. </script>
  400. <style lang="less" scoped>
  401. .home-warp {
  402. position: relative;
  403. height: 100vh;
  404. background: linear-gradient(180deg, #faede2 0%, #f4f4f4 100%);
  405. /* padding: 24rpx 30rpx 20rpx; */
  406. }
  407. .header {
  408. display: flex;
  409. align-items: center;
  410. justify-content: space-between;
  411. padding: 90rpx 80rpx;
  412. }
  413. .headerPng {
  414. z-index: 1;
  415. }
  416. .headerPng image {
  417. width: 70rpx;
  418. height: 70rpx;
  419. border-radius: 50%;
  420. }
  421. .title {
  422. position: absolute;
  423. left: 50%;
  424. transform: translateX(-50%);
  425. color: #111111;
  426. font-size: 32rpx;
  427. }
  428. .leineng {
  429. position: absolute;
  430. top: -100rpx;
  431. display: flex;
  432. align-items: center;
  433. justify-content: flex-end;
  434. width: 100vw;
  435. height: 100vh;
  436. }
  437. .leineng image {
  438. position: absolute;
  439. top: 10%;
  440. left: 0;
  441. width: 700rpx;
  442. height: 1200rpx;
  443. }
  444. .right {
  445. z-index: 2;
  446. padding-right: 100rpx;
  447. }
  448. .right .rightItem {
  449. margin-bottom: 80rpx;
  450. color: #666666;
  451. }
  452. .right .rightItem .rightTitle {
  453. font-size: 23.44rpx;
  454. text-align: center;
  455. }
  456. .right .rightItem .rightContent {
  457. display: flex;
  458. justify-content: center;
  459. align-items: baseline;
  460. margin-top: 17rpx;
  461. font-size: 24rpx;
  462. font-weight: bold;
  463. }
  464. .right .rightItem .rightContent text {
  465. font-weight: 700;
  466. font-size: 66rpx;
  467. }
  468. .right .rightItem .rightAlarm {
  469. margin-top: 17rpx;
  470. font-size: 24rpx;
  471. font-weight: bold;
  472. color: #f55050;
  473. }
  474. .right .rightItem .rightAlarm text {
  475. font-weight: 700;
  476. font-size: 66rpx;
  477. color: #f55050;
  478. }
  479. .content {
  480. position: absolute;
  481. bottom: 200rpx;
  482. width: 100vw;
  483. display: flex;
  484. justify-content: space-around;
  485. }
  486. .card {
  487. width: 350rpx;
  488. height: 300rpx;
  489. border: 2rpx solid #ffffff;
  490. border-radius: 37rpx;
  491. background: #ffffff;
  492. padding: 38rpx 30rpx;
  493. box-sizing: border-box;
  494. }
  495. .contentTitle {
  496. display: flex;
  497. align-items: center;
  498. font-size: 32rpx;
  499. color: #111111;
  500. }
  501. .contentTitle image {
  502. width: 28rpx;
  503. height: 28rpx;
  504. margin-left: 8rpx;
  505. }
  506. .contentCenter {
  507. margin-top: 14rpx;
  508. font-size: 24rpx;
  509. color: #999999;
  510. }
  511. .contentImg image {
  512. margin-top: 60rpx;
  513. width: 94rpx;
  514. height: 94rpx;
  515. }
  516. .bottom {
  517. position: absolute;
  518. bottom: 80rpx;
  519. left: 50%;
  520. transform: translate(-50%, -50%);
  521. display: flex;
  522. justify-content: center;
  523. align-items: center;
  524. }
  525. .bottom image {
  526. width: 28rpx;
  527. height: 28rpx;
  528. }
  529. .bottom button {
  530. all: unset;
  531. margin: 0;
  532. padding: 0;
  533. border: none;
  534. background: none;
  535. font: inherit;
  536. text-align: inherit;
  537. line-height: normal;
  538. outline: none;
  539. box-shadow: none;
  540. -webkit-appearance: none;
  541. margin-left: 6rpx;
  542. color: #a1aab4;
  543. font-size: 28rpx;
  544. }
  545. .bot_version {
  546. opacity: 0.4;
  547. position: absolute;
  548. bottom: 20rpx;
  549. left: 50%;
  550. font-size: 28rpx;
  551. transform: translate(-50%, -50%);
  552. display: flex;
  553. justify-content: center;
  554. align-items: center;
  555. }
  556. .shareInfo {
  557. width: 100%;
  558. padding: 0 16rpx;
  559. color: #ffffff;
  560. display: flex;
  561. align-items: center;
  562. font-size: 28rpx;
  563. position: absolute;
  564. // top:210rpx;
  565. // top: 400rpx;
  566. left: 50%;
  567. transform: translate(-50%, -50%);
  568. box-sizing: border-box;
  569. background: linear-gradient(
  570. to right,
  571. #6f4e37 0%,
  572. rgba(210, 180, 140, 0.3) 100%
  573. );
  574. .shareimage {
  575. width: 60rpx;
  576. height: 60rpx;
  577. border-radius: 50%;
  578. }
  579. .sharetitle {
  580. margin-left: 20rpx;
  581. font-size: 28rpx;
  582. color: #ffffff;
  583. letter-spacing: 4rpx;
  584. }
  585. .sharenum {
  586. font-weight: bold;
  587. font-size: 28rpx;
  588. color: #ffffff;
  589. }
  590. .arrimage {
  591. width: 20rpx;
  592. height: 30rpx;
  593. margin-left: auto;
  594. }
  595. }
  596. .warmInfo {
  597. width: 100%;
  598. padding: 0rpx 10rpx;
  599. color: #ffffff;
  600. display: flex;
  601. align-items: center;
  602. font-size: 28rpx;
  603. position: absolute;
  604. top: 210rpx;
  605. left: 50%;
  606. transform: translate(-50%, -50%);
  607. box-sizing: border-box;
  608. background: linear-gradient(
  609. to right,
  610. #f9e0d7 0%,
  611. #ff6262 45%,
  612. #ff6262 55%,
  613. #f9e0d7 100%
  614. );
  615. border-radius: 12rpx;
  616. }
  617. .shareImage {
  618. width: 60rpx;
  619. height: 60rpx;
  620. border-radius: 50%;
  621. }
  622. .warmImage {
  623. width: 30rpx;
  624. height: 30rpx;
  625. margin-left: auto;
  626. }
  627. .shareTitleContainer {
  628. flex: 1;
  629. overflow: hidden;
  630. height: 40rpx;
  631. margin-left: 20rpx;
  632. display: flex;
  633. align-items: center;
  634. }
  635. /* 内层列表:滚动 */
  636. .shareTitleList {
  637. display: flex;
  638. flex-direction: column;
  639. animation: scrollUp 7s linear infinite;
  640. }
  641. .shareTitleTwo {
  642. display: flex;
  643. flex-direction: column;
  644. }
  645. .shareTitle {
  646. font-size: 28rpx;
  647. color: #ffffff;
  648. letter-spacing: 4rpx;
  649. height: 40rpx;
  650. line-height: 40rpx;
  651. white-space: nowrap;
  652. }
  653. .movable-area {
  654. position: fixed;
  655. width: 100%;
  656. height: 80%;
  657. }
  658. .movable-button {
  659. display: flex;
  660. justify-content: center;
  661. z-index: 999;
  662. align-items: center;
  663. width: 80rpx;
  664. height: 80rpx;
  665. }
  666. .movable-button .icon {
  667. pointer-events: none;
  668. width: 80rpx;
  669. height: 80rpx;
  670. }
  671. .movable-button .contact-btn {
  672. position: absolute;
  673. width: 80rpx;
  674. height: 80rpx;
  675. background: none;
  676. border: none;
  677. padding: 0;
  678. top: 0;
  679. left: 0;
  680. z-index: 10;
  681. }
  682. /* 去掉伪元素 after 样式 */
  683. .movable-button .contact-btn::after,
  684. .movable-button .contact-btn::before,
  685. wx-button::after,
  686. wx-button::before {
  687. content: none !important;
  688. border: none !important;
  689. background: transparent !important;
  690. box-shadow: none !important;
  691. }
  692. .pulse {
  693. position: absolute;
  694. pointer-events: none;
  695. top: 50%;
  696. left: 50%;
  697. width: 80rpx;
  698. height: 80rpx;
  699. border: 2px solid #ffd700; /* 黄色边框 */
  700. border-radius: 50%;
  701. transform: translate(-50%, -50%) scale(1);
  702. opacity: 0.6;
  703. animation: pulseAnim 2s ease-out infinite;
  704. z-index: 4;
  705. }
  706. /* 第二个 pulse 动画延迟,产生连续效果 */
  707. .pulse:nth-child(2) {
  708. animation-delay: 0.75s;
  709. }
  710. @keyframes pulseAnim {
  711. 0% {
  712. transform: translate(-50%, -50%) scale(1);
  713. opacity: 0.6;
  714. }
  715. 70% {
  716. transform: translate(-50%, -50%) scale(2);
  717. opacity: 0;
  718. }
  719. 100% {
  720. transform: translate(-50%, -50%) scale(2);
  721. opacity: 0;
  722. }
  723. }
  724. /* 无限无缝滚动 */
  725. @keyframes scrollUp {
  726. 0% {
  727. transform: translateY(0);
  728. }
  729. 100% {
  730. transform: translateY(-50%);
  731. }
  732. }
  733. </style>