| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677 |
- <template>
- <view>
- <!-- 背景图 -->
- <view class="index-bg">
- <image src="../../static/pages/images/self/indexBg.png"></image>
- </view>
- <!-- 数据 -->
- <view class="data-box">
- <view>
- <view class="ljsy">{{statisticData.totalProfit?statisticData.totalProfit:0}}</view>
- <view class="ljsy-label">累计收益(元)</view>
- </view>
- <view class="jy ddflex">
- <view>
- <view class="jy-data">{{statisticData.todayOrderCount?statisticData.todayOrderCount:0}}</view>
- <view class="jy-label">今日订单数</view>
- </view>
- <view class="jy-line"></view>
- <view>
- <view class="jy-data"><text style="font-size: 22rpx;font-weight: 400;">¥</text>{{statisticData.todayTurnover?statisticData.todayTurnover:0}}</view>
- <view class="jy-label">今日营业额</view>
- </view>
- <view class="jy-line"></view>
- <view>
- <view class="jy-data"><text style="font-size: 22rpx;font-weight: 400;">¥</text>{{statisticData.todayProfit?statisticData.todayProfit:0}}</view>
- <view class="jy-label">今日收益额</view>
- </view>
- </view>
- </view>
- <!-- 总数 -->
- <view class="total-box ddflex">
- <view class="fflex" v-if="!userInfo.storeId">
- <view class="total-label">商家总数</view>
- <view class="total-data">{{statisticData.merchantCount?statisticData.merchantCount:0}}</view>
- </view>
- <view v-if="!userInfo.storeId" class="total-data-line"></view>
- <view class="fflex" v-if="!userInfo.storeId">
- <view class="total-label">门店总数</view>
- <view class="total-data">{{statisticData.storeCount?statisticData.storeCount:0}}</view>
- </view>
- <view v-if="!userInfo.storeId" class="total-data-line"></view>
- <view class="fflex">
- <view class="total-label">设备总数</view>
- <view class="total-data">{{statisticData.batteryCount?statisticData.batteryCount:0}}</view>
- </view>
- <view class="total-data-line"></view>
- <view class="fflex">
- <view class="total-label">订单总数</view>
- <view class="total-data">{{statisticData.totalOrderCount?statisticData.totalOrderCount:0}}</view>
- </view>
- </view>
- <!-- nav -->
- <view v-if="!userInfo.storeId" class="nav-box ddflex">
- <view class="nav-item">
- <image class="nav-item-icon" src="../../static/pages/images/wdsj.png" @click="jumpUrl('/pages/myStore/myStore')"></image>
- <view class="nav-item-title">我的商家</view>
- </view>
- <view class="nav-item" @click="jumpUrl('/pages/myMerchant/myMerchant')">
- <image class="nav-item-icon" src="../../static/pages/images/wdmd.png"></image>
- <view class="nav-item-title">我的门店</view>
- </view>
- <view class="nav-item" v-if="!userInfo.storeId&&!userInfo.merchantId" @click="jumpUrl('/mine/myUser/myUser')">
- <image class="nav-item-icon" src="../../static/pages/images/wdyh.png"></image>
- <view class="nav-item-title">我的用户</view>
- </view>
- <view class="nav-item" @click="jumpUrl('/pages/operationData/operationData')">
- <image class="nav-item-icon" src="../../static/pages/images/yysj.png"></image>
- <view class="nav-item-title">运营数据</view>
- </view>
- </view>
-
- <view v-if="userInfo.storeId" class="nav-box ddflex" style="padding: 10rpx 30rpx;justify-content: space-between;" @click="jumpUrl('/pages/operationData/operationData')">
- <view class="nav-item ddflex">
- <image class="nav-item-icon" src="../../static/pages/images/yysj.png"></image>
- <view class="nav-item-title">运营数据</view>
- </view>
- <image style="width: 36rpx;height:36rpx;" src="../../static/pages/images/ssicon.png"></image>
- </view>
- <!-- 图表统计 -->
- <view class="echart-box">
- <view class="echart-box-header ddflex">
- <view class="echart-box-title">交易趋势</view>
- <view class="echart-box-timeType ddflex">
- <view :class="'echart-box-timeType-item '+(timeType==1?'echart-box-timeType-item-acitve':'')"
- @click="timeTypeChange(1)">今日</view>
- <view :class="'echart-box-timeType-item '+(timeType==2?'echart-box-timeType-item-acitve':'')"
- @click="timeTypeChange(2)">近7日</view>
- <view :class="'echart-box-timeType-item '+(timeType==3?'echart-box-timeType-item-acitve':'')"
- @click="timeTypeChange(3)">近30日</view>
- </view>
- </view>
- <view style="height:500rpx">
- <l-echart ref="chart" @finished="init"></l-echart>
- </view>
- </view>
- <!-- 图表统计 -->
- <view class="echart-box">
- <view class="echart-box-header ddflex">
- <view class="echart-box-title">商家营业额排名</view>
- </view>
- <view>
- <l-echart ref="chart2" @finished="init"></l-echart>
- </view>
- </view>
- <!-- 图表统计 -->
- <view class="echart-box">
- <view class="echart-box-header ddflex">
- <view class="echart-box-title">设备状态</view>
- </view>
- <view class="ddflex">
- <view class="fflex" style="height: 250rpx;">
- <l-echart ref="chart4" @finished="init"></l-echart>
- </view>
- <view class="fflex" style="height: 250rpx;">
- <l-echart ref="chart5" @finished="init"></l-echart>
- </view>
- <view class="fflex" style="height: 250rpx;">
- <l-echart ref="chart6" @finished="init"></l-echart>
- </view>
- </view>
- <view class="echart-line"></view>
- <view class="ddflex">
- <view style="width: 100%;height: 300rpx;">
- <l-echart ref="chart3" @finished="init"></l-echart>
- </view>
- </view>
- </view>
- <view class="guide" @tap="hideGuide" v-if="first">
- <image src="/static/pages/images/guide.png" mode="widthFix"></image>
- </view>
- <foot channel="home" :isUpdate="isUpdate"></foot>
- </view>
- </template>
- <script>
- //index.js
- //获取应用实例
- const app = getApp();
- const req = require('../../utils/request.js');
- const api = require('../../utils/api.js');
- const utils = require('../../utils/util.js');
- const mes = require('../../utils/requestmessage.js');
- const route = require('../../utils/route');
- const QQMapWX = require("../../utils/qqmap.js");
- import foot from '../../components/nav-bar/index';
- import footerCopyright from '../../components/footer-copyright/footer-copyright';
- import LEchart from '../../components/l-echart/l-echart.vue';
- import * as echarts from '../../utils/echarts.min.js'
- export default {
- data() {
- return {
- systems: {},
- bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
- pxToRpxScale: 0,
- rpxTopxScale: 0,
- timeType: 1, //统计时间 1.按日 2.按月 3.按季度
-
- statisticData:{},//统计数据
- echartData:{},//曲线图
-
- userInfo:{},
- // 交易趋势图表数据
- option: {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- },
- confine: true
- },
- legend: {
- data: ['订单数', '订单金额','收益金额'],
- x: 'center', //可设定图例在左、右、居中
- y: 'top', //可设定图例在上、下、居中
- padding: [15, 0, 0, 0]
- },
- grid: {
- left: 0,
- right: 8,
- bottom: 5,
- top: 45,
- containLabel: true
- },
- xAxis: [{
- type: 'category',
- data: [],
- axisLine: {
- lineStyle: {
- color: '#999999'
- }
- },
- axisLabel: {
- color: '#666666',
- // interval: 0,
- }
- }],
- yAxis: [{
- type: 'value',
- axisTick: {
- show: false
- },
- axisLine: {
- lineStyle: {
- color: '#999999'
- }
- },
- axisLabel: {
- color: '#666666'
- }
- }],
- series: [{
- name: '订单数',
- type: 'line',
- data: [300, 270, 340, 344, 300, 320, 310],
- barWidth: 10,
- itemStyle: {
- // 颜色
- color: '#5F50E6',
- // 给bar设置倒角
- barBorderRadius: [15, 15, 0, 0]
- }
- },
- {
- name: '订单金额',
- type: 'line',
- data: [120, 102, 141, 174, 190, 250, 220],
- barWidth: 10,
- itemStyle: {
- // 颜色
- color: '#FF7D00',
- // 给bar设置倒角
- barBorderRadius: [15, 15, 0, 0]
- }
- },
- {
- name: '收益金额',
- type: 'line',
- data: [120, 102, 141, 174, 190, 250, 120],
- barWidth: 10,
- itemStyle: {
- // 颜色
- color: '#FFDC0F',
- // 给bar设置倒角
- barBorderRadius: [15, 15, 0, 0]
- }
- },
- ]
- },
- // 商家营业额排名
- option2: {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- },
- confine: true
- },
- grid: {
- left: 0,
- right: 20,
- bottom: 40,
- top: 40,
- containLabel: true
- },
- xAxis: [{
- type: 'value',
- // data: [],
- axisLine: {
- lineStyle: {
- color: '#999999'
- }
- },
- axisLabel: {
- color: '#666666',
- // interval: 0,
- }
- }],
- yAxis: [{
- type: 'category',
- axisTick: {
- show: false
- },
- data: [],
- axisLine: {
- lineStyle: {
- color: '#999999'
- }
- },
- axisLabel: {
- color: '#666666',
- // inside:true,
- padding: [0, 0, 0, 0]
- }
- }],
- series: [{
- name: '订单',
- type: 'bar',
- label: {
- normal: {
- show: true,
- position: 'right',
- color: '#4c4a4a',
- formatter:'¥{c}',
- },
- },
- data: [300, 270, 340, 344, 300, 320, 310],
- barWidth: 5,
- itemStyle: {
- // 颜色
- color: '#FF770F',
- // 给bar设置倒角
- barBorderRadius: [0, 15, 15, 0]
- }
- }]
- },
- // 设备状态
- option3: {
- title: {
- text: '设备出租比例',
- textStyle: {
- fontSize: 14
- },
- left: '70%',
- top: '30%'
- },
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- },
- confine: true
- },
- legend: {
- data: ['已租', '未租'],
- x: 'right', //可设定图例在左、右、居中
- y: '50%', //可设定图例在上、下、居中
- itemHeight:5,
- itemWidth:20
- },
- grid: {
- left: 0,
- containLabel: true
- },
- series: [{
- name: '设备出租比例',
- type: 'pie',
- center: ['30%', '50%'],
- radius: ['60%', '80%'],
- label: {
- show: false
- },
- data: [{
- value: 1055,
- name: '未租',
- itemStyle: {
- color: "#FF770F"
- }
- },
- {
- value: 735,
- name: '已租',
- itemStyle: {
- color: "#EAECF5"
- }
- }
- ]
- }]
- },
- // 已租设备
- option4: {
- title: {
- text: '已租设备',
- textStyle: {
- fontSize: 14,
- fontWeight: 500
- },
- left: 'center',
- bottom: '0'
- },
- series: [{
- type: 'pie',
- radius: ['60%', '70%'],
- label: {
- normal: {
- show: true,
- position: 'center',
- color: '#4c4a4a',
- formatter:'{c}',
- },
- emphasis: { //中间文字显示
- show: true,
- textStyle:{
-
- }
- }
- },
- data: [{
- value: 1055,
- name: '已租',
- itemStyle: {
- color: "#0FCB27"
- }
- },
- {
- value: 735,
- name: '未租',
- itemStyle: {
- color: "#EAECF5"
- }
- }
- ]
- }]
- },
- // 未租设备
- option5: {
- title: {
- text: '未租设备',
- textStyle: {
- fontSize: 14,
- fontWeight: 500
- },
- left: 'center',
- bottom: '0'
- },
- series: [{
- type: 'pie',
- center: ['50%', '50%'],
- radius: ['60%', '70%'],
- label: {
- normal: {
- show: true,
- position: 'center',
- color: '#4c4a4a',
- formatter:'{c}',
- },
- emphasis: { //中间文字显示
- show: true,
- textStyle:{
-
- }
- }
- },
- data: [{
- value: 1055,
- name: '未租设备',
- itemStyle: {
- color: "#666464"
- }
- },
- {
- value: 735,
- name: '已租设备',
- itemStyle: {
- color: "#EAECF5"
- }
- }
- ]
- }]
- },
- // 到期设备
- option6: {
- title: {
- text: '到期设备',
- textStyle: {
- fontSize: 14,
- fontWeight: 500
- },
- left: 'center',
- bottom: '0'
- },
- series: [{
- type: 'pie',
- center: ['50%', '50%'],
- radius: ['60%', '70%'],
- label: {
- normal: {
- show: true,
- position: 'center',
- color: '#4c4a4a',
- formatter:'{c}',
- },
- emphasis: { //中间文字显示
- show: true,
- textStyle:{
-
- }
- }
- },
- data: [{
- value: 1055,
- name: '到期',
- itemStyle: {
- color: "#FF770F"
- }
- },
- {
- value: 735,
- name: '未到期',
- itemStyle: {
- color: "#EAECF5"
- }
- }
- ]
- }]
- },
- };
- },
- components: {
- foot,
- footerCopyright,
- LEchart
- },
- props: {},
- onLoad: async function(options) {
- QQMapWX.initMap();
- req.getLocation(res => {
- const to = {
- latitude: res.latitude,
- longitude: res.longitude
- };
- QQMapWX.reverseGeocoder(to, resp => {});
- });
- },
- async onShow() {
- await this.getEchartData()
- await this.getStatisticData()
-
- this.init()
-
- this.getUserInfo()
- },
- onUnload() {},
- onHide() {},
- onReachBottom() {},
- methods: {
- jumpUrl(url){
- if(req.isLogins(true)){
- uni.navigateTo({
- url:url
- })
- }
- },
- // 统计时间切换
- async timeTypeChange(val) {
- if (this.timeType == val) return false
- this.timeType = val
- await this.getEchartData()
- // await this.getStatisticData()
-
- this.init()
- },
- init() {
- this.$refs.chart.init(echarts, async chart => {
- // let echartData = await this.getEchartData()
- this.option.legend.itemHeight = 10 * this.rpxTopxScale
- this.option.legend.itemWidth = 40 * this.rpxTopxScale
- this.option.xAxis[0].data = this.echartData.orderList.map(item=>{return item.showTime})
- this.option.series[0].data = this.echartData.orderList.map(item=>{return item.orderCount})
- this.option.series[1].data = this.echartData.profitList.map(item=>{return item.profit})
- this.option.series[2].data = this.echartData.turnoverList.map(item=>{return item.turnover})
- chart.setOption(this.option);
- });
- if (this.$refs.chart2) {
- this.$refs.chart2.init(echarts, async chart => {
- // let echartData = await this.getEchartData()
- this.option2.yAxis[0].data = ['罗技', '刘涛', '陈楚生', '罗巧红', '李冰冰']
- this.option2.series[0].data = [8125, 6802, 5622, 4588, 2458]
- chart.setOption(this.option2);
- });
- }
- if (this.$refs.chart3) {
- this.$refs.chart3.init(echarts, async chart => {
- this.option3.title.textStyle.fontSize = 28 * this.rpxTopxScale
- this.option3.legend.itemHeight = 10 * this.rpxTopxScale
- this.option3.legend.itemWidth = 40 * this.rpxTopxScale
- this.option3.series[0].data[0].value = this.statisticData.noLeaseCount
- this.option3.series[0].data[1].value = this.statisticData.leaseCount
- chart.setOption(this.option3);
- });
- }
- if (this.$refs.chart4) {
- this.$refs.chart4.init(echarts, async chart => {
- this.option4.title.textStyle.fontSize = 24 * this.rpxTopxScale
- this.option4.series[0].data[0].value = this.statisticData.leaseCount
- this.option4.series[0].data[1].value = this.statisticData.noLeaseCount
- this.option4.series[0].label.normal.formatter = ()=>{return this.statisticData.leaseCount}
- chart.setOption(this.option4);
- });
- }
- if (this.$refs.chart5) {
- this.$refs.chart5.init(echarts, async chart => {
- this.option5.title.textStyle.fontSize = 24 * this.rpxTopxScale
- this.option5.series[0].data[0].value = this.statisticData.noLeaseCount
- this.option5.series[0].data[1].value = this.statisticData.leaseCount
- this.option4.series[0].label.normal.formatter = ()=>{return this.statisticData.noLeaseCount}
- chart.setOption(this.option5);
- });
- }
- if (this.$refs.chart6) {
- this.$refs.chart6.init(echarts, async chart => {
- this.option6.title.textStyle.fontSize = 24 * this.rpxTopxScale
- this.option6.series[0].data[0].value = this.statisticData.expireCount
- this.option6.series[0].data[1].value =Number(this.statisticData.batteryCount) - Number(this.statisticData.leaseCount)
- this.option6.series[0].label.normal.formatter = ()=>{return this.statisticData.expireCount}
- chart.setOption(this.option6);
- });
- }
- },
- // 获取图表数据
- getEchartData() {
- return new Promise((r, j) => {
- req.getRequest('/admin/v2/statistic/chart', {type: this.timeType}, res => {
- this.echartData = res
- console.log('statistic chart', res)
- r(res)
- })
- })
- },
- // 获取图表数据
- getStatisticData() {
- return new Promise((r, j) => {
- req.getRequest('/admin/v2/statistic/top', {}, res => {
- console.log('statistic top', res)
- this.statisticData = res
- r(res)
- })
- })
- },
- // 获取当前用户
- getUserInfo(){
- req.getRequest('/admin/v2/userInfo',{},res=>{
- this.userInfo = res
- })
- }
- },
- mounted() {
- const systemInfo = uni.getSystemInfoSync();
- // px转换到rpx的比例
- let pxToRpxScale = 750 / systemInfo.windowWidth;
- this.pxToRpxScale = pxToRpxScale
- this.rpxTopxScale = systemInfo.windowWidth / 750
- let systems = {
- ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
- navigationHeight: 44 * pxToRpxScale // 导航栏的高度
- };
- systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
- this.systems = systems;
- }
- };
- </script>
- <style>
- @import './index.css';
- </style>
|