123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- <template>
- <view>
- <u-navbar title="用电统计" title-color="#101010">
- </u-navbar>
- <!-- 折线图 -->
- <view class="chat-box">
- <view class="title">
- <view class="month">
- {{queryDate}}年 共用电
- </view>
- <view class="month-pick" @click="show = true">
- {{queryDate}}年<u-icon name="arrow-down"></u-icon>
- </view>
- </view>
- <view class="degree">
- {{sumQuantity.toFixed(2)}}<text class="unit">度</text>
- </view>
- <view class="chat">
- <view id="lineEcharts" style="min-height:240rpx;">
- </view>
- <!-- <image class="img" src="@/assets/img/jVzkNKE@1x.png" mode=""></image> -->
- </view>
- </view>
- <u-picker mode="time" :defaultTime="defaultTime" v-model="show" :params="params" @confirm="timeChange"></u-picker>
- <!-- 记录 -->
- <view class="record">
- <view class="total">
-
- </view>
- <view class="record-item" v-for="(item,index) in electricityList" :key="index"
- @click="toElectricityDetails(item.yue)">
- <view class="item-left">
- <view class="number">
- {{item.yue}}月 用电 {{item.kwh}} 度
- </view>
- <view class="date">
- <!-- 01-03 00:01 -->
- </view>
- </view>
- <view class="money">
- {{item.fee}}元
- <!-- 箭头 -->
- <view class="more">
- <u-icon name="arrow-right" color="#acacac" size="24"></u-icon>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import * as API_electricityMeter from '@/apis/pagejs/electricityMeter.js'
- import * as echarts from 'echarts';
- export default {
- data() {
- return {
- show: false, // 时间选择
- defaultTime: '',
- params: {
- year: true,
- month: false,
- day: false,
- hour: false,
- minute: false,
- second: false,
- timestamp: false
- },
- queryDate: '',
- meterId: '',
- myLineChart: null,
- sumQuantity: 0,
- electricityList: [],
- graphMap: {}
- }
- },
- onLoad(op) {
- var date = new Date();
- var year = date.getFullYear();
- this.queryDate = year;
- if (op.id) {
- this.meterId = op.id;
- this.getElectricityConsumptionStatistics();
- }
- },
- methods: {
- getLineCharts(list) {
- if (!this.myLineChart) {
- this.myLineChart = echarts.init(document.getElementById('lineEcharts'), null, {
- width: uni.upx2px(700),
- height: uni.upx2px(240)
- });
- }
- this.myLineChart.clear();
- var data1 = [];
- var data2 = [];
- var sumQuantity = 0;
- var electricityList = [];
- for (var i in list) {
- var obj=list[i]
- obj.yue=i
- data1.push(i+'月');
- data2.push(list[i].kwh);
- sumQuantity += list[i].kwh;
- electricityList.push(obj);
- }
- this.sumQuantity = sumQuantity;
- this.electricityList = electricityList.reverse();
-
- var axisLabel = {
- rotate: 40,
- interval: 0,
- textStyle: {
- color: "#333"
- }
- }
- if (data1.length < 7) {
- axisLabel = {
- interval: 0,
- textStyle: {
- color: "#333"
- },
- }
- }
-
- var option = {
- tooltip: {
- trigger: 'axis',
- axisPointer: {
- type: 'shadow'
- }
- },
- grid: {
- top: '6%',
- left: '3%',
- right: '8%',
- bottom: '8%',
- containLabel: true
- },
- xAxis: {
- type: 'category',
- data: data1,
- axisLabel: axisLabel
- },
- yAxis: {
- type: 'value'
- },
- series: [{
- name: '电量',
- type: 'line',
- data: data2
- }]
- };
- this.myLineChart.setOption(option);
- },
- getElectricityConsumptionStatistics() {
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- API_electricityMeter.electricityConsumptionStatistics({
- meterId: this.meterId,
- queryDate: this.queryDate+'-01-01'
- }).then((res) => {
- uni.hideLoading();
- this.graphMap = res.data.graphMap;
- this.getLineCharts(this.graphMap);
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- timeChange(params) {
- this.queryDate = params.year;
-
- this.getElectricityConsumptionStatistics();
- },
- toElectricityDetails(index) {
- //var month = index+1 >= 10 ? index+1 : '0'+(index+1);
- var date = this.queryDate + '-' + index;
- uni.navigateTo({
- url: '/pages/equipmentDataMonitoring/electricityDetails?id='+this.meterId+'&queryDate='+date
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- // 折线图
- .chat-box {
- background: linear-gradient(180deg, rgba(203, 234, 255, 1) 0%, rgba(255, 255, 255, 1) 75%);
- padding: 24rpx 32rpx;
- .title {
- display: flex;
- align-items: center;
- justify-content: space-between;
- .month {
- color: rgba(16, 16, 16, 1);
- }
- .month-pick {
- color: rgba(51, 51, 51, 1);
- }
- }
- .degree {
- color: rgb(51, 51, 51);
- font-size: 64rpx;
- .unit {
- color: rgb(16, 16, 16);
- font-size: 28rpx;
- margin-left: 8rpx;
- }
- }
- .chat {
- width: 100%;
- height: 240rpx;
- margin-top: 8rpx;
- .img {
- width: 100%;
- height: 100%;
- }
- }
- }
- // 记录
- .record {
- .total {
- color: rgba(119, 119, 119, 1);
- font-size: 32rpx;
- padding: 24rpx 32rpx;
- }
- .record-item {
- background-color: #fff;
- padding: 32rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- border-bottom: 1px solid rgba(244, 244, 244, 1);
- .item-left {
- .number {
- color: rgba(51, 51, 51, 1);
- font-size: 32rpx;
- font-weight: bold;
- }
- .date {
- color: rgb(153, 153, 153);
- font-size: 24rpx;
- margin-top: 4rpx;
- }
- }
- .money {
- color: rgb(16, 16, 16);
- font-size: 40rpx;
- display: flex;
- align-items: center;
- .more {
- margin-left: 8rpx;
- }
- }
- }
- }
- </style>
|