解决登录后的提示错误

This commit is contained in:
zhonghua1
2025-12-16 23:32:46 +08:00
parent 9b8f4e196d
commit 69400a9b01
3 changed files with 20 additions and 4 deletions

View File

@@ -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',