fix(user): 修复用户页面组件状态刷新和水票余额显示问题
- 在订单确认页面添加水票模板购买数量限制逻辑 - 为用户页面添加dealerViewKey状态确保子组件正确刷新 - 交换用户卡片中水票和余额的位置显示正确数据 - 移除自动跳转邀请注册页面逻辑改用显式跳转 - 添加预期失败场景的日志过滤避免不必要的错误输出
This commit is contained in:
@@ -335,13 +335,9 @@ const UserCard = forwardRef<any, any>((_, ref) => {
|
||||
<View className={'py-2'}>
|
||||
<View className={'flex justify-around mt-1'}>
|
||||
<View className={'item flex justify-center flex-col items-center'}
|
||||
onClick={() => navTo('/user/wallet/wallet', true)}>
|
||||
<Text className={'text-xs text-gray-200'} style={themeStyles.textColor}>余额</Text>
|
||||
<Text className={'text-xl text-white'} style={themeStyles.textColor}>{data?.balance || '0.00'}</Text>
|
||||
</View>
|
||||
<View className={'item flex justify-center flex-col items-center'}>
|
||||
<Text className={'text-xs text-gray-200'} style={themeStyles.textColor}>积分</Text>
|
||||
<Text className={'text-xl text-white'} style={themeStyles.textColor}>{data?.points || 0}</Text>
|
||||
onClick={() => navTo('/user/ticket/index', true)}>
|
||||
<Text className={'text-xs text-gray-200'} style={themeStyles.textColor}>水票</Text>
|
||||
<Text className={'text-xl text-white'} style={themeStyles.textColor}>{ticketTotal}</Text>
|
||||
</View>
|
||||
<View className={'item flex justify-center flex-col items-center'}
|
||||
onClick={() => navTo('/user/coupon/index', true)}>
|
||||
@@ -349,9 +345,13 @@ const UserCard = forwardRef<any, any>((_, ref) => {
|
||||
<Text className={'text-xl text-white'} style={themeStyles.textColor}>{data?.coupons || 0}</Text>
|
||||
</View>
|
||||
<View className={'item flex justify-center flex-col items-center'}
|
||||
onClick={() => navTo('/user/ticket/index', true)}>
|
||||
<Text className={'text-xs text-gray-200'} style={themeStyles.textColor}>水票</Text>
|
||||
<Text className={'text-xl text-white'} style={themeStyles.textColor}>{ticketTotal}</Text>
|
||||
onClick={() => navTo('/user/wallet/wallet', true)}>
|
||||
<Text className={'text-xs text-gray-200'} style={themeStyles.textColor}>余额</Text>
|
||||
<Text className={'text-xl text-white'} style={themeStyles.textColor}>{data?.balance || '0.00'}</Text>
|
||||
</View>
|
||||
<View className={'item flex justify-center flex-col items-center'}>
|
||||
<Text className={'text-xs text-gray-200'} style={themeStyles.textColor}>积分</Text>
|
||||
<Text className={'text-xl text-white'} style={themeStyles.textColor}>{data?.points || 0}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {useEffect, useRef} from 'react'
|
||||
import {useEffect, useRef, useState} from 'react'
|
||||
import {PullToRefresh} from '@nutui/nutui-react-taro'
|
||||
import UserCard from "./components/UserCard";
|
||||
import UserOrder from "./components/UserOrder";
|
||||
@@ -14,12 +14,15 @@ function User() {
|
||||
|
||||
const userCardRef = useRef<any>()
|
||||
const themeStyles = useThemeStyles();
|
||||
// TabBar 页在小程序里通常不会销毁;从“注册/申请”页返回时需要触发子组件重新初始化/拉取最新状态。
|
||||
const [dealerViewKey, setDealerViewKey] = useState(0)
|
||||
|
||||
// 下拉刷新处理
|
||||
const handleRefresh = async () => {
|
||||
if (userCardRef.current?.handleRefresh) {
|
||||
await userCardRef.current.handleRefresh()
|
||||
}
|
||||
setDealerViewKey(v => v + 1)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
@@ -30,6 +33,7 @@ function User() {
|
||||
userCardRef.current?.reloadStats?.()
|
||||
// 个人资料(头像/昵称)可能在其它页面被修改,这里确保返回时立刻刷新
|
||||
userCardRef.current?.reloadUserInfo?.()
|
||||
setDealerViewKey(v => v + 1)
|
||||
})
|
||||
|
||||
return (
|
||||
@@ -58,7 +62,7 @@ function User() {
|
||||
</View>
|
||||
<UserCard ref={userCardRef}/>
|
||||
<UserOrder/>
|
||||
<IsDealer/>
|
||||
<IsDealer key={dealerViewKey}/>
|
||||
<UserGrid/>
|
||||
<UserFooter/>
|
||||
</PullToRefresh>
|
||||
|
||||
Reference in New Issue
Block a user