refactor(user): 禁用 loginByOpenId 静默登录并优化登录状态控制
- 移除 UserContext 和 useUser 中的 loginByOpenId 调用及相关降级逻辑 - 无本地 token 时保持未登录状态,不再自动触发静默登录 - 清理无用导入 TenantId 和 loginByOpenId - 订单列表页增加登录校验,未登录用户跳转登录页并阻止渲染订单 - 商城首页价格改为 Price 组件,未登录游客显示登录遮罩,单位仅登录后可见
This commit is contained in:
@@ -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 标题栏 */}
|
||||
|
||||
@@ -13,6 +13,7 @@ import { requireLogin } from '@/utils/login-guard'
|
||||
import { useShare } from '@/hooks/useShare'
|
||||
import EmptyState from '@/components/common/EmptyState'
|
||||
import LoadMore from '@/components/common/LoadMore'
|
||||
import Price from '@/components/common/Price'
|
||||
|
||||
definePageConfig({
|
||||
navigationBarTitleText: '商品分类',
|
||||
@@ -305,24 +306,21 @@ const ShopPage: React.FC = () => {
|
||||
{/* 价格 + 销量 + 加购 */}
|
||||
<View className='flex items-end justify-between'>
|
||||
<View className='flex-1 min-w-0'>
|
||||
<Text className='text-sm text-red-500 font-medium'>
|
||||
¥{getDisplayPrice(item)}
|
||||
</Text>
|
||||
{item.unitName ? (
|
||||
<Price
|
||||
price={getDisplayPrice(item)}
|
||||
original={
|
||||
isVipMember() && item.dealerPrice
|
||||
? item.price
|
||||
: item.salePrice && item.salePrice !== item.price
|
||||
? item.salePrice
|
||||
: undefined
|
||||
}
|
||||
size='small'
|
||||
loginMask
|
||||
/>
|
||||
{item.unitName && !isGuest() ? (
|
||||
<Text className='text-xs text-gray-400'>/{item.unitName}</Text>
|
||||
) : null}
|
||||
{/* VIP 划掉原价 */}
|
||||
{isVipMember() && item.dealerPrice ? (
|
||||
<Text className='text-xs text-gray-400 line-through ml-1'>
|
||||
¥{item.price}
|
||||
</Text>
|
||||
) : item.salePrice && item.salePrice !== item.price ? (
|
||||
isGuest() ? null : (
|
||||
<Text className='text-xs text-gray-400 line-through ml-1'>
|
||||
¥{item.salePrice}
|
||||
</Text>
|
||||
)
|
||||
) : null}
|
||||
{/* 销量 */}
|
||||
{item.sales !== undefined && item.sales > 0 && (
|
||||
<Text className='text-xs text-gray-400 block mt-0.5'>
|
||||
|
||||
Reference in New Issue
Block a user