home.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  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="http://jkld.radar-power.com//uploadFiles/framework/file/20250620/home_ln.png"
  13. mode=""
  14. />
  15. </view>
  16. <view class="right">
  17. <view class="rightItem">
  18. <view class="rightTitle">今日天气</view>
  19. <view class="rightPng">
  20. <view class="rightContent">暂无</view>
  21. </view>
  22. </view>
  23. <view
  24. class="rightItem"
  25. @click="gotoDevice('/pagesA/devices/devices')"
  26. >
  27. <view class="rightTitle">我的家庭</view>
  28. <view class="rightContent"
  29. ><text>{{ groupNum }}</text
  30. >家</view
  31. >
  32. </view>
  33. <view
  34. class="rightItem"
  35. @click="gotoDevice('/pagesA/devices/devices')"
  36. >
  37. <view class="rightTitle">全部设备</view>
  38. <view class="rightContent"
  39. ><text>{{ devNum }}</text
  40. >台</view
  41. >
  42. </view>
  43. <view class="rightItem" @click="goAbnormalInfo()">
  44. <view class="rightTitle">异常信息</view>
  45. <view class="rightContent" v-if="warnNum == 0"
  46. ><text>0</text>条</view
  47. >
  48. <view class="rightAlarm" v-else
  49. ><text>{{ warnNum }}</text
  50. >条</view
  51. >
  52. </view>
  53. </view>
  54. </view>
  55. <view class="content">
  56. <view class="card" @click="gotoPath('/pagesA/adDevice/adDevice')">
  57. <view class="contentTitle">
  58. <text>添加设备</text>
  59. <image src="../../static/rightArrow.png" />
  60. </view>
  61. <view class="contentCenter"> 家庭陪伴探测器 </view>
  62. <view class="contentImg">
  63. <image src="../../static/smalLn.png" mode="" />
  64. </view>
  65. </view>
  66. <view class="card" @click="gotoDevice('/pagesA/devices/devices')">
  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. <view class="bot_version"> v3.0.5 </view>
  82. <view
  83. class="shareInfo"
  84. @click="goDeviceShare()"
  85. v-if="shareNum > 0"
  86. :style="{ top: warnNum > 0 ? '280rpx' : '210rpx' }"
  87. >
  88. <image src="../../static/ln_small.png" class="shareimage"></image>
  89. <text class="sharetitle"
  90. >您有<text class="sharenum">{{ shareNum }}</text
  91. >台设备待授权</text
  92. >
  93. <image src="../../static/arrTwo.png" class="arrimage"></image>
  94. </view>
  95. <view
  96. class="warmInfo"
  97. @click="goAbnormalInfo()"
  98. v-if="warmList.length > 0"
  99. >
  100. <image src="../../static/warmImage.png" class="shareImage"></image>
  101. <view class="shareTitleContainer">
  102. <view class="shareTitleList" v-if="warmList.length > 1">
  103. <view
  104. class="shareTitle"
  105. v-for="item in warmList"
  106. :key="item.devId"
  107. >
  108. {{ item.devName }}检测到有目标滞留
  109. </view>
  110. <view
  111. class="shareTitle"
  112. v-for="item in warmList"
  113. :key="item.devId + '-copy'"
  114. >
  115. {{ item.devName }}检测到有目标滞留
  116. </view>
  117. </view>
  118. <view class="shareTitleTwo" v-else>
  119. <view class="shareTitle">
  120. {{ warmList[0].devName }}检测到有目标滞留
  121. </view>
  122. </view>
  123. </view>
  124. <image src="../../static/arrFour.png" class="warmImage"></image>
  125. </view>
  126. <alarModel />
  127. </view>
  128. </template>
  129. <script>
  130. export default {
  131. name: "my",
  132. data() {
  133. return {
  134. notices: [],
  135. groupNum: 0,
  136. shareNum: 0,
  137. devNum: 0,
  138. warnNum: 0,
  139. imageUrl: "../../static/headerInfo.png",
  140. devDevice: "",
  141. warmNum: "",
  142. warmDetail: [],
  143. warmList: [],
  144. };
  145. },
  146. computed: {},
  147. methods: {
  148. gotoPath(path) {
  149. if (uni.getStorageSync("userId")) {
  150. uni.navigateTo({
  151. url: path,
  152. });
  153. } else {
  154. uni.showToast({
  155. title: "暂未登录,请先登录",
  156. icon: "none",
  157. duration: 1500,
  158. });
  159. uni.reLaunch({
  160. url: "/pagesA/loginNew/loginNew",
  161. });
  162. }
  163. },
  164. gotoDevice(url) {
  165. if (uni.getStorageSync("userId")) {
  166. if (this.devDevice.length == 1) {
  167. uni.navigateTo({
  168. url:
  169. "/pagesA/deviceDetail/deviceDetail?devItem=" +
  170. JSON.stringify(this.devDevice[0]),
  171. });
  172. } else {
  173. uni.navigateTo({
  174. url: url,
  175. });
  176. }
  177. } else {
  178. uni.showToast({
  179. title: "暂未登录,请先登录",
  180. icon: "none",
  181. duration: 1500,
  182. });
  183. uni.reLaunch({
  184. url: "/pagesA/loginNew/loginNew",
  185. });
  186. }
  187. },
  188. goAbnormalInfo() {
  189. if (uni.getStorageSync("userId")) {
  190. // if (this.warnNum <= 0) {
  191. // uni.showToast({
  192. // title: "暂无异常信息",
  193. // icon: "none",
  194. // duration: 1500,
  195. // });
  196. // return;
  197. // }
  198. uni.navigateTo({
  199. url: "/pagesA/abnormalInfo/abnormalInfo",
  200. });
  201. return;
  202. }
  203. uni.reLaunch({
  204. url: "/pagesA/loginNew/loginNew",
  205. });
  206. },
  207. goDeviceShare() {
  208. uni.setStorageSync("shareStatus", "authorized");
  209. uni.navigateTo({
  210. url: "/pagesA/shareList/shareList",
  211. });
  212. },
  213. getperSonInfo() {
  214. this.$http
  215. .get("wap/home/homeInfo", {
  216. userId: uni.getStorageSync("userId"),
  217. })
  218. .then((res) => {
  219. if (res.data.data) {
  220. const { groupNum, devNum, warnNum } = res.data.data;
  221. this.groupNum = groupNum;
  222. this.devNum = devNum;
  223. this.warnNum = warnNum;
  224. this.devDevice = res.data.data.deviceList;
  225. }
  226. });
  227. },
  228. getShareNum() {
  229. // uni.showLoading({
  230. // title: "雷能守护中...",
  231. // });
  232. this.$http
  233. .post("wap/share/queryDevShare", {
  234. userId: uni.getStorageSync("userId"),
  235. state: 0,
  236. })
  237. .then((res) => {
  238. this.shareNum = res.data.data?.length || 0;
  239. });
  240. },
  241. // 需要跟车对接一下,换一个接口
  242. getWarmList() {
  243. this.$http
  244. .post(
  245. "wap/stats/alarmRetentionQuery",
  246. {
  247. pageNo: 1,
  248. pageSize: 20,
  249. },
  250. {
  251. header: {
  252. "Content-Type": "application/json;charset=UTF-8",
  253. token: uni.getStorageSync("tokenValue") || "",
  254. },
  255. }
  256. )
  257. .then((res) => {
  258. if (res.data.data) {
  259. // this.warmNum = res.data.data.total;
  260. if (res.data.data.rows.length > 0) {
  261. this.warmDetail = res.data.data.rows;
  262. const mergedMap = new Map();
  263. this.warmDetail.forEach((alarm) => {
  264. const devId = alarm.devId;
  265. if (mergedMap.has(devId)) {
  266. const existingAlarm = mergedMap.get(devId);
  267. const existingTime = new Date(
  268. existingAlarm.createTime
  269. );
  270. const currentTime = new Date(
  271. alarm.createTime
  272. );
  273. if (currentTime > existingTime) {
  274. mergedMap.set(devId, alarm);
  275. }
  276. } else {
  277. mergedMap.set(devId, alarm);
  278. }
  279. });
  280. const entries = mergedMap.entries();
  281. // 遍历
  282. for (const [devId, object] of entries) {
  283. this.warmList.push(object);
  284. }
  285. }
  286. }
  287. });
  288. },
  289. },
  290. onLoad() {},
  291. onShow() {
  292. if (uni.getStorageSync("userId")) {
  293. this.getperSonInfo();
  294. this.getShareNum();
  295. this.getWarmList();
  296. }
  297. // 配置服务器
  298. let selectedService = uni.getStorageSync("sercviceChoice");
  299. if (!selectedService) {
  300. uni.setStorageSync("sercviceChoice", "aloneServe");
  301. }
  302. },
  303. onShareAppMessage() {
  304. return {
  305. title: "好友向您分享雷能守护",
  306. path: "/pages/home/home",
  307. };
  308. },
  309. };
  310. </script>
  311. <style lang="less" scoped>
  312. .home-warp {
  313. position: relative;
  314. height: 100vh;
  315. background: linear-gradient(180deg, #faede2 0%, #f4f4f4 100%);
  316. /* padding: 24rpx 30rpx 20rpx; */
  317. }
  318. .header {
  319. display: flex;
  320. align-items: center;
  321. justify-content: space-between;
  322. padding: 90rpx 80rpx;
  323. }
  324. .headerPng {
  325. z-index: 1;
  326. }
  327. .headerPng image {
  328. width: 70rpx;
  329. height: 70rpx;
  330. border-radius: 50%;
  331. }
  332. .title {
  333. position: absolute;
  334. left: 50%;
  335. transform: translateX(-50%);
  336. color: #111111;
  337. font-size: 32rpx;
  338. }
  339. .leineng {
  340. position: absolute;
  341. top: -100rpx;
  342. display: flex;
  343. align-items: center;
  344. justify-content: flex-end;
  345. width: 100vw;
  346. height: 100vh;
  347. }
  348. .leineng image {
  349. position: absolute;
  350. top: 10%;
  351. left: 0;
  352. width: 700rpx;
  353. height: 1200rpx;
  354. }
  355. .right {
  356. z-index: 99;
  357. padding-right: 100rpx;
  358. }
  359. .right .rightItem {
  360. margin-bottom: 60rpx;
  361. color: #666666;
  362. }
  363. .right .rightItem .rightTitle {
  364. font-size: 23.44rpx;
  365. text-align: center;
  366. }
  367. .right .rightItem .rightContent {
  368. margin-top: 17rpx;
  369. font-size: 24rpx;
  370. font-weight: bold;
  371. }
  372. .right .rightItem .rightContent text {
  373. font-weight: 700;
  374. font-size: 66rpx;
  375. }
  376. .right .rightItem .rightAlarm {
  377. margin-top: 17rpx;
  378. font-size: 24rpx;
  379. font-weight: bold;
  380. color: #f55050;
  381. }
  382. .right .rightItem .rightAlarm text {
  383. font-weight: 700;
  384. font-size: 66rpx;
  385. color: #f55050;
  386. }
  387. .content {
  388. position: absolute;
  389. bottom: 200rpx;
  390. width: 100vw;
  391. display: flex;
  392. justify-content: space-around;
  393. }
  394. .card {
  395. width: 350rpx;
  396. height: 300rpx;
  397. border: 2rpx solid #ffffff;
  398. border-radius: 37rpx;
  399. background: #ffffff;
  400. padding: 38rpx 30rpx;
  401. box-sizing: border-box;
  402. }
  403. .contentTitle {
  404. display: flex;
  405. align-items: center;
  406. font-size: 32rpx;
  407. color: #111111;
  408. }
  409. .contentTitle image {
  410. width: 28rpx;
  411. height: 28rpx;
  412. margin-left: 8rpx;
  413. }
  414. .contentCenter {
  415. margin-top: 14rpx;
  416. font-size: 24rpx;
  417. color: #999999;
  418. }
  419. .contentImg image {
  420. margin-top: 60rpx;
  421. width: 94rpx;
  422. height: 94rpx;
  423. }
  424. .bottom {
  425. position: absolute;
  426. bottom: 80rpx;
  427. left: 50%;
  428. transform: translate(-50%, -50%);
  429. display: flex;
  430. justify-content: center;
  431. align-items: center;
  432. }
  433. .bottom image {
  434. width: 28rpx;
  435. height: 28rpx;
  436. }
  437. .bottom button {
  438. all: unset;
  439. margin: 0;
  440. padding: 0;
  441. border: none;
  442. background: none;
  443. font: inherit;
  444. text-align: inherit;
  445. line-height: normal;
  446. outline: none;
  447. box-shadow: none;
  448. -webkit-appearance: none;
  449. margin-left: 6rpx;
  450. color: #a1aab4;
  451. font-size: 28rpx;
  452. }
  453. .bot_version {
  454. opacity: 0.4;
  455. position: absolute;
  456. bottom: 20rpx;
  457. left: 50%;
  458. font-size: 28rpx;
  459. transform: translate(-50%, -50%);
  460. display: flex;
  461. justify-content: center;
  462. align-items: center;
  463. }
  464. .shareInfo {
  465. width: 100%;
  466. padding: 0 16rpx;
  467. color: #ffffff;
  468. display: flex;
  469. align-items: center;
  470. font-size: 28rpx;
  471. position: absolute;
  472. // top:210rpx;
  473. // top: 400rpx;
  474. left: 50%;
  475. transform: translate(-50%, -50%);
  476. box-sizing: border-box;
  477. background: linear-gradient(
  478. to right,
  479. #6f4e37 0%,
  480. rgba(210, 180, 140, 0.3) 100%
  481. );
  482. .shareimage {
  483. width: 60rpx;
  484. height: 60rpx;
  485. border-radius: 50%;
  486. }
  487. .sharetitle {
  488. margin-left: 20rpx;
  489. font-size: 28rpx;
  490. color: #ffffff;
  491. letter-spacing: 4rpx;
  492. }
  493. .sharenum {
  494. font-weight: bold;
  495. font-size: 28rpx;
  496. color: #ffffff;
  497. }
  498. .arrimage {
  499. width: 20rpx;
  500. height: 30rpx;
  501. margin-left: auto;
  502. }
  503. }
  504. .warmInfo {
  505. width: 100%;
  506. padding: 0rpx 10rpx;
  507. color: #ffffff;
  508. display: flex;
  509. align-items: center;
  510. font-size: 28rpx;
  511. position: absolute;
  512. top: 210rpx;
  513. left: 50%;
  514. transform: translate(-50%, -50%);
  515. box-sizing: border-box;
  516. background: linear-gradient(
  517. to right,
  518. #f9e0d7 0%,
  519. #ff6262 45%,
  520. #ff6262 55%,
  521. #f9e0d7 100%
  522. );
  523. border-radius: 12rpx;
  524. }
  525. .shareImage {
  526. width: 60rpx;
  527. height: 60rpx;
  528. border-radius: 50%;
  529. }
  530. .warmImage {
  531. width: 30rpx;
  532. height: 30rpx;
  533. margin-left: auto;
  534. }
  535. .shareTitleContainer {
  536. flex: 1;
  537. overflow: hidden;
  538. height: 40rpx;
  539. margin-left: 20rpx;
  540. display: flex;
  541. align-items: center;
  542. }
  543. /* 内层列表:滚动 */
  544. .shareTitleList {
  545. display: flex;
  546. flex-direction: column;
  547. animation: scrollUp 10s linear infinite;
  548. }
  549. .shareTitleTwo {
  550. display: flex;
  551. flex-direction: column;
  552. }
  553. .shareTitle {
  554. font-size: 28rpx;
  555. color: #ffffff;
  556. letter-spacing: 4rpx;
  557. height: 40rpx;
  558. line-height: 40rpx;
  559. white-space: nowrap;
  560. }
  561. /* 无限无缝滚动 */
  562. @keyframes scrollUp {
  563. 0% {
  564. transform: translateY(0);
  565. }
  566. 100% {
  567. transform: translateY(-50%);
  568. }
  569. }
  570. </style>