|
@@ -10,13 +10,13 @@
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="device-header_fun">
|
|
<view class="device-header_fun">
|
|
|
- <uv-tags plain size="mini" type="primary" :text="fmtDictName('WashDevice.state',state.device.state)"></uv-tags>
|
|
|
|
|
|
|
+ <uv-tags plain size="mini" type="primary" :text="fmtDictName('WashDevice.state',state.device?.state)"></uv-tags>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
</view>
|
|
</view>
|
|
|
<view class="device-body">
|
|
<view class="device-body">
|
|
|
<view class="device-body_ops" @click="debounceStartStopDevice">
|
|
<view class="device-body_ops" @click="debounceStartStopDevice">
|
|
|
- <text v-if="state.device.state==='idle'">启动设备</text>
|
|
|
|
|
|
|
+ <text v-if="state.device?.state==='idle'">启动设备</text>
|
|
|
<text v-else>停止设备</text>
|
|
<text v-else>停止设备</text>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
@@ -37,9 +37,10 @@
|
|
|
|
|
|
|
|
<view class="device-body_recharge">
|
|
<view class="device-body_recharge">
|
|
|
<uv-button
|
|
<uv-button
|
|
|
|
|
+ v-if="state.isLogin"
|
|
|
type="default"
|
|
type="default"
|
|
|
color="#19A497"
|
|
color="#19A497"
|
|
|
- @click="handleGotoRechage">充值
|
|
|
|
|
|
|
+ @click="handleGotoRechage">余额¥ {{ fmtMoney(state.balance) }},去充值
|
|
|
</uv-button>
|
|
</uv-button>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -55,9 +56,12 @@ import {reactive, ref} from "vue";
|
|
|
import {debounce, fmtDictName} from "@/utils/common";
|
|
import {debounce, fmtDictName} from "@/utils/common";
|
|
|
import {get, post} from "@/utils/https";
|
|
import {get, post} from "@/utils/https";
|
|
|
import {checkLogin, fetchToken, tryLogin} from "@/utils/auth";
|
|
import {checkLogin, fetchToken, tryLogin} from "@/utils/auth";
|
|
|
|
|
+import {fmtMoney} from "@/utils/common";
|
|
|
import LoginBar from "@/components/login-bar/index.vue";
|
|
import LoginBar from "@/components/login-bar/index.vue";
|
|
|
|
|
|
|
|
const initState = () => ({
|
|
const initState = () => ({
|
|
|
|
|
+ isLogin:false,
|
|
|
|
|
+ balance:0,
|
|
|
device: {
|
|
device: {
|
|
|
functions: [],
|
|
functions: [],
|
|
|
deviceName: '',
|
|
deviceName: '',
|
|
@@ -92,21 +96,25 @@ onLoad((options: any) => {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ getApp<any>().globalData.deviceId = id;
|
|
|
state.device = getApp<any>().globalData.last.device;
|
|
state.device = getApp<any>().globalData.last.device;
|
|
|
checkLogin().then((token) => {
|
|
checkLogin().then((token) => {
|
|
|
|
|
+ state.isLogin =true;
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
loadDeviceDetail(id);
|
|
loadDeviceDetail(id);
|
|
|
|
|
+ state.balance = getApp<any>().globalData.user.balance
|
|
|
}, 200)
|
|
}, 200)
|
|
|
}).catch(e => {
|
|
}).catch(e => {
|
|
|
console.error("onLoad 校验登录失败,自动跳转登录页")
|
|
console.error("onLoad 校验登录失败,自动跳转登录页")
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: `/pages-user/login/index?shortId=${state.deviceId}&redirectUrl=/pages-wash/device/index`
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // uni.navigateTo({
|
|
|
|
|
+ // url: `/pages-user/login/index?shortId=${state.deviceId}&redirectUrl=/pages-wash/device/index`
|
|
|
|
|
+ // })
|
|
|
})
|
|
})
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
-onShow(() => {
|
|
|
|
|
|
|
+onShow((options:any) => {
|
|
|
|
|
+ console.log(options)
|
|
|
addListener();
|
|
addListener();
|
|
|
// uni.showToast({
|
|
// uni.showToast({
|
|
|
// title:'onShow,'
|
|
// title:'onShow,'
|
|
@@ -116,7 +124,7 @@ onShow(() => {
|
|
|
// title:'onShow,loaded'
|
|
// title:'onShow,loaded'
|
|
|
// })
|
|
// })
|
|
|
if (!state.deviceId) {
|
|
if (!state.deviceId) {
|
|
|
- console.log("deviceId", getApp<any>().globalData.deviceId)
|
|
|
|
|
|
|
+ console.log("device page deviceId", getApp<any>().globalData.deviceId)
|
|
|
let deviceId = getApp<any>().globalData.deviceId;
|
|
let deviceId = getApp<any>().globalData.deviceId;
|
|
|
if (deviceId) {
|
|
if (deviceId) {
|
|
|
loadDeviceDetail(deviceId);
|
|
loadDeviceDetail(deviceId);
|
|
@@ -124,11 +132,16 @@ onShow(() => {
|
|
|
} else {
|
|
} else {
|
|
|
loadDeviceDetail(state.deviceId);
|
|
loadDeviceDetail(state.deviceId);
|
|
|
}
|
|
}
|
|
|
|
|
+ state.isLogin =true;
|
|
|
|
|
+ state.balance = getApp<any>().globalData.user.balance
|
|
|
}).catch(e => {
|
|
}).catch(e => {
|
|
|
console.error("校验登录失败,自动跳转登录页")
|
|
console.error("校验登录失败,自动跳转登录页")
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: `/pages-user/login/index?shortId=${state.deviceId}&redirectUrl=/pages-wash/device/index`
|
|
|
|
|
|
|
+ setTimeout(()=>{
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: `/pages-user/login/index?shortId=${state.deviceId}&redirectUrl=/pages-wash/device/index`
|
|
|
|
|
+ },100)
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
@@ -137,8 +150,10 @@ onShow(() => {
|
|
|
|
|
|
|
|
const addListener = () => {
|
|
const addListener = () => {
|
|
|
uni.$on('login', function (data) {
|
|
uni.$on('login', function (data) {
|
|
|
|
|
+ state.isLogin =true;
|
|
|
if (state.deviceId && data.isLogin) {
|
|
if (state.deviceId && data.isLogin) {
|
|
|
loadDeviceDetail(state.deviceId);
|
|
loadDeviceDetail(state.deviceId);
|
|
|
|
|
+ state.balance = getApp<any>().globalData.user.balance
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|