修复无网情况列表仍然显示和长时间loading问题
This commit is contained in:
parent
9c6b7ce85f
commit
09b45762ce
@ -340,6 +340,10 @@
|
||||
}
|
||||
const { code } = await this.getLockList(search)
|
||||
if(code !== 0) {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
this.updateLockSearch(search)
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,13 +96,22 @@ export default {
|
||||
...this.keySearch,
|
||||
lockId: this.currentLockInfo.lockId
|
||||
})
|
||||
const { code, meesage } = await this.getKeyList(this.keySearch)
|
||||
this.requestFinished = true
|
||||
const { code, message } = await this.getKeyList(this.keySearch)
|
||||
uni.hideLoading()
|
||||
this.requestFinished = true
|
||||
if(code !== 0) {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
onUnload() {
|
||||
this.clearList('key')
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']),
|
||||
...mapActions(useLockStore, ['getKeyList', 'updateCurrentKeyInfo', 'updateKeySearch', 'getKeyStatus']),
|
||||
...mapActions(useLockStore, ['getKeyList', 'updateCurrentKeyInfo', 'updateKeySearch', 'getKeyStatus', 'clearList']),
|
||||
changeRadio() {
|
||||
this.checked = !this.checked
|
||||
},
|
||||
@ -239,12 +248,17 @@ export default {
|
||||
...this.keySearch,
|
||||
pageNo: 1
|
||||
})
|
||||
const { code, meesage } = await this.getKeyList(this.keySearch)
|
||||
const { code, message } = await this.getKeyList(this.keySearch)
|
||||
if(code === 0) {
|
||||
uni.showToast({
|
||||
title: '刷新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
this.refresherTriggered = false
|
||||
},
|
||||
@ -257,12 +271,17 @@ export default {
|
||||
...this.keySearch,
|
||||
pageNo
|
||||
}
|
||||
const { code, meesage } = await this.getKeyList(params)
|
||||
const { code, message } = await this.getKeyList(params)
|
||||
if(code === 0) {
|
||||
this.updateKeySearch({
|
||||
...this.keySearch,
|
||||
pageNo
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
async changeSearch(data) {
|
||||
@ -270,7 +289,13 @@ export default {
|
||||
...this.keySearch,
|
||||
searchStr: data
|
||||
})
|
||||
const { code, meesage } = await this.getKeyList(this.keySearch)
|
||||
const { code, message } = await this.getKeyList(this.keySearch)
|
||||
if(code !== 0) {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -80,9 +80,18 @@ export default {
|
||||
lockId: this.currentLockInfo.lockId,
|
||||
lockStatus: this.currentLockInfo.lockStatus
|
||||
})
|
||||
const { code, meesage } = await this.getPasswordList(this.passwordSearch)
|
||||
const { code, message } = await this.getPasswordList(this.passwordSearch)
|
||||
this.requestFinished = true
|
||||
uni.hideLoading()
|
||||
if(code !== 0) {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
onUnload() {
|
||||
this.clearList('password')
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo']),
|
||||
@ -225,12 +234,17 @@ export default {
|
||||
...this.passwordSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
const { code, meesage } = await this.getPasswordList(this.passwordSearch)
|
||||
const { code, message } = await this.getPasswordList(this.passwordSearch)
|
||||
if(code === 0) {
|
||||
uni.showToast({
|
||||
title: '刷新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
this.refresherTriggered = false
|
||||
},
|
||||
@ -243,12 +257,17 @@ export default {
|
||||
...this.passwordSearch,
|
||||
pageNo
|
||||
}
|
||||
const { code, meesage } = await this.getPasswordList(params)
|
||||
const { code, message } = await this.getPasswordList(params)
|
||||
if(code === 0) {
|
||||
that.updatePasswordSearch({
|
||||
...that.passwordSearch,
|
||||
pageNo
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
async changeSearch(data) {
|
||||
@ -256,7 +275,13 @@ export default {
|
||||
...this.passwordSearch,
|
||||
searchStr: data
|
||||
})
|
||||
const { code, meesage } = await this.getPasswordList(this.passwordSearch)
|
||||
const { code, message } = await this.getPasswordList(this.passwordSearch)
|
||||
if(code !== 0) {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -81,9 +81,12 @@ export default {
|
||||
...mapState(useUserStore, ['userInfo'])
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useBasicStore, ['routeJump']),
|
||||
...mapActions(useBasicStore, ['routeJump', 'getNetworkType']),
|
||||
...mapActions(useUserStore, ['updateUserInfo', 'checkSession', 'getUserInfo']),
|
||||
async rebindPhone(detail) {
|
||||
if(!(detail.detail.encryptedData && detail.detail.iv)) {
|
||||
return
|
||||
}
|
||||
if(detail.detail.errMsg === 'getPhoneNumber:fail user deny') {
|
||||
return
|
||||
}
|
||||
@ -99,10 +102,6 @@ export default {
|
||||
})
|
||||
if(code === 0) {
|
||||
this.getUserInfo()
|
||||
// this.updateUserInfo({
|
||||
// ...this.userInfo,
|
||||
// mobile: data.mobile
|
||||
// })
|
||||
uni.showToast({
|
||||
title: '更换成功',
|
||||
icon: 'none'
|
||||
|
||||
@ -51,6 +51,10 @@ export const useLockStore = defineStore('lock', {
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
// 清空列表
|
||||
clearList(type) {
|
||||
this[type + 'List'] = []
|
||||
},
|
||||
// 获取电量icon
|
||||
getPowerIcon(power) {
|
||||
if(power >= 80) {
|
||||
@ -164,10 +168,6 @@ export const useLockStore = defineStore('lock', {
|
||||
}
|
||||
return { code }
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
return { code, message }
|
||||
}
|
||||
},
|
||||
@ -220,19 +220,15 @@ export const useLockStore = defineStore('lock', {
|
||||
}
|
||||
return { code }
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
return { code, message }
|
||||
}
|
||||
},
|
||||
async getKeyList(params) {
|
||||
const { code, data, message } = await getKeyListRequest(params)
|
||||
console.log(11111223, code, data, message)
|
||||
if(code === 0) {
|
||||
this.keyTotal = data.total
|
||||
for(let i = 0; i < data.list.length; i++) {
|
||||
console.log(data.list[i].keyType)
|
||||
if(data.list[i].keyType === 1) {
|
||||
data.list[i].timeText = `${timeFormat(new Date(data.list[i].sendDate), 'yyyy-mm-dd h:M')} 永久`
|
||||
} else if(data.list[i].keyType === 2) {
|
||||
@ -250,10 +246,6 @@ export const useLockStore = defineStore('lock', {
|
||||
}
|
||||
return { code }
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
return { code, message }
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import env from '@/config/env'
|
||||
* */
|
||||
|
||||
const request = (config) => {
|
||||
let timer
|
||||
return new Promise((resolve) => {
|
||||
const baseConfig = env[getApp().globalData.getEnvConfig()]
|
||||
|
||||
@ -25,6 +26,9 @@ const request = (config) => {
|
||||
const header = config.header || headerDefault
|
||||
const data = config.data || {}
|
||||
const timestamp = new Date().getTime()
|
||||
timer = setTimeout(() => {
|
||||
resolve({ code: -1, message: '网络访问失败,请检查网络是否正常' })
|
||||
}, 8000)
|
||||
uni.request({
|
||||
url: URL,
|
||||
method,
|
||||
@ -33,6 +37,9 @@ const request = (config) => {
|
||||
timeout: 7000,
|
||||
async success(res) {
|
||||
const { statusCode, data } = res
|
||||
if(timer) {
|
||||
clearTimeout(timer)
|
||||
}
|
||||
if (statusCode === 200) {
|
||||
const code = data.errorCode
|
||||
const message = data.errorMsg
|
||||
@ -61,8 +68,12 @@ const request = (config) => {
|
||||
resolve({ code: -1, data, message: '网络访问失败,请检查网络是否正常' })
|
||||
}
|
||||
},
|
||||
async fail() {
|
||||
resolve({ code: -1, data, message: '网络访问失败,请检查网络是否正常' })
|
||||
async fail(res) {
|
||||
console.log('网络访问失败', res)
|
||||
if(timer) {
|
||||
clearTimeout(timer)
|
||||
}
|
||||
resolve({ code: -1, message: '网络访问失败,请检查网络是否正常' })
|
||||
},
|
||||
async complete(res) {
|
||||
console.log(URL.substring(baseConfig.baseUrl.length + 1), {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user