home.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  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>{{ groupNum }}</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>{{ devNum }}</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.navigateTo({
  176. url:
  177. "/pagesA/deviceDetail/deviceDetail?devItem=" +
  178. JSON.stringify(this.devDevice[0]),
  179. });
  180. } else {
  181. uni.navigateTo({
  182. url: url,
  183. });
  184. }
  185. } else {
  186. uni.showToast({
  187. title: "暂未登录,请先登录",
  188. icon: "none",
  189. duration: 1500,
  190. });
  191. uni.reLaunch({
  192. url: "/pagesA/loginNew/loginNew",
  193. });
  194. }
  195. },
  196. goAbnormalInfo() {
  197. if (uni.getStorageSync("userId")) {
  198. if (this.warnNum <= 0) {
  199. uni.showToast({
  200. title: "暂无异常信息",
  201. icon: "none",
  202. duration: 1500,
  203. });
  204. return;
  205. }
  206. uni.navigateTo({
  207. url: "/pagesA/abnormalInfo/abnormalInfo",
  208. });
  209. return;
  210. }
  211. uni.reLaunch({
  212. url: "/pagesA/loginNew/loginNew",
  213. });
  214. },
  215. goDeviceShare() {
  216. uni.setStorageSync("shareStatus", "authorized");
  217. uni.navigateTo({
  218. url: "/pagesA/shareList/shareList",
  219. });
  220. },
  221. getperSonInfo() {
  222. this.$http
  223. .get("wap/home/homeInfo", {
  224. userId: uni.getStorageSync("userId"),
  225. })
  226. .then((res) => {
  227. if (res.data.data) {
  228. const { groupNum, devNum, warnNum } = res.data.data;
  229. this.groupNum = groupNum;
  230. this.devNum = devNum;
  231. this.warnNum = warnNum;
  232. this.devDevice = res.data.data.deviceList;
  233. }
  234. });
  235. },
  236. getShareNum() {
  237. // uni.showLoading({
  238. // title: "雷能守护中...",
  239. // });
  240. this.$http
  241. .post("wap/share/queryDevShare", {
  242. userId: uni.getStorageSync("userId"),
  243. state: 0,
  244. })
  245. .then((res) => {
  246. this.shareNum = res.data.data?.length || 0;
  247. });
  248. },
  249. // 获取天气接口
  250. getWeather() {
  251. uni.request({
  252. url: "https://kp36x7gr79.re.qweatherapi.com/v7/weather/now", // 使用官方域名
  253. data: {
  254. location: "101220101", // 城市ID
  255. key: "72afe228cd7f436ebea7caa1345956f2", // 你的API Key
  256. },
  257. method: "GET",
  258. success: (res) => {
  259. if (res.statusCode === 200) {
  260. this.weatherText = res.data.now.text;
  261. }
  262. },
  263. fail: (err) => {
  264. console.error("网络错误:", err);
  265. },
  266. });
  267. },
  268. // 需要跟车对接一下,换一个接口
  269. getWarmList() {
  270. this.$http
  271. .post(
  272. "wap/stats/alarmRetentionQuery",
  273. {
  274. pageNo: 1,
  275. pageSize: 20,
  276. },
  277. {
  278. header: {
  279. "Content-Type": "application/json;charset=UTF-8",
  280. token: uni.getStorageSync("tokenValue") || "",
  281. },
  282. }
  283. )
  284. .then((res) => {
  285. if (res.data.data) {
  286. // this.warmNum = res.data.data.total;
  287. if (res.data.data.rows.length > 0) {
  288. this.warmDetail = res.data.data.rows;
  289. this.warmList = res.data.data.rows;
  290. }
  291. }
  292. });
  293. uni.hideLoading();
  294. },
  295. },
  296. onLoad() {},
  297. onShow() {
  298. if (uni.getStorageSync("userId")) {
  299. uni.showLoading({
  300. title: "雷能为您守护中...",
  301. });
  302. this.getperSonInfo();
  303. this.getShareNum();
  304. this.getWarmList();
  305. this.getWeather();
  306. this.isInitAlarm = true;
  307. this.isIniTenMinutes = true;
  308. }
  309. // 配置服务器
  310. let selectedService = uni.getStorageSync("sercviceChoice");
  311. if (!selectedService) {
  312. uni.setStorageSync("sercviceChoice", "aloneServe");
  313. }
  314. },
  315. onHide() {
  316. this.isInitAlarm = false;
  317. this.isIniTenMinutes = false;
  318. },
  319. onUnload() {
  320. this.isInitAlarm = false;
  321. this.isIniTenMinutes = false;
  322. },
  323. onShareAppMessage() {
  324. return {
  325. title: "好友向您分享雷能守护",
  326. path: "/pages/home/home",
  327. };
  328. },
  329. };
  330. </script>
  331. <style lang="less" scoped>
  332. .home-warp {
  333. position: relative;
  334. height: 100vh;
  335. background: linear-gradient(180deg, #faede2 0%, #f4f4f4 100%);
  336. /* padding: 24rpx 30rpx 20rpx; */
  337. }
  338. .header {
  339. display: flex;
  340. align-items: center;
  341. justify-content: space-between;
  342. padding: 90rpx 80rpx;
  343. }
  344. .headerPng {
  345. z-index: 1;
  346. }
  347. .headerPng image {
  348. width: 70rpx;
  349. height: 70rpx;
  350. border-radius: 50%;
  351. }
  352. .title {
  353. position: absolute;
  354. left: 50%;
  355. transform: translateX(-50%);
  356. color: #111111;
  357. font-size: 32rpx;
  358. }
  359. .leineng {
  360. position: absolute;
  361. top: -100rpx;
  362. display: flex;
  363. align-items: center;
  364. justify-content: flex-end;
  365. width: 100vw;
  366. height: 100vh;
  367. }
  368. .leineng image {
  369. position: absolute;
  370. top: 10%;
  371. left: 0;
  372. width: 700rpx;
  373. height: 1200rpx;
  374. }
  375. .right {
  376. z-index: 99;
  377. padding-right: 100rpx;
  378. }
  379. .right .rightItem {
  380. margin-bottom: 60rpx;
  381. color: #666666;
  382. }
  383. .right .rightItem .rightTitle {
  384. font-size: 23.44rpx;
  385. text-align: center;
  386. }
  387. .right .rightItem .rightContent {
  388. margin-top: 17rpx;
  389. font-size: 24rpx;
  390. font-weight: bold;
  391. }
  392. .right .rightItem .rightContent text {
  393. font-weight: 700;
  394. font-size: 66rpx;
  395. }
  396. .right .rightItem .rightAlarm {
  397. margin-top: 17rpx;
  398. font-size: 24rpx;
  399. font-weight: bold;
  400. color: #f55050;
  401. }
  402. .right .rightItem .rightAlarm text {
  403. font-weight: 700;
  404. font-size: 66rpx;
  405. color: #f55050;
  406. }
  407. .content {
  408. position: absolute;
  409. bottom: 200rpx;
  410. width: 100vw;
  411. display: flex;
  412. justify-content: space-around;
  413. }
  414. .card {
  415. width: 350rpx;
  416. height: 300rpx;
  417. border: 2rpx solid #ffffff;
  418. border-radius: 37rpx;
  419. background: #ffffff;
  420. padding: 38rpx 30rpx;
  421. box-sizing: border-box;
  422. }
  423. .contentTitle {
  424. display: flex;
  425. align-items: center;
  426. font-size: 32rpx;
  427. color: #111111;
  428. }
  429. .contentTitle image {
  430. width: 28rpx;
  431. height: 28rpx;
  432. margin-left: 8rpx;
  433. }
  434. .contentCenter {
  435. margin-top: 14rpx;
  436. font-size: 24rpx;
  437. color: #999999;
  438. }
  439. .contentImg image {
  440. margin-top: 60rpx;
  441. width: 94rpx;
  442. height: 94rpx;
  443. }
  444. .bottom {
  445. position: absolute;
  446. bottom: 80rpx;
  447. left: 50%;
  448. transform: translate(-50%, -50%);
  449. display: flex;
  450. justify-content: center;
  451. align-items: center;
  452. }
  453. .bottom image {
  454. width: 28rpx;
  455. height: 28rpx;
  456. }
  457. .bottom button {
  458. all: unset;
  459. margin: 0;
  460. padding: 0;
  461. border: none;
  462. background: none;
  463. font: inherit;
  464. text-align: inherit;
  465. line-height: normal;
  466. outline: none;
  467. box-shadow: none;
  468. -webkit-appearance: none;
  469. margin-left: 6rpx;
  470. color: #a1aab4;
  471. font-size: 28rpx;
  472. }
  473. .bot_version {
  474. opacity: 0.4;
  475. position: absolute;
  476. bottom: 20rpx;
  477. left: 50%;
  478. font-size: 28rpx;
  479. transform: translate(-50%, -50%);
  480. display: flex;
  481. justify-content: center;
  482. align-items: center;
  483. }
  484. .shareInfo {
  485. width: 100%;
  486. padding: 0 16rpx;
  487. color: #ffffff;
  488. display: flex;
  489. align-items: center;
  490. font-size: 28rpx;
  491. position: absolute;
  492. // top:210rpx;
  493. // top: 400rpx;
  494. left: 50%;
  495. transform: translate(-50%, -50%);
  496. box-sizing: border-box;
  497. background: linear-gradient(
  498. to right,
  499. #6f4e37 0%,
  500. rgba(210, 180, 140, 0.3) 100%
  501. );
  502. .shareimage {
  503. width: 60rpx;
  504. height: 60rpx;
  505. border-radius: 50%;
  506. }
  507. .sharetitle {
  508. margin-left: 20rpx;
  509. font-size: 28rpx;
  510. color: #ffffff;
  511. letter-spacing: 4rpx;
  512. }
  513. .sharenum {
  514. font-weight: bold;
  515. font-size: 28rpx;
  516. color: #ffffff;
  517. }
  518. .arrimage {
  519. width: 20rpx;
  520. height: 30rpx;
  521. margin-left: auto;
  522. }
  523. }
  524. .warmInfo {
  525. width: 100%;
  526. padding: 0rpx 10rpx;
  527. color: #ffffff;
  528. display: flex;
  529. align-items: center;
  530. font-size: 28rpx;
  531. position: absolute;
  532. top: 210rpx;
  533. left: 50%;
  534. transform: translate(-50%, -50%);
  535. box-sizing: border-box;
  536. background: linear-gradient(
  537. to right,
  538. #f9e0d7 0%,
  539. #ff6262 45%,
  540. #ff6262 55%,
  541. #f9e0d7 100%
  542. );
  543. border-radius: 12rpx;
  544. }
  545. .shareImage {
  546. width: 60rpx;
  547. height: 60rpx;
  548. border-radius: 50%;
  549. }
  550. .warmImage {
  551. width: 30rpx;
  552. height: 30rpx;
  553. margin-left: auto;
  554. }
  555. .shareTitleContainer {
  556. flex: 1;
  557. overflow: hidden;
  558. height: 40rpx;
  559. margin-left: 20rpx;
  560. display: flex;
  561. align-items: center;
  562. }
  563. /* 内层列表:滚动 */
  564. .shareTitleList {
  565. display: flex;
  566. flex-direction: column;
  567. animation: scrollUp 10s linear infinite;
  568. }
  569. .shareTitleTwo {
  570. display: flex;
  571. flex-direction: column;
  572. }
  573. .shareTitle {
  574. font-size: 28rpx;
  575. color: #ffffff;
  576. letter-spacing: 4rpx;
  577. height: 40rpx;
  578. line-height: 40rpx;
  579. white-space: nowrap;
  580. }
  581. /* 无限无缝滚动 */
  582. @keyframes scrollUp {
  583. 0% {
  584. transform: translateY(0);
  585. }
  586. 100% {
  587. transform: translateY(-50%);
  588. }
  589. }
  590. </style>