home.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  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. 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. getWeather() {
  253. uni.request({
  254. url: "https://kp36x7gr79.re.qweatherapi.com/v7/weather/now", // 使用官方域名
  255. data: {
  256. location: "101220101", // 城市ID
  257. key: "72afe228cd7f436ebea7caa1345956f2", // 你的API Key
  258. },
  259. method: "GET",
  260. success: (res) => {
  261. if (res.statusCode === 200) {
  262. this.weatherText = res.data.now.text;
  263. }
  264. },
  265. fail: (err) => {
  266. console.error("网络错误:", err);
  267. },
  268. });
  269. },
  270. // 需要跟车对接一下,换一个接口
  271. getWarmList() {
  272. this.$http
  273. .post(
  274. "wap/stats/alarmRetentionQuery",
  275. {
  276. pageNo: 1,
  277. pageSize: 20,
  278. },
  279. {
  280. header: {
  281. "Content-Type": "application/json;charset=UTF-8",
  282. token: uni.getStorageSync("tokenValue") || "",
  283. },
  284. }
  285. )
  286. .then((res) => {
  287. if (res.data.data) {
  288. // this.warmNum = res.data.data.total;
  289. if (res.data.data.rows.length > 0) {
  290. this.warmDetail = res.data.data.rows;
  291. this.warmList = res.data.data.rows;
  292. }
  293. }
  294. });
  295. uni.hideLoading();
  296. },
  297. },
  298. onLoad() {},
  299. onShow() {
  300. if (uni.getStorageSync("userId")) {
  301. uni.showLoading({
  302. title: "雷能为您守护中...",
  303. });
  304. this.getperSonInfo();
  305. this.getShareNum();
  306. this.getWarmList();
  307. this.getWeather();
  308. this.isInitAlarm = true;
  309. this.isIniTenMinutes = true;
  310. }
  311. // 配置服务器
  312. let selectedService = uni.getStorageSync("sercviceChoice");
  313. if (!selectedService) {
  314. uni.setStorageSync("sercviceChoice", "aloneServe");
  315. }
  316. // uni.getLocation({
  317. // type: "wgs84",
  318. // success: (res) => {
  319. // console.log(res, 999999);
  320. // if (res) {
  321. // uni.request({
  322. // url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${res.latitude},${res.longitude}&key=${key}&get_poi=0`,
  323. // data: {
  324. // // location: "101220101", // 城市ID
  325. // // key: "72afe228cd7f436ebea7caa1345956f2", // 你的API Key
  326. // },
  327. // method: "GET",
  328. // success: (res) => {
  329. // console.log(res, 8870);
  330. // if (res.statusCode === 200) {
  331. // this.weatherText = res.data.now.text;
  332. // }
  333. // },
  334. // fail: (err) => {
  335. // console.error("网络错误:", err);
  336. // },
  337. // });
  338. // console.log(res, 99999);
  339. // }
  340. // this.getWeather();
  341. // },
  342. // });
  343. },
  344. onHide() {
  345. this.isInitAlarm = false;
  346. this.isIniTenMinutes = false;
  347. },
  348. onUnload() {
  349. this.isInitAlarm = false;
  350. this.isIniTenMinutes = false;
  351. },
  352. onShareAppMessage() {
  353. return {
  354. title: "好友向您分享雷能守护",
  355. path: "/pages/home/home",
  356. };
  357. },
  358. };
  359. </script>
  360. <style lang="less" scoped>
  361. .home-warp {
  362. position: relative;
  363. height: 100vh;
  364. background: linear-gradient(180deg, #faede2 0%, #f4f4f4 100%);
  365. /* padding: 24rpx 30rpx 20rpx; */
  366. }
  367. .header {
  368. display: flex;
  369. align-items: center;
  370. justify-content: space-between;
  371. padding: 90rpx 80rpx;
  372. }
  373. .headerPng {
  374. z-index: 1;
  375. }
  376. .headerPng image {
  377. width: 70rpx;
  378. height: 70rpx;
  379. border-radius: 50%;
  380. }
  381. .title {
  382. position: absolute;
  383. left: 50%;
  384. transform: translateX(-50%);
  385. color: #111111;
  386. font-size: 32rpx;
  387. }
  388. .leineng {
  389. position: absolute;
  390. top: -100rpx;
  391. display: flex;
  392. align-items: center;
  393. justify-content: flex-end;
  394. width: 100vw;
  395. height: 100vh;
  396. }
  397. .leineng image {
  398. position: absolute;
  399. top: 10%;
  400. left: 0;
  401. width: 700rpx;
  402. height: 1200rpx;
  403. }
  404. .right {
  405. z-index: 99;
  406. padding-right: 100rpx;
  407. }
  408. .right .rightItem {
  409. margin-bottom: 60rpx;
  410. color: #666666;
  411. }
  412. .right .rightItem .rightTitle {
  413. font-size: 23.44rpx;
  414. text-align: center;
  415. }
  416. .right .rightItem .rightContent {
  417. margin-top: 17rpx;
  418. font-size: 24rpx;
  419. font-weight: bold;
  420. }
  421. .right .rightItem .rightContent text {
  422. font-weight: 700;
  423. font-size: 66rpx;
  424. }
  425. .right .rightItem .rightAlarm {
  426. margin-top: 17rpx;
  427. font-size: 24rpx;
  428. font-weight: bold;
  429. color: #f55050;
  430. }
  431. .right .rightItem .rightAlarm text {
  432. font-weight: 700;
  433. font-size: 66rpx;
  434. color: #f55050;
  435. }
  436. .content {
  437. position: absolute;
  438. bottom: 200rpx;
  439. width: 100vw;
  440. display: flex;
  441. justify-content: space-around;
  442. }
  443. .card {
  444. width: 350rpx;
  445. height: 300rpx;
  446. border: 2rpx solid #ffffff;
  447. border-radius: 37rpx;
  448. background: #ffffff;
  449. padding: 38rpx 30rpx;
  450. box-sizing: border-box;
  451. }
  452. .contentTitle {
  453. display: flex;
  454. align-items: center;
  455. font-size: 32rpx;
  456. color: #111111;
  457. }
  458. .contentTitle image {
  459. width: 28rpx;
  460. height: 28rpx;
  461. margin-left: 8rpx;
  462. }
  463. .contentCenter {
  464. margin-top: 14rpx;
  465. font-size: 24rpx;
  466. color: #999999;
  467. }
  468. .contentImg image {
  469. margin-top: 60rpx;
  470. width: 94rpx;
  471. height: 94rpx;
  472. }
  473. .bottom {
  474. position: absolute;
  475. bottom: 80rpx;
  476. left: 50%;
  477. transform: translate(-50%, -50%);
  478. display: flex;
  479. justify-content: center;
  480. align-items: center;
  481. }
  482. .bottom image {
  483. width: 28rpx;
  484. height: 28rpx;
  485. }
  486. .bottom button {
  487. all: unset;
  488. margin: 0;
  489. padding: 0;
  490. border: none;
  491. background: none;
  492. font: inherit;
  493. text-align: inherit;
  494. line-height: normal;
  495. outline: none;
  496. box-shadow: none;
  497. -webkit-appearance: none;
  498. margin-left: 6rpx;
  499. color: #a1aab4;
  500. font-size: 28rpx;
  501. }
  502. .bot_version {
  503. opacity: 0.4;
  504. position: absolute;
  505. bottom: 20rpx;
  506. left: 50%;
  507. font-size: 28rpx;
  508. transform: translate(-50%, -50%);
  509. display: flex;
  510. justify-content: center;
  511. align-items: center;
  512. }
  513. .shareInfo {
  514. width: 100%;
  515. padding: 0 16rpx;
  516. color: #ffffff;
  517. display: flex;
  518. align-items: center;
  519. font-size: 28rpx;
  520. position: absolute;
  521. // top:210rpx;
  522. // top: 400rpx;
  523. left: 50%;
  524. transform: translate(-50%, -50%);
  525. box-sizing: border-box;
  526. background: linear-gradient(
  527. to right,
  528. #6f4e37 0%,
  529. rgba(210, 180, 140, 0.3) 100%
  530. );
  531. .shareimage {
  532. width: 60rpx;
  533. height: 60rpx;
  534. border-radius: 50%;
  535. }
  536. .sharetitle {
  537. margin-left: 20rpx;
  538. font-size: 28rpx;
  539. color: #ffffff;
  540. letter-spacing: 4rpx;
  541. }
  542. .sharenum {
  543. font-weight: bold;
  544. font-size: 28rpx;
  545. color: #ffffff;
  546. }
  547. .arrimage {
  548. width: 20rpx;
  549. height: 30rpx;
  550. margin-left: auto;
  551. }
  552. }
  553. .warmInfo {
  554. width: 100%;
  555. padding: 0rpx 10rpx;
  556. color: #ffffff;
  557. display: flex;
  558. align-items: center;
  559. font-size: 28rpx;
  560. position: absolute;
  561. top: 210rpx;
  562. left: 50%;
  563. transform: translate(-50%, -50%);
  564. box-sizing: border-box;
  565. background: linear-gradient(
  566. to right,
  567. #f9e0d7 0%,
  568. #ff6262 45%,
  569. #ff6262 55%,
  570. #f9e0d7 100%
  571. );
  572. border-radius: 12rpx;
  573. }
  574. .shareImage {
  575. width: 60rpx;
  576. height: 60rpx;
  577. border-radius: 50%;
  578. }
  579. .warmImage {
  580. width: 30rpx;
  581. height: 30rpx;
  582. margin-left: auto;
  583. }
  584. .shareTitleContainer {
  585. flex: 1;
  586. overflow: hidden;
  587. height: 40rpx;
  588. margin-left: 20rpx;
  589. display: flex;
  590. align-items: center;
  591. }
  592. /* 内层列表:滚动 */
  593. .shareTitleList {
  594. display: flex;
  595. flex-direction: column;
  596. animation: scrollUp 10s linear infinite;
  597. }
  598. .shareTitleTwo {
  599. display: flex;
  600. flex-direction: column;
  601. }
  602. .shareTitle {
  603. font-size: 28rpx;
  604. color: #ffffff;
  605. letter-spacing: 4rpx;
  606. height: 40rpx;
  607. line-height: 40rpx;
  608. white-space: nowrap;
  609. }
  610. /* 无限无缝滚动 */
  611. @keyframes scrollUp {
  612. 0% {
  613. transform: translateY(0);
  614. }
  615. 100% {
  616. transform: translateY(-50%);
  617. }
  618. }
  619. </style>