From d44e7157e8fbd8edcf122b8e4bf10ec346d98bd0 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Mar 2026 21:02:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5=EF=BC=8C?= =?UTF-8?q?=E8=B5=84=E4=BA=A7=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Wallet.vue | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/views/Wallet.vue b/src/views/Wallet.vue index a366048..039ecb5 100644 --- a/src/views/Wallet.vue +++ b/src/views/Wallet.vue @@ -735,7 +735,8 @@ import { useUserStore } from '../stores/user' import { useLocaleStore } from '../stores/locale' import { useAuthError } from '../composables/useAuthError' import { cancelOrder as apiCancelOrder } from '../api/order' -import { getOrderList, mapOrderToHistoryItem, mapOrderToOpenOrderItem, OrderStatus } from '../api/order' +import { getOrderList, mapOrderToOpenOrderItem, OrderStatus } from '../api/order' +import { getHistoryRecordListClient, getHistoryRecordList } from '../api/historyRecord' import { getPositionList, mapPositionToDisplayItem, claimPosition } from '../api/position' import { getSettlementRequestsListClient, @@ -780,7 +781,7 @@ const withdrawStatusOptions = computed(() => [ const currentPositionList = computed(() => USE_MOCK_WALLET ? positions.value : positionList.value, ) -/** 未结算项:从持仓列表中筛出可领取的(有 marketID+tokenID;若后端有 needClaim 则仅 needClaim 为 true) */ +/** 未结算项:从持仓列表中筛出可领取的(有 marketID+tokenID,且所属市场已关闭 market.closed=true) */ const unsettledItems = computed(() => { const list = currentPositionList.value return list @@ -788,7 +789,7 @@ const unsettledItems = computed(() => { (p) => p.marketID && p.tokenID && - (p.needClaim === undefined || p.needClaim === true), + p.marketClosed === true, ) .map((p) => { const amount = parseFloat(String(p.value).replace(/[^0-9.-]/g, '')) || 0 @@ -872,8 +873,8 @@ interface Position { marketID?: string /** Token ID(从持仓列表来,用于领取结算) */ tokenID?: string - /** 是否待领取/未结算(后端可选,无则按有 marketID+tokenID 视为可领取) */ - needClaim?: boolean + /** 所属市场是否已关闭,marketClosed=true 表示可结算/可领取 */ + marketClosed?: boolean } /** 从 avgNow "72¢ → 0.5¢" 解析出 [avg, now] */ @@ -1030,6 +1031,7 @@ const historyList = ref([]) const historyTotal = ref(0) const historyLoading = ref(false) +/** 历史记录来自 GET /hr/getHistoryRecordListClient(需鉴权,按当前用户分页) */ async function loadHistoryOrders() { if (USE_MOCK_WALLET) return const headers = userStore.getAuthHeaders() @@ -1047,18 +1049,18 @@ async function loadHistoryOrders() { } historyLoading.value = true try { - const res = await getOrderList( + const res = await getHistoryRecordListClient( { page: page.value, pageSize: itemsPerPage.value, - userID, + userId: userID, }, { headers }, ) if (res.code === 0 || res.code === 200) { - const list = res.data?.list ?? [] - historyList.value = list.map(mapOrderToHistoryItem) - historyTotal.value = res.data?.total ?? 0 + const { list, total } = getHistoryRecordList(res.data) + historyList.value = list + historyTotal.value = total } else { historyList.value = [] historyTotal.value = 0 @@ -1346,8 +1348,11 @@ function shareHistory(id: string) { const plChartRef = ref(null) let plChartInstance: ECharts | null = null -/** 根据时间范围生成盈亏折线数据 [timestamp, pnl] */ -function generatePlData(range: string): [number, number][] { +/** + * 资产变化折线图数据 [timestamp_ms, pnl] + * 暂无接口时返回真实格式的时间序列,数值均为 0;有接口后改为从 API 拉取并在此处做分时过滤 + */ +function getPlChartData(range: string): [number, number][] { const now = Date.now() let stepMs: number let count: number @@ -1371,11 +1376,9 @@ function generatePlData(range: string): [number, number][] { break } const data: [number, number][] = [] - let pnl = 0 for (let i = count; i >= 0; i--) { const t = now - i * stepMs - pnl += (Math.random() - 0.48) * 20 - data.push([t, Math.round(pnl * 100) / 100]) + data.push([t, 0]) } return data } @@ -1437,18 +1440,18 @@ function buildPlChartOption(chartData: [number, number][]) { const plChartData = ref<[number, number][]>([]) function updatePlChart() { - plChartData.value = generatePlData(plRange.value) + plChartData.value = getPlChartData(plRange.value) const last = plChartData.value[plChartData.value.length - 1] - if (last) profitLoss.value = last[1].toFixed(2) + if (last != null) profitLoss.value = last[1].toFixed(2) if (plChartInstance) plChartInstance.setOption(buildPlChartOption(plChartData.value), { replaceMerge: ['series'] }) } function initPlChart() { if (!plChartRef.value) return - plChartData.value = generatePlData(plRange.value) + plChartData.value = getPlChartData(plRange.value) const last = plChartData.value[plChartData.value.length - 1] - if (last) profitLoss.value = last[1].toFixed(2) + if (last != null) profitLoss.value = last[1].toFixed(2) plChartInstance = echarts.init(plChartRef.value) plChartInstance.setOption(buildPlChartOption(plChartData.value)) }