修改无网络时报错
This commit is contained in:
parent
3ba74c1c21
commit
855068a3f9
@ -207,7 +207,7 @@
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else if(code === -1) {
|
||||
} else if(resetDeviceCode === -1) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '删除失败,请保持在锁附近',
|
||||
|
||||
@ -101,7 +101,7 @@ export default {
|
||||
timeFormat,
|
||||
...mapActions(useLockStore, ['getRole', 'updateLockSearch', 'getLockList', 'getPowerIcon']),
|
||||
...mapActions(useBluetoothStore, ['openDoor', 'updateServerTimestamp', 'closeBluetoothConnection']),
|
||||
...mapActions(useBasicStore, ['routeJump', 'backAndToast']),
|
||||
...mapActions(useBasicStore, ['routeJump', 'backAndToast', 'getNetworkType']),
|
||||
closePopup() {
|
||||
this.show = false
|
||||
},
|
||||
@ -140,6 +140,16 @@ export default {
|
||||
if(this.pending) {
|
||||
return
|
||||
}
|
||||
if(this.currentLockInfo.lockSetting.appUnlockOnline) {
|
||||
const netWork = await this.getNetworkType()
|
||||
if(!netWork) {
|
||||
uni.showToast({
|
||||
title: '网络访问失败,请检查网络是否正常',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
uni.vibrateLong()
|
||||
this.pending = true
|
||||
this.$refs.loading.open()
|
||||
|
||||
@ -134,6 +134,23 @@ export const useBasicStore = defineStore('basic', {
|
||||
})
|
||||
}
|
||||
},
|
||||
// 获取当前网络状态
|
||||
getNetworkType() {
|
||||
return new Promise((resolve) => {
|
||||
uni.getNetworkType({
|
||||
success: function (res) {
|
||||
if(res.networkType === 'none') {
|
||||
resolve(false)
|
||||
return
|
||||
}
|
||||
resolve(true)
|
||||
},
|
||||
fail: function () {
|
||||
resolve(false)
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
// 获取设备信息
|
||||
getDeviceInfo() {
|
||||
const that = this
|
||||
|
||||
@ -58,11 +58,11 @@ const request = (config) => {
|
||||
})
|
||||
}
|
||||
} else {
|
||||
resolve({ code: -1, data, message: '网络不太好哦,请稍后再试' })
|
||||
resolve({ code: -1, data, message: '网络访问失败,请检查网络是否正常' })
|
||||
}
|
||||
},
|
||||
async fail() {
|
||||
resolve({ code: -1, data, message: '网络不太好哦,请稍后再试' })
|
||||
resolve({ code: -1, data, message: '网络访问失败,请检查网络是否正常' })
|
||||
},
|
||||
async complete(res) {
|
||||
console.log(URL.substring(baseConfig.baseUrl.length + 1), {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user