forked from gxwebsoft/mp-10550
refactor(dealer): 优化团队页面数据获取逻辑
- 修改了 fetchTeamData 函数中的 dealerId 获取逻辑,使用可选链操作符简化代码 - 更新了 getNextUser 函数的参数类型,使其与接口定义一致 -调整了 useEffect 的依赖项,增加了 dealerId - 移除了未使用的 ShopDealerUser 类型导入
This commit is contained in:
@@ -7,7 +7,6 @@ import {useDealerUser} from '@/hooks/useDealerUser'
|
|||||||
import {listShopDealerReferee} from '@/api/shop/shopDealerReferee'
|
import {listShopDealerReferee} from '@/api/shop/shopDealerReferee'
|
||||||
import {pageShopDealerOrder} from '@/api/shop/shopDealerOrder'
|
import {pageShopDealerOrder} from '@/api/shop/shopDealerOrder'
|
||||||
import type {ShopDealerReferee} from '@/api/shop/shopDealerReferee/model'
|
import type {ShopDealerReferee} from '@/api/shop/shopDealerReferee/model'
|
||||||
import type {ShopDealerUser} from "@/api/shop/shopDealerUser/model";
|
|
||||||
|
|
||||||
interface TeamMemberWithStats extends ShopDealerReferee {
|
interface TeamMemberWithStats extends ShopDealerReferee {
|
||||||
name?: string
|
name?: string
|
||||||
@@ -32,7 +31,7 @@ const DealerTeam: React.FC = () => {
|
|||||||
console.log(dealerId, 'dealerId>>>>>>>>>')
|
console.log(dealerId, 'dealerId>>>>>>>>>')
|
||||||
// 获取团队成员关系
|
// 获取团队成员关系
|
||||||
const refereeResult = await listShopDealerReferee({
|
const refereeResult = await listShopDealerReferee({
|
||||||
dealerId: dealerId ? dealerId : dealerUser.userId
|
dealerId: dealerId ? dealerId : dealerUser?.userId
|
||||||
})
|
})
|
||||||
|
|
||||||
if (refereeResult) {
|
if (refereeResult) {
|
||||||
@@ -100,16 +99,16 @@ const DealerTeam: React.FC = () => {
|
|||||||
icon: 'error'
|
icon: 'error'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [dealerUser?.userId])
|
}, [dealerUser?.userId, dealerId])
|
||||||
|
|
||||||
const getNextUser = (item: ShopDealerUser) => {
|
const getNextUser = (item: TeamMemberWithStats) => {
|
||||||
|
console.log('点击用户:', item.userId, item.name)
|
||||||
setDealerId(item.userId)
|
setDealerId(item.userId)
|
||||||
fetchTeamData().then()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化加载数据
|
// 监听数据变化,获取团队数据
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dealerUser?.userId) {
|
if (dealerUser?.userId || dealerId) {
|
||||||
fetchTeamData().then()
|
fetchTeamData().then()
|
||||||
}
|
}
|
||||||
}, [fetchTeamData])
|
}, [fetchTeamData])
|
||||||
|
|||||||
Reference in New Issue
Block a user