index.vue 18 KB

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