operationData.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. <template>
  2. <view style="padding-bottom: 30rpx;">
  3. <!-- tab -->
  4. <view class="tab-box ddflex">
  5. <view :class="'tab-item fflex '+(queryType==1?'tab-item-active':'')" @click="queryTypeChange(1)">
  6. <view>我的</view>
  7. <image class="tab-active-icon" src="../../static/images/tab_cur.png"></image>
  8. </view>
  9. <view :class="'tab-item fflex '+(queryType==2?'tab-item-active':'')" @click="queryTypeChange(2)">
  10. <view>商家</view>
  11. <image class="tab-active-icon" src="../../static/images/tab_cur.png"></image>
  12. </view>
  13. <view :class="'tab-item fflex '+(queryType==3?'tab-item-active':'')" @click="queryTypeChange(3)">
  14. <view>门店</view>
  15. <image class="tab-active-icon" src="../../static/images/tab_cur.png"></image>
  16. </view>
  17. </view>
  18. <view style="height: 110rpx;"></view>
  19. <!-- 我的收益 -->
  20. <block v-if="queryType==1">
  21. <!-- 图表统计 -->
  22. <view class="echart-box">
  23. <view class="echart-box-header ddflex">
  24. <view class="echart-box-title">交易趋势</view>
  25. <view class="echart-box-timeType ddflex">
  26. <view :class="'echart-box-timeType-item '+(timeType==1?'echart-box-timeType-item-acitve':'')"
  27. @click="timeTypeChange(1)">今日</view>
  28. <view :class="'echart-box-timeType-item '+(timeType==2?'echart-box-timeType-item-acitve':'')"
  29. @click="timeTypeChange(2)">近7日</view>
  30. <view :class="'echart-box-timeType-item '+(timeType==3?'echart-box-timeType-item-acitve':'')"
  31. @click="timeTypeChange(3)">近30日</view>
  32. </view>
  33. </view>
  34. <view style="margin-top: 30rpx;height:500rpx">
  35. <l-echart ref="chart" @finished="init"></l-echart>
  36. </view>
  37. </view>
  38. <!-- 图表统计 -->
  39. <view class="echart-box">
  40. <view class="echart-box-header ddflex">
  41. <view class="echart-box-title">实时设备数据</view>
  42. </view>
  43. <view class="sssb-box ddflex">
  44. <view class="sssb-item fflex">
  45. <view class="sssb-label">总数</view>
  46. <view class="sssb-data">{{statisticData.batteryCount?statisticData.batteryCount:0}}台</view>
  47. </view>
  48. <view class="sssb-line"></view>
  49. <view class="sssb-item fflex">
  50. <view class="sssb-label">使用总次数</view>
  51. <view class="sssb-data">{{statisticData.useCount?statisticData.useCount:0}}次</view>
  52. </view>
  53. </view>
  54. <!-- <view class="sssb-box ddflex">
  55. <view class="sssb-item">
  56. <view class="sssb-label">已下发</view>
  57. <view class="sssb-data">509台</view>
  58. </view>
  59. <view class="sssb-line"></view>
  60. <view class="sssb-item">
  61. <view class="sssb-label">总收益</view>
  62. <view class="sssb-data sssb-color">92516元</view>
  63. </view>
  64. </view> -->
  65. </view>
  66. <!-- 图表统计 -->
  67. <view class="echart-box">
  68. <view class="echart-box-header ddflex">
  69. <view class="echart-box-title">我的运营情况</view>
  70. </view>
  71. <view class="sssb-box ddflex">
  72. <view class="sssb-item fflex">
  73. <view class="sssb-data sssb-color">{{statisticData.totalTurnover?statisticData.totalTurnover:0}}</view>
  74. <view class="sssb-label">营业总额</view>
  75. </view>
  76. <view class="sssb-line"></view>
  77. <view class="sssb-item fflex">
  78. <view class="sssb-data sssb-color">{{statisticData.totalRefund?statisticData.totalRefund:0}}</view>
  79. <view class="sssb-label">累计退款</view>
  80. </view>
  81. </view>
  82. <view class="sssb-box ddflex">
  83. <view class="sssb-item fflex">
  84. <view class="sssb-data sssb-color">{{statisticData.totalProfit?statisticData.totalProfit:0}}</view>
  85. <view class="sssb-label">收益总额</view>
  86. </view>
  87. <view class="sssb-line"></view>
  88. <view class="sssb-item fflex">
  89. <view class="sssb-data sssb-color">{{statisticData.useProfit?statisticData.useProfit:0}}</view>
  90. <view class="sssb-label">可分账金额</view>
  91. </view>
  92. </view>
  93. <view style="margin-top: 30rpx;height:500rpx">
  94. <view class="echart-title">近一周营业额度(元)图表数据</view>
  95. <l-echart ref="chart2" @finished="init"></l-echart>
  96. </view>
  97. <view style="margin-top: 30rpx;height:500rpx">
  98. <view class="echart-title">近一周收益额度(元)</view>
  99. <l-echart ref="chart3" @finished="init"></l-echart>
  100. </view>
  101. </view>
  102. </block>
  103. <!-- 商家营业额 -->
  104. <block v-if="queryType==2">
  105. <!-- 搜索 -->
  106. <view>
  107. <view class="search-box ddflex">
  108. <image class="search-icon" src="../../static/images/ssico.png"></image>
  109. <input class="fflex" v-model="searchValue" confirm-type="search" @confirm="searchFn" placeholder="请输入商家名称或电话"/>
  110. <view class="search-btn" @click="searchFn">搜索</view>
  111. </view>
  112. </view>
  113. <!-- 数据 -->
  114. <view>
  115. <view class="sjyy-item" v-for="item,index in groupList" :key="index">
  116. <view class="ddflex">
  117. <view class="sjyy-header">
  118. <image src="../../static/pages/images/wdsj.png"></image>
  119. </view>
  120. <view class="fflex">
  121. <view class="sjyy-name">{{item.name}}</view>
  122. <view class="sjyy-phone">{{item.phone}}</view>
  123. </view>
  124. <view class="sjyy-btn" @click="jumpUrl('/pages/operationDataPersonal/operationDataPersonal?merchantId='+item.id+'&totalTurnover='+item.totalTurnover+'&totalRefund='+item.totalRefund+'&totalProfit='+item.totalProfit+'&useProfit='+item.useProfit)">运营情况</view>
  125. </view>
  126. <view class="sjyy-data">
  127. <view class="ddflex">
  128. <view class="sjyy-data-item fflex">
  129. <view class="sssb-data sssb-color">{{item.totalTurnover?item.totalTurnover:0}}</view>
  130. <view class="sssb-label">营业总额</view>
  131. </view>
  132. <view class="sjyy-data-item fflex">
  133. <view class="sssb-data sssb-color">{{item.totalRefund?item.totalRefund:0}}</view>
  134. <view class="sssb-label">累计退款</view>
  135. </view>
  136. </view>
  137. <view class="ddflex" style="margin-top: 40rpx;">
  138. <view class="sjyy-data-item fflex">
  139. <view class="sssb-data sssb-color">{{item.totalProfit?item.totalProfit:0}}</view>
  140. <view class="sssb-label">收益总额</view>
  141. </view>
  142. <view class="sjyy-data-item fflex">
  143. <view class="sssb-data sssb-color">{{item.useProfit?item.useProfit:0}}</view>
  144. <view class="sssb-label">可分账金额</view>
  145. </view>
  146. </view>
  147. </view>
  148. </view>
  149. </view>
  150. </block>
  151. <!-- 门店营业额 -->
  152. <block v-if="queryType==3">
  153. <!-- 搜索 -->
  154. <view>
  155. <view class="search-box ddflex">
  156. <image class="search-icon" src="../../static/images/ssico.png"></image>
  157. <input class="fflex" v-model="searchValue" confirm-type="search" @confirm="searchFn" placeholder="请输入门店名称或电话"/>
  158. <view class="search-btn" @click="searchFn">搜索</view>
  159. </view>
  160. </view>
  161. <!-- 数据 -->
  162. <view>
  163. <view class="sjyy-item" v-for="item,index in groupList" :key="index">
  164. <view class="ddflex">
  165. <view class="sjyy-header">
  166. <image src="../../static/pages/images/wdmd.png"></image>
  167. </view>
  168. <view class="fflex">
  169. <view class="sjyy-name">{{item.name}}</view>
  170. <view class="sjyy-phone">{{item.linkman}}({{item.phone}})</view>
  171. </view>
  172. <view class="sjyy-btn"
  173. @click="jumpUrl('/pages/operationDataPersonal/operationDataPersonal?storeId='+item.id+'&totalTurnover='+item.totalTurnover+'&totalRefund='+item.totalRefund+'&totalProfit='+item.totalProfit+'&useProfit='+item.useProfit)">
  174. 运营情况</view>
  175. </view>
  176. <view class="sjyy-data ddflex" style="padding: 20rpx;">
  177. <image style="width: 26rpx;height: 26rpx;margin-right: 10rpx;" src="../../static/pages/images/address-icon.png"></image>
  178. <view class="tover fflex" style="font-size: 24rpx;line-height: 36rpx;color: #A8A5A5;">{{item.address}}</view>
  179. </view>
  180. <view class="sjyy-data">
  181. <view class="ddflex">
  182. <view class="sjyy-data-item fflex">
  183. <view class="sssb-data sssb-color">{{item.totalTurnover?item.totalTurnover:0}}</view>
  184. <view class="sssb-label">营业总额</view>
  185. </view>
  186. <view class="sjyy-data-item fflex">
  187. <view class="sssb-data sssb-color">{{item.totalRefund?item.totalRefund:0}}</view>
  188. <view class="sssb-label">累计退款</view>
  189. </view>
  190. </view>
  191. <view class="ddflex" style="margin-top: 40rpx;">
  192. <view class="sjyy-data-item fflex">
  193. <view class="sssb-data sssb-color">{{item.totalProfit?item.totalProfit:0}}</view>
  194. <view class="sssb-label">收益总额</view>
  195. </view>
  196. <view class="sjyy-data-item fflex">
  197. <view class="sssb-data sssb-color">{{item.useProfit?item.useProfit:0}}</view>
  198. <view class="sssb-label">可分账金额</view>
  199. </view>
  200. </view>
  201. </view>
  202. </view>
  203. </view>
  204. </block>
  205. </view>
  206. </template>
  207. <script>
  208. const app = getApp();
  209. const req = require("../../utils/request.js");
  210. import LEchart from '../../components/l-echart/l-echart.vue';
  211. import * as echarts from '../../utils/echarts.min.js'
  212. export default {
  213. components: {
  214. LEchart
  215. },
  216. props: {},
  217. data() {
  218. return {
  219. systems: {},
  220. isTop: 0,
  221. pxToRpxScale: 0,
  222. rpxTopxScale: 0,
  223. merchantId:null,
  224. storeId:null,
  225. queryType: 1,
  226. timeType: 1, //统计时间 1.按日 2.按月 3.按季度
  227. groupList: [],
  228. page: 1,
  229. limit: 10,
  230. searchValue:'',
  231. isQuerying:false,//正在查询数据
  232. echartData:{},//交易趋势图表
  233. statisticData:{},
  234. barEchartData:{},
  235. // 交易趋势图表数据
  236. option: {
  237. tooltip: {
  238. trigger: 'axis',
  239. axisPointer: {
  240. type: 'shadow'
  241. },
  242. confine: true
  243. },
  244. legend: {
  245. data: ['订单数', '订单金额','收益金额'],
  246. x: 'center', //可设定图例在左、右、居中
  247. y: 'top', //可设定图例在上、下、居中
  248. padding: [15, 0, 0, 0]
  249. },
  250. grid: {
  251. left: 0,
  252. right: 8,
  253. bottom: 5,
  254. top: 45,
  255. containLabel: true
  256. },
  257. xAxis: [{
  258. type: 'category',
  259. data: [],
  260. axisLine: {
  261. lineStyle: {
  262. color: '#999999'
  263. }
  264. },
  265. axisLabel: {
  266. color: '#666666',
  267. // interval: 0,
  268. }
  269. }],
  270. yAxis: [{
  271. type: 'value',
  272. axisTick: {
  273. show: false
  274. },
  275. axisLine: {
  276. lineStyle: {
  277. color: '#999999'
  278. }
  279. },
  280. axisLabel: {
  281. color: '#666666'
  282. }
  283. }],
  284. series: [{
  285. name: '订单数',
  286. type: 'line',
  287. data: [300, 270, 340, 344, 300, 320, 310],
  288. showSymbol: false,
  289. smooth: true,
  290. itemStyle: {
  291. // 颜色
  292. color: '#5F50E6',
  293. // 给bar设置倒角
  294. barBorderRadius: [15, 15, 0, 0]
  295. }
  296. },
  297. {
  298. name: '订单金额',
  299. type: 'line',
  300. data: [120, 102, 141, 174, 190, 250, 220],
  301. showSymbol: false,
  302. smooth: true,
  303. itemStyle: {
  304. // 颜色
  305. color: '#FF7D00',
  306. // 给bar设置倒角
  307. barBorderRadius: [15, 15, 0, 0]
  308. }
  309. },
  310. {
  311. name: '收益金额',
  312. type: 'line',
  313. data: [120, 102, 141, 174, 190, 250, 120],
  314. showSymbol: false,
  315. smooth: true,
  316. itemStyle: {
  317. // 颜色
  318. color: '#FFDC0F',
  319. // 给bar设置倒角
  320. barBorderRadius: [15, 15, 0, 0]
  321. }
  322. },
  323. ]
  324. },
  325. // 近一周营业额度(元)图表数据
  326. option2: {
  327. tooltip: {
  328. trigger: 'axis',
  329. axisPointer: {
  330. type: 'shadow'
  331. },
  332. confine: true
  333. },
  334. grid: {
  335. left: 0,
  336. right: 8,
  337. bottom: 20,
  338. top: 30,
  339. containLabel: true
  340. },
  341. xAxis: [{
  342. type: 'category',
  343. data: [],
  344. axisLine: {
  345. lineStyle: {
  346. color: '#999999'
  347. }
  348. },
  349. axisLabel: {
  350. color: '#666666',
  351. // interval: 0,
  352. }
  353. }],
  354. yAxis: [{
  355. type: 'value',
  356. axisTick: {
  357. show: false
  358. },
  359. axisLine: {
  360. lineStyle: {
  361. color: '#999999'
  362. }
  363. },
  364. axisLabel: {
  365. color: '#666666'
  366. }
  367. }],
  368. series: [{
  369. name: '订单',
  370. type: 'bar',
  371. label: {
  372. normal: {
  373. show: true,
  374. position: 'top',
  375. color: '#FF770F',
  376. formatter: (res)=>{
  377. if(res.value>0) return '¥'+res.value
  378. else return ''
  379. },
  380. },
  381. },
  382. data: [285, 200, 285, 300, 285, 285, 320],
  383. barWidth: 15,
  384. itemStyle: {
  385. // 颜色
  386. color: '#FF770F',
  387. // 给bar设置倒角
  388. barBorderRadius: [0, 0, 0, 0]
  389. }
  390. }]
  391. },
  392. // 近一周收益额度(元)
  393. option3: {
  394. tooltip: {
  395. trigger: 'axis',
  396. axisPointer: {
  397. type: 'shadow'
  398. },
  399. confine: true
  400. },
  401. grid: {
  402. left: 0,
  403. right: 8,
  404. bottom: 20,
  405. top: 30,
  406. containLabel: true
  407. },
  408. xAxis: [{
  409. type: 'category',
  410. data: [],
  411. axisLine: {
  412. lineStyle: {
  413. color: '#999999'
  414. }
  415. },
  416. axisLabel: {
  417. color: '#666666',
  418. // interval: 0,
  419. }
  420. }],
  421. yAxis: [{
  422. type: 'value',
  423. axisTick: {
  424. show: false
  425. },
  426. axisLine: {
  427. lineStyle: {
  428. color: '#999999'
  429. }
  430. },
  431. axisLabel: {
  432. color: '#666666'
  433. }
  434. }],
  435. series: [{
  436. name: '订单',
  437. type: 'bar',
  438. label: {
  439. normal: {
  440. show: true,
  441. position: 'top',
  442. color: '#FF770F',
  443. formatter: (res)=>{
  444. if(res.value>0) return '¥'+res.value
  445. else return ''
  446. },
  447. },
  448. },
  449. data: [285, 200, 285, 300, 285, 285, 320],
  450. barWidth: 15,
  451. itemStyle: {
  452. // 颜色
  453. color: '#FF770F',
  454. // 给bar设置倒角
  455. barBorderRadius: [0, 0, 0, 0]
  456. }
  457. }]
  458. }
  459. }
  460. },
  461. onLoad(options) {
  462. this.getStatisticData()
  463. },
  464. onShow() {
  465. },
  466. methods: {
  467. jumpUrl(url) {
  468. if (req.isLogins(true)) {
  469. uni.navigateTo({
  470. url: url
  471. })
  472. }
  473. },
  474. queryTypeChange(val) {
  475. if (this.queryType == val) return false
  476. this.queryType = val
  477. if(this.queryType==1){
  478. this.getStatisticData()
  479. }
  480. if(this.queryType==2||this.queryType==3){
  481. this.getDataList()
  482. this.searchValue = ''
  483. }
  484. },
  485. // 统计时间切换
  486. timeTypeChange(val) {
  487. if (this.timeType == val) return false
  488. this.timeType = val
  489. this.getStatisticData()
  490. },
  491. init() {
  492. this.$refs.chart.init(echarts, async chart => {
  493. // let echartData = await this.getEchartData()
  494. this.option.legend.itemHeight = 10 * this.rpxTopxScale
  495. this.option.legend.itemWidth = 40 * this.rpxTopxScale
  496. this.option.xAxis[0].data = this.echartData.orderList.map(item=>{return item.showTime})
  497. this.option.series[0].data = this.echartData.orderList.map(item=>{return item.orderCount})
  498. this.option.series[1].data = this.echartData.profitList.map(item=>{return item.profit})
  499. this.option.series[2].data = this.echartData.turnoverList.map(item=>{return item.turnover})
  500. chart.setOption(this.option);
  501. });
  502. if (this.$refs.chart2) {
  503. this.$refs.chart2.init(echarts, async chart => {
  504. // let echartData = await this.getEchartData()
  505. this.option2.xAxis[0].data = this.echartData.orderList.map(item=>{return item.showTime})
  506. this.option2.yAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
  507. this.option2.xAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
  508. this.option2.series[0].data = this.echartData.orderList.map(item=>{return item.orderCount})
  509. this.option2.series[0].label.normal.fontSize = 13 * this.rpxTopxScale
  510. chart.setOption(this.option2);
  511. });
  512. }
  513. if (this.$refs.chart3) {
  514. this.$refs.chart3.init(echarts, async chart => {
  515. // let echartData = await this.getEchartData()
  516. this.option3.xAxis[0].data = this.echartData.profitList.map(item=>{return item.showTime})
  517. this.option3.yAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
  518. this.option3.xAxis[0].axisLabel.fontSize = 13 * this.rpxTopxScale
  519. this.option3.series[0].data = this.echartData.profitList.map(item=>{return item.profit})
  520. this.option3.series[0].label.normal.fontSize = 13 * this.rpxTopxScale
  521. chart.setOption(this.option3);
  522. });
  523. }
  524. },
  525. getDataList(isPage) {
  526. if(this.isQuerying) return
  527. else this.isQuerying = true
  528. if (!isPage) {
  529. this.page = 1
  530. }
  531. let queryParams = {
  532. page: this.page,
  533. limit: this.limit,
  534. }
  535. if(this.searchValue){
  536. queryParams.name=this.searchValue
  537. }
  538. let api = '/admin/v2/merchant/pageDate'
  539. if(this.queryType==2){
  540. api = '/admin/v2/merchant/pageDate'
  541. }
  542. if(this.queryType==3){
  543. api = '/admin/v2/store/pageData'
  544. }
  545. req.getRequest(
  546. api,
  547. queryParams,
  548. data => {
  549. if (data != null && data.list.length > 0) {
  550. if (!isPage) {
  551. this.groupList = data.list
  552. } else {
  553. this.groupList = this.groupList.concat(data.list)
  554. }
  555. this.page++
  556. } else {
  557. if (!isPage)
  558. this.groupList = data.list
  559. else {}
  560. }
  561. uni.hideLoading()
  562. this.isQuerying = false
  563. }
  564. )
  565. },
  566. searchFn(){
  567. this.getDataList()
  568. },
  569. // 获取运营数据-交易趋势
  570. async getStatisticData(){
  571. await this.getEchartData()
  572. await this.getTopData()
  573. await this.getBarEchartData()
  574. this.init()
  575. },
  576. getEchartData() {
  577. return new Promise((r, j) => {
  578. req.getRequest('/admin/v2/statistic/chart', {type: this.timeType}, res => {
  579. this.echartData = res
  580. console.log('statistic chart', res)
  581. r(res)
  582. })
  583. })
  584. },
  585. // 获取统计数据
  586. getTopData() {
  587. return new Promise((r, j) => {
  588. req.getRequest('/admin/v2/statistic/top', {}, res => {
  589. console.log('statistic top', res)
  590. this.statisticData = res
  591. r(res)
  592. })
  593. })
  594. },
  595. getBarEchartData() {
  596. return new Promise((r, j) => {
  597. let merchantId = this.merchantId?this.merchantId:req.getStorage('userInfo').merchantId?req.getStorage('userInfo').merchantId:''
  598. let storeId = this.storeId?this.storeId:req.getStorage('userInfo').storeId?req.getStorage('userInfo').storeId:''
  599. let pData = {
  600. merchantId:merchantId,
  601. storeId:storeId
  602. }
  603. req.getRequest('/admin/v2/statistic/histogram', pData, res => {
  604. this.barEchartData = res
  605. console.log('statistic chart', res)
  606. r(res)
  607. })
  608. })
  609. },
  610. },
  611. mounted() {
  612. const systemInfo = uni.getSystemInfoSync();
  613. // px转换到rpx的比例
  614. let pxToRpxScale = 750 / systemInfo.windowWidth;
  615. this.pxToRpxScale = pxToRpxScale
  616. this.rpxTopxScale = systemInfo.windowWidth / 750
  617. let systems = {
  618. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  619. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  620. };
  621. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  622. this.systems = systems;
  623. },
  624. onPageScroll: function(e) {
  625. if (e.scrollTop > this.systems.barHeight) {
  626. this.isTop = 1;
  627. } else {
  628. this.isTop = 0;
  629. }
  630. }
  631. }
  632. </script>
  633. <style>
  634. @import "./operationData.css";
  635. </style>