2024-03-13 10:54:22 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view class="page">
|
2024-04-27 17:20:50 +08:00
|
|
|
|
<u-navbar title="用电分析" :border-bottom="false" :background="bgc" title-color='#2E4975' title-size='36'
|
|
|
|
|
height='36' id="navbar"></u-navbar>
|
|
|
|
|
<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-03-13 10:54:22 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="tit">
|
2024-04-27 17:20:50 +08:00
|
|
|
|
本月收入(元)
|
2024-03-13 10:54:22 +08:00
|
|
|
|
</view>
|
|
|
|
|
<div class="txt">
|
2024-04-27 17:20:50 +08:00
|
|
|
|
{{quantity}}
|
2024-03-13 10:54:22 +08:00
|
|
|
|
</div>
|
2024-04-27 17:20:50 +08:00
|
|
|
|
<view class="echarts" v-if="loging">
|
2024-03-13 10:54:22 +08:00
|
|
|
|
<!-- <mpvue-echarts id="main" ref="pieChart" :echarts="echarts" @onInit="initChart" /> -->
|
|
|
|
|
<l-echart ref="chart" @finished="initChart"></l-echart>
|
|
|
|
|
</view>
|
2024-04-27 17:20:50 +08:00
|
|
|
|
</view>
|
|
|
|
|
<view class="list" style="padding-bottom: 120rpx;">
|
|
|
|
|
<view class="card_list" v-for="(item,index) in timelist" :key="index">
|
2024-03-13 10:54:22 +08:00
|
|
|
|
<view class="left">
|
2024-04-27 17:20:50 +08:00
|
|
|
|
{{yeartime.year + '年' + yeartime.month + '月' + item.createDay + '日'}}
|
2024-03-13 10:54:22 +08:00
|
|
|
|
</view>
|
2024-04-27 17:20:50 +08:00
|
|
|
|
<view class="right">
|
|
|
|
|
{{item.usedElectriQuantity}}度
|
|
|
|
|
</view>
|
2024-03-13 10:54:22 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2024-04-27 17:20:50 +08:00
|
|
|
|
|
2024-03-13 10:54:22 +08:00
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import * as echarts from 'echarts'
|
|
|
|
|
import LEchart from '@/uni_modules/lime-echart/components/l-echart/l-echart.vue';
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
|
LEchart
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
bgc: {
|
|
|
|
|
backgroundColor: "#F7FAFE",
|
|
|
|
|
},
|
2024-04-27 17:20:50 +08:00
|
|
|
|
params: {
|
|
|
|
|
year: true,
|
|
|
|
|
month: true,
|
|
|
|
|
day: false,
|
|
|
|
|
hour: false,
|
|
|
|
|
minute: false,
|
|
|
|
|
second: false
|
|
|
|
|
},
|
|
|
|
|
show: false,
|
|
|
|
|
yeartime: {
|
|
|
|
|
year: '',
|
|
|
|
|
month: ''
|
|
|
|
|
},
|
|
|
|
|
timelist: '',
|
|
|
|
|
quantity: 0, //电量
|
|
|
|
|
chartData: [],
|
|
|
|
|
chartday: [],
|
|
|
|
|
loging: true,
|
|
|
|
|
deviceId: '',
|
|
|
|
|
userType: ''
|
2024-03-13 10:54:22 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2024-04-27 17:20:50 +08:00
|
|
|
|
onLoad(e) {
|
2024-03-13 10:54:22 +08:00
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
|
|
|
|
|
// this.initChart()
|
|
|
|
|
// }, 300);
|
|
|
|
|
// this.initChart()
|
2024-04-27 17:20:50 +08:00
|
|
|
|
this.deviceId = e.id
|
|
|
|
|
|
|
|
|
|
const now = new Date();
|
|
|
|
|
this.yeartime.year = now.getFullYear()
|
|
|
|
|
this.yeartime.month = now.getMonth() + 1
|
|
|
|
|
this.gettimes()
|
2024-03-13 10:54:22 +08:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2024-04-27 17:20:50 +08:00
|
|
|
|
confirm(e) {
|
|
|
|
|
this.yeartime = e
|
|
|
|
|
this.gettimes()
|
|
|
|
|
},
|
|
|
|
|
// 进行获取用电量请求
|
|
|
|
|
gettimes() {
|
|
|
|
|
let data = {
|
|
|
|
|
deviceId:this.deviceId,
|
|
|
|
|
year: this.yeartime.year,
|
|
|
|
|
month: this.yeartime.month,
|
|
|
|
|
groupBy: 'create_date'
|
|
|
|
|
}
|
|
|
|
|
this.loging=false
|
|
|
|
|
this.$u.get('/app/device/electric/count', data).then((res) => {
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
this.timelist = res.data
|
|
|
|
|
this.chartData = this.timelist.map(item => item.usedElectriQuantity);
|
|
|
|
|
this.chartday = this.timelist.map(item => item.createDay + '日');
|
|
|
|
|
|
|
|
|
|
// console.log('用电', this.chartData, '时间', this.chartday);
|
|
|
|
|
this.loging=true
|
|
|
|
|
// 求用电总度数
|
|
|
|
|
// this.quantity = 0
|
|
|
|
|
// for (let i = 0; i < this.timelist.length; i++) {
|
|
|
|
|
// this.quantity += this.timelist[i].recharge / 0.5
|
|
|
|
|
// }
|
|
|
|
|
// return this.quantity
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
2024-03-13 10:54:22 +08:00
|
|
|
|
generateWaveData(length) {
|
|
|
|
|
const data = [];
|
|
|
|
|
for (let i = 0; i < length; i++) {
|
|
|
|
|
const y = Math.sin((i / (length - 1)) * Math.PI * 2); // 正弦函数生成波浪形状的y值
|
|
|
|
|
data.push((y + 1) * 50); // 映射到0-100的范围
|
|
|
|
|
}
|
|
|
|
|
return data;
|
|
|
|
|
},
|
|
|
|
|
async initChart() {
|
|
|
|
|
console.log('111111');
|
2024-04-27 17:20:50 +08:00
|
|
|
|
let that =this
|
2024-03-13 10:54:22 +08:00
|
|
|
|
// let _this = this
|
2024-04-27 17:20:50 +08:00
|
|
|
|
const option = {
|
|
|
|
|
grid: {
|
|
|
|
|
left: 60,
|
|
|
|
|
right: 10,
|
|
|
|
|
top: 10,
|
|
|
|
|
bottom: 30,
|
|
|
|
|
},
|
|
|
|
|
xAxis: {
|
|
|
|
|
type: 'category',
|
|
|
|
|
boundaryGap: false,
|
|
|
|
|
axisLine: {
|
|
|
|
|
show: false,
|
|
|
|
|
},
|
|
|
|
|
axisTick: {
|
|
|
|
|
show: false,
|
|
|
|
|
},
|
|
|
|
|
axisLabel: {
|
|
|
|
|
show: true,
|
|
|
|
|
color: '#fff',
|
|
|
|
|
fontSize: 11,
|
|
|
|
|
rotate: 0,
|
|
|
|
|
},
|
|
|
|
|
splitLine: {
|
|
|
|
|
show: false,
|
|
|
|
|
},
|
|
|
|
|
data:that.chartday,
|
|
|
|
|
},
|
|
|
|
|
yAxis: {
|
|
|
|
|
show: true,
|
|
|
|
|
axisLine: {
|
|
|
|
|
show: false,
|
|
|
|
|
},
|
|
|
|
|
axisTick: {
|
|
|
|
|
show: false,
|
|
|
|
|
},
|
|
|
|
|
axisLabel: {
|
|
|
|
|
show: true,
|
|
|
|
|
color: '#fff',
|
|
|
|
|
fontSize: 11,
|
|
|
|
|
formatter: function(value) {
|
|
|
|
|
// 保留两位小数,没有小数时显示00
|
|
|
|
|
return value + '度'
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
splitLine: {
|
|
|
|
|
show: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
visualMap: {
|
|
|
|
|
type: 'piecewise',
|
|
|
|
|
show: false,
|
|
|
|
|
dimension: 0,
|
|
|
|
|
seriesIndex: 0,
|
|
|
|
|
pieces: [{
|
|
|
|
|
gt: 1,
|
|
|
|
|
lt: 3,
|
|
|
|
|
color: 'rgba(0, 0, 180, 0.4)',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
gt: 5,
|
|
|
|
|
lt: 7,
|
|
|
|
|
color: 'rgba(0, 0, 180, 0.4)',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
series: [{
|
|
|
|
|
type: 'line',
|
|
|
|
|
smooth: 0.6,
|
|
|
|
|
symbol: 'none',
|
|
|
|
|
lineStyle: {
|
|
|
|
|
color: '#E0DBFF',
|
|
|
|
|
width: 4,
|
|
|
|
|
},
|
|
|
|
|
areaStyle: {
|
|
|
|
|
normal: {
|
|
|
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
|
|
|
|
|
offset: 0,
|
|
|
|
|
color: '#B4B0F7'
|
|
|
|
|
}, ]),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
data:that.chartData,
|
|
|
|
|
}],
|
|
|
|
|
};
|
|
|
|
|
const chart = await that.$refs.chart.init(echarts)
|
|
|
|
|
console.log(option,'111');
|
|
|
|
|
// 给折线图赋值
|
|
|
|
|
// option.series[0].data = that.chartData
|
|
|
|
|
option.xAxis.data = that.chartday
|
2024-03-13 10:54:22 +08:00
|
|
|
|
chart.setOption(option)
|
2024-04-27 17:20:50 +08:00
|
|
|
|
return chart
|
2024-03-13 10:54:22 +08:00
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
page {
|
|
|
|
|
background-color: #F7FAFE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.page {
|
2024-04-27 17:20:50 +08:00
|
|
|
|
padding: 0 59rpx;
|
|
|
|
|
|
|
|
|
|
.title {
|
|
|
|
|
margin-top: 120rpx;
|
|
|
|
|
font-size: 48rpx;
|
2024-03-13 10:54:22 +08:00
|
|
|
|
font-weight: 400;
|
2024-04-27 17:20:50 +08:00
|
|
|
|
letter-spacing: 0rpx;
|
|
|
|
|
|
|
|
|
|
color: rgba(38, 43, 55, 1);
|
2024-03-13 10:54:22 +08:00
|
|
|
|
}
|
2024-04-27 17:20:50 +08:00
|
|
|
|
|
|
|
|
|
.card {
|
|
|
|
|
padding-top: 32rpx;
|
|
|
|
|
margin-top: 46rpx;
|
2024-03-13 10:54:22 +08:00
|
|
|
|
width: 632rpx;
|
2024-04-27 17:20:50 +08:00
|
|
|
|
height: 586rpx;
|
|
|
|
|
background: #8883F0;
|
2024-03-13 10:54:22 +08:00
|
|
|
|
box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(42, 130, 228, 0.1);
|
|
|
|
|
opacity: 1;
|
2024-04-27 17:20:50 +08:00
|
|
|
|
// filter: blur(0px);
|
|
|
|
|
border-radius: 40rpx;
|
|
|
|
|
|
|
|
|
|
.month {
|
|
|
|
|
|
|
|
|
|
margin-left: 22rpx;
|
2024-03-13 10:54:22 +08:00
|
|
|
|
font-size: 28rpx;
|
2024-04-27 17:20:50 +08:00
|
|
|
|
font-family: Source Han Sans, Source Han Sans;
|
2024-03-13 10:54:22 +08:00
|
|
|
|
font-weight: 400;
|
2024-04-27 17:20:50 +08:00
|
|
|
|
color: #FFFFFF;
|
2024-03-13 10:54:22 +08:00
|
|
|
|
}
|
2024-04-27 17:20:50 +08:00
|
|
|
|
|
|
|
|
|
.tit {
|
|
|
|
|
margin-top: 18rpx;
|
|
|
|
|
margin-left: 22rpx;
|
|
|
|
|
font-size: 20rpx;
|
2024-03-13 10:54:22 +08:00
|
|
|
|
font-family: HarmonyOS Sans SC, HarmonyOS Sans SC;
|
|
|
|
|
font-weight: 400;
|
2024-04-27 17:20:50 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.echarts {
|
|
|
|
|
margin-left: 22rpx;
|
|
|
|
|
margin-top: 60rpx;
|
|
|
|
|
// width: 100%;
|
|
|
|
|
// height: 80%;
|
|
|
|
|
width: 588rpx;
|
|
|
|
|
height: 320rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.list {
|
|
|
|
|
margin-top: 16rpx;
|
|
|
|
|
// height:280rpx;
|
|
|
|
|
// overflow-y: scroll;
|
|
|
|
|
.card_list {
|
|
|
|
|
width: 632rpx;
|
|
|
|
|
height: 88rpx;
|
|
|
|
|
background: #FFFFFF;
|
|
|
|
|
box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(42, 130, 228, 0.1);
|
|
|
|
|
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-03-13 10:54:22 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-27 17:20:50 +08:00
|
|
|
|
|
|
|
|
|
|
2024-03-13 10:54:22 +08:00
|
|
|
|
</style>
|