73 changed files with 500 additions and 137 deletions
@ -1,4 +1,4 @@ |
|||||
export default definePageConfig({ |
export default definePageConfig({ |
||||
navigationBarTitleText: '注册成为经销商', |
|
||||
|
navigationBarTitleText: '注册成为VIP', |
||||
navigationBarTextStyle: 'black' |
navigationBarTextStyle: 'black' |
||||
}) |
}) |
||||
|
@ -0,0 +1,157 @@ |
|||||
|
import React from 'react' |
||||
|
import { View, Text } from '@tarojs/components' |
||||
|
import { Button, Cell, CellGroup, Tag } from '@nutui/nutui-react-taro' |
||||
|
import { useDealerUser } from '@/hooks/useDealerUser' |
||||
|
import Taro from '@tarojs/taro' |
||||
|
|
||||
|
const DealerInfo: 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="bg-gray-50 min-h-screen"> |
||||
|
{/* 页面标题 */} |
||||
|
<View className="bg-white px-4 py-3 border-b border-gray-100"> |
||||
|
<Text className="text-lg font-bold text-center"> |
||||
|
经销商信息 |
||||
|
</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> |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
export default DealerInfo |
@ -0,0 +1,81 @@ |
|||||
|
import {useState, useEffect, useCallback} from 'react' |
||||
|
import Taro from '@tarojs/taro' |
||||
|
import {getShopDealerApply} from '@/api/shop/shopDealerApply' |
||||
|
import type {ShopDealerApply} from '@/api/shop/shopDealerApply/model' |
||||
|
|
||||
|
// Hook 返回值接口
|
||||
|
export interface UseDealerApplyReturn { |
||||
|
// 经销商用户信息
|
||||
|
dealerApply: ShopDealerApply | null |
||||
|
// 加载状态
|
||||
|
loading: boolean |
||||
|
// 错误信息
|
||||
|
error: string | null |
||||
|
// 刷新数据
|
||||
|
refresh: () => Promise<void> |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 经销商用户 Hook - 简化版本 |
||||
|
* 只查询经销商用户信息和判断是否存在 |
||||
|
*/ |
||||
|
export const useDealerApply = (): UseDealerApplyReturn => { |
||||
|
const [dealerApply, setDealerApply] = useState<ShopDealerApply | null>(null) |
||||
|
const [loading, setLoading] = useState(false) |
||||
|
const [error, setError] = useState<string | null>(null) |
||||
|
|
||||
|
const userId = Taro.getStorageSync('UserId'); |
||||
|
|
||||
|
// 获取经销商用户数据
|
||||
|
const fetchDealerData = useCallback(async () => { |
||||
|
|
||||
|
if (!userId) { |
||||
|
console.log('🔍 用户未登录,提前返回') |
||||
|
setDealerApply(null) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
try { |
||||
|
setLoading(true) |
||||
|
setError(null) |
||||
|
|
||||
|
// 查询当前用户的经销商信息
|
||||
|
const dealer = await getShopDealerApply(userId) |
||||
|
|
||||
|
if (dealer) { |
||||
|
setDealerApply(dealer) |
||||
|
} else { |
||||
|
setDealerApply(null) |
||||
|
} |
||||
|
} catch (err) { |
||||
|
const errorMessage = err instanceof Error ? err.message : '获取经销商信息失败' |
||||
|
setError(errorMessage) |
||||
|
setDealerApply(null) |
||||
|
} finally { |
||||
|
setLoading(false) |
||||
|
} |
||||
|
}, [userId]) |
||||
|
|
||||
|
// 刷新数据
|
||||
|
const refresh = useCallback(async () => { |
||||
|
await fetchDealerData() |
||||
|
}, [fetchDealerData]) |
||||
|
|
||||
|
// 初始化加载数据
|
||||
|
useEffect(() => { |
||||
|
if (userId) { |
||||
|
console.log('🔍 调用 fetchDealerData') |
||||
|
fetchDealerData() |
||||
|
} else { |
||||
|
console.log('🔍 用户ID不存在,不调用 fetchDealerData') |
||||
|
} |
||||
|
}, [fetchDealerData, userId]) |
||||
|
|
||||
|
return { |
||||
|
dealerApply, |
||||
|
loading, |
||||
|
error, |
||||
|
refresh |
||||
|
} |
||||
|
} |
@ -0,0 +1,81 @@ |
|||||
|
import {useState, useEffect, useCallback} from 'react' |
||||
|
import Taro from '@tarojs/taro' |
||||
|
import {getShopDealerUser} from '@/api/shop/shopDealerUser' |
||||
|
import type {ShopDealerUser} from '@/api/shop/shopDealerUser/model' |
||||
|
|
||||
|
// Hook 返回值接口
|
||||
|
export interface UseDealerUserReturn { |
||||
|
// 经销商用户信息
|
||||
|
dealerUser: ShopDealerUser | null |
||||
|
// 加载状态
|
||||
|
loading: boolean |
||||
|
// 错误信息
|
||||
|
error: string | null |
||||
|
// 刷新数据
|
||||
|
refresh: () => Promise<void> |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 经销商用户 Hook - 简化版本 |
||||
|
* 只查询经销商用户信息和判断是否存在 |
||||
|
*/ |
||||
|
export const useDealerUser = (): UseDealerUserReturn => { |
||||
|
const [dealerUser, setDealerUser] = useState<ShopDealerUser | null>(null) |
||||
|
const [loading, setLoading] = useState(false) |
||||
|
const [error, setError] = useState<string | null>(null) |
||||
|
|
||||
|
const userId = Taro.getStorageSync('UserId'); |
||||
|
|
||||
|
// 获取经销商用户数据
|
||||
|
const fetchDealerData = useCallback(async () => { |
||||
|
|
||||
|
if (!userId) { |
||||
|
console.log('🔍 用户未登录,提前返回') |
||||
|
setDealerUser(null) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
try { |
||||
|
setLoading(true) |
||||
|
setError(null) |
||||
|
|
||||
|
// 查询当前用户的经销商信息
|
||||
|
const dealer = await getShopDealerUser(userId) |
||||
|
|
||||
|
if (dealer) { |
||||
|
setDealerUser(dealer) |
||||
|
} else { |
||||
|
setDealerUser(null) |
||||
|
} |
||||
|
} catch (err) { |
||||
|
const errorMessage = err instanceof Error ? err.message : '获取经销商信息失败' |
||||
|
setError(errorMessage) |
||||
|
setDealerUser(null) |
||||
|
} finally { |
||||
|
setLoading(false) |
||||
|
} |
||||
|
}, [userId]) |
||||
|
|
||||
|
// 刷新数据
|
||||
|
const refresh = useCallback(async () => { |
||||
|
await fetchDealerData() |
||||
|
}, [fetchDealerData]) |
||||
|
|
||||
|
// 初始化加载数据
|
||||
|
useEffect(() => { |
||||
|
if (userId) { |
||||
|
console.log('🔍 调用 fetchDealerData') |
||||
|
fetchDealerData() |
||||
|
} else { |
||||
|
console.log('🔍 用户ID不存在,不调用 fetchDealerData') |
||||
|
} |
||||
|
}, [fetchDealerData, userId]) |
||||
|
|
||||
|
return { |
||||
|
dealerUser, |
||||
|
loading, |
||||
|
error, |
||||
|
refresh |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue