home.vue 17 KB

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