解决登录后的提示错误
This commit is contained in:
@@ -299,7 +299,8 @@
|
||||
}]
|
||||
},
|
||||
"uniIdRouter": {
|
||||
"loginPage": "uni_modules/uni-id-pages/pages/login/login-withoutpwd",
|
||||
// 默认登录页改为账号密码登录
|
||||
"loginPage": "uni_modules/uni-id-pages/pages/login/login-withpwd",
|
||||
"needLogin": [
|
||||
"/uni_modules/uni-id-pages/pages/userinfo/userinfo"
|
||||
],
|
||||
|
||||
@@ -81,7 +81,8 @@
|
||||
await mutations.logout()
|
||||
}else{
|
||||
uni.redirectTo({
|
||||
url: '/uni_modules/uni-id-pages/pages/login/login-withoutpwd',
|
||||
// 默认使用账号密码登录页
|
||||
url: '/uni_modules/uni-id-pages/pages/login/login-withpwd',
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -36,13 +36,15 @@
|
||||
|
||||
<script>
|
||||
import mixin from '@/uni_modules/uni-id-pages/common/login-page.mixin.js';
|
||||
import { mutations } from '@/uni_modules/uni-id-pages/common/store.js'
|
||||
import { getApiUrl } from '@/common/config.js'
|
||||
export default {
|
||||
mixins: [mixin],
|
||||
data() {
|
||||
return {
|
||||
"password": "",
|
||||
"username": "",
|
||||
// 默认账号密码(仅用于开发调试,发布前请移除或置空)
|
||||
"password": "aaa123",
|
||||
"username": "15810181776",
|
||||
"captcha": "",
|
||||
"needCaptcha": false,
|
||||
"focusUsername": false,
|
||||
@@ -134,6 +136,18 @@
|
||||
console.error('缓存登录信息失败:', e)
|
||||
}
|
||||
|
||||
// 同步更新前端 store,保证“我的”页等能识别为已登录状态
|
||||
try {
|
||||
mutations.setUserInfo({
|
||||
username: loginData.userName,
|
||||
mobile: loginData.phone,
|
||||
email: loginData.email,
|
||||
avatar_file: loginData.avatar ? { url: loginData.avatar } : undefined
|
||||
}, { cover: true })
|
||||
} catch (e) {
|
||||
console.error('更新本地用户信息失败:', e)
|
||||
}
|
||||
|
||||
uni.showToast({
|
||||
title: body.message || '登录成功',
|
||||
icon: 'none',
|
||||
|
||||
Reference in New Issue
Block a user