kaiguan-zfb/pages/tj.vue

591 lines
12 KiB
Vue
Raw Normal View History

2023-12-05 16:45:28 +08:00
<template>
2024-06-08 18:04:47 +08:00
<view class="page" >
2024-05-21 18:02:34 +08:00
<u-navbar :is-back="false" title="统计" :border-bottom="false" :background="bgc" title-color='#fff'
2024-05-24 16:48:42 +08:00
title-size='44' height='48' id="navbar">
2024-05-10 17:37:36 +08:00
</u-navbar>
2024-06-08 18:04:47 +08:00
<view v-if="userType=='01'" style="padding-top: 30rpx;">
2024-05-10 17:37:36 +08:00
<view class="card">
<view class="xzsj">
2024-05-10 21:35:42 +08:00
<u-picker mode="time" v-model="show" :params="params" @confirm="confirm"></u-picker>
2024-05-10 17:37:36 +08:00
</view>
<view class="month" @click="show = true">
2024-05-10 21:35:42 +08:00
{{yeartime.year + '年' + yeartime.month + '月'}} <u-icon style="margin-left: 10rpx;"
name="arrow-down-fill"></u-icon>
2024-05-10 17:37:36 +08:00
</view>
<view class="tit">
2024-09-30 13:47:14 +08:00
本月收入{{recharge.toFixed(2)}} 累计收入{{totalRecharge.toFixed(2)}}
2024-05-10 17:37:36 +08:00
</view>
2024-05-10 21:35:42 +08:00
2024-05-24 16:48:42 +08:00
<view class="echarts" >
2024-11-21 17:51:50 +08:00
<l-echart class="line-chart" ref="lineChart"></l-echart>
2024-05-10 17:37:36 +08:00
</view>
2024-01-24 11:55:35 +08:00
</view>
2024-05-24 16:48:42 +08:00
<view class="list" style="padding-bottom: 240rpx;">
2024-06-14 18:51:43 +08:00
<view class="card_list" v-for="(item,index) in timelists" :key="index">
2024-05-10 17:37:36 +08:00
<view class="left">
{{yeartime.year + '年' + yeartime.month + '月' + item.createDay + '日'}}
</view>
<view class="right">
{{item.recharge}}
</view>
</view>
2024-01-24 11:55:35 +08:00
</view>
2024-05-10 17:37:36 +08:00
</view>
<view v-if="userType=='00'">
<view class="title">
统计
2024-01-24 11:55:35 +08:00
</view>
2024-05-10 17:37:36 +08:00
<view class="card">
<view class="xzsj">
<u-picker mode="time" v-model="show" :params="params" @confirm="confirm"></u-picker>
</view>
<view class="month" @click="show = true">
{{yeartime.year + '年' + yeartime.month + '月'}}
2024-01-27 16:37:52 +08:00
</view>
2024-05-10 17:37:36 +08:00
<view class="tit">
本月用电量
</view>
<div class="txt">
{{quantity}}
</div>
<view class="echarts" v-if="loging">
2024-05-10 21:35:42 +08:00
2024-05-10 17:37:36 +08:00
</view>
</view>
2024-01-27 16:37:52 +08:00
</view>
2024-11-09 18:02:13 +08:00
<!-- #ifdef MP-WEIXIN -->
<tab-bar :indexs='1'></tab-bar>
<!-- #endif -->
2023-12-05 16:45:28 +08:00
</view>
</template>
<script>
2024-11-21 17:51:50 +08:00
import * as echarts from '@/components/lime-echart/static/echarts.min.js';
2024-05-10 21:35:42 +08:00
let chart = null
2023-12-05 16:45:28 +08:00
export default {
2024-01-24 11:55:35 +08:00
components: {
2024-11-21 17:51:50 +08:00
// uniEcCanvas
2024-01-24 11:55:35 +08:00
},
2023-12-05 16:45:28 +08:00
data() {
return {
2024-11-21 17:51:50 +08:00
type: 1, //交易分析模块里的类型
jdData: {}, //进度那块数据
2024-05-10 21:35:42 +08:00
ec: {
lazyLoad: true
},
2024-03-25 19:46:07 +08:00
params: {
year: true,
month: true,
day: false,
hour: false,
minute: false,
second: false
},
2024-05-10 21:35:42 +08:00
recharge: 0,
2024-05-10 17:37:36 +08:00
bgc: {
2024-05-21 18:02:34 +08:00
backgroundColor: "#8883f0",
2024-05-10 17:37:36 +08:00
},
2024-03-25 19:46:07 +08:00
show: false,
yeartime: {
year: '',
month: ''
},
timelist: '',
chartData: [],
2024-05-10 21:35:42 +08:00
chartday: [],
loging: true,
deviceId: '',
userType: '',
totalRecharge: 0,
2024-06-14 18:51:43 +08:00
dateday:'',
timelists:'',
monthdui:''
2024-01-23 19:15:52 +08:00
}
},
2024-07-17 17:59:51 +08:00
// 分享到好友(会话)
onShareAppMessage: function () {
return {
title: '创想物联',
path: '/pages/shouye/index'
}
},
// 分享到朋友圈
onShareTimeline: function () {
return {
title: '创想物联',
query: '',
path: '/pages/shouye/index'
}
},
2024-01-24 11:55:35 +08:00
onLoad() {
2024-05-11 13:33:17 +08:00
2024-03-25 19:46:07 +08:00
},
onShow() {
2024-05-27 16:06:08 +08:00
this.timelist = []
2024-05-11 13:33:17 +08:00
setTimeout(() => {
2024-11-21 17:51:50 +08:00
//加载折线图数据
this.loadLineData();
2024-05-27 16:06:08 +08:00
}, 500)
2024-05-10 17:37:36 +08:00
this.recharge = 0
2024-05-10 21:35:42 +08:00
this.deviceId = uni.getStorageSync('deviceId')
2024-05-10 17:37:36 +08:00
this.userType = uni.getStorageSync('userType')
this.userType = '01'
2024-05-10 21:35:42 +08:00
const now = new Date();
2024-05-10 17:37:36 +08:00
this.yeartime.year = now.getFullYear()
this.yeartime.month = now.getMonth() + 1
2024-06-14 18:51:43 +08:00
this.monthdui = this.yeartime.month
this.dateday = String(now.getDate()).padStart(2, '0')
2024-05-11 13:33:17 +08:00
this.gettime()
2024-01-24 11:55:35 +08:00
},
2024-01-23 19:15:52 +08:00
methods: {
2024-03-25 19:46:07 +08:00
// 点击获取时间
confirm(e) {
2024-05-10 17:37:36 +08:00
this.recharge = 0
2024-03-25 19:46:07 +08:00
this.yeartime = e
this.gettime()
2024-05-11 13:33:17 +08:00
setTimeout(() => {
2024-11-21 17:51:50 +08:00
//加载折线图数据
this.loadLineData();
2024-05-27 16:06:08 +08:00
}, 500)
2024-03-25 19:46:07 +08:00
},
// 进行获取用电量请求
gettime() {
let data = {
year: this.yeartime.year,
month: this.yeartime.month,
2024-05-24 16:48:42 +08:00
groupBy: 'create_date'
2024-03-25 19:46:07 +08:00
}
2024-05-10 21:35:42 +08:00
this.loging = false
2024-03-25 19:46:07 +08:00
this.$u.get('app/bill/landlordCount', data).then((res) => {
if (res.code == 200) {
this.timelist = res.data
2024-06-14 18:51:43 +08:00
if(this.monthdui != this.yeartime.month){
this.timelists = this.timelist
this.totalRecharge = res.totalRecharge
this.chartData = this.timelist.map(item => item.recharge);
this.chartday = this.timelist.map(item => item.createDay + '日');
}else{
2024-06-18 13:43:37 +08:00
this.timelists = this.timelist.slice(0,this.dateday)
2024-06-14 18:51:43 +08:00
this.timelists.reverse()
this.totalRecharge = res.totalRecharge
this.chartData = this.timelist.slice(0, this.dateday).map(item => item.recharge)
this.chartday = this.timelist.slice(0, this.dateday).map(item => item.createDay + '日');
}
2024-05-10 21:35:42 +08:00
this.loging = true
2024-03-25 19:46:07 +08:00
for (let i = 0; i < this.timelist.length; i++) {
2024-05-10 21:35:42 +08:00
this.recharge += this.timelist[i].recharge
2024-03-25 19:46:07 +08:00
}
2024-05-10 17:37:36 +08:00
return this.recharge
2024-11-21 17:51:50 +08:00
//加载折线图数据
this.loadLineData();
2024-05-10 17:37:36 +08:00
}
})
},
2024-11-21 17:51:50 +08:00
//加载折线图数据
loadLineData() {
//这里请求服务器拿到数据
let res = {
//x轴数据
xData: this.chartday,
//y轴数据
yData: this.chartData,
2024-01-27 16:37:52 +08:00
}
2024-11-21 17:51:50 +08:00
//这里option配置参考文档https://echarts.apache.org/zh/option.html
let option = {
2024-03-25 19:46:07 +08:00
xAxis: {
type: 'category',
2024-11-21 17:51:50 +08:00
// x轴数据文字颜色
2024-03-25 19:46:07 +08:00
axisLabel: {
2024-11-21 17:51:50 +08:00
color: '#fff'
2024-03-25 19:46:07 +08:00
},
2024-11-21 17:51:50 +08:00
// x轴那天坐标轴线的颜色
2024-03-25 19:46:07 +08:00
axisLine: {
2024-11-21 17:51:50 +08:00
lineStyle: {
color: '#fff',
}
2024-03-25 19:46:07 +08:00
},
2024-11-21 17:51:50 +08:00
//x轴上面刻度线隐藏
2024-03-25 19:46:07 +08:00
axisTick: {
show: false,
},
2024-11-21 17:51:50 +08:00
//这里是x轴数据
data: res.xData
2024-03-25 19:46:07 +08:00
},
2024-11-21 17:51:50 +08:00
//设置网格
2024-05-10 17:37:36 +08:00
grid: {
2024-11-21 17:51:50 +08:00
top: 40,
2024-05-10 17:37:36 +08:00
bottom: 30,
},
2024-11-21 17:51:50 +08:00
//y轴设置
2024-05-10 17:37:36 +08:00
yAxis: {
2024-11-21 17:51:50 +08:00
type: 'value',
//y轴标签文字颜色
2024-05-10 17:37:36 +08:00
axisLabel: {
2024-11-21 17:51:50 +08:00
color: '#fff'
2024-05-10 17:37:36 +08:00
},
2024-11-21 17:51:50 +08:00
// y轴分割线设置为虚线
2024-05-10 17:37:36 +08:00
splitLine: {
2024-11-21 17:51:50 +08:00
show: true,
lineStyle: {
type: 'dashed'
}
}
2024-05-10 17:37:36 +08:00
},
2024-11-21 17:51:50 +08:00
//设置提示为点击时
tooltip: {
trigger: 'axis',
triggerOn: 'click',
formatter: '{b} \n 收入: {c}¥'
2024-05-10 17:37:36 +08:00
},
2024-11-21 17:51:50 +08:00
//设置曲线的颜色
color: ['#fff'],
2024-05-10 17:37:36 +08:00
series: [{
2024-11-21 17:51:50 +08:00
//这里是数据
data: res.yData,
2024-05-10 17:37:36 +08:00
type: 'line',
2024-11-21 17:51:50 +08:00
//设置为平滑,默认为折线
smooth: true,
}]
2024-05-10 17:37:36 +08:00
};
2024-11-21 17:51:50 +08:00
this.$refs.lineChart.init(echarts, chart => {
chart.setOption(option);
});
}
2024-01-23 19:15:52 +08:00
}
}
2023-12-05 16:45:28 +08:00
</script>
2024-01-24 11:55:35 +08:00
<style lang="scss">
2024-11-21 17:51:50 +08:00
.content {
width: 100%;
min-height: 100vh;
background-color: #f1f3f2;
padding: 20rpx 0rpx 100rpx;
}
.t-sm {
font-size: 22rpx;
color: #6e6e6e;
padding-left: 10rpx;
}
.chart-con {
width: 100%;
box-sizing: border-box;
padding: 0rpx 28rpx;
.chart-wrap {
width: 100%;
box-sizing: border-box;
background-color: #ffffff;
padding: 32rpx 0rpx;
border-radius: 20rpx;
.title {
box-sizing: border-box;
width: 100%;
padding: 0rpx 28rpx;
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
}
.ver-line {
height: 30rpx;
width: 8rpx;
border-radius: 10rpx;
background-color: #4e9d77;
}
.title-desc {
font-size: 30rpx;
color: #222222;
margin-left: 22rpx;
font-weight: bold;
}
.ring-chart {
height: 400rpx;
width: 100%;
box-sizing: border-box;
padding: 0rpx 28rpx;
margin-top: 32rpx;
}
.process-con {
padding: 50rpx 28rpx 18rpx;
box-sizing: border-box;
width: 100%;
.process-item:not(:last-child) {
margin-bottom: 50rpx;
}
.process-item {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
.pay-img {
width: 65rpx;
height: 65rpx;
}
.percent-con {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
flex: 1;
padding-left: 28rpx;
.top {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
color: #222222;
width: 100%;
}
.bot {
width: 100%;
height: 12rpx;
background-color: #f5f5f5;
border-radius: 10rpx;
position: relative;
margin-top: 14rpx;
.percent-num {
background-color: #4e9d77;
position: absolute;
height: 100%;
top: 0;
left: 0;
z-index: 1;
border-radius: 10rpx;
transition: width .5s ease-in;
}
}
}
}
}
.line-chart-con {
width: 100%;
box-sizing: border-box;
padding: 0rpx 28rpx;
.fun-tabs {
margin-top: 42rpx;
display: flex;
flex-direction: row;
justify-content: space-between;
align-self: center;
width: 100%;
box-sizing: border-box;
.tab-item {
width: 200rpx;
height: 120rpx;
border-radius: 10rpx;
padding-left: 20rpx;
background: #ffffff;
border: 1rpx solid #ececec;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
box-sizing: border-box;
.item-name {
color: #6e6e6e;
font-size: 20rpx;
}
.item-val {
color: #222222;
font-size: 24rpx;
font-weight: bold;
margin-top: 20rpx;
}
}
.selected {
background: #edf5f1 !important;
border: 1rpx solid #4e9d77 !important;
.item-name {
color: #4e9d77 !important;
}
.item-val {
color: #4e9d77 !important;
}
}
}
.line-chart {
margin-top: 30rpx;
height: 380rpx;
}
}
}
}
.gap {
margin-top: 30rpx;
}
.t-items {
width: 690rpx;
box-sizing: border-box;
display: flex;
flex-direction: row;
justify-content: space-evenly;
align-items: center;
background: #fff;
margin: 10rpx auto;
height: 100rpx;
.t-item {
font-size: 28rpx;
height: 60rpx;
font-weight: bold;
background: green;
padding: 0rpx 40rpx;
border-radius: 6rpx;
color: #ffffff;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
}
2024-05-24 16:48:42 +08:00
/deep/ .u-title{
padding-bottom: 20rpx;
}
/deep/ .u-icon__icon{
padding-bottom: 20rpx;
}
2024-05-10 21:35:42 +08:00
.uni-ec-canvas {
width: 100%;
height: 320rpx;
display: block;
margin-top: 30rpx;
}
2024-03-25 19:46:07 +08:00
.btnxz {
padding: 0 20rpx;
box-sizing: border-box;
font-size: 28rpx;
font-family: Source Han Sans, Source Han Sans;
font-weight: 400;
color: #FFFFFF;
}
2024-01-24 11:55:35 +08:00
page {
background-color: #F7FAFE;
}
.page {
padding: 0 59rpx;
.title {
2024-03-25 19:46:07 +08:00
margin-top: 120rpx;
2024-01-24 11:55:35 +08:00
font-size: 48rpx;
font-weight: 400;
letter-spacing: 0rpx;
color: rgba(38, 43, 55, 1);
}
2024-01-23 19:15:52 +08:00
2024-01-24 11:55:35 +08:00
.card {
padding-top: 32rpx;
2024-05-24 16:48:42 +08:00
margin-top: 10rpx;
2024-01-24 11:55:35 +08:00
width: 632rpx;
2024-11-21 17:51:50 +08:00
height: 480rpx;
2024-01-24 11:55:35 +08:00
background: #8883F0;
box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(42, 130, 228, 0.1);
opacity: 1;
border-radius: 40rpx;
.month {
2024-01-27 16:37:52 +08:00
2024-01-24 11:55:35 +08:00
margin-left: 22rpx;
font-size: 28rpx;
font-family: Source Han Sans, Source Han Sans;
font-weight: 400;
color: #FFFFFF;
}
.tit {
margin-top: 18rpx;
margin-left: 22rpx;
font-size: 20rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #FFFFFF;
}
.txt {
margin-top: 2rpx;
margin-left: 22rpx;
font-size: 36rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 700;
color: #FFFFFF;
}
2024-01-27 16:37:52 +08:00
2024-01-24 11:55:35 +08:00
.echarts {
margin-left: 22rpx;
2024-11-21 17:51:50 +08:00
// margin-top: 20rpx;
2024-01-24 11:55:35 +08:00
width: 588rpx;
height: 320rpx;
}
}
2024-01-27 16:37:52 +08:00
.list {
margin-top: 16rpx;
2024-11-21 17:51:50 +08:00
height: 800rpx;
2024-06-08 18:04:47 +08:00
overflow: auto;
2024-01-27 16:37:52 +08:00
.card_list {
2024-11-21 17:51:50 +08:00
width: 632rpx;
2024-01-27 16:37:52 +08:00
height: 88rpx;
background: #FFFFFF;
opacity: 1;
border-radius: 30rpx;
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
margin-top: 16rpx;
align-items: center;
.left {
margin-left: 52rpx;
font-size: 28rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #808080;
}
.right {
margin-right: 20rpx;
font-size: 28rpx;
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
font-weight: 400;
color: #808080;
}
}
}
2024-01-24 11:55:35 +08:00
}
</style>