Files
xinlong-shop-taro/src/pages/user/withdraw-list/index.tsx
赵忠林 f3886664f7 fix(api): 替换所有接口请求的域名为 guilixu-api.websoft.top
- 将获取 STS Token 的接口地址由 paopao-api 改为 guilixu-api
- 更新图片上传接口地址为新的 guilixu-api 域名
- 修改用户推广页面中邀请码链接和二维码接口的域名
- 更改注册页微信登录接口请求的域名为 guilixu-api
2026-06-16 17:15:59 +08:00

170 lines
4.8 KiB
TypeScript

import { View, Text, ScrollView } from '@tarojs/components';
import Taro from '@tarojs/taro';
import { useState, useEffect } from 'react';
import { getWithdrawStats, getMyWithdrawList } from '@/api/shop/shopWithdrawRecord';
import EmptyState from '@/components/common/EmptyState';
import { Loading } from '@nutui/nutui-react-taro';
import './index.scss';
definePageConfig({
navigationBarTitleText: '提现记录',
});
export default function WithdrawListPage() {
const [stats, setStats] = useState<any>({});
const [list, setList] = useState<any[]>([]);
const [loading, setLoading] = useState(false);
const [page, setPage] = useState(1);
const [hasMore, setHasMore] = useState(true);
const [activeTab, setActiveTab] = useState(-1); // -1全部/0待审核/1通过/4完成
useEffect(() => {
loadStats();
loadList(true);
}, []);
const loadStats = async () => {
try {
const res = await getWithdrawStats();
if (res.code === 200) {
setStats(res.data);
}
} catch (error) {
console.error('加载统计失败', error);
}
};
const loadList = async (isRefresh = false) => {
if (loading) return;
setLoading(true);
try {
const currentPage = isRefresh ? 1 : page;
const params: any = {
page: currentPage,
limit: 20
};
if (activeTab >= 0) {
params.status = activeTab;
}
const res = await getMyWithdrawList(params);
if (res.code === 200) {
const newList = res.data.list || [];
setList(isRefresh ? newList : [...list, ...newList]);
setPage(currentPage + 1);
setHasMore(newList.length >= 20);
}
} catch (error) {
console.error('加载列表失败', error);
} finally {
setLoading(false);
}
};
const handleTabChange = (tab: number) => {
setActiveTab(tab);
setPage(1);
setHasMore(true);
loadList(true);
};
const getStatusText = (status: number) => {
const map: Record<number, string> = {
0: '待审核',
1: '审核通过',
2: '审核拒绝',
3: '打款中',
4: '已完成',
5: '已取消'
};
return map[status] || '未知';
};
const getStatusClass = (status: number) => {
if (status === 4) return 'status-success';
if (status === 2 || status === 5) return 'status-fail';
return 'status-pending';
};
return (
<View className="withdraw-list-page">
{/* 统计区域 */}
<View className="stats-card">
<View className="stats-item">
<Text className="stats-label">()</Text>
<Text className="stats-value">{stats.withdrawingTotal || '0.00'}</Text>
</View>
<View className="stats-item">
<Text className="stats-label">()</Text>
<Text className="stats-value">{stats.todayTotal || '0.00'}</Text>
</View>
</View>
{/* 标签页 */}
<View className="tab-bar">
<View
className={`tab-item ${activeTab === -1 ? 'active' : ''}`}
onClick={() => handleTabChange(-1)}
>
</View>
<View
className={`tab-item ${activeTab === 0 ? 'active' : ''}`}
onClick={() => handleTabChange(0)}
>
</View>
<View
className={`tab-item ${activeTab === 4 ? 'active' : ''}`}
onClick={() => handleTabChange(4)}
>
</View>
</View>
{/* 列表 */}
<ScrollView
className="withdraw-scroll"
scrollY
onScrollToLower={() => hasMore && loadList()}
>
{list.length === 0 && !loading ? (
<EmptyState description="暂无提现记录" />
) : (
list.map((item) => (
<View key={item.id} className="withdraw-item">
<View className="withdraw-header">
<Text className="withdraw-amount">¥{item.withdrawAmount}</Text>
<Text className={`status-tag ${getStatusClass(item.status)}`}>
{getStatusText(item.status)}
</Text>
</View>
<View className="withdraw-info">
<Text className="info-text">
: ¥{item.actualAmount}
</Text>
{item.fee > 0 && (
<Text className="info-text">
: ¥{item.fee}
</Text>
)}
</View>
<Text className="withdraw-time">{item.createTime}</Text>
{item.auditRemark && (
<Text className="audit-remark">
: {item.auditRemark}
</Text>
)}
</View>
))
)}
{loading && <Loading>...</Loading>}
</ScrollView>
</View>
);
}