123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- <template>
- <view>
- <u-navbar :title="title" title-color="#101010"></u-navbar>
-
- <view class="control-group" v-if="role">
-
-
- <view class="control">
- <view class="text">
- 电源状态
- </view>
- <view class="icon" style=" display: flex;">
- <span>关</span>
- <u-switch size="32" @change="switchBtnApi(meterDetails.meter,$event)"
- v-model="meterDetails.meter.switchStatus" inactive-color="#ff9900" ></u-switch >
- <span>开</span>
- <!--
- <img src="@/assets/img/switchIcon.png"
- @tap.stop="switchBtnApi(meterDetails.meter,0)" class="img"
- v-if="meterDetails.meter.switchStatus" alt="" ></img >
- <img src="@/assets/img/switchClose.png"
- @tap.stop="switchBtnApi(meterDetails.meter,1)" class="img"
- v-else alt="" ></img > -->
- <!-- <img src="@/assets/img/control.png" alt="" /> -->
- </view>
- </view>
- </view>
-
- <!-- 用电信息 -->
- <view class="electricity-information">
- <view class="title">
-
-
- <view class="text">
- 用电信息
-
- </view>
- <!-- <view class="more" @click="gotoUrl('/pages/tenantList/electricityInformation')">
- <u-icon name="arrow-right" size="24" color="#d4d4d4"></u-icon>
- </view> -->
- </view>
-
- <view class="infos">
- <view class="item" style="width: 30%;">
-
- <view class="item-value">
- {{meterDetails.thisDayKwh}}
- </view>
- <view class="item-title">
- 今日用电量(度)
- </view>
- </view>
-
- <view class="item" style="width: 30%;">
-
- <view class="item-value">
- {{meterDetails.thisMonthKwh}}
- </view>
- <view class="item-title">
- 当月用电量(度)
- </view>
- </view>
-
- <view class="item" style="width: 30%;">
-
- <view class="item-value" v-if="meterDetails.nowRecord">
- {{meterDetails.nowRecord.totalPower}}
- </view>
- <view class="item-title">
- 当前功率(千瓦)
- </view>
- </view>
- </view>
- </view>
-
- <!-- 日志
- source=2 由他人分配的不能操作定时
- -->
- <view class="log" v-if="source!='2'" @click="gotoUrl('/pages/timing/timing?id='+meterId+'&title='+title)">
- <view class="icon">
- <u-icon name="clock" color="#fff" size="40" ></u-icon>
- </view>
- <view class="text">
- 供电管理
- </view>
- <view class="more">
- <u-icon name="arrow-right" size="32" color="#bbbbbb" ></u-icon>
- </view>
-
- </view>
-
- <view class="log" @click="gotoUrl('/pages/tenantList/operationLog?id='+meterId)">
- <view class="icon">
- <img src="@/assets/img/riLine-file-list-2-line.svg" alt="" />
- </view>
- <view class="text">
- 操作日志
- </view>
- <view class="more">
- <u-icon name="arrow-right" size="32" color="#bbbbbb" ></u-icon>
- </view>
- </view>
-
- </view>
-
-
- </template>
- <script>
- import * as API from '@/apis/pagejs/energyManage.js'
- import * as API_meterTimer from '@/apis/pagejs/meterTimer.js'
-
-
- export default {
- data() {
- return {
- codes:"",
- meterId:"",
- meterDetails:{},
- role:false,
- title:"",
- intervalId:"",
- getMeterReady:false,
- source:"",
- }
- },
- onLoad(op) {
- if(op.id){
- this.meterId=op.id;
- this.getMeter()
- }
- },
- onShow() {
- if(this.meterId&&this.getMeterReady){
- this.startInterval()
- }
-
- },
- onHide() {
- this.clearTimer()
- },
- methods: {
- clearTimer() {
- if (this.intervalId) {
- clearInterval(this.intervalId); // 清除定时器
- this.intervalId = null; // 重置定时器ID
- }
- },
- startInterval() {
- this.clearTimer(); // 组件销毁前清除定时器
- this.intervalId = setInterval(() => {
-
- this.getMeter(true)
- }, 60000);
- },
- switchBtnApiMethod(node,key){
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- API.remoteSwitch({
- meterId:node.id,
- enabled:key
- }).then((res) => {
- uni.hideLoading();
- node.switchStatus=key
-
- }).catch(error => {
-
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- switchBtnApi(node,key){
- uni.showModal({
- confirmColor:`${key?'#3CC51F':'red'}`,
- confirmText:`${key?'开启':'关闭'}`,
- content: `确认是否要"${key?'开启':'关闭'}"${this.replaceLastTwoWords(node.name)}`,
- title: "提示",
- success:res=> {
- if(res.confirm){
- //this.switchBtnApiMethod(node,key);
- }else{
- node.switchStatus=!key
- }
- }
- })
- console.log(node,key)
- },
- getMeter(bl){
- if(!bl){
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- }
-
- API_meterTimer.meterDetails({
- meterId:this.meterId
- }).then((response) => {
- this.codes =this.carhelp.getPersonInfo().codes;
- this.role=this.codes&&this.codes.indexOf('switch')!=-1;
- this.meterDetails=response.data
-
-
- if(!bl){
- uni.hideLoading();
- }
- this.getMeterReady=true;
- if(this.meterDetails.meter){
- this.title=this.replaceLastTwoWords(this.meterDetails.meter.name)
- this.source=this.meterDetails.meter.source
- }
-
-
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .control-group{
- margin: 24rpx 32rpx;
- padding: 40rpx 32rpx;
- background-color: #fff;
- border-radius: 8px;
-
- .control:first-of-type{
- margin-top: 0;
- }
- .control{
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-top: 56rpx;
- .text{
- color: rgba(51,51,51,1);
- font-size: 32rpx;
- font-weight: bold;
- }
- .icon{
- img{
- width: 64rpx;
- height: 64rpx;
- }
- }
- }
-
-
- }
-
- .electricity-information {
- margin: 24rpx 32rpx;
- padding: 40rpx 0rpx;
- background-color: #fff;
- border-radius: 8px;
-
- .title {
- display: flex;
- align-items: center;
- padding: 0 32rpx;
- margin-bottom: 40rpx;
-
-
-
- .text {
- display: flex;
- align-items: center;
- color: rgba(51, 51, 51, 1);
- font-size: 36rpx;
- margin-left: 16rpx;
- font-weight: bold;
- }
-
- .date {
- margin-left: auto;
- }
-
- .more {
- color: #838383;
- font-size: 24rpx;
- margin-left: auto;
-
- }
- }
-
- .chart {
- width: 100%;
- height: 440rpx;
-
- .img {
- width: 100%;
- height: 440rpx;
- }
- }
-
- .infos {
- padding: 0 32rpx;
- display: flex;
- justify-content: space-between;
- text-align: center;
-
-
-
- .item-title {
- color: rgba(119,119,119,1);
- font-size: 24rpx;
- margin-top: 8rpx;
- }
-
- .item-value {
- color: rgba(16, 16, 16, 1);
- font-size: 56rpx;
- margin-top: 16rpx;
- }
-
- }
- }
-
-
- .log{
- margin: 24rpx 32rpx;
- padding: 40rpx 32rpx;
- background-color: #fff;
- border-radius: 8px;
- display: flex;
- align-items: center;
- .icon{
- width: 88rpx;
- height: 88rpx;
- border-radius: 999px;
- background-color: rgba(22,119,255,1);
- display: flex;
- align-items: center;
- justify-content: center;
- img{
- width: 48rpx;
- height: 48rpx;
- }
- }
- .text{
- color: rgba(51,51,51,1);
- font-size: 32rpx;
- margin-left: 24rpx;
- font-weight: bold;
- }
- .more{
- margin-left: auto;
- }
-
- }
- </style>
|