index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. <template>
  2. <view>
  3. <uni-nav-bar fixed :border="false" backgroundColor="#fff" title="设备管理" :statusBar="true" left-icon="left"
  4. @clickLeft="$navBack()" @clickRight="refresh" rightWidth="140rpx">
  5. <!-- #ifndef MP-WEIXIN -->
  6. <template v-slot:right>
  7. <button class="nav-bar-refresh" :loading="refreshLoading" :disabled="refreshLoading">刷新</button>
  8. </template>
  9. <!-- #endif -->
  10. </uni-nav-bar>
  11. <view class="container">
  12. <!-- #ifndef APP-PLUS || H5 -->
  13. <view class="refresh-box">
  14. <button class="nav-bar-refresh" :loading="refreshLoading" :disabled="refreshLoading" @click="refresh">刷新</button>
  15. </view>
  16. <!-- #endif -->
  17. <view class="box">
  18. <view class="box-item" @click="navigatorUrl()">
  19. <view class="box-iteml">
  20. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management1_icon.png"></image>
  21. <text>智慧医生</text>
  22. </view>
  23. <view class="box-itemr">
  24. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  25. </image>
  26. </view>
  27. </view>
  28. <view class="box-item" @click="navigatorUrl('运动轨迹')">
  29. <view class="box-iteml">
  30. <image class="box-item-icon" src="@/static/images/pages_watch/icons/sports_trajectory_icon.png" style="border-radius: 10rpx;"></image>
  31. <text>运动轨迹</text>
  32. </view>
  33. <view class="box-itemr">
  34. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  35. </image>
  36. </view>
  37. </view>
  38. <view class="box-item" @click="navigatorUrl('久坐提醒')">
  39. <view class="box-iteml">
  40. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management2_icon.png"></image>
  41. <text>久坐提醒</text>
  42. </view>
  43. <view class="box-itemr">
  44. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  45. </image>
  46. </view>
  47. </view>
  48. <view class="box-item">
  49. <view class="box-iteml">
  50. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management3_icon.png"></image>
  51. <text>跌倒检测</text>
  52. </view>
  53. <view class="box-itemr">
  54. <mySwitch :activeValue="1" :inactiveValue="0" :value="info.fallcheck"
  55. @change="onChange($event,'fallcheck')" />
  56. </view>
  57. </view>
  58. <view class="box-item">
  59. <view class="box-iteml">
  60. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management4_icon.png"></image>
  61. <text>心脏健康</text>
  62. </view>
  63. <view class="box-itemr">
  64. <mySwitch :activeValue="1" :inactiveValue="0" :value="info.heartHealth"
  65. @change="onChange($event,'heartHealth')" />
  66. </view>
  67. </view>
  68. <view class="box-item" @click="navigatorUrl('心率指导')">
  69. <view class="box-iteml">
  70. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management5_icon.png"></image>
  71. <text>心率指导</text>
  72. </view>
  73. <view class="box-itemr">
  74. <text>{{info.hralarm && info.hralarm.open ? `${info.hralarm.low}-${info.hralarm.high}`: '关闭'}}</text>
  75. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  76. </image>
  77. </view>
  78. </view>
  79. <view class="box-item" @click="navigatorUrl('血氧预警')">
  80. <view class="box-iteml">
  81. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management6_icon.png"></image>
  82. <text>血氧预警</text>
  83. </view>
  84. <view class="box-itemr">
  85. <text>{{info.spo2alarm&&info.spo2alarm.open ? info.spo2alarm.low + '%' : '关闭'}}</text>
  86. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  87. </image>
  88. </view>
  89. </view>
  90. </view>
  91. <view class="box">
  92. <view class="box-item" @click="navigatorUrl('闹钟&日程')">
  93. <view class="box-iteml">
  94. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management7_icon.png"></image>
  95. <text>闹钟&日程</text>
  96. </view>
  97. <view class="box-itemr">
  98. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  99. </image>
  100. </view>
  101. </view>
  102. <view class="box-item" @click="navigatorUrl('省电设置')">
  103. <view class="box-iteml">
  104. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management8_icon.png"></image>
  105. <text>省电设置</text>
  106. </view>
  107. <view class="box-itemr">
  108. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  109. </image>
  110. </view>
  111. </view>
  112. <view class="box-item" @click="navigatorUrl('常用联系人')">
  113. <view class="box-iteml">
  114. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management9_icon.png"></image>
  115. <text>常用联系人</text>
  116. </view>
  117. <view class="box-itemr">
  118. <text>添加好友/联系人</text>
  119. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  120. </image>
  121. </view>
  122. </view>
  123. <view class="box-item" @click="navigatorUrl('手表通知')">
  124. <view class="box-iteml">
  125. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management10_icon.png"></image>
  126. <text>手表通知</text>
  127. </view>
  128. <view class="box-itemr">
  129. <view class="alarmNum" v-show="alarmNum">{{alarmNum}}</view>
  130. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  131. </image>
  132. </view>
  133. </view>
  134. <view class="box-item" @click="navigatorUrl('日期与时间')">
  135. <view class="box-iteml">
  136. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management11_icon.png"></image>
  137. <text>日期与时间</text>
  138. </view>
  139. <view class="box-itemr">
  140. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  141. </image>
  142. </view>
  143. </view>
  144. <view class="box-item" @click="navigatorUrl('翻腕亮屏')">
  145. <view class="box-iteml">
  146. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management12_icon.png"></image>
  147. <text>翻腕亮屏</text>
  148. </view>
  149. <view class="box-itemr">
  150. <text>{{info.lcdgesture&&info.lcdgesture.open ? `${$formatHour(info.lcdgesture.start_hour)}-${$formatHour(info.lcdgesture.end_hour)}`: '关闭'}}</text>
  151. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  152. </image>
  153. </view>
  154. </view>
  155. <view class="box-item" @click="navigatorUrl('单位设置')">
  156. <view class="box-iteml">
  157. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management13_icon.png"></image>
  158. <text>单位设置</text>
  159. </view>
  160. <view class="box-itemr">
  161. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  162. </image>
  163. </view>
  164. </view>
  165. </view>
  166. <view class="box">
  167. <view class="box-item" @click="navigatorUrl('新手指导')">
  168. <view class="box-iteml">
  169. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management14_icon.png"></image>
  170. <text>新手指导</text>
  171. </view>
  172. <view class="box-itemr">
  173. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  174. </image>
  175. </view>
  176. </view>
  177. <view class="box-item" @click="navigatorUrl('手表模式')">
  178. <view class="box-iteml">
  179. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management15_icon.png"></image>
  180. <text>手表模式</text>
  181. </view>
  182. <view class="box-itemr">
  183. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  184. </image>
  185. </view>
  186. </view>
  187. <view class="box-item" @click="navigatorUrl('设备信息')">
  188. <view class="box-iteml">
  189. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management16_icon.png"></image>
  190. <text>设备信息</text>
  191. </view>
  192. <view class="box-itemr">
  193. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  194. </image>
  195. </view>
  196. </view>
  197. <view class="box-item" @click="navigatorUrl()">
  198. <view class="box-iteml">
  199. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management17_icon.png"></image>
  200. <text>固件升级</text>
  201. </view>
  202. <view class="box-itemr">
  203. <text>{{info.version}}</text>
  204. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  205. </image>
  206. </view>
  207. </view>
  208. <view class="box-item" @click="factorySettings">
  209. <view class="box-iteml">
  210. <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management18_icon.png"></image>
  211. <text>恢复出厂</text>
  212. </view>
  213. <view class="box-itemr">
  214. <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
  215. </image>
  216. </view>
  217. </view>
  218. </view>
  219. <!-- 解除绑定 -->
  220. <button class="bind-btn" @click="handleRemoveDevice">解除绑定</button>
  221. </view>
  222. </view>
  223. </template>
  224. <script>
  225. import mySwitch from "@/pages_watch/components/mySwitch/mySwitch.vue";
  226. import { editMyfamily } from "@/api/pages_watch/user.js";
  227. import { queryAlarmPageByStatus } from "@/api/pages_watch/message.js"
  228. import {
  229. getSetUpInfoByDeviceId,
  230. refresh,
  231. fallcheck,
  232. autoaf,
  233. resetFactory,
  234. removeDevice
  235. } from "@/api/pages_watch/index.js";
  236. export default {
  237. components: {
  238. mySwitch
  239. },
  240. data() {
  241. return {
  242. refreshLoading: false,
  243. deviceId: uni.getStorageSync("deviceId") || "",
  244. defaultInfo: {
  245. fallcheck: 0,
  246. heartHealth: 0,
  247. hralarm: {
  248. open: false,
  249. low: "",
  250. high: ""
  251. },
  252. spo2alarm: {
  253. open: false,
  254. low: ""
  255. },
  256. lcdgesture: {
  257. open: false,
  258. end_hour: "",
  259. start_hour: ""
  260. },
  261. version: ""
  262. },
  263. info: {},
  264. alarmNum: 0, // 手表通知未读消息
  265. selectUser: '0'
  266. }
  267. },
  268. onLoad(option) {
  269. this.selectUser = option.selectUser
  270. this.info = this.defaultInfo
  271. },
  272. onShow() {
  273. this.refreshLoading = false
  274. this.deviceId = uni.getStorageSync("deviceId") || ""
  275. if (this.deviceId) {
  276. this.getSetUpInfo()
  277. this.getAlarmNum()
  278. }
  279. },
  280. methods: {
  281. getSetUpInfo() {
  282. getSetUpInfoByDeviceId({
  283. deviceId: this.deviceId
  284. }).then(res => {
  285. if (res.code == 200) {
  286. this.info = res.data || this.defaultInfo
  287. } else {
  288. uni.showToast({
  289. title: res.msg,
  290. icon: "none"
  291. })
  292. }
  293. })
  294. },
  295. // 获取手表通知未读消息
  296. getAlarmNum() {
  297. const param = {
  298. deviceId: uni.getStorageSync("deviceId") || '',
  299. pageSize: 10,
  300. pageNum: 1,
  301. appStatus: 0
  302. }
  303. queryAlarmPageByStatus(param).then(res => {
  304. const num = res.total || 0
  305. this.alarmNum = num > 99 ? '99+' : num
  306. })
  307. },
  308. refresh() {
  309. if (this.$isLogin()) {
  310. this.refreshLoading = true
  311. refresh({deviceId: this.deviceId}).then(res => {
  312. this.refreshLoading = false
  313. if (res.code == 200) {
  314. uni.showToast({
  315. title: res.data ? '刷新成功' : '刷新失败',
  316. icon: "none",
  317. position: 'top',
  318. duration: 2000
  319. })
  320. } else {
  321. uni.showToast({
  322. title: res.msg,
  323. icon: "none",
  324. position: 'top',
  325. duration: 2000
  326. })
  327. }
  328. }).catch(()=>{
  329. this.refreshLoading = false
  330. })
  331. } else {
  332. this.$showLoginPage()
  333. }
  334. },
  335. onChange(e, type) {
  336. this.info[type] = e
  337. const options = {
  338. // 跌倒检测开关
  339. "fallcheck": () => fallcheck({
  340. deviceId: this.deviceId,
  341. flag: e == 1 ? true : false
  342. }),
  343. // 心脏健康开关
  344. "heartHealth": () => autoaf({
  345. deviceId: this.deviceId,
  346. flag: e == 1 ? true : false
  347. })
  348. }
  349. const option = options[type];
  350. if (option) {
  351. option().then(res => {
  352. if (res.code != 200) {
  353. this.info[type] = e == 1 ? false : true
  354. uni.showToast({
  355. title: res.msg,
  356. icon: "none"
  357. })
  358. }
  359. }).catch((err) => {
  360. this.info[type] = e == 1 ? false : true
  361. uni.showToast({
  362. title: err,
  363. icon: "none"
  364. })
  365. })
  366. }
  367. },
  368. // 恢复出厂
  369. factorySettings() {
  370. uni.showModal({
  371. title: '恢复出厂',
  372. content: '恢复出厂将会清除手表的数据,以及还原手表设置,是否继续?',
  373. success: (res)=> {
  374. if (res.confirm) {
  375. uni.showLoading({
  376. title: ""
  377. })
  378. resetFactory({deviceId: this.deviceId}).then(res=>{
  379. uni.hideLoading();
  380. if(res.code == 200) {
  381. uni.showToast({
  382. title: '操作成功',
  383. icon: 'none',
  384. position: 'top',
  385. duration: 2000
  386. })
  387. this.getSetUpInfo()
  388. } else {
  389. uni.showToast({
  390. title: res.msg,
  391. icon: 'none'
  392. })
  393. }
  394. }).catch(()=>{
  395. uni.hideLoading();
  396. })
  397. }
  398. }
  399. });
  400. },
  401. navigatorUrl(txt) {
  402. const title = txt || ""
  403. if(!txt) {
  404. uni.showToast({
  405. title: '功能开发中...',
  406. icon: 'none',
  407. position: 'top',
  408. duration: 2000
  409. })
  410. return
  411. }
  412. const that = this
  413. if (txt == '手表通知') {
  414. uni.navigateTo({
  415. url: "/pages_watch/message/detail?title=" + title
  416. })
  417. } else if (txt == '常用联系人') {
  418. uni.navigateTo({
  419. url: "/pages_watch/index/equipment/emergencyContact"
  420. })
  421. } else if (txt == '新手指导') {
  422. uni.navigateTo({
  423. url: "/pages_watch/index/equipment/instructions"
  424. })
  425. } else if (txt == '设备信息') {
  426. uni.navigateTo({
  427. url: "/pages_watch/index/equipment/deviceInfo"
  428. })
  429. } else if(txt=='闹钟&日程') {
  430. uni.navigateTo({
  431. url: "/pages_watch/index/equipment/clockalarm?title=闹钟"
  432. })
  433. } else if(txt == '运动轨迹'){
  434. uni.navigateTo({
  435. url: "/pages_watch/index/equipment/sportsTrajectory?selectUser="+this.selectUser
  436. })
  437. }else {
  438. uni.navigateTo({
  439. url: "/pages_watch/index/equipment/set?title=" + title
  440. })
  441. }
  442. },
  443. // 解除绑定
  444. handleRemoveDevice() {
  445. uni.showModal({
  446. title: '',
  447. content: '确定解除绑定吗?',
  448. success: (res)=> {
  449. if (res.confirm) {
  450. this.removeDevice()
  451. }
  452. }
  453. });
  454. },
  455. removeDevice() {
  456. uni.showLoading({
  457. title: ""
  458. })
  459. // const myDeviceId = uni.getStorageSync("userWatchInfo") && JSON.parse(uni.getStorageSync("userWatchInfo")).deviceId
  460. const isFamily = this.selectUser != 0
  461. if(!isFamily) {
  462. removeDevice({deviceId: this.deviceId}).then(res=>{
  463. uni.hideLoading();
  464. if(res.code == 200) {
  465. uni.switchTab({url: '/pages/index/index' });
  466. } else {
  467. uni.showToast({
  468. title: res.msg,
  469. icon: "none"
  470. })
  471. }
  472. }).catch(()=>{
  473. uni.hideLoading();
  474. })
  475. } else {
  476. let otherDevice =JSON.parse(uni.getStorageSync("userWatchInfo")).otherDevice || []
  477. otherDevice = JSON.parse(otherDevice)
  478. otherDevice = otherDevice.map(item=>({
  479. ...item,
  480. deviceId: item.deviceId ? item.deviceId.split(',') : []
  481. }))
  482. otherDevice.forEach(el=>{
  483. if(el.deviceId && el.deviceId.includes(this.deviceId)) {
  484. el.deviceId.splice(el.deviceId.indexOf,1)
  485. }
  486. })
  487. const param = otherDevice.map(item=>({
  488. ...item,
  489. deviceId: item.deviceId ? item.deviceId.join(',') : ""
  490. }))
  491. editMyfamily({otherDevice: JSON.stringify(param)}).then(res=>{
  492. uni.hideLoading();
  493. this.btnLoading = false
  494. if(res.code == 200) {
  495. uni.switchTab({url: '/pages/index/index' });
  496. } else {
  497. uni.showToast({
  498. title: res.msg,
  499. icon: "none"
  500. })
  501. }
  502. }).catch(err => {
  503. this.btnLoading = false
  504. uni.hideLoading();
  505. console.log('err', err);
  506. })
  507. }
  508. }
  509. }
  510. }
  511. </script>
  512. <style lang="scss" scoped>
  513. .refresh-box {
  514. display: flex;
  515. align-items: center;
  516. justify-content: flex-end;
  517. margin-bottom: 24rpx;
  518. }
  519. .nav-bar-refresh {
  520. display: inline-block;
  521. min-width: 136rpx;
  522. height: 52rpx;
  523. margin: 0;
  524. padding: 0 24rpx;
  525. box-sizing: border-box;
  526. background: #FF7700 !important;
  527. border-radius: 26rpx 26rpx 26rpx 26rpx;
  528. line-height: 52rpx;
  529. text-align: center;
  530. font-family: PingFang SC, PingFang SC;
  531. font-weight: 400;
  532. font-size: 26rpx;
  533. color: #FFFFFF !important;
  534. &::after {
  535. border: none;
  536. }
  537. }
  538. .alarmNum{
  539. min-width: 48rpx;
  540. height: 48rpx;
  541. padding: 0 6rpx;
  542. box-sizing: border-box;
  543. background: linear-gradient( 180deg, #FA432D 0%, #FD7148 100%);
  544. border-radius: 28rpx 28rpx 28rpx 28rpx;
  545. border: 3rpx solid #FFFFFF;
  546. text-align: center;
  547. line-height: 48rpx;
  548. font-weight: 500;
  549. color: #FFFFFF;
  550. }
  551. .container {
  552. padding: 24rpx 24rpx 34rpx 24rpx;
  553. .box {
  554. margin-bottom: 20rpx;
  555. background: #FFFFFF;
  556. border-radius: 16rpx 16rpx 16rpx 16rpx;
  557. &-item {
  558. height: 108rpx;
  559. padding: 0 30rpx;
  560. display: flex;
  561. align-items: center;
  562. justify-content: space-between;
  563. font-family: PingFang SC, PingFang SC;
  564. font-weight: 400;
  565. font-size: 32rpx;
  566. color: #333333;
  567. }
  568. &-iteml {
  569. flex-shrink: 0;
  570. display: flex;
  571. align-items: center;
  572. justify-content: flex-start;
  573. }
  574. &-itemr {
  575. font-size: 28rpx;
  576. color: #999999;
  577. display: inline-flex;
  578. align-items: center;
  579. justify-content: flex-start;
  580. }
  581. .arrow_black {
  582. flex-shrink: 0;
  583. height: 48rpx;
  584. width: 48rpx;
  585. }
  586. &-item-icon {
  587. height: 56rpx;
  588. width: 56rpx;
  589. margin-right: 24rpx;
  590. }
  591. }
  592. .bind-btn {
  593. height: 98rpx;
  594. background: #FFFFFF;
  595. border-radius: 16rpx 16rpx 16rpx 16rpx;
  596. font-family: PingFang SC, PingFang SC;
  597. font-weight: 500;
  598. font-size: 32rpx;
  599. line-height: 98rpx;
  600. color: #FF7700;
  601. &::after {
  602. border: none;
  603. }
  604. }
  605. }
  606. </style>