operationDataPersonal.vue 7.8 KB

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