123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617 |
- <template>
- <view>
- <uni-nav-bar fixed :border="false" backgroundColor="#fff" title="设备管理" :statusBar="true" left-icon="left"
- @clickLeft="$navBack()" @clickRight="refresh" rightWidth="140rpx">
- <!-- #ifndef MP-WEIXIN -->
- <template v-slot:right>
- <button class="nav-bar-refresh" :loading="refreshLoading" :disabled="refreshLoading">刷新</button>
- </template>
- <!-- #endif -->
- </uni-nav-bar>
- <view class="container">
- <!-- #ifndef APP-PLUS || H5 -->
- <view class="refresh-box">
- <button class="nav-bar-refresh" :loading="refreshLoading" :disabled="refreshLoading" @click="refresh">刷新</button>
- </view>
- <!-- #endif -->
- <view class="box">
- <view class="box-item" @click="navigatorUrl()">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management1_icon.png"></image>
- <text>智慧医生</text>
- </view>
- <view class="box-itemr">
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="box-item" @click="navigatorUrl('运动轨迹')">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/sports_trajectory_icon.png" style="border-radius: 10rpx;"></image>
- <text>运动轨迹</text>
- </view>
- <view class="box-itemr">
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="box-item" @click="navigatorUrl('久坐提醒')">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management2_icon.png"></image>
- <text>久坐提醒</text>
- </view>
- <view class="box-itemr">
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="box-item">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management3_icon.png"></image>
- <text>跌倒检测</text>
- </view>
- <view class="box-itemr">
- <mySwitch :activeValue="1" :inactiveValue="0" :value="info.fallcheck"
- @change="onChange($event,'fallcheck')" />
- </view>
- </view>
- <view class="box-item">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management4_icon.png"></image>
- <text>心脏健康</text>
- </view>
- <view class="box-itemr">
- <mySwitch :activeValue="1" :inactiveValue="0" :value="info.heartHealth"
- @change="onChange($event,'heartHealth')" />
- </view>
- </view>
- <view class="box-item" @click="navigatorUrl('心率指导')">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management5_icon.png"></image>
- <text>心率指导</text>
- </view>
- <view class="box-itemr">
- <text>{{info.hralarm && info.hralarm.open ? `${info.hralarm.low}-${info.hralarm.high}`: '关闭'}}</text>
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="box-item" @click="navigatorUrl('血氧预警')">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management6_icon.png"></image>
- <text>血氧预警</text>
- </view>
- <view class="box-itemr">
- <text>{{info.spo2alarm&&info.spo2alarm.open ? info.spo2alarm.low + '%' : '关闭'}}</text>
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- </view>
- <view class="box">
- <view class="box-item" @click="navigatorUrl('闹钟&日程')">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management7_icon.png"></image>
- <text>闹钟&日程</text>
- </view>
- <view class="box-itemr">
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="box-item" @click="navigatorUrl('省电设置')">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management8_icon.png"></image>
- <text>省电设置</text>
- </view>
- <view class="box-itemr">
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="box-item" @click="navigatorUrl('常用联系人')">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management9_icon.png"></image>
- <text>常用联系人</text>
- </view>
- <view class="box-itemr">
- <text>添加好友/联系人</text>
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="box-item" @click="navigatorUrl('手表通知')">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management10_icon.png"></image>
- <text>手表通知</text>
- </view>
- <view class="box-itemr">
- <view class="alarmNum" v-show="alarmNum">{{alarmNum}}</view>
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="box-item" @click="navigatorUrl('日期与时间')">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management11_icon.png"></image>
- <text>日期与时间</text>
- </view>
- <view class="box-itemr">
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="box-item" @click="navigatorUrl('翻腕亮屏')">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management12_icon.png"></image>
- <text>翻腕亮屏</text>
- </view>
- <view class="box-itemr">
- <text>{{info.lcdgesture&&info.lcdgesture.open ? `${$formatHour(info.lcdgesture.start_hour)}-${$formatHour(info.lcdgesture.end_hour)}`: '关闭'}}</text>
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="box-item" @click="navigatorUrl('单位设置')">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management13_icon.png"></image>
- <text>单位设置</text>
- </view>
- <view class="box-itemr">
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- </view>
- <view class="box">
- <view class="box-item" @click="navigatorUrl('新手指导')">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management14_icon.png"></image>
- <text>新手指导</text>
- </view>
- <view class="box-itemr">
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="box-item" @click="navigatorUrl('手表模式')">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management15_icon.png"></image>
- <text>手表模式</text>
- </view>
- <view class="box-itemr">
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="box-item" @click="navigatorUrl('设备信息')">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management16_icon.png"></image>
- <text>设备信息</text>
- </view>
- <view class="box-itemr">
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="box-item" @click="navigatorUrl()">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management17_icon.png"></image>
- <text>固件升级</text>
- </view>
- <view class="box-itemr">
- <text>{{info.version}}</text>
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- <view class="box-item" @click="factorySettings">
- <view class="box-iteml">
- <image class="box-item-icon" src="@/static/images/pages_watch/icons/equipment_management18_icon.png"></image>
- <text>恢复出厂</text>
- </view>
- <view class="box-itemr">
- <image class="arrow_black" src="@/static/images/pages_watch/icons/my_right_arrow_right_icon.png" mode="aspectFill">
- </image>
- </view>
- </view>
- </view>
- <!-- 解除绑定 -->
- <button class="bind-btn" @click="handleRemoveDevice">解除绑定</button>
- </view>
- </view>
- </template>
- <script>
- import mySwitch from "@/pages_watch/components/mySwitch/mySwitch.vue";
- import { editMyfamily } from "@/api/pages_watch/user.js";
- import { queryAlarmPageByStatus } from "@/api/pages_watch/message.js"
- import {
- getSetUpInfoByDeviceId,
- refresh,
- fallcheck,
- autoaf,
- resetFactory,
- removeDevice
- } from "@/api/pages_watch/index.js";
- export default {
- components: {
- mySwitch
- },
- data() {
- return {
- refreshLoading: false,
- deviceId: uni.getStorageSync("deviceId") || "",
- defaultInfo: {
- fallcheck: 0,
- heartHealth: 0,
- hralarm: {
- open: false,
- low: "",
- high: ""
- },
- spo2alarm: {
- open: false,
- low: ""
- },
- lcdgesture: {
- open: false,
- end_hour: "",
- start_hour: ""
- },
- version: ""
- },
- info: {},
- alarmNum: 0, // 手表通知未读消息
- selectUser: '0'
- }
- },
- onLoad(option) {
- this.selectUser = option.selectUser
- this.info = this.defaultInfo
- },
- onShow() {
- this.refreshLoading = false
- this.deviceId = uni.getStorageSync("deviceId") || ""
- if (this.deviceId) {
- this.getSetUpInfo()
- this.getAlarmNum()
- }
- },
- methods: {
- getSetUpInfo() {
- getSetUpInfoByDeviceId({
- deviceId: this.deviceId
- }).then(res => {
- if (res.code == 200) {
- this.info = res.data || this.defaultInfo
- } else {
- uni.showToast({
- title: res.msg,
- icon: "none"
- })
- }
- })
- },
- // 获取手表通知未读消息
- getAlarmNum() {
- const param = {
- deviceId: uni.getStorageSync("deviceId") || '',
- pageSize: 10,
- pageNum: 1,
- appStatus: 0
- }
- queryAlarmPageByStatus(param).then(res => {
- const num = res.total || 0
- this.alarmNum = num > 99 ? '99+' : num
- })
- },
- refresh() {
- if (this.$isLogin()) {
- this.refreshLoading = true
- refresh({deviceId: this.deviceId}).then(res => {
- this.refreshLoading = false
- if (res.code == 200) {
- uni.showToast({
- title: res.data ? '刷新成功' : '刷新失败',
- icon: "none",
- position: 'top',
- duration: 2000
- })
- } else {
- uni.showToast({
- title: res.msg,
- icon: "none",
- position: 'top',
- duration: 2000
- })
- }
- }).catch(()=>{
- this.refreshLoading = false
- })
- } else {
- this.$showLoginPage()
- }
- },
- onChange(e, type) {
- this.info[type] = e
- const options = {
- // 跌倒检测开关
- "fallcheck": () => fallcheck({
- deviceId: this.deviceId,
- flag: e == 1 ? true : false
- }),
- // 心脏健康开关
- "heartHealth": () => autoaf({
- deviceId: this.deviceId,
- flag: e == 1 ? true : false
- })
- }
- const option = options[type];
- if (option) {
- option().then(res => {
- if (res.code != 200) {
- this.info[type] = e == 1 ? false : true
- uni.showToast({
- title: res.msg,
- icon: "none"
- })
- }
- }).catch((err) => {
- this.info[type] = e == 1 ? false : true
- uni.showToast({
- title: err,
- icon: "none"
- })
- })
- }
- },
- // 恢复出厂
- factorySettings() {
- uni.showModal({
- title: '恢复出厂',
- content: '恢复出厂将会清除手表的数据,以及还原手表设置,是否继续?',
- success: (res)=> {
- if (res.confirm) {
- uni.showLoading({
- title: ""
- })
- resetFactory({deviceId: this.deviceId}).then(res=>{
- uni.hideLoading();
- if(res.code == 200) {
- uni.showToast({
- title: '操作成功',
- icon: 'none',
- position: 'top',
- duration: 2000
- })
- this.getSetUpInfo()
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- })
- }
- }).catch(()=>{
- uni.hideLoading();
- })
- }
- }
- });
- },
- navigatorUrl(txt) {
- const title = txt || ""
- if(!txt) {
- uni.showToast({
- title: '功能开发中...',
- icon: 'none',
- position: 'top',
- duration: 2000
- })
- return
- }
- const that = this
- if (txt == '手表通知') {
- uni.navigateTo({
- url: "/pages_watch/message/detail?title=" + title
- })
- } else if (txt == '常用联系人') {
- uni.navigateTo({
- url: "/pages_watch/index/equipment/emergencyContact"
- })
- } else if (txt == '新手指导') {
- uni.navigateTo({
- url: "/pages_watch/index/equipment/instructions"
- })
- } else if (txt == '设备信息') {
- uni.navigateTo({
- url: "/pages_watch/index/equipment/deviceInfo"
- })
- } else if(txt=='闹钟&日程') {
- uni.navigateTo({
- url: "/pages_watch/index/equipment/clockalarm?title=闹钟"
- })
- } else if(txt == '运动轨迹'){
- uni.navigateTo({
- url: "/pages_watch/index/equipment/sportsTrajectory?selectUser="+this.selectUser
- })
- }else {
- uni.navigateTo({
- url: "/pages_watch/index/equipment/set?title=" + title
- })
- }
- },
- // 解除绑定
- handleRemoveDevice() {
- uni.showModal({
- title: '',
- content: '确定解除绑定吗?',
- success: (res)=> {
- if (res.confirm) {
- this.removeDevice()
- }
- }
- });
- },
- removeDevice() {
- uni.showLoading({
- title: ""
- })
- // const myDeviceId = uni.getStorageSync("userWatchInfo") && JSON.parse(uni.getStorageSync("userWatchInfo")).deviceId
- const isFamily = this.selectUser != 0
- if(!isFamily) {
- removeDevice({deviceId: this.deviceId}).then(res=>{
- uni.hideLoading();
- if(res.code == 200) {
- uni.switchTab({url: '/pages/index/index' });
- } else {
- uni.showToast({
- title: res.msg,
- icon: "none"
- })
- }
- }).catch(()=>{
- uni.hideLoading();
- })
- } else {
- let otherDevice =JSON.parse(uni.getStorageSync("userWatchInfo")).otherDevice || []
- otherDevice = JSON.parse(otherDevice)
- otherDevice = otherDevice.map(item=>({
- ...item,
- deviceId: item.deviceId ? item.deviceId.split(',') : []
- }))
- otherDevice.forEach(el=>{
- if(el.deviceId && el.deviceId.includes(this.deviceId)) {
- el.deviceId.splice(el.deviceId.indexOf,1)
- }
- })
- const param = otherDevice.map(item=>({
- ...item,
- deviceId: item.deviceId ? item.deviceId.join(',') : ""
- }))
- editMyfamily({otherDevice: JSON.stringify(param)}).then(res=>{
- uni.hideLoading();
- this.btnLoading = false
- if(res.code == 200) {
- uni.switchTab({url: '/pages/index/index' });
- } else {
- uni.showToast({
- title: res.msg,
- icon: "none"
- })
- }
- }).catch(err => {
- this.btnLoading = false
- uni.hideLoading();
- console.log('err', err);
- })
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .refresh-box {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- margin-bottom: 24rpx;
- }
- .nav-bar-refresh {
- display: inline-block;
- min-width: 136rpx;
- height: 52rpx;
- margin: 0;
- padding: 0 24rpx;
- box-sizing: border-box;
- background: #FF7700 !important;
- border-radius: 26rpx 26rpx 26rpx 26rpx;
- line-height: 52rpx;
- text-align: center;
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 26rpx;
- color: #FFFFFF !important;
- &::after {
- border: none;
- }
- }
- .alarmNum{
- min-width: 48rpx;
- height: 48rpx;
- padding: 0 6rpx;
- box-sizing: border-box;
- background: linear-gradient( 180deg, #FA432D 0%, #FD7148 100%);
- border-radius: 28rpx 28rpx 28rpx 28rpx;
- border: 3rpx solid #FFFFFF;
- text-align: center;
- line-height: 48rpx;
- font-weight: 500;
- color: #FFFFFF;
- }
- .container {
- padding: 24rpx 24rpx 34rpx 24rpx;
- .box {
- margin-bottom: 20rpx;
- background: #FFFFFF;
- border-radius: 16rpx 16rpx 16rpx 16rpx;
- &-item {
- height: 108rpx;
- padding: 0 30rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- font-family: PingFang SC, PingFang SC;
- font-weight: 400;
- font-size: 32rpx;
- color: #333333;
- }
- &-iteml {
- flex-shrink: 0;
- display: flex;
- align-items: center;
- justify-content: flex-start;
- }
- &-itemr {
- font-size: 28rpx;
- color: #999999;
- display: inline-flex;
- align-items: center;
- justify-content: flex-start;
- }
- .arrow_black {
- flex-shrink: 0;
- height: 48rpx;
- width: 48rpx;
- }
- &-item-icon {
- height: 56rpx;
- width: 56rpx;
- margin-right: 24rpx;
- }
- }
- .bind-btn {
- height: 98rpx;
- background: #FFFFFF;
- border-radius: 16rpx 16rpx 16rpx 16rpx;
- font-family: PingFang SC, PingFang SC;
- font-weight: 500;
- font-size: 32rpx;
- line-height: 98rpx;
- color: #FF7700;
- &::after {
- border: none;
- }
- }
- }
- </style>
|