index.vue 18 KB

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