forked from gxwebsoft/mp-10550
fix(user): 修复用户页面组件状态刷新和水票余额显示问题
- 在订单确认页面添加水票模板购买数量限制逻辑 - 为用户页面添加dealerViewKey状态确保子组件正确刷新 - 交换用户卡片中水票和余额的位置显示正确数据 - 移除自动跳转邀请注册页面逻辑改用显式跳转 - 添加预期失败场景的日志过滤避免不必要的错误输出
This commit is contained in:
@@ -3,7 +3,7 @@ import Taro from '@tarojs/taro';
|
||||
import { User } from '@/api/system/user/model';
|
||||
import { getUserInfo, updateUserInfo, loginByOpenId } from '@/api/layout';
|
||||
import { TenantId } from '@/config/app';
|
||||
import {getStoredInviteParams, handleInviteRelation} from '@/utils/invite';
|
||||
import { handleInviteRelation } from '@/utils/invite';
|
||||
|
||||
// 用户Hook
|
||||
export const useUser = () => {
|
||||
@@ -44,15 +44,10 @@ export const useUser = () => {
|
||||
reject(new Error('自动登录失败'));
|
||||
}
|
||||
}).catch(_ => {
|
||||
// 首次注册,跳转到邀请注册页面
|
||||
const pages = Taro.getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
const inviteParams = getStoredInviteParams()
|
||||
if (currentPage?.route !== 'dealer/apply/add' && inviteParams?.inviter) {
|
||||
return Taro.navigateTo({
|
||||
url: '/dealer/apply/add'
|
||||
});
|
||||
}
|
||||
// 登录失败(通常是新用户尚未注册/未绑定手机号等)。
|
||||
// 这里不做任何“自动跳转”,避免用户点击「我的」时被强制带到分销/申请页,体验割裂。
|
||||
// 需要登录的页面请使用 utils/auth 的 ensureLoggedIn / goToRegister 做显式跳转。
|
||||
reject(new Error('autoLoginByOpenId failed'));
|
||||
});
|
||||
},
|
||||
fail: reject
|
||||
@@ -60,7 +55,11 @@ export const useUser = () => {
|
||||
});
|
||||
return res;
|
||||
} catch (error) {
|
||||
console.error('自动登录失败:', error);
|
||||
const msg = error instanceof Error ? error.message : String(error);
|
||||
// 新用户首次进入、未绑定手机号等场景属于“预期失败”,避免刷屏报错。
|
||||
if (msg !== 'autoLoginByOpenId failed') {
|
||||
console.error('自动登录失败:', error);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user