修复bug
This commit is contained in:
@@ -58,12 +58,12 @@
|
||||
title: '注销账号',
|
||||
type: 'arrow'
|
||||
},
|
||||
{
|
||||
title: '升级版本',
|
||||
type: 'text',
|
||||
value: '当前版本 1.0.0',
|
||||
valueClass: 'item-version'
|
||||
}
|
||||
// {
|
||||
// title: '升级版本',
|
||||
// type: 'text',
|
||||
// value: '当前版本 1.0.0',
|
||||
// valueClass: 'item-version'
|
||||
// }
|
||||
])
|
||||
|
||||
// 格式化字节大小
|
||||
@@ -105,7 +105,9 @@
|
||||
currentVersion.value = manifest.version
|
||||
}
|
||||
// #endif
|
||||
settingList.value[5].value = '当前版本 ' + currentVersion.value
|
||||
if (settingList.value[5]) {
|
||||
settingList.value[5].value = '当前版本 ' + currentVersion.value
|
||||
}
|
||||
}
|
||||
|
||||
// 版本号比较:v1 > v2 返回 1,v1 = v2 返回 0,v1 < v2 返回 -1
|
||||
@@ -247,7 +249,12 @@
|
||||
url: '/pageSubPack/my/changePwd'
|
||||
});
|
||||
} else if (item.title == '清除缓存') {
|
||||
uni.clearStorageSync();
|
||||
// 保存登录相关数据,清完恢复
|
||||
const preserveKeys = ['token', 'userId', 'currentVillageId', 'hasShowGuide', 'push_cid']
|
||||
const saved = {}
|
||||
preserveKeys.forEach(key => { saved[key] = uni.getStorageSync(key) })
|
||||
uni.clearStorageSync()
|
||||
preserveKeys.forEach(key => { if (saved[key]) uni.setStorageSync(key, saved[key]) })
|
||||
// #ifdef APP-PLUS
|
||||
plus.cache.clear(() => {})
|
||||
// #endif
|
||||
@@ -279,52 +286,30 @@
|
||||
title: '提示',
|
||||
content: '确定要退出当前账号吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
uni.showLoading({
|
||||
title: '退出中...',
|
||||
mask: true
|
||||
});
|
||||
authLogout().then(res => {
|
||||
if (res.code === 200) {
|
||||
// 清除本地登录凭证
|
||||
uni.removeStorageSync('token');
|
||||
uni.removeStorageSync('userId');
|
||||
uni.removeStorageSync('currentVillageId');
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '退出成功',
|
||||
icon: 'success'
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
uni.reLaunch({
|
||||
url: '/pageSubPack/loginSub/login?mode=pwd'
|
||||
});
|
||||
}, 1500);
|
||||
} else {
|
||||
// 即使服务端返回失败,也清除本地数据并跳转登录页
|
||||
uni.removeStorageSync('token');
|
||||
uni.removeStorageSync('userId');
|
||||
uni.removeStorageSync('currentVillageId');
|
||||
uni.hideLoading();
|
||||
uni.reLaunch({
|
||||
url: '/pageSubPack/loginSub/login?mode=pwd'
|
||||
});
|
||||
}
|
||||
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
// 网络异常时也清除本地数据并跳转登录页
|
||||
uni.removeStorageSync('token');
|
||||
uni.removeStorageSync('userId');
|
||||
uni.removeStorageSync('currentVillageId');
|
||||
uni.hideLoading();
|
||||
uni.reLaunch({
|
||||
url: '/pageSubPack/loginSub/login?mode=pwd'
|
||||
});
|
||||
})
|
||||
if (!res.confirm) return
|
||||
uni.showLoading({ title: '退出中...', mask: true })
|
||||
|
||||
const clearAndGo = () => {
|
||||
uni.removeStorageSync('token')
|
||||
uni.removeStorageSync('userId')
|
||||
uni.removeStorageSync('currentVillageId')
|
||||
uni.hideLoading()
|
||||
uni.hideToast()
|
||||
uni.reLaunch({ url: '/pageSubPack/loginSub/login?mode=pwd' })
|
||||
}
|
||||
|
||||
authLogout().then(res => {
|
||||
if (res.code === 200) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '退出成功', icon: 'success' })
|
||||
setTimeout(clearAndGo, 1500)
|
||||
} else {
|
||||
clearAndGo()
|
||||
}
|
||||
}).catch(err => {
|
||||
console.log(err)
|
||||
clearAndGo()
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user