index.vue 17 KB

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