balance.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. let balanceChart = null;
  2. let balanceChartOption = {
  3. tooltip: {
  4. trigger: 'axis',
  5. },
  6. grid: {
  7. right: 15,
  8. bottom: 25
  9. },
  10. xAxis: {
  11. type: 'category',
  12. data: []
  13. },
  14. yAxis: {
  15. type: 'value',
  16. splitLine: {
  17. show: true,
  18. lineStyle: {
  19. type: 'dashed',
  20. color: "#f0f3f6",
  21. opacity: 1
  22. }
  23. }
  24. },
  25. series: [{
  26. data: [],
  27. type: 'line'
  28. }]
  29. }
  30. const mixin = {
  31. data() {
  32. return {
  33. overall: {
  34. balanceUseCount: 0,
  35. balanceUsedCount: 0,
  36. balanceWithdrawCount: 0,
  37. balanceIncomeCount: 0,
  38. balanceRechargeCount: 0,
  39. balanceMemberRechargeCount: 0,
  40. },
  41. balanceStatisticsTime: null,
  42. balanceStatisticsData: [],
  43. balanceUseData: [],
  44. balanceUseDataSearchMember: null,
  45. balanceUseDataSearchMemberLoading: false,
  46. balanceUsePagination: {
  47. pages: 1,
  48. limit: 10,
  49. total: 50
  50. }
  51. }
  52. },
  53. mounted() {
  54. balanceChart = echarts.init(this.$refs['balanceChart']);
  55. balanceChart.setOption(balanceChartOption);
  56. this.getBalanceOverallData();
  57. this.getBalanceStatisticsData();
  58. this.getMemberBalanceUseData();
  59. },
  60. methods: {
  61. getBalanceOverallData() {
  62. this.fetchData(GetBalanceOverallDataUrl).then(res => {
  63. this.overall = res.cumulative_data;
  64. });
  65. },
  66. getBalanceStatisticsData() {
  67. balanceChart.showLoading();
  68. this.fetchData(GetBalanceStaitsticsUrl, {
  69. time: this.balanceStatisticsTime ? this.balanceStatisticsTime / 1000 : null
  70. }).then(data => {
  71. let balanceStatisticsData = [];
  72. let XAxisData = null;
  73. let legendData = [];
  74. let series = [];
  75. for (const key in data) {
  76. if (Object.hasOwnProperty.call(data, key)) {
  77. const dataItem = data[key];
  78. if (XAxisData === null) {
  79. XAxisData = dataItem['x_axis'];
  80. }
  81. balanceStatisticsData.push({
  82. title: dataItem.name,
  83. count: dataItem.value,
  84. tip: dataItem.tips,
  85. key,
  86. decimals:this.getDecimals(dataItem.value)
  87. });
  88. series.push({
  89. name: dataItem.name,
  90. type: "line",
  91. data: dataItem.series
  92. })
  93. legendData.push(dataItem['name']);
  94. }
  95. }
  96. balanceChart.setOption({
  97. legend: {
  98. data: legendData
  99. },
  100. xAxis: {
  101. data: XAxisData,
  102. },
  103. series
  104. });
  105. this.balanceStatisticsData = balanceStatisticsData;
  106. balanceChart.hideLoading();
  107. });
  108. },
  109. searchMemberBalanceUseData() {
  110. this.balanceUsePagination.pages = 1;
  111. this.getMemberBalanceUseData();
  112. },
  113. getMemberBalanceUseData(page = this.balanceUsePagination.pages) {
  114. this.balanceUseDataSearchMemberLoading = true;
  115. this.balanceUsePagination.pages = page;
  116. this.fetchData(GetMemberBalanceUseDataUrl, {
  117. page,
  118. member: this.balanceUseDataSearchMember
  119. }).then(({ data, per_page, total }) => {
  120. this.balanceUsePagination.total = total;
  121. this.balanceUsePagination.limit = per_page;
  122. for (let index = 0; index < data.length; index++) {
  123. data[index]['rank'] = ((this.balanceUsePagination.pages - 1) * this.balanceUsePagination.limit) + index + 1;
  124. }
  125. this.balanceUseData = data;
  126. this.balanceUseDataSearchMemberLoading = false;
  127. });
  128. }
  129. }
  130. }