refactor(user): 禁用 loginByOpenId 静默登录并优化登录状态控制

- 移除 UserContext 和 useUser 中的 loginByOpenId 调用及相关降级逻辑
- 无本地 token 时保持未登录状态,不再自动触发静默登录
- 清理无用导入 TenantId 和 loginByOpenId
- 订单列表页增加登录校验,未登录用户跳转登录页并阻止渲染订单
- 商城首页价格改为 Price 组件,未登录游客显示登录遮罩,单位仅登录后可见
This commit is contained in:
2026-07-14 01:36:58 +08:00
parent 93a46bdae7
commit fd03ed80fd
5 changed files with 55 additions and 66 deletions

View File

@@ -31,7 +31,7 @@ interface TabState {
}
const OrderListPage: React.FC = () => {
const { user } = useUser()
const { user, isLoggedIn } = useUser()
const initTab = Taro.getCurrentInstance().router?.params?.tab
?? Taro.getStorageSync('order_tab')
// 读取后清除,避免影响下次进入
@@ -104,10 +104,14 @@ const OrderListPage: React.FC = () => {
// 切换 tab 时加载数据
useEffect(() => {
if (!isLoggedIn) {
Taro.navigateTo({ url: '/passport/login' })
return
}
if (!tabStates[tabIndex].initialized) {
loadOrders(tabIndex, 1)
}
}, [tabIndex])
}, [tabIndex, isLoggedIn])
const handleLoadMore = () => {
if (!currentState.finished && !currentState.loading) {
@@ -121,6 +125,10 @@ const OrderListPage: React.FC = () => {
}
}
if (!isLoggedIn) {
return null
}
return (
<View className='min-h-screen bg-gray-50 flex flex-col'>
{/* 自定义 Tabs 标题栏 */}