<template> <view class="page"> <u-navbar :is-back="false" title="首页" :border-bottom="false" :background="bgc" title-color='#2E4975' title-size='36' height='45'></u-navbar> <view class="info_box"> <view class="tit"> 运营概览 </view> <!-- <view class="data_box"> <view class="data1"> 近7天 </view> <view class="data1"> 2024-09-05 <view class="iconfont icon-xiangxia1"></view> </view> <view class="data1"> 近30天 </view> </view> --> <view class="top_box"> <view class="left_text"> 时间范围 </view> <view class="timebox"> <view class="left_time" @click="time1=true"> {{firsTime}} </view> - <view class="right_time" @click="time2=true"> {{lasTime}} </view> </view> </view> <view class="tit_box" > <view class="tit_line"></view> 经营概况 </view> <view class="echarts"> <uni-ec-canvas class="uni-ec-canvas" id="uni-ec-canvas" ref="canvas1" canvas-id="uni-ec-canvas" :ec="ec"> </uni-ec-canvas> </view> <view class="log_box"> <view class="log_li"> <image src="https://lxnapi.ccttiot.com/bike/img/static/uLJmp6DVyyoeGsIIh7IJ" mode=""></image> 订单营收 </view> <view class="log_li"> <image src="https://lxnapi.ccttiot.com/bike/img/static/u5m5JeBXwVdNB4LWB3Nr" mode=""></image> 订单数量 </view> </view> <view class="info_boxs"> <view class="info_li"> <view class="tit"> 1359.00 </view> <view class="txt"> 今日订单营收(元) </view> <view class="txt"> 较昨日 <span>500.00</span> <image src="https://lxnapi.ccttiot.com/bike/img/static/uL4sBdN3Pbvn5tQvhwtk" mode=""></image> </view> </view> <view class="info_li"> <view class="tit"> 1359.00 </view> <view class="txt"> 今日订单数(单) </view> <view class="txt"> 较昨日 <span>40</span> <image src="https://lxnapi.ccttiot.com/bike/img/static/ugghyGkhTlc3xr0nle2a" mode=""></image> </view> </view> </view> </view> <view class="tits" v-if="AccountInfo.userType==02"> 车辆统计 </view> <view class="info_cont"> <view class="li"> <view class="top"> 车辆总数 </view> <view class="bot"> 390 </view> </view> <view class="line"></view> <view class="li"> <view class="top"> 车辆总数 </view> <view class="bot"> 390 </view> </view> <view class="line"></view> <view class="li"> <view class="top"> 车辆总数 </view> <view class="bot"> 390 </view> </view> </view> <view class="tits"> 更多功能 </view> <view class="feature" v-if="AccountInfo.userType==03"> <image src="https://lxnapi.ccttiot.com/bike/img/static/u3J6GbXvEvdTtebETjfH" mode="" @click="topage(0)"></image> <image src="https://lxnapi.ccttiot.com/bike/img/static/uahBs1ruuAha5PHiiTp9" mode="" @click="topage(1)"></image> <image src="https://lxnapi.ccttiot.com/bike/img/static/u5yEuqhkS7785kZRiQqC" mode="" @click="topage(2)"></image> </view> <view class="feature" v-if="AccountInfo.userType==02"> <image src="https://lxnapi.ccttiot.com/bike/img/static/u3J6GbXvEvdTtebETjfH" mode="" @click="topages(0)"></image> <image src="https://lxnapi.ccttiot.com/bike/img/static/ufE1T9RDOm7OmhLgTzXi" mode="" @click="topages(1)"></image> <image src="https://lxnapi.ccttiot.com/bike/img/static/u5yEuqhkS7785kZRiQqC" mode="" @click="topages(2)"></image> </view> <u-picker mode="time" v-model="time1" :params="params" @confirm="confirm1" :default-time='pickertime'></u-picker> <u-picker mode="time" v-model="time2" :params="params" @confirm="confirm2" :default-time='pickertime'></u-picker> <tab-bar :indexs='0' style=""></tab-bar> </view> </template> <script> const app = getApp(); var xBlufi = require("@/utils/blufi/xBlufi.js"); let _this = null; import uniEcCanvas from '@/components/uni-ec-canvas/uni-ec-canvas.vue' import * as echarts from '@/components/uni-ec-canvas/echarts' let chart = null export default { components: { uniEcCanvas }, data() { return { bgc: { backgroundColor: "#F7FAFE", }, ec: { lazyLoad: true }, chartday: [], // 保存日期的数组 chartData1: [], // 保存温度数据的数组 chartData2: [120, 90, 150, 80, 130, 110, 160], info:{}, AccountInfo:{}, time1: false, time2: false, lasTime: '', firsTime: '', params: { year: true, month: true, day: true, hour: false, minute: false, second: false }, } }, onLoad() { this.generateMockData() }, computed: { }, onShow() { this.$refs.canvas1.init(this.initChart) this.getIndexInfo() this.getAccountInfo() }, watch: { }, methods: { topages(num ){ if(this.AccountInfo.userId){ if(num==0){ uni.navigateTo({ url:'/page_Operator/deviceMgmt' }) }else if(num==1){ uni.navigateTo({ url:'/page_Operator/CarModel' }) }else if(num==2){ uni.navigateTo({ url:'/page_Operator/order' }) } }else{ uni.navigateTo({ url:'/pages/login/login' }) } }, callPhone(phone) { uni.makePhoneCall({ phoneNumber: phone }) }, getAccountInfo(){ this.$u.get(`appAdmin/myAccountInfo`).then((res) => { if (res.code === 200) { this.AccountInfo=res.data if(this.AccountInfo.userType=='04'){ uni.redirectTo({ url:'/page_Delivery/orerList' }) } } else { uni.showToast({ title: res.msg, icon: 'none', duration: 2000 }); } }); }, topage(num){ if(num==0){ uni.navigateTo({ url:'/page_Merchant/deviceMgmt' }) }else if(num==1){ uni.navigateTo({ url:'/page_Merchant/StoreManagement' }) }else if(num==2){ uni.navigateTo({ url:'/page_Merchant/order' }) } }, confirm1(e) { console.log(e, 'eeeeeeee'); this.firsTime = e.year + '-' + e.month + '-' + e.day if (this.firsTime != '' && this.lasTime != '') { this.getIndexInfo() } }, confirm2(e) { this.lasTime = e.year + '-' + e.month + '-' + e.day // this.pageNum=1 if (this.firsTime != '' && this.lasTime != '') { this.getIndexInfo() } }, getIndexInfo(){ this.$u.get(`appAdmin/index`).then((res) => { if (res.code === 200) { this.info=res.data } else { uni.showToast({ title: res.msg, icon: 'none', duration: 2000 }); } }); }, generateMockData() { // 生成 7 天的日期 let days = 7 let today = new Date() for (let i = 0; i < days; i++) { let day = new Date(today) day.setDate(today.getDate() - (days - i - 1)) let month = day.getMonth() + 1 let date = day.getDate() this.chartday.push(`${month}-${date}`) // 生成随机温度数据,假设范围为20℃到35℃ let temp = (Math.random() * 15 + 20).toFixed(2) this.chartData1.push(temp) } }, initChart(canvas, width, height, canvasDpr) { let that = this const option = { grid: { left: '4%', right: '4%', bottom: '3%', top: '4%', containLabel: true }, xAxis: { show: true, type: 'category', boundaryGap: false, axisLine: { show: false // 隐藏X轴线 }, axisTick: { show: false // 隐藏X轴刻度 }, axisLabel: { show: true, color: '#999', // 调整为浅灰色 fontSize: 12, rotate: 0, }, splitLine: { show: false, }, data: that.chartday, }, yAxis: [{ show: true, type: 'value', axisLine: { show: false, // 隐藏Y轴线 }, axisTick: { show: false, // 隐藏Y轴刻度 }, axisLabel: { show: true, color: '#999', // 调整为浅灰色 fontSize: 12, }, splitLine: { show: true, // 显示网格线 lineStyle: { type: 'dashed', // 设置为虚线 color: '#ccc', // 虚线颜色 width: 1 } } }, { show: true, type: 'value', position: 'right', // 右侧Y轴 axisLine: { show: false, // 隐藏Y轴线 }, axisTick: { show: false, // 隐藏Y轴刻度 }, axisLabel: { show: true, color: '#999', // 调整为浅灰色 fontSize: 12, }, splitLine: { show: false, // 不显示网格线 } } ], series: [{ name: '近7日订单营收', type: 'line', smooth: true, symbol: 'none', // 取消圆形标志 symbolSize: 8, // 圆形标志大小 itemStyle: { color: '#8E6BF9', // 圆形标志颜色 borderColor: '#fff', borderWidth: 2 }, lineStyle: { color: '#8E6BF9', // 线条颜色 width: 3, // 线条宽度 }, areaStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgba(142, 107, 249, 0.3)' }, // 顶部颜色 { offset: 1, color: 'rgba(142, 107, 249, 0)' } // 底部颜色 ]) } }, data: that.chartData1, // 订单营收数据 }, { name: '近7日订单单数', type: 'line', smooth: true, yAxisIndex: 1, // 使用右侧Y轴 symbol: 'none', // 取消圆形标志 symbolSize: 8, // 圆形标志大小 itemStyle: { color: '#67B8FF', // 圆形标志颜色 borderColor: '#fff', borderWidth: 2 }, lineStyle: { color: '#67B8FF', // 线条颜色 width: 3, // 线条宽度 }, areaStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgba(103, 184, 255, 0.3)' }, // 顶部颜色 { offset: 1, color: 'rgba(103, 184, 255, 0)' } // 底部颜色 ]) } }, data: that.chartData2, // 订单单数数据 } ], }; chart = echarts.init(canvas, null, { width: width, height: height, devicePixelRatio: canvasDpr }); canvas.setChart(chart); chart.setOption(option); return chart; } } } </script> <style lang="scss"> page { background: #F7FAFE; } .page { width: 100%; padding-bottom: 200rpx; .info_cont{ display: flex; flex-wrap: nowrap; align-items: center; justify-content: space-around; margin: 0 auto; margin-top: 18rpx; width: 680rpx; // height: 172rpx; padding: 40rpx 0rpx; background: #FFFFFF; box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(42,130,228,0.1); border-radius: 24rpx 24rpx 24rpx 24rpx; .li{ width: 110rpx; display: flex; flex-wrap: wrap; justify-content: center; .top{ font-weight: 400; font-size: 24rpx; color: #3D3D3D; } .bot{ font-weight: 600; font-size: 40rpx; color: #3D3D3D; } } .line{ width: 2rpx; height: 74rpx; background: #C7C7C7; border-radius: 0rpx 0rpx 0rpx 0rpx; } } .feature{ margin: 0 auto; margin-top: 24rpx; width: 658rpx; padding: 30rpx 40rpx; background: #FFFFFF; border-radius: 24rpx 24rpx 24rpx 24rpx; image{ margin-right: 66rpx; width: 96rpx; height: 98rpx; } } .tits{ margin-top: 40rpx; margin-left: 44rpx; font-weight: 600; font-size: 36rpx; color: #3D3D3D; } .info_box { margin: 0 auto; padding: 30rpx 22rpx; width: 680rpx; // height: 966rpx; background: #FFFFFF; box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(42, 130, 228, 0.1); border-radius: 24rpx 24rpx 24rpx 24rpx; .top_box { display: flex; flex-wrap: nowrap; align-items: center; // padding: 28rpx 30rpx; // padding: 20rpx 0; margin: 0 auto; // width: 672rpx; height: 100rpx; background: #FFFFFF; // box-shadow: 0rpx 4rpx 22rpx 0rpx rgba(0, 0, 0, 0.07); border-radius: 10rpx 10rpx 10rpx 10rpx; .left_text { display: flex; flex-wrap: nowrap; align-items: center; width: 25%; font-weight: 400; font-size: 32rpx; color: #3D3D3D; .icon-xiangxia1 { font-size: 26rpx; } } .timebox { width: 75%; display: flex; flex-wrap: nowrap; align-items: center; margin-left: 34rpx; .left_time { text-align: center; margin-right: 6rpx; height: 50rpx; width: 45%; border: 2rpx solid #ccc; border-radius: 12rpx; font-weight: 400; font-size: 32rpx; color: #979797; } .right_time { text-align: center; margin-left: 6rpx; height: 50rpx; width: 45%; border: 2rpx solid #ccc; border-radius: 12rpx; font-weight: 400; font-size: 32rpx; color: #979797; } } } .info_boxs{ margin-top: 26rpx; width: 636rpx; padding: 24rpx 0; background: #F4FBFF; border-radius: 24rpx 24rpx 24rpx 24rpx; display: flex; flex-wrap: nowrap; .info_li:first-child{ border-right: 1rpx solid #D8D8D8; } .info_li{ padding: 0 40rpx; display: flex; flex-wrap: wrap; width: 50%; .tit{ text-align: left; width: 100%; font-weight: 600; font-size: 24rpx; color: #3D3D3D; } .txt{ margin-top: 10rpx; width: 100%; display: flex; align-items: center; font-weight: 400; font-size: 24rpx; color: #3D3D3D; span{ font-size: 600; } image{ width: 32rpx; height: 32rpx; } } } } .log_box{ display: flex; flex-wrap: nowrap; justify-content: space-around; .log_li{ font-weight: 400; font-size: 24rpx; color: #3D3D3D; image{ margin-right: 8rpx; width: 76rpx; height:18rpx ; } } } .echarts { width: 650rpx; height: 500rpx; } .tit_box { margin-top: 40rpx; margin-bottom: 30rpx; display: flex; align-items: center; font-weight: 600; font-size: 32rpx; color: #3D3D3D; .tit_line { margin-right: 6rpx; width: 10rpx; height: 46rpx; background: #4297F3; border-radius: 5rpx 5rpx 5rpx 5rpx; } } .data_box { margin-top: 32rpx; width: 100%; display: flex; flex-wrap: nowrap; justify-content: space-around; .act { background: #4297F3; color: #FFFFFF; } .data1 { display: flex; flex-wrap: nowrap; padding: 8rpx 32rpx; border-radius: 26rpx 26rpx 26rpx 26rpx; background: #FFFFFF; border: 2rpx solid #4297F3; font-weight: 400; font-size: 28rpx; color: #4297F3; } // .data2{ // } } .tit { margin-top: 40rpx; width: 100%; text-align: center; font-weight: 600; font-size: 36rpx; color: #3D3D3D; } } } </style>