diff --git a/src/components/workspace/GoldGraph.vue b/src/components/workspace/GoldGraph.vue index d83a520..9f0cf73 100644 --- a/src/components/workspace/GoldGraph.vue +++ b/src/components/workspace/GoldGraph.vue @@ -655,27 +655,7 @@ const getAdminData = async function () { console.log('请求失败', error) } } -// 获取卡片数据 -const getCardData = async () => { - try { - const response = await API({url: '/workbench/getCard', data: {}}) - workDataUpdateTime.value = response.updateTime - // 周同比 - sumWow.value = response.sumWow.toFixed(2) - // 日环比 - sumDaily.value = response.sumDaily.toFixed(2) - - if (response && response.data) { - processData(response.data) - } else if (Array.isArray(response?.marketCards)) { - processData(response) - } else { - console.error('无效的API响应结构:', response) - } - } catch (error) { - console.error('获取卡片数据失败:', error) - } -} + const workDataUpdateTime = ref(null) // 标记当前激活的时间范围按钮 @@ -687,7 +667,6 @@ const handleDatePickerChange = () => { onMounted(async () => { await getAdminData() - await getCardData() await getMarkets() getYear() window.addEventListener('resize', () => { diff --git a/src/components/workspace/GoldGraphMarkets.vue b/src/components/workspace/GoldGraphMarkets.vue new file mode 100644 index 0000000..9f0cf73 --- /dev/null +++ b/src/components/workspace/GoldGraphMarkets.vue @@ -0,0 +1,817 @@ + + + + diff --git a/src/views/workspace/index.vue b/src/views/workspace/index.vue index f7d02fe..0cf0a5e 100644 --- a/src/views/workspace/index.vue +++ b/src/views/workspace/index.vue @@ -6,7 +6,7 @@
- + @@ -15,7 +15,7 @@ - +
@@ -29,76 +29,7 @@ import GoldManagement from "@/components/workspace/GoldManagement.vue" import CashManagement from "@/components/workspace/CashManagement.vue" import GoldGraph from "@/components/workspace/GoldGraph.vue" -const cardData = ref({}) -const graphData = ref([]) -const markets = ref([]) -const account = ref('') -const activeTab = ref('recharge') -// tab 切换时重新调图表接口 -const handleTabChange = async (tab) => { - activeTab.value = tab - await getGraphData() -} - -// 获取用户信息(拿 account) -const getUserInfo = async () => { - const res = await API({ url: '/admin/userinfo', data: {} }) - account.value = res?.account || '' -} - -// 获取市场列表 -const getMarkets = async () => { - if (!account.value) return - const res = await API({ url: '/general/adminMarkets', data: { account: account.value } }) - markets.value = res.data - console.log('获取市场列表:res:', res) - console.log('获取市场列表:market:', markets.value) -} - -// 获取金币卡片数据 -const getCardData = async () => { - const res = await API({ url: '/workbench/getCard', data: {} }) - cardData.value = res?.data || {} -} - -// 获取金币图表数据 -const getGraphData = async () => { - if (!markets.value.length) return - - const params = { - markets: markets.value, - startDate: '2025-01-01 00:00:00', - endDate: '2025-12-31 23:59:59' - } - - const res = await API({ url: '/workbench/getGraph', data: params }) - if (!res?.marketGraphs) return - - graphData.value = res.marketGraphs.map(m => ({ - market: m.market, - permanent: activeTab.value === 'recharge' - ? m.sumRechargePermanent / 100 - : m.sumConsumePermanent / 100, - free: activeTab.value === 'recharge' - ? m.sumRechargeFree / 100 - : m.sumConsumeFree / 100, - task: activeTab.value === 'recharge' - ? m.sumRechargeTask / 100 - : m.sumConsumeTask / 100, - })) -} - -onMounted(async () => { - try { - await getUserInfo() // 先拿 account - await getMarkets() // 再拿 markets - await getCardData() // 卡片 - await getGraphData() // 图表 - } catch (err) { - console.error('初始化失败:', err) - } -})