operationDataPersonal.vue 7.4 KB

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