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