operationDataPersonal.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view style="padding-bottom: 30rpx;">
  3. <!-- 图表统计 -->
  4. <view class="echart-box">
  5. <view class="echart-box-header ddflex">
  6. <view class="echart-box-title">运营情况</view>
  7. </view>
  8. <view class="sssb-box ddflex">
  9. <view class="sssb-item fflex">
  10. <view class="sssb-data sssb-color">{{totalTurnover?totalTurnover:0}}</view>
  11. <view class="sssb-label">营业总额</view>
  12. </view>
  13. <view class="sssb-line"></view>
  14. <view class="sssb-item fflex">
  15. <view class="sssb-data sssb-color">{{totalRefund?totalRefund:0}}</view>
  16. <view class="sssb-label">累计退款</view>
  17. </view>
  18. </view>
  19. <view class="sssb-box ddflex">
  20. <view class="sssb-item fflex">
  21. <view class="sssb-label">收益总额</view>
  22. <view class="sssb-data sssb-color">{{totalProfit?totalProfit:0}}</view>
  23. </view>
  24. <view class="sssb-line"></view>
  25. <view class="sssb-item fflex">
  26. <view class="sssb-label">可分账金额</view>
  27. <view class="sssb-data sssb-color">{{useProfit?useProfit:0}}</view>
  28. </view>
  29. </view>
  30. <view style="margin-top: 30rpx;height:500rpx">
  31. <view class="echart-title">近一周营业额度(元)图表数据</view>
  32. <l-echart ref="chart2" @finished="init"></l-echart>
  33. </view>
  34. <view style="margin-top: 30rpx;height:500rpx">
  35. <view class="echart-title">近一周收益额度(元)</view>
  36. <l-echart ref="chart3" @finished="init"></l-echart>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. const app = getApp();
  43. const req = require("../../utils/request.js");
  44. import LEchart from '../../components/l-echart/l-echart.vue';
  45. import * as echarts from '../../utils/echarts.min.js'
  46. export default {
  47. components: {
  48. LEchart
  49. },
  50. props: {},
  51. data() {
  52. return {
  53. systems: {},
  54. isTop: 0,
  55. pxToRpxScale: 0,
  56. rpxTopxScale: 0,
  57. merchantId:null,
  58. storeId:null,
  59. totalTurnover:0,
  60. totalRefund :0,
  61. totalProfit:0,
  62. useProfit :0,
  63. // 近一周营业额度(元)图表数据
  64. option2: {
  65. tooltip: {
  66. trigger: 'axis',
  67. axisPointer: {
  68. type: 'shadow'
  69. },
  70. confine: true
  71. },
  72. grid: {
  73. left: 0,
  74. right: 8,
  75. bottom: 20,
  76. top: 30,
  77. containLabel: true
  78. },
  79. xAxis: [{
  80. type: 'category',
  81. data: [],
  82. axisLine: {
  83. lineStyle: {
  84. color: '#999999'
  85. }
  86. },
  87. axisLabel: {
  88. color: '#666666',
  89. // interval: 0,
  90. }
  91. }],
  92. yAxis: [{
  93. type: 'value',
  94. axisTick: {
  95. show: false
  96. },
  97. axisLine: {
  98. lineStyle: {
  99. color: '#999999'
  100. }
  101. },
  102. axisLabel: {
  103. color: '#666666'
  104. }
  105. }],
  106. series: [{
  107. name: '订单',
  108. type: 'bar',
  109. label: {
  110. normal: {
  111. show: true,
  112. position: 'top',
  113. color: '#FF770F',
  114. formatter: '¥{c}',
  115. },
  116. },
  117. data: [285, 200, 285, 300, 285, 285, 320],
  118. barWidth: 15,
  119. itemStyle: {
  120. // 颜色
  121. color: '#FF770F',
  122. // 给bar设置倒角
  123. barBorderRadius: [0, 0, 0, 0]
  124. }
  125. }]
  126. },
  127. // 近一周收益额度(元)
  128. option3: {
  129. tooltip: {
  130. trigger: 'axis',
  131. axisPointer: {
  132. type: 'shadow'
  133. },
  134. confine: true
  135. },
  136. grid: {
  137. left: 0,
  138. right: 8,
  139. bottom: 20,
  140. top: 30,
  141. containLabel: true
  142. },
  143. xAxis: [{
  144. type: 'category',
  145. data: [],
  146. axisLine: {
  147. lineStyle: {
  148. color: '#999999'
  149. }
  150. },
  151. axisLabel: {
  152. color: '#666666',
  153. // interval: 0,
  154. }
  155. }],
  156. yAxis: [{
  157. type: 'value',
  158. axisTick: {
  159. show: false
  160. },
  161. axisLine: {
  162. lineStyle: {
  163. color: '#999999'
  164. }
  165. },
  166. axisLabel: {
  167. color: '#666666'
  168. }
  169. }],
  170. series: [{
  171. name: '订单',
  172. type: 'bar',
  173. label: {
  174. normal: {
  175. show: true,
  176. position: 'top',
  177. color: '#FF770F',
  178. formatter: '¥{c}',
  179. },
  180. },
  181. data: [285, 200, 285, 300, 285, 285, 320],
  182. barWidth: 15,
  183. itemStyle: {
  184. // 颜色
  185. color: '#FF770F',
  186. // 给bar设置倒角
  187. barBorderRadius: [0, 0, 0, 0]
  188. }
  189. }]
  190. }
  191. }
  192. },
  193. onLoad(options) {
  194. if(options.merchantId){
  195. this.merchantId = options.merchantId
  196. }
  197. if(options.storeId){
  198. this.storeId = options.storeId
  199. }
  200. this.totalTurnover = options.totalTurnover?options.totalTurnover:0
  201. this.totalRefund = options.totalRefund?options.totalRefund:0
  202. this.totalProfit = options.totalProfit?options.totalProfit:0
  203. this.useProfit = options.useProfit?options.useProfit:0
  204. this.getStatisticData()
  205. },
  206. onShow() {
  207. },
  208. methods: {
  209. jumpUrl(url) {
  210. if (req.isLogins(true)) {
  211. uni.navigateTo({
  212. url: url
  213. })
  214. }
  215. },
  216. init() {
  217. if (this.$refs.chart2) {
  218. this.$refs.chart2.init(echarts, async chart => {
  219. // let echartData = await this.getEchartData()
  220. this.option2.xAxis[0].data = this.echartData.orderList.map(item=>{return item.showTime})
  221. this.option2.yAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
  222. this.option2.xAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
  223. this.option2.series[0].data = this.echartData.orderList.map(item=>{return item.orderCount})
  224. this.option2.series[0].label.normal.fontSize = 13 * this.rpxTopxScale
  225. chart.setOption(this.option2);
  226. });
  227. }
  228. if (this.$refs.chart3) {
  229. this.$refs.chart3.init(echarts, async chart => {
  230. // let echartData = await this.getEchartData()
  231. this.option3.xAxis[0].data = this.echartData.profitList.map(item=>{return item.showTime})
  232. this.option3.yAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
  233. this.option3.xAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
  234. his.option3.series[0].data = this.echartData.profitList.map(item=>{return item.profit})
  235. this.option3.series[0].label.normal.fontSize = 13 * this.rpxTopxScale
  236. chart.setOption(this.option3);
  237. });
  238. }
  239. },
  240. async getStatisticData(){
  241. await this.getBarEchartData()
  242. this.init()
  243. },
  244. getBarEchartData() {
  245. return new Promise((r, j) => {
  246. let merchantId = this.merchantId?this.merchantId:''
  247. let storeId = this.storeId?this.storeId:''
  248. let pData = {
  249. merchantId:merchantId,
  250. storeId:storeId
  251. }
  252. req.getRequest('/admin/v2/statistic/histogram', pData, res => {
  253. this.barEchartData = res
  254. console.log('statistic chart', res)
  255. r(res)
  256. })
  257. })
  258. },
  259. },
  260. mounted() {
  261. },
  262. onPageScroll: function(e) {
  263. }
  264. }
  265. </script>
  266. <style>
  267. @import "./operationDataPersonal.css";
  268. </style>