home.vue 16 KB

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