index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <script setup>
  2. import { Page } from '@vben/common-ui';
  3. import { requestClient } from '#/api/request';
  4. import { Button, message } from 'ant-design-vue';
  5. import { ref, reactive, computed, onMounted, useTemplateRef } from 'vue';
  6. import dayjs from 'dayjs';
  7. import MatchCard from '../components/match_card.vue';
  8. const solutions = ref([]);
  9. const getSolutions = async () => {
  10. try {
  11. const data = await requestClient.get('/triangle/get_solutions');
  12. return data;
  13. }
  14. catch (error) {
  15. console.error('Failed to fetch solutions:', error);
  16. message.error('获取中单方案失败');
  17. return [];
  18. }
  19. }
  20. const getGamesEvents = async () => {
  21. try {
  22. const data = await requestClient.get('/triangle/get_games_events');
  23. return data;
  24. }
  25. catch (error) {
  26. console.error('Failed to fetch games events:', error);
  27. message.error('获取比赛盘口失败');
  28. return {};
  29. }
  30. }
  31. const moveToFront = (arr, index) => {
  32. if (index <= 0 || index >= arr.length) {
  33. return arr;
  34. }
  35. const item = arr.splice(index, 1)[0];
  36. arr.unshift(item);
  37. return arr;
  38. }
  39. const updateSolutions = async () => {
  40. const [solutionsList, eventsList] = await Promise.all([getSolutions(), getGamesEvents()]);
  41. solutions.value = solutionsList.map(item => {
  42. const { cpr, info, sol: { cross_type, jc_index, gold_side_a, gold_side_b, gold_side_m, win_side_a, win_side_b, win_side_m, win_average } } = item;
  43. const cprKeys = cpr.map(item => item.k);
  44. const jcEvents = eventsList.jc[info.jc.eventId];
  45. const psEvents = eventsList.ps[info.ps.eventId];
  46. const obEvents = eventsList.ob[info.ob.eventId];
  47. cpr[0].g = gold_side_a;
  48. cpr[0].w = win_side_a;
  49. cpr[1].g = gold_side_b;
  50. cpr[1].w = win_side_b;
  51. cpr[2].g = gold_side_m;
  52. cpr[2].w = win_side_m;
  53. const newCpr = moveToFront(cpr, jc_index);
  54. return { ...item, cpr: newCpr, sol: { cross_type, jc_index, win_average }, events };
  55. });
  56. }
  57. const updateGamesEvents = async () => {
  58. const events = await getGamesEvents();
  59. gamesEvents.value = events;
  60. }
  61. onMounted(() => {
  62. updateSolutions();
  63. });
  64. </script>
  65. <!-- eventId
  66. platform
  67. leagueName
  68. teamHomeName
  69. teamAwayName
  70. dateTime
  71. eventInfo
  72. solutionKey -->
  73. <template>
  74. <div class="solution-container">
  75. <div class="solution-header">
  76. <span>JC</span>
  77. <span>PS</span>
  78. <span>OB</span>
  79. <em>利润</em>
  80. </div>
  81. <div class="solution-list">
  82. <!-- <div class="solution-item" v-for="solution in solutions" :key="solution.sid">
  83. <MatchCard />
  84. <MatchCard />
  85. <MatchCard />
  86. <div class="solution-profit"></div>
  87. </div> -->
  88. </div>
  89. </div>
  90. </template>
  91. <style lang="scss" scoped>
  92. .solution-container {
  93. height: 100%;
  94. display: flex;
  95. flex-direction: column;
  96. }
  97. .solution-header {
  98. display: flex;
  99. align-items: center;
  100. height: 40px;
  101. background: #fff;
  102. box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  103. span, em {
  104. display: block;
  105. text-align: center;
  106. }
  107. span {
  108. flex: 1;
  109. }
  110. em {
  111. width: 80px;
  112. font-style: normal;
  113. }
  114. }
  115. </style>