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

- 优化部分 API 调用的参数传递方式
- 统一导入 ApiResult 和 PageResult 类型的路径
This commit is contained in:
2025-08-18 20:51:29 +08:00
parent 06a3b15842
commit 1403a1888e
2 changed files with 150 additions and 29 deletions

View File

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

View File

@@ -1,35 +1,156 @@
import React from 'react' import React from 'react'
import { View, Text } from '@tarojs/components' 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' import Taro from '@tarojs/taro'
const DealerIndex: React.FC = () => { const DealerIndex: React.FC = () => {
const {
dealerUser,
loading,
error,
refresh,
} = useDealerUser()
// 跳转到申请页面
const navigateToApply = () => {
Taro.navigateTo({
url: '/pages/dealer/apply/add'
})
}
if (error) {
return ( return (
<View className="p-4"> <View className="p-4">
<Text className="text-lg font-bold mb-4"></Text> <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>
)
}
<Cell.Group> return (
<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 <Cell
title="我的团队" title="经销商ID"
description="查看团队成员" extra={dealerUser.userId || '-'}
extra={<Button size="small" onClick={() => Taro.navigateTo({url: '/dealer/team/index'})}></Button>}
/> />
<Cell <Cell
title="我的订单" title="refereeId"
description="查看分销订单" extra={dealerUser.refereeId || '-'}
extra={<Button size="small" onClick={() => Taro.navigateTo({url: '/dealer/orders/index'})}></Button>}
/> />
<Cell <Cell
title="提现管理" title="成为经销商时间"
description="申请提现" extra={
extra={<Button size="small" onClick={() => Taro.navigateTo({url: '/dealer/withdraw/index'})}></Button>} dealerUser.money
}
/> />
<Cell
title="推广二维码" </CellGroup>
description="生成推广码"
extra={<Button size="small" onClick={() => Taro.navigateTo({url: '/dealer/qrcode/index'})}></Button>} {/* 操作按钮 */}
/> <View className="mt-6 space-y-3">
</Cell.Group> <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> </View>
) )
} }