This commit is contained in:
@@ -87,10 +87,16 @@
|
||||
<script setup lang="ts">
|
||||
import { CommissionService } from '@/api/modules'
|
||||
import type { MyCommissionSummary } from '@/types/api/commission'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { formatMoney } from '@/utils/business/format'
|
||||
|
||||
defineOptions({ name: 'CommissionSummaryWidget' })
|
||||
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 获取当前用户的 shop_id
|
||||
const currentShopId = computed(() => userStore.userInfo?.shop_id)
|
||||
|
||||
// 错误信息
|
||||
const errorMsg = ref<string>('')
|
||||
|
||||
@@ -105,13 +111,33 @@
|
||||
|
||||
// 加载佣金概览
|
||||
const loadSummary = async () => {
|
||||
if (!currentShopId.value) {
|
||||
errorMsg.value = '当前账号未关联店铺'
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await CommissionService.getMyCommissionSummary()
|
||||
if (res.code === 0) {
|
||||
summary.value = res.data
|
||||
errorMsg.value = ''
|
||||
// 调用 fund-summary 接口,通过 shop_id 过滤获取自己的数据
|
||||
const res = await CommissionService.getShopFundSummary({
|
||||
page: 1,
|
||||
pageSize: 1
|
||||
})
|
||||
if (res.code === 0 && res.data.items && res.data.items.length > 0) {
|
||||
// 从结果中找到当前用户的店铺数据
|
||||
const myShopData = res.data.items.find(item => item.shop_id === currentShopId.value)
|
||||
if (myShopData) {
|
||||
summary.value = {
|
||||
total_commission: myShopData.total_commission,
|
||||
available_commission: myShopData.available_commission,
|
||||
frozen_commission: myShopData.frozen_commission,
|
||||
withdrawing_commission: myShopData.withdrawing_commission,
|
||||
withdrawn_commission: myShopData.withdrawn_commission
|
||||
}
|
||||
errorMsg.value = ''
|
||||
} else {
|
||||
errorMsg.value = '未找到佣金数据'
|
||||
}
|
||||
} else {
|
||||
// 显示错误信息
|
||||
errorMsg.value = res.msg || '获取佣金概览失败'
|
||||
}
|
||||
} catch (error: any) {
|
||||
|
||||
Reference in New Issue
Block a user