operationDataPersonal.vue 7.5 KB

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