point.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. let pointChart = null;
  2. let pointChartOption = {
  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. mounted() {
  32. pointChart = echarts.init(this.$refs['pointChart']);
  33. pointChart.setOption(pointChartOption);
  34. this.getPointOverallData();
  35. this.getPointStatisticsData();
  36. this.getPointUseData();
  37. },
  38. data() {
  39. return {
  40. overall: {
  41. usePoint: 0,
  42. usedPoint: 0,
  43. pointGivenCount: 0,
  44. pointRechargeCount: 0
  45. },
  46. pointStatistics: {
  47. data: [],
  48. dataTime: null
  49. },
  50. pointRank: {
  51. pagination: {
  52. pages: 1,
  53. limit: 10,
  54. total: 50
  55. },
  56. data: [],
  57. search: {
  58. type: null,
  59. value: null
  60. },
  61. loading: false
  62. }
  63. }
  64. },
  65. methods: {
  66. getPointOverallData() {
  67. this.fetchData(GetPointOverallDataUrl).then(res => {
  68. this.overall = res.cumulative_data;
  69. });
  70. },
  71. getPointStatisticsData() {
  72. pointChart.showLoading();
  73. this.pointStatistics.data = [];
  74. this.fetchData(GetPointStatisticsDataUrl, {
  75. time: this.pointStatistics.dataTime ? this.pointStatistics.dataTime / 1000 : null
  76. }).then(data => {
  77. let legendData = [];
  78. let xAxisData = null;
  79. let series = [];
  80. for (const key in data) {
  81. if (Object.hasOwnProperty.call(data, key)) {
  82. const dataItem = data[key];
  83. this.pointStatistics.data.push({
  84. title: dataItem.name,
  85. count: dataItem.value,
  86. tip: dataItem.tips,
  87. decimals:this.getDecimals(dataItem.value)
  88. });
  89. legendData.push(dataItem.name);
  90. if (xAxisData === null) {
  91. xAxisData = dataItem['x_axis'];
  92. }
  93. series.push({
  94. type: "line",
  95. name: dataItem.name,
  96. data: dataItem.series
  97. });
  98. }
  99. }
  100. pointChart.setOption({
  101. legend: {
  102. data: legendData,
  103. },
  104. xAxis: {
  105. data: xAxisData
  106. },
  107. series
  108. });
  109. pointChart.hideLoading();
  110. });
  111. },
  112. searchMemberPointUseData() {
  113. this.pointRank.pagination.pages = 1;
  114. this.getPointUseData();
  115. },
  116. getPointUseData(page = this.pointRank.pagination.pages) {
  117. this.pointRank.loading = true;
  118. this.pointRank.pagination.pages = page;
  119. this.fetchData(GetPointUseDataUrl, {
  120. page,
  121. search_type: this.pointRank.search.type,
  122. search_data: this.pointRank.search.value,
  123. }).then(({ data, per_page, total }) => {
  124. this.pointRank.pagination.total = total;
  125. this.pointRank.pagination.limit = per_page;
  126. for (let index = 0; index < data.length; index++) {
  127. data[index]['rank'] = ((this.pointRank.pagination.pages - 1) * this.pointRank.pagination.limit) + index + 1;
  128. }
  129. this.pointRank.data = data;
  130. this.pointRank.loading = false;
  131. }).catch(() => {
  132. this.pointRank.loading = false;
  133. })
  134. }
  135. }
  136. }