修复安卓设备回退toast无法显示bug

This commit is contained in:
范鹏 2024-08-29 17:40:41 +08:00
parent 86c398b754
commit 053d14db47
14 changed files with 60 additions and 151 deletions

View File

@ -14,6 +14,7 @@ import { useUserStore } from '@/stores/user'
import { mapActions, mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { bindLockAdmin } from '@/api/lock' import { bindLockAdmin } from '@/api/lock'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
import { useBasicStore } from '@/stores/basic'
export default { export default {
data () { data () {
@ -34,6 +35,7 @@ export default {
methods: { methods: {
...mapActions(useBluetoothStore, ['addLockUser']), ...mapActions(useBluetoothStore, ['addLockUser']),
...mapActions(useLockStore, ['getLockList', 'updateLockSearch']), ...mapActions(useLockStore, ['getLockList', 'updateLockSearch']),
...mapActions(useBasicStore, ['backAndToast']),
uopdateName(data) { uopdateName(data) {
this.name = data.detail.value this.name = data.detail.value
}, },
@ -71,15 +73,8 @@ export default {
password password
}) })
if(addUserCode !== 0) { if(addUserCode !== 0) {
uni.navigateBack({
complete() {
uni.showToast({
title: '添加失败,请重试',
icon: 'none'
})
}
})
uni.hideLoading() uni.hideLoading()
this.backAndToast('添加失败,请重试')
return return
} }
const params = { const params = {
@ -122,14 +117,7 @@ export default {
}) })
this.getLockList(this.lockSearch) this.getLockList(this.lockSearch)
uni.hideLoading() uni.hideLoading()
uni.navigateBack({ this.backAndToast('添加成功')
complete() {
uni.showToast({
title: '添加成功',
icon: 'none'
})
}
})
} else { } else {
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({

View File

@ -80,7 +80,7 @@ export default {
this.temporaryInvalidTime = this.setTime() this.temporaryInvalidTime = this.setTime()
}, },
methods: { methods: {
...mapActions(useBasicStore, ['getDeviceInfo']), ...mapActions(useBasicStore, ['getDeviceInfo', 'backAndToast']),
...mapActions(useLockStore, ['getKeyList', 'updateKeySearch']), ...mapActions(useLockStore, ['getKeyList', 'updateKeySearch']),
setTime () { setTime () {
const now = new Date() const now = new Date()
@ -154,14 +154,7 @@ export default {
pageNo: 1 pageNo: 1
}) })
this.getKeyList(this.keySearch) this.getKeyList(this.keySearch)
uni.navigateBack({ this.backAndToast('钥匙已发送')
complete: () => {
uni.showToast({
title: '钥匙已发送',
icon: 'none'
})
}
})
} else if(code === 425) { } else if(code === 425) {
this.pending = false this.pending = false
await this.createKey(type, true) await this.createKey(type, true)

View File

@ -70,7 +70,7 @@ export default {
this.temporaryTime = this.setTime() this.temporaryTime = this.setTime()
}, },
methods: { methods: {
...mapActions(useBasicStore, ['getDeviceInfo']), ...mapActions(useBasicStore, ['getDeviceInfo', 'backAndToast']),
...mapActions(useLockStore, ['getPasswordList', 'updatePasswordSearch']), ...mapActions(useLockStore, ['getPasswordList', 'updatePasswordSearch']),
setTime() { setTime() {
const now = new Date() const now = new Date()
@ -80,6 +80,7 @@ export default {
return now.getTime() return now.getTime()
}, },
async createPassword(type) { async createPassword(type) {
const that = this
if((type === 'temporary' && this.temporaryName === '') || (type === 'permanent' && this.permanentName === '')) { if((type === 'temporary' && this.temporaryName === '') || (type === 'permanent' && this.permanentName === '')) {
uni.showToast({ uni.showToast({
title: '名称不能为空', title: '名称不能为空',
@ -131,14 +132,7 @@ export default {
uni.setClipboardData({ uni.setClipboardData({
data: data.keyboardPwd, data: data.keyboardPwd,
success: () => { success: () => {
uni.navigateBack({ that.backAndToast('复制成功')
complete: () => {
uni.showToast({
title: '复制成功',
icon: 'none'
})
}
})
} }
}) })
} }

View File

@ -33,6 +33,7 @@ import { mapActions, mapState } from 'pinia'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
import { timeFormat } from 'uview-plus' import { timeFormat } from 'uview-plus'
import { deleteKeyRequest } from '@/api/key' import { deleteKeyRequest } from '@/api/key'
import { useBasicStore } from '@/stores/basic'
export default { export default {
data () { data () {
@ -44,6 +45,7 @@ export default {
methods: { methods: {
timeFormat, timeFormat,
...mapActions(useLockStore, ['updateKeySearch', 'getKeyList']), ...mapActions(useLockStore, ['updateKeySearch', 'getKeyList']),
...mapActions(useBasicStore, ['backAndToast']),
async deleteKey () { async deleteKey () {
const that = this const that = this
uni.showModal({ uni.showModal({
@ -65,14 +67,7 @@ export default {
pageNo: 1 pageNo: 1
}) })
await that.getKeyList(that.keySearch) await that.getKeyList(that.keySearch)
uni.navigateBack({ that.backAndToast('删除成功')
complete: () => {
uni.showToast({
title: '删除成功',
icon: 'none'
})
}
})
} else { } else {
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({

View File

@ -52,7 +52,7 @@
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
import { mapState, mapActions } from 'pinia' import { mapState, mapActions } from 'pinia'
import { getUserInfoRequest, phoneLoginRequest } from '@/api/user' import { phoneLoginRequest } from '@/api/user'
export default { export default {
data() { data() {
@ -70,7 +70,8 @@
methods: { methods: {
...mapActions(useBasicStore, ['getButtonInfo', 'routeJump']), ...mapActions(useBasicStore, ['getButtonInfo', 'routeJump']),
...mapActions(useLockStore, ['getLockList', 'updateLockSearch']), ...mapActions(useLockStore, ['getLockList', 'updateLockSearch']),
...mapActions(useUserStore, ['updateLoginStatus', 'phoneLogin', 'updateUserInfo', 'getUserInfo', 'checkSession']), ...mapActions(useUserStore, ['updateLoginStatus', 'phoneLogin', 'updateUserInfo', 'getUserInfo',
'checkSession']),
async changePhone(res) { async changePhone(res) {
if(res.detail.errMsg === 'getPhoneNumber:fail user deny') { if(res.detail.errMsg === 'getPhoneNumber:fail user deny') {
return return
@ -93,9 +94,10 @@
if(code === 0) { if(code === 0) {
uni.setStorageSync('token', data.accessToken) uni.setStorageSync('token', data.accessToken)
this.updateLockSearch({ this.updateLockSearch({
...that.lockSearch, ...this.lockSearch,
pageNo: 1 pageNo: 1
}) })
this.getUserInfo()
this.getLockList(this.lockSearch) this.getLockList(this.lockSearch)
uni.showToast({ uni.showToast({
title: '账号切换成功', title: '账号切换成功',

View File

@ -36,6 +36,7 @@ import { timeFormat } from 'uview-plus'
import { deletePsaawordRequest } from '@/api/keyboardPwd' import { deletePsaawordRequest } from '@/api/keyboardPwd'
import { useBluetoothStore } from '@/stores/bluetooth' import { useBluetoothStore } from '@/stores/bluetooth'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { useBasicStore } from '@/stores/basic'
export default { export default {
data () { data () {
@ -44,12 +45,13 @@ export default {
computed: { computed: {
...mapState(useLockStore, ['currentPasswordInfo', 'passwordSearch']), ...mapState(useLockStore, ['currentPasswordInfo', 'passwordSearch']),
...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']), ...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']),
...mapState(useUserStore, ['userInfo']), ...mapState(useUserStore, ['userInfo'])
}, },
methods: { methods: {
timeFormat, timeFormat,
...mapActions(useBluetoothStore, ['setLockPassword']), ...mapActions(useBluetoothStore, ['setLockPassword']),
...mapActions(useLockStore, ['updatePasswordSearch', 'getPasswordList']), ...mapActions(useLockStore, ['updatePasswordSearch', 'getPasswordList']),
...mapActions(useBasicStore, ['backAndToast']),
async deletePassword () { async deletePassword () {
const that = this const that = this
uni.showModal({ uni.showModal({
@ -86,14 +88,7 @@ export default {
pageNo: 1 pageNo: 1
}) })
that.getPasswordList(that.passwordSearch) that.getPasswordList(that.passwordSearch)
uni.navigateBack({ that.backAndToast('删除成功')
complete: () => {
uni.showToast({
title: '删除成功',
icon: 'none'
})
}
})
} else { } else {
uni.hideLoading() uni.hideLoading()
uni.showToast({ uni.showToast({

View File

@ -49,6 +49,7 @@ import { deleteLockRequest } from '@/api/lock'
import { useLockStore } from '@/stores/lock' import { useLockStore } from '@/stores/lock'
import { updateLockSettingRequest } from '@/api/lockSetting' import { updateLockSettingRequest } from '@/api/lockSetting'
import { deleteKeyRequest } from '@/api/key' import { deleteKeyRequest } from '@/api/key'
import { useBasicStore } from '@/stores/basic'
export default { export default {
data () { data () {
@ -67,6 +68,7 @@ export default {
methods: { methods: {
...mapActions(useBluetoothStore, ['resetDevice', 'updateCurrentLockInfo']), ...mapActions(useBluetoothStore, ['resetDevice', 'updateCurrentLockInfo']),
...mapActions(useLockStore, ['getLockList', 'updateLockSearch']), ...mapActions(useLockStore, ['getLockList', 'updateLockSearch']),
...mapActions(useBasicStore, ['backAndToast']),
async changeUnlockApp(value) { async changeUnlockApp(value) {
uni.showLoading({ uni.showLoading({
title: '更新中', title: '更新中',
@ -122,15 +124,7 @@ export default {
pageNo: 1 pageNo: 1
}) })
that.getLockList(that.lockSearch) that.getLockList(that.lockSearch)
uni.navigateBack({ that.backAndToast('删除成功', 2)
delta: 2,
complete: () => {
uni.showToast({
title: '删除成功',
icon: 'none'
})
}
})
uni.navigateBack() uni.navigateBack()
} else { } else {
uni.hideLoading() uni.hideLoading()
@ -157,15 +151,7 @@ export default {
pageNo: 1 pageNo: 1
}) })
that.getLockList(that.lockSearch) that.getLockList(that.lockSearch)
uni.navigateBack({ that.backAndToast('删除成功', 2)
delta: 2,
complete: () => {
uni.showToast({
title: '删除成功',
icon: 'none'
})
}
})
uni.navigateBack() uni.navigateBack()
} else { } else {
uni.hideLoading() uni.hideLoading()

View File

@ -42,7 +42,7 @@ export default {
}, },
methods: { methods: {
...mapActions(useUserStore, ['updateUserInfo']), ...mapActions(useUserStore, ['updateUserInfo']),
...mapActions(useBasicStore, ['routeJump']), ...mapActions(useBasicStore, ['routeJump', 'backAndToast']),
updateInputEmail(data) { updateInputEmail(data) {
this.email = data.detail.value this.email = data.detail.value
}, },
@ -100,14 +100,7 @@ export default {
...this.userInfo, ...this.userInfo,
email: this.email email: this.email
}) })
uni.navigateBack({ this.backAndToast('邮箱绑定成功')
complete () {
uni.showToast({
title: '邮箱更新成功',
icon: 'none'
})
}
})
} else { } else {
uni.showToast({ uni.showToast({
title: message, title: message,

View File

@ -10,6 +10,7 @@
import { mapActions, mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { updateUserInfoRequest } from '@/api/user' import { updateUserInfoRequest } from '@/api/user'
import { useBasicStore } from '@/stores/basic'
export default { export default {
data() { data() {
@ -26,6 +27,7 @@ export default {
}, },
methods: { methods: {
...mapActions(useUserStore, ['updateUserInfo']), ...mapActions(useUserStore, ['updateUserInfo']),
...mapActions(useBasicStore, ['backAndToast']),
updateInput(data) { updateInput(data) {
this.nickname = data.detail.value this.nickname = data.detail.value
console.log(data) console.log(data)
@ -50,14 +52,7 @@ export default {
...this.userInfo, ...this.userInfo,
nickname: this.nickname nickname: this.nickname
}) })
uni.navigateBack({ this.backAndToast('昵称更新成功')
complete() {
uni.showToast({
title: '昵称更新成功',
icon: 'none'
})
}
})
} else { } else {
uni.showToast({ uni.showToast({
title: '昵称更新失败', title: '昵称更新失败',

View File

@ -17,6 +17,7 @@ import { mapActions, mapState } from 'pinia'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { changePasswordRequest, getEmailCodeRequest, updatePasswordRequest } from '@/api/user' import { changePasswordRequest, getEmailCodeRequest, updatePasswordRequest } from '@/api/user'
import { test } from 'uview-plus' import { test } from 'uview-plus'
import { useBasicStore } from '@/stores/basic'
export default { export default {
data () { data () {
@ -32,6 +33,7 @@ export default {
}, },
methods: { methods: {
...mapActions(useUserStore, ['updateUserInfo']), ...mapActions(useUserStore, ['updateUserInfo']),
...mapActions(useBasicStore, ['backAndToast']),
updateNewPassword (data) { updateNewPassword (data) {
this.password = data.detail.value this.password = data.detail.value
}, },
@ -100,18 +102,7 @@ export default {
channel: '1' channel: '1'
}) })
if (code === 0) { if (code === 0) {
this.updateUserInfo({ this.backAndToast('密码重置成功')
...this.userInfo,
nickname: this.nickname
})
uni.navigateBack({
complete () {
uni.showToast({
title: '密码重置成功',
icon: 'none'
})
}
})
} else { } else {
uni.showToast({ uni.showToast({
title: message, title: message,

View File

@ -46,6 +46,7 @@
import { getQuestionAnswerRequest, getQuestionListRequest, updateQuestionAnswerRequest } from '@/api/safeAnswer' import { getQuestionAnswerRequest, getQuestionListRequest, updateQuestionAnswerRequest } from '@/api/safeAnswer'
import { mapActions, mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
import { useBasicStore } from '@/stores/basic'
export default { export default {
data() { data() {
@ -75,6 +76,7 @@ export default {
}, },
methods: { methods: {
...mapActions(useUserStore, ['updateUserInfo']), ...mapActions(useUserStore, ['updateUserInfo']),
...mapActions(useBasicStore, ['backAndToast']),
async updateAnswer() { async updateAnswer() {
console.log('答案', this.answer) console.log('答案', this.answer)
for(let i = 0; i < this.answer.length; i++) { for(let i = 0; i < this.answer.length; i++) {
@ -107,14 +109,7 @@ export default {
...this.userInfo, ...this.userInfo,
haveSafeAnswer: 1 haveSafeAnswer: 1
}) })
uni.navigateBack({ this.backAndToast('设置成功')
complete() {
uni.showToast({
title: '安全问题设置成功',
icon: 'none'
})
}
})
} else { } else {
uni.showToast({ uni.showToast({
title: message, title: message,

View File

@ -82,9 +82,9 @@ export default {
}, },
methods: { methods: {
...mapActions(useBasicStore, ['routeJump']), ...mapActions(useBasicStore, ['routeJump']),
...mapActions(useUserStore, ['updateUserInfo', 'checkSession']), ...mapActions(useUserStore, ['updateUserInfo', 'checkSession', 'getUserInfo']),
async rebindPhone(detail) { async rebindPhone(detail) {
if(data.detail.errMsg === 'getPhoneNumber:fail user deny') { if(detail.detail.errMsg === 'getPhoneNumber:fail user deny') {
return return
} }
if(this.pending) { if(this.pending) {
@ -98,12 +98,13 @@ export default {
iv: detail.detail.iv iv: detail.detail.iv
}) })
if(code === 0) { if(code === 0) {
this.updateUserInfo({ this.getUserInfo()
...this.userInfo, // this.updateUserInfo({
mobile: data.mobile // ...this.userInfo,
}) // mobile: data.mobile
// })
uni.showToast({ uni.showToast({
title: '手机号换绑成功', title: '更换成功',
icon: 'none' icon: 'none'
}) })
} else { } else {
@ -113,10 +114,7 @@ export default {
}) })
} }
} else { } else {
uni.showToast({ this.rebindPhone()
title: '手机号换绑失败,请重试',
icon: 'none'
})
} }
this.pending = false this.pending = false
}, },

View File

@ -87,37 +87,6 @@ export default {
}, },
updateInput(data) { updateInput(data) {
this.verificationCode = data.detail.value this.verificationCode = data.detail.value
},
async updateName() {
if(this.nickname === '') {
uni.showToast({
title: '昵称不能为空',
icon: 'none'
})
return
}
const { code } = await updateUserInfoRequest({
nickname: this.nickname
})
if(code === 0) {
this.updateUserInfo({
...this.userInfo,
nickname: this.nickname
})
uni.navigateBack({
complete() {
uni.showToast({
title: '昵称更新成功',
icon: 'none'
})
}
})
} else {
uni.showToast({
title: '昵称更新失败',
icon: 'none'
})
}
} }
} }
} }

View File

@ -181,6 +181,21 @@ export const useBasicStore = defineStore('basic', {
} }
} }
return totalWidth return totalWidth
},
// 回退页面并弹出toast提示
backAndToast(message, delta = 1) {
const that = this
uni.navigateBack({
delta: delta,
complete: function () {
setTimeout(() => {
uni.showToast({
title: message,
icon: 'none'
})
}, 200)
}
})
} }
} }
}) })