解决登录后的提示错误
This commit is contained in:
@@ -299,7 +299,8 @@
|
|||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
"uniIdRouter": {
|
"uniIdRouter": {
|
||||||
"loginPage": "uni_modules/uni-id-pages/pages/login/login-withoutpwd",
|
// 默认登录页改为账号密码登录
|
||||||
|
"loginPage": "uni_modules/uni-id-pages/pages/login/login-withpwd",
|
||||||
"needLogin": [
|
"needLogin": [
|
||||||
"/uni_modules/uni-id-pages/pages/userinfo/userinfo"
|
"/uni_modules/uni-id-pages/pages/userinfo/userinfo"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -81,7 +81,8 @@
|
|||||||
await mutations.logout()
|
await mutations.logout()
|
||||||
}else{
|
}else{
|
||||||
uni.redirectTo({
|
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>
|
<script>
|
||||||
import mixin from '@/uni_modules/uni-id-pages/common/login-page.mixin.js';
|
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'
|
import { getApiUrl } from '@/common/config.js'
|
||||||
export default {
|
export default {
|
||||||
mixins: [mixin],
|
mixins: [mixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
"password": "",
|
// 默认账号密码(仅用于开发调试,发布前请移除或置空)
|
||||||
"username": "",
|
"password": "aaa123",
|
||||||
|
"username": "15810181776",
|
||||||
"captcha": "",
|
"captcha": "",
|
||||||
"needCaptcha": false,
|
"needCaptcha": false,
|
||||||
"focusUsername": false,
|
"focusUsername": false,
|
||||||
@@ -134,6 +136,18 @@
|
|||||||
console.error('缓存登录信息失败:', e)
|
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({
|
uni.showToast({
|
||||||
title: body.message || '登录成功',
|
title: body.message || '登录成功',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
|
|||||||
Reference in New Issue
Block a user