You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 lines
3.4 KiB

2 weeks ago
2 months ago
2 months ago
2 months ago
4 months ago
4 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 months ago
2 months ago
2 weeks ago
  1. <template>
  2. <!-- 头部 -->
  3. <el-header class="header">
  4. <div class="title">数据总览</div>
  5. </el-header>
  6. <div style="height: 100vh;">
  7. <el-row class="cards" >
  8. <el-col :span="14">
  9. <GoldManagement :cardData="cardData" />
  10. </el-col>
  11. <!-- 右上格子占12列 -->
  12. <el-col :span="10">
  13. <CashManagement />
  14. </el-col>
  15. </el-row>
  16. <el-row class="graphs">
  17. <el-col :span="24">
  18. <GoldGraph :graphData="graphData" @tab-change="handleTabChange" />
  19. </el-col>
  20. </el-row>
  21. </div>
  22. </template>
  23. <script setup>
  24. import { ref, onMounted } from 'vue'
  25. import API from '@/util/http'
  26. import GoldManagement from "@/components/workspace/GoldManagement.vue"
  27. import CashManagement from "@/components/workspace/CashManagement.vue"
  28. import GoldGraph from "@/components/workspace/GoldGraph.vue"
  29. const cardData = ref({})
  30. const graphData = ref([])
  31. const markets = ref([])
  32. const account = ref('')
  33. const activeTab = ref('recharge')
  34. // tab 切换时重新调图表接口
  35. const handleTabChange = async (tab) => {
  36. activeTab.value = tab
  37. await getGraphData()
  38. }
  39. // 获取用户信息(拿 account)
  40. const getUserInfo = async () => {
  41. const res = await API({ url: '/admin/userinfo', data: {} })
  42. account.value = res?.account || ''
  43. }
  44. // 获取市场列表
  45. const getMarkets = async () => {
  46. if (!account.value) return
  47. const res = await API({ url: '/general/adminMarkets', data: { account: account.value } })
  48. markets.value = res.data
  49. console.log('获取市场列表:res:', res)
  50. console.log('获取市场列表:market:', markets.value)
  51. }
  52. // 获取金币卡片数据
  53. const getCardData = async () => {
  54. const res = await API({ url: '/workbench/getCard', data: {} })
  55. cardData.value = res?.data || {}
  56. }
  57. // 获取金币图表数据
  58. const getGraphData = async () => {
  59. if (!markets.value.length) return
  60. const params = {
  61. markets: markets.value,
  62. startDate: '2025-01-01 00:00:00',
  63. endDate: '2025-12-31 23:59:59'
  64. }
  65. const res = await API({ url: '/workbench/getGraph', data: params })
  66. if (!res?.marketGraphs) return
  67. graphData.value = res.marketGraphs.map(m => ({
  68. market: m.market,
  69. permanent: activeTab.value === 'recharge'
  70. ? m.sumRechargePermanent / 100
  71. : m.sumConsumePermanent / 100,
  72. free: activeTab.value === 'recharge'
  73. ? m.sumRechargeFree / 100
  74. : m.sumConsumeFree / 100,
  75. task: activeTab.value === 'recharge'
  76. ? m.sumRechargeTask / 100
  77. : m.sumConsumeTask / 100,
  78. }))
  79. }
  80. onMounted(async () => {
  81. try {
  82. await getUserInfo() // 先拿 account
  83. await getMarkets() // 再拿 markets
  84. await getCardData() // 卡片
  85. await getGraphData() // 图表
  86. } catch (err) {
  87. console.error('初始化失败:', err)
  88. }
  89. })
  90. </script>
  91. <style scoped>
  92. .header {
  93. /* 将纯色背景替换为线性渐变 */
  94. background: linear-gradient(
  95. 90deg,
  96. rgba(228, 240, 252, 1) 20%,
  97. rgba(190, 218, 247, 1) 50%,
  98. rgba(228, 240, 252, 1) 100%
  99. );
  100. height: 6vh;
  101. border-radius: 12px;
  102. margin-bottom: 4px;
  103. box-shadow: 0 2px 5px rgba(8, 4, 4, 0.1);
  104. /* 添加阴影增强层次感 */
  105. z-index: 80;
  106. display: flex;
  107. align-items: center;
  108. justify-content: center;
  109. }
  110. .title {
  111. width: 136px;
  112. color: #040a2d;
  113. font-family: "PingFang SC";
  114. font-size: 34px;
  115. font-style: normal;
  116. font-weight: 900;
  117. line-height: 31.79px;
  118. text-align: center;
  119. }
  120. </style>