Browse Source

refactor(api): 更新 API调用以使用新的请求工具- 将所有 API 调用中的 request-legacy 替换为 request

- 优化部分 API 调用的参数传递方式
- 统一导入 ApiResult 和 PageResult 类型的路径
dev
科技小王子 6 days ago
parent
commit
1403a1888e
  1. 6
      src/dealer/apply/add.tsx
  2. 173
      src/dealer/index.tsx

6
src/dealer/apply/add.tsx

@ -86,7 +86,7 @@ const AddUserAddress = () => {
}
Taro.showToast({
title: `${isEditMode ? '更新' : '保存'}成功`,
title: `${isEditMode ? '更新' : '提交'}成功`,
icon: 'success'
});
@ -95,9 +95,9 @@ const AddUserAddress = () => {
}, 1000);
} catch (error) {
console.error('保存失败:', error);
console.error('提交失败:', error);
Taro.showToast({
title: `${isEditMode ? '更新' : '保存'}失败`,
title: `${isEditMode ? '更新' : '提交'}失败`,
icon: 'error'
});
}

173
src/dealer/index.tsx

@ -1,35 +1,156 @@
import React from 'react'
import { View, Text } from '@tarojs/components'
import { Cell, Button } from '@nutui/nutui-react-taro'
import { Button, Cell, CellGroup, Tag } from '@nutui/nutui-react-taro'
import { useDealerUser } from '@/hooks/useDealerUser'
import Taro from '@tarojs/taro'
const DealerIndex: React.FC = () => {
const {
dealerUser,
loading,
error,
refresh,
} = useDealerUser()
// 跳转到申请页面
const navigateToApply = () => {
Taro.navigateTo({
url: '/pages/dealer/apply/add'
})
}
if (error) {
return (
<View className="p-4">
<View className="bg-red-50 border border-red-200 rounded-lg p-4 mb-4">
<Text className="text-red-600">{error}</Text>
</View>
<Button type="primary" onClick={refresh}>
</Button>
</View>
)
}
return (
<View className="p-4">
<Text className="text-lg font-bold mb-4"></Text>
<Cell.Group>
<Cell
title="我的团队"
description="查看团队成员"
extra={<Button size="small" onClick={() => Taro.navigateTo({url: '/dealer/team/index'})}></Button>}
/>
<Cell
title="我的订单"
description="查看分销订单"
extra={<Button size="small" onClick={() => Taro.navigateTo({url: '/dealer/orders/index'})}></Button>}
/>
<Cell
title="提现管理"
description="申请提现"
extra={<Button size="small" onClick={() => Taro.navigateTo({url: '/dealer/withdraw/index'})}></Button>}
/>
<Cell
title="推广二维码"
description="生成推广码"
extra={<Button size="small" onClick={() => Taro.navigateTo({url: '/dealer/qrcode/index'})}></Button>}
/>
</Cell.Group>
<View className="bg-gray-50 min-h-screen">
{/* 页面标题 */}
<View className="bg-white px-4 py-3 border-b border-gray-100 flex justify-between items-center">
<Text className="text-lg font-bold text-center">
{dealerUser?.realName}
</Text>
<Text className={'text-gray-400 text-xs'}>ID{dealerUser?.refereeId}</Text>
</View>
{!dealerUser ? (
// 非经销商状态
<View className="bg-white mx-4 mt-4 rounded-lg p-6">
<View className="text-center py-8">
<Text className="text-gray-500 mb-4"></Text>
<Text className="text-sm text-gray-400 mb-6">
</Text>
<Button
type="primary"
size="large"
onClick={navigateToApply}
>
</Button>
</View>
</View>
) : (
// 经销商信息展示
<View>
{/* 状态卡片 */}
<View className="bg-white mx-4 mt-4 rounded-lg p-4">
<View className="flex items-center justify-between mb-4">
<Text className="text-lg font-semibold"></Text>
<Tag>
{dealerUser.realName}
</Tag>
</View>
{/* 基本信息 */}
<CellGroup>
<Cell
title="经销商ID"
extra={dealerUser.userId || '-'}
/>
<Cell
title="refereeId"
extra={dealerUser.refereeId || '-'}
/>
<Cell
title="成为经销商时间"
extra={
dealerUser.money
}
/>
</CellGroup>
{/* 操作按钮 */}
<View className="mt-6 space-y-3">
<Button
type="primary"
size="large"
loading={loading}
>
</Button>
</View>
</View>
{/* 经销商权益 */}
<View className="bg-white mx-4 mt-4 rounded-lg p-4">
<Text className="font-semibold mb-3"></Text>
<View className="space-y-2">
<Text className="text-sm text-gray-600">
</Text>
<Text className="text-sm text-gray-600">
广
</Text>
<Text className="text-sm text-gray-600">
</Text>
<Text className="text-sm text-gray-600">
</Text>
</View>
</View>
{/* 佣金统计 */}
<View className="bg-white mx-4 mt-4 rounded-lg p-4">
<Text className="font-semibold mb-3"></Text>
<View className="grid grid-cols-3 gap-4">
<View className="text-center">
<Text className="text-lg font-bold text-blue-600">0</Text>
<Text className="text-sm text-gray-500"></Text>
</View>
<View className="text-center">
<Text className="text-lg font-bold text-green-600">0</Text>
<Text className="text-sm text-gray-500"></Text>
</View>
<View className="text-center">
<Text className="text-lg font-bold text-orange-600">0</Text>
<Text className="text-sm text-gray-500"></Text>
</View>
</View>
</View>
</View>
)}
{/* 刷新按钮 */}
<View className="text-center py-4">
<Text
className="text-blue-500 text-sm"
onClick={refresh}
>
</Text>
</View>
</View>
)
}

Loading…
Cancel
Save