operationDataPersonal.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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. echartData:{},
  64. // 近一周营业额度(元)图表数据
  65. option2: {
  66. tooltip: {
  67. trigger: 'axis',
  68. axisPointer: {
  69. type: 'shadow'
  70. },
  71. confine: true
  72. },
  73. grid: {
  74. left: 0,
  75. right: 8,
  76. bottom: 20,
  77. top: 30,
  78. containLabel: true
  79. },
  80. xAxis: [{
  81. type: 'category',
  82. data: [],
  83. axisLine: {
  84. lineStyle: {
  85. color: '#999999'
  86. }
  87. },
  88. axisLabel: {
  89. color: '#666666',
  90. // interval: 0,
  91. }
  92. }],
  93. yAxis: [{
  94. type: 'value',
  95. axisTick: {
  96. show: false
  97. },
  98. axisLine: {
  99. lineStyle: {
  100. color: '#999999'
  101. }
  102. },
  103. axisLabel: {
  104. color: '#666666'
  105. }
  106. }],
  107. series: [{
  108. name: '订单',
  109. type: 'bar',
  110. label: {
  111. normal: {
  112. show: true,
  113. position: 'top',
  114. color: '#FF770F',
  115. formatter: '¥{c}',
  116. },
  117. },
  118. data: [285, 200, 285, 300, 285, 285, 320],
  119. barWidth: 15,
  120. itemStyle: {
  121. // 颜色
  122. color: '#FF770F',
  123. // 给bar设置倒角
  124. barBorderRadius: [0, 0, 0, 0]
  125. }
  126. }]
  127. },
  128. // 近一周收益额度(元)
  129. option3: {
  130. tooltip: {
  131. trigger: 'axis',
  132. axisPointer: {
  133. type: 'shadow'
  134. },
  135. confine: true
  136. },
  137. grid: {
  138. left: 0,
  139. right: 8,
  140. bottom: 20,
  141. top: 30,
  142. containLabel: true
  143. },
  144. xAxis: [{
  145. type: 'category',
  146. data: [],
  147. axisLine: {
  148. lineStyle: {
  149. color: '#999999'
  150. }
  151. },
  152. axisLabel: {
  153. color: '#666666',
  154. // interval: 0,
  155. }
  156. }],
  157. yAxis: [{
  158. type: 'value',
  159. axisTick: {
  160. show: false
  161. },
  162. axisLine: {
  163. lineStyle: {
  164. color: '#999999'
  165. }
  166. },
  167. axisLabel: {
  168. color: '#666666'
  169. }
  170. }],
  171. series: [{
  172. name: '订单',
  173. type: 'bar',
  174. label: {
  175. normal: {
  176. show: true,
  177. position: 'top',
  178. color: '#FF770F',
  179. formatter: '¥{c}',
  180. },
  181. },
  182. data: [285, 200, 285, 300, 285, 285, 320],
  183. barWidth: 15,
  184. itemStyle: {
  185. // 颜色
  186. color: '#FF770F',
  187. // 给bar设置倒角
  188. barBorderRadius: [0, 0, 0, 0]
  189. }
  190. }]
  191. }
  192. }
  193. },
  194. onLoad(options) {
  195. if(options.merchantId){
  196. this.merchantId = options.merchantId
  197. }
  198. if(options.storeId){
  199. this.storeId = options.storeId
  200. }
  201. this.totalTurnover = options.totalTurnover&&options.totalTurnover!='null'?options.totalTurnover:0
  202. this.totalRefund = options.totalRefund&&options.totalRefund!='null'?options.totalRefund:0
  203. this.totalProfit = options.totalProfit&&options.totalProfit!='null'?options.totalProfit:0
  204. this.useProfit = options.useProfit&&options.useProfit!='null'?options.useProfit:0
  205. this.getStatisticData()
  206. },
  207. onShow() {
  208. },
  209. methods: {
  210. jumpUrl(url) {
  211. if (req.isLogins(true)) {
  212. uni.navigateTo({
  213. url: url
  214. })
  215. }
  216. },
  217. init() {
  218. if (this.$refs.chart2) {
  219. this.$refs.chart2.init(echarts, async chart => {
  220. // let echartData = await this.getEchartData()
  221. this.option2.xAxis[0].data = this.echartData.orderList.map(item=>{return item.showTime})
  222. this.option2.yAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
  223. this.option2.xAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
  224. this.option2.series[0].data = this.echartData.orderList.map(item=>{return item.orderCount})
  225. this.option2.series[0].label.normal.fontSize = 13 * this.rpxTopxScale
  226. chart.setOption(this.option2);
  227. });
  228. }
  229. if (this.$refs.chart3) {
  230. this.$refs.chart3.init(echarts, async chart => {
  231. // let echartData = await this.getEchartData()
  232. this.option3.xAxis[0].data = this.echartData.profitList.map(item=>{return item.showTime})
  233. this.option3.yAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
  234. this.option3.xAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
  235. this.option3.series[0].data = this.echartData.profitList.map(item=>{return item.profit})
  236. this.option3.series[0].label.normal.fontSize = 13 * this.rpxTopxScale
  237. chart.setOption(this.option3);
  238. });
  239. }
  240. },
  241. async getStatisticData(){
  242. await this.getBarEchartData()
  243. this.init()
  244. },
  245. getBarEchartData() {
  246. return new Promise((r, j) => {
  247. let merchantId = this.merchantId?this.merchantId:''
  248. let storeId = this.storeId?this.storeId:''
  249. let pData = {
  250. merchantId:merchantId?merchantId:null,
  251. storeId:storeId?storeId:null
  252. }
  253. req.getRequest('/admin/v2/statistic/histogram', pData, res => {
  254. this.echartData = res
  255. console.log('statistic chart', res)
  256. r(res)
  257. })
  258. })
  259. },
  260. },
  261. mounted() {
  262. },
  263. onPageScroll: function(e) {
  264. }
  265. }
  266. </script>
  267. <style>
  268. @import "./operationDataPersonal.css";
  269. </style>