index.vue 18 KB

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