electricity.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471
  1. <template>
  2. <view>
  3. <view class="background" :class="{
  4. 'background-padding-bottom':!showtab
  5. }">
  6. <u-picker v-model="tabsFrom.show1"
  7. :defaultSelector="[tabsFrom.show1Index]"
  8. mode="selector" :range="tabsFrom.selector1" range-key="label" @confirm="selector1confirm" ></u-picker>
  9. <u-picker-select title="日期选择" v-model="tabsFrom.show2"
  10. :defaultTime="tabsFrom.show2Index" :endYear="endYear" @cancel="selector2cancel"
  11. mode="time" :params="params" :noselect="false" @confirm="selector2confirm" @reset="selector2reset" ></u-picker-select>
  12. <u-navbar :background="background"
  13. @titleCk="titleCk" :title-icon="componentsMeterList.length>1?'arrow-down':''"
  14. back-icon-color="#fff" :title="title" title-color="#fff">
  15. <!-- <view class="u-nav-slot" slot="right" @click="tabsFrom.show2=true,params.day=true">
  16. <image class="img" src="@/assets/img/riLine-calendar-todo-line 1.svg" mode=""></image>
  17. </view> -->
  18. </u-navbar>
  19. <!-- 日期 -->
  20. <view class="date-box" v-if="false" >
  21. <view class="item" v-for="(item,i) in topDate"
  22. :class="{
  23. 'item-today':item.queryDate==FormData.queryDate
  24. }"
  25. @click="queryDate(item.queryDate,true)"
  26. :key="i">
  27. <view class="date">
  28. {{item.num}}
  29. </view>
  30. <view class="week">
  31. {{item.week}}
  32. </view>
  33. <view class="dot" v-if="item.today==0">
  34. </view>
  35. </view>
  36. <view class="item item-today" v-if="0">
  37. <view class="date">
  38. 26
  39. </view>
  40. <view class="week ">
  41. 今天
  42. </view>
  43. <view class="dot">
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- 用电量 -->
  49. <view class="electricity-consumption">
  50. <!-- 统计 -->
  51. <view class="statistics-content">
  52. <view class="statistics-item"
  53. @click="gotoUrl('/pages/mine/electricityConsumptionDetail?id='
  54. +FormData.meterId+'&type='+FormData.type)">
  55. <view class="item-title">
  56. <image class="img" src="@/assets/img/meterStatistics@3x.png"></image>电量统计(度)
  57. </view>
  58. <view class="item-value">
  59. <text>{{electricityNum}}</text> <u-icon name="arrow-right" color="#cccccc" size="24" ></u-icon>
  60. </view>
  61. </view>
  62. <view class="statistics-item" >
  63. <view class="item-title item-title2">
  64. <image class="img" src="@/assets/img/electricityStatistics@3x.png"></image>电费统计(元)
  65. </view>
  66. <view class="item-value">
  67. {{fee}}
  68. </view>
  69. </view>
  70. </view>
  71. <view class="radio">
  72. <u-radio-group v-model="value" @change="radioGroupChange">
  73. <u-radio @change="radioChange" v-for="(item, index) in list" :key="index" :name="item.id"
  74. :disabled="item.disabled">
  75. {{item.name}}
  76. </u-radio>
  77. </u-radio-group>
  78. </view>
  79. </view>
  80. <!-- 远程控制电源开关 -->
  81. <view class="control"
  82. v-if="meterDetail.type!=6&&meterDetail.allowSwitch&&personInfo.balance">
  83. <view class="text" @click="gotoUrl('/pages/remoteControl/switchDetail?id='+meterDetail.id)" >
  84. 智能监控电源
  85. <u-icon name="arrow-right" color="#cccccc" size="24" ></u-icon>
  86. </view>
  87. <view class="icon" style=" display: flex;" >
  88. <span>关</span>
  89. <u-switch size="32" @change="switchBtnApi(meterDetail,$event)"
  90. v-model="meterDetail.switchStatus" inactive-color="#ff9900" ></u-switch >
  91. <span >开</span>
  92. <!-- <img src="@/assets/img/control.png"
  93. @tap.stop="switchBtnApi(meterDetail,0)"
  94. v-if="meterDetail.switchStatus"
  95. alt="" />
  96. <img @tap.stop="switchBtnApi(meterDetail,1)"
  97. v-else
  98. src="@/assets/img/switchClose.png" alt="" /> -->
  99. </view>
  100. <!-- <view class="icon" v-i>
  101. <img src="@/assets/img/control.png"
  102. @tap.stop="switchBtnApi(meterDetail,0)"
  103. v-if="meterDetail.switchStatus"
  104. alt="" />
  105. <img @tap.stop="switchBtnApi(meterDetail,1)"
  106. v-else
  107. src="@/assets/img/switchClose.png" alt="" />
  108. </view> -->
  109. </view>
  110. <!-- 各时段用电量 -->
  111. <view class="electricity-chart">
  112. <view class="title">
  113. <view class="text">
  114. <view class="icon-title">
  115. </view> 各时段用电量 (度)
  116. </view>
  117. <view @click="tabsFrom.show2=true,params.day=true" class="queryDayClass" >
  118. {{queryDay}}<u-icon name="arrow-down"></u-icon>
  119. </view>
  120. </view>
  121. <view class="chart">
  122. <view id="pieEcharts" >
  123. </view>
  124. <view
  125. style="background: white; display: flex;justify-content: space-between;padding: 0 12px;" >
  126. <view>电量合计:{{sumQuantity}}度</view>
  127. <view>电费合计:{{sumFee}}元</view>
  128. </view>
  129. </view>
  130. </view>
  131. <!-- 设备信息 -->
  132. <view class="equipment-information">
  133. <view class="title">
  134. <view class="icon-title">
  135. </view>
  136. <view class="text">
  137. 设备信息
  138. </view>
  139. <view class="more" @click="equipmentInfosShow=true">
  140. 查看全部<u-icon name="arrow-right" size="24" color="#d4d4d4"></u-icon>
  141. </view>
  142. </view>
  143. <view class="infos">
  144. <view class="item" style="width: 30%;">
  145. <view class="item-title">
  146. 设备类型
  147. </view>
  148. <view class="item-value">
  149. {{meterDetail.deviceTypeN}}
  150. </view>
  151. </view>
  152. <view class="border">
  153. </view>
  154. <view class="item" style="width: 30%;">
  155. <view class="item-title">
  156. 设备编号
  157. </view>
  158. <view class="item-value">
  159. {{meterDetail.deviceNo}}
  160. </view>
  161. </view>
  162. <view class="border">
  163. </view>
  164. <view class="item" style="width: 30%;">
  165. <view class="item-title">
  166. 设备地址
  167. </view>
  168. <view class="item-value">
  169. {{meterDetail.installationAddressSimple}}
  170. </view>
  171. </view>
  172. </view>
  173. </view>
  174. <!-- 设备信息弹窗 -->
  175. <view class="equipment-popup">
  176. <u-popup v-model="equipmentInfosShow" mode="bottom" border-radius="12">
  177. <view class="content">
  178. <view class="headline">
  179. 设备信息
  180. </view>
  181. <view class="infos">
  182. <view class="item">
  183. <view class="item-title">
  184. 设备名称
  185. </view>
  186. <view class="item-value">
  187. {{meterDetail.name}}
  188. </view>
  189. </view>
  190. <view class="item">
  191. <view class="item-title">
  192. 设备类型
  193. </view>
  194. <view class="item-value">
  195. {{meterDetail.deviceTypeN}}
  196. </view>
  197. </view>
  198. <view class="item">
  199. <view class="item-title">
  200. 设备编号
  201. </view>
  202. <view class="item-value">
  203. {{meterDetail.deviceNo}}
  204. </view>
  205. </view>
  206. <view class="item">
  207. <view class="item-title">
  208. 产权单位
  209. </view>
  210. <view class="item-value">
  211. {{meterDetail.companyFullName}}
  212. </view>
  213. </view>
  214. <view class="item">
  215. <view class="item-title">
  216. 设备地址
  217. </view>
  218. <view class="item-value">
  219. <span>{{meterDetail.installationAddress}}</span>
  220. <image class="img" v-if="false" src="@/assets/img/riFill-navigation-fill 1.svg"></image>
  221. </view>
  222. </view>
  223. <view class="item">
  224. <view class="item-title">
  225. 地址简称
  226. </view>
  227. <view class="item-value">
  228. <span>{{meterDetail.installationAddressSimple}}</span>
  229. <image class="img" v-if="false" src="@/assets/img/riFill-navigation-fill 1.svg"></image>
  230. </view>
  231. </view>
  232. <view class="item">
  233. <view class="item-title">
  234. 使用单位
  235. </view>
  236. <view class="item-value">
  237. {{meterDetail.customer}}
  238. </view>
  239. </view>
  240. <view class="item">
  241. <view class="item-title">
  242. 启用时间
  243. </view>
  244. <view class="item-value">
  245. {{meterDetail.enablingTime}}
  246. </view>
  247. </view>
  248. </view>
  249. <button class="get" @click="equipmentInfosShow=false">知道了</button>
  250. </view>
  251. </u-popup>
  252. </view>
  253. </view>
  254. </template>
  255. <script>
  256. import {
  257. parseUnixTime,
  258. beforeTimeStamp,
  259. getWeek,newDate
  260. } from '@/apis/utils'
  261. import * as API from '@/apis/pagejs/tenantElectricityMeter.js'
  262. import * as echarts from "echarts";
  263. import * as API_water from '@/apis/pagejs/water.js'
  264. export default {
  265. data() {
  266. return {
  267. queryDay:'',
  268. title:"查询中",
  269. myChart:null,
  270. showTop: [0, 0, 0, 0, 0, 0, 0, 0],
  271. fee:0,
  272. topDate:[],
  273. waterMeterList:[],
  274. FormData:{
  275. },
  276. FormData2:{
  277. },
  278. endYear:'',
  279. params: {
  280. year: true,
  281. month: true,
  282. day: true,
  283. hour: false,
  284. minute: false,
  285. second: false
  286. },
  287. tabsFrom: {
  288. show1: false,
  289. show1Index:0,
  290. show2Index:'',
  291. show2: false,
  292. show1Text: "全部类型",
  293. show2Text: "全部时间",
  294. selector1:[
  295. {
  296. label: '全部类型',
  297. value: '',
  298. },
  299. {
  300. label: '线上充值',
  301. value: '1',
  302. },
  303. {
  304. label: '线下充值',
  305. value: '2',
  306. },
  307. ]
  308. },
  309. background: {
  310. backgroundColor: '#1677FF',
  311. },
  312. list: [
  313. {
  314. id:1,
  315. name: '本月',
  316. disabled: false
  317. },
  318. {
  319. id:4,
  320. name: '今日',
  321. disabled: false
  322. },
  323. {
  324. id:2,
  325. name: '上月',
  326. disabled: false
  327. },
  328. {
  329. id:3,
  330. name: '本年',
  331. disabled: false
  332. }, {
  333. id:0,
  334. name: '合计',
  335. disabled: false
  336. }, {
  337. id:10,
  338. name: '指定月份',
  339. disabled: false
  340. }
  341. ],
  342. sumQuantity:0,
  343. sumFee:0,
  344. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  345. value: '4',
  346. oldvalue: '4',
  347. intervalId: null, // 用于存储间隔ID
  348. intervalReady: true, // 用于存储间隔ID
  349. electricityNum: 0, //电量统计
  350. electricity:{
  351. },
  352. meterDetail:{
  353. },
  354. componentsMeterList:[],
  355. meterId:"",
  356. waterId:"",
  357. equipmentInfosShow:false,
  358. personInfo:{}
  359. };
  360. },
  361. props:{
  362. showtab:false,
  363. },
  364. onLoad(op) {
  365. this.init(op)
  366. // for(var i =4;i>=0;i--){
  367. // var time=new Date(beforeTimeStamp(i,new Date()));
  368. // this.topDate.push({
  369. // num:time.getDate(),
  370. // week:i==0?'今日':getWeek(time),
  371. // today:i,
  372. // queryDate:parseUnixTime(time, '{y}-{m}-{d}')
  373. // })
  374. // }
  375. // console.log( this.topDate)
  376. },
  377. beforeDestroy() {
  378. this.clearTimer(); // 组件销毁前清除定时器
  379. this.intervalReady=false;
  380. console.log( "组件销毁前清除定时器")
  381. },
  382. methods: {
  383. initSet(id,list){
  384. this.meterId=id
  385. this.componentsMeterList=list;
  386. },
  387. init(){
  388. this.current=0
  389. this.endYear=new Date().getFullYear()
  390. this.FormData.queryDate=parseUnixTime(new Date(), '{y}-{m}-{d}')
  391. this.FormData2.queryDate=parseUnixTime(new Date(), '{y}-{m}-{d}')
  392. this.FormData.type=4
  393. this.getcomponentsMeterList();
  394. },
  395. clearTimer() {
  396. if (this.intervalId) {
  397. clearInterval(this.intervalId); // 清除定时器
  398. this.intervalId = null; // 重置定时器ID
  399. }
  400. },
  401. startInterval(){
  402. this.clearTimer(); // 组件销毁前清除定时器
  403. this.intervalId = setInterval(() => {
  404. // 每隔5秒运行的代码
  405. console.log('这段代码每隔5秒运行一次');
  406. this.getTimeSlotStatistics(true)
  407. this.getElectricityStatistics(true)
  408. }, 60*1000);
  409. },
  410. titleCk(){
  411. if(this.componentsMeterList.length>1){
  412. this.tabsFrom.show1=true
  413. }
  414. },
  415. selector1confirm(e){
  416. var index=e[0]
  417. this.tabsFrom.show1Index=index
  418. this.tabsFrom.show1Text=this.tabsFrom.selector1[index].label
  419. this.title=this.tabsFrom.selector1[index].label
  420. this.FormData.meterId=this.tabsFrom.selector1[index].value
  421. this.FormData.queryDate=parseUnixTime(new Date(), '{y}-{m}-{d}')
  422. this.FormData2.meterId=this.tabsFrom.selector1[index].value
  423. this.FormData2.queryDate=parseUnixTime(new Date(), '{y}-{m}-{d}')
  424. this.FormData.type=4
  425. this.value="4"
  426. this.electricity=this.componentsMeterList[index]
  427. this.getMeterDetails()
  428. this.getTimeSlotStatistics()
  429. this.getElectricityStatistics()
  430. },
  431. callback(){
  432. if(this.componentsMeterList.length==0&&this.waterMeterList.length==0){
  433. uni.showModal({
  434. title:"提示",
  435. content:"未绑定设备,请联系管理员!",
  436. showCancel:false,
  437. success() {
  438. uni.navigateBack()
  439. }
  440. })
  441. }
  442. },
  443. queryDate(queryTime,day){
  444. if(day){
  445. this.FormData2.queryDate=queryTime;
  446. //this.FormData2.type =day?"9":"10"
  447. //this.value="-1"
  448. this.getTimeSlotStatistics()
  449. }else{
  450. this.FormData.queryDate=queryTime+"-01";
  451. this.FormData.type ="10"
  452. //this.value="-1"
  453. this.list[5].name = queryTime;
  454. this.getElectricityStatistics()
  455. }
  456. },
  457. getElectricityStatistics(interval){
  458. // if(!this.intervalReady){
  459. // return
  460. // }
  461. if(!interval){
  462. uni.showLoading({
  463. title: "加载中",
  464. mask: true,
  465. })
  466. }
  467. var obj={
  468. ...this.FormData
  469. }
  470. if(obj.type!=10){
  471. this.list[5].name = '指定月份';
  472. }
  473. API.electricityStatistics(obj).then((response) => {
  474. if(!interval){
  475. uni.hideLoading();
  476. }
  477. this.showTop = [0, 0, 0, 0, 0, 0, 0, 0]
  478. var electricity = response.data.kwhMap.kwh+"";
  479. this.electricityNum = response.data.kwhMap.kwh;
  480. this.fee = response.data.kwhMap.fee;
  481. if (electricity) {
  482. var sz = electricity.split(".")
  483. var str1 = sz[0];
  484. var str2 = [];
  485. if (sz.length > 1) {
  486. str2 = sz[1];
  487. this.showTop[7] = str2[0];
  488. }
  489. var j = 0;
  490. for (var i in str1) {
  491. if (i != undefined) {
  492. this.showTop[6 - str1.length + j + 1] = str1[i]
  493. }
  494. j++;
  495. }
  496. this.$forceUpdate()
  497. }
  498. //this.componentsMeterList=response.data.meterList
  499. if(!interval){
  500. this.startInterval(); // 组件挂载后开始间隔
  501. }
  502. }).catch(error => {
  503. uni.showToast({
  504. title: error,
  505. icon: "none"
  506. })
  507. })
  508. },
  509. getMeterDetails(){
  510. API.meterDetails({
  511. meterId:this.FormData.meterId
  512. }).then((response) => {
  513. this.meterDetail=response.data.meter;
  514. this.personInfo=this.carhelp.getPersonInfo()
  515. }).catch(error => {
  516. uni.showToast({
  517. title: error,
  518. icon: "none"
  519. })
  520. })
  521. },
  522. getTimeSlotStatistics(interval){
  523. if(!interval){
  524. uni.showLoading({
  525. title: "加载中",
  526. mask: true,
  527. })
  528. }
  529. this.queryDay=parseUnixTime(newDate(this.FormData2.queryDate), '{y}年{m}月{d}日');
  530. API.timeSlotStatistics(this.FormData2).then((response) => {
  531. if(!interval){
  532. uni.hideLoading();
  533. }
  534. this.hourMap=response.data.hourMap
  535. this.sumQuantity=response.data.kwhMap.kwh
  536. this.sumFee=response.data.kwhMap.fee
  537. this.getPle(this.hourMap,interval)
  538. }).catch(error => {
  539. uni.showToast({
  540. title: error,
  541. icon: "none"
  542. })
  543. })
  544. },
  545. getPle(list,interval){
  546. if (!this.myChart) {
  547. this.myChart = echarts.init(document.getElementById('pieEcharts'),null,{
  548. width:uni.upx2px(700),height:uni.upx2px(480)
  549. });
  550. }
  551. if(!interval){
  552. this.myChart.clear();
  553. }
  554. var data1=[];
  555. var data2=[];
  556. for(var i in list){
  557. data1.push(i)
  558. data2.push(list[i].kwh)
  559. }
  560. var axisLabel={
  561. rotate:40,
  562. interval:0,
  563. textStyle: {
  564. color: "#333"
  565. }
  566. }
  567. if(data1.length<4){
  568. axisLabel={
  569. interval:0,
  570. textStyle: {
  571. color: "#333"
  572. },
  573. }
  574. }
  575. var headitemby=""
  576. var showkey = "";
  577. var option = {
  578. tooltip: {
  579. trigger: 'axis',
  580. formatter: (value) => {
  581. var name = value[0].name;
  582. var obj=list[name]
  583. var text= `<p>${name}</p>`
  584. if(obj.electricityPrice!=undefined){
  585. text+=`<p>电价:${obj.electricityPrice}元/度</p>`
  586. }
  587. if(obj.kwh!=undefined){
  588. text+=`<p>电量:${obj.kwh}度</p>`
  589. }
  590. if(obj.amount!=undefined){
  591. text+=` <p>电费:${obj.amount}元</p>`
  592. }
  593. return text
  594. }
  595. },
  596. grid: {
  597. top: 20,
  598. left: 5,
  599. right: 10,
  600. bottom: 20,
  601. containLabel: true
  602. },
  603. xAxis: {
  604. type: 'category',
  605. data: data1,
  606. axisLabel: axisLabel,
  607. },
  608. yAxis: {
  609. type: 'value',
  610. },
  611. series: [
  612. {
  613. name: '电量',
  614. data: data2,
  615. type: 'bar',
  616. label: {
  617. show: true,
  618. position: 'top',
  619. color: '#5C7BD9'
  620. }
  621. }
  622. ]
  623. }
  624. console.log(option)
  625. this.myChart.setOption(option);
  626. },
  627. switchBtnApiMethod(node,key){
  628. uni.showLoading({
  629. title: "加载中",
  630. mask: true,
  631. })
  632. API.remoteSwitch({
  633. meterId:node.id,
  634. enabled:key
  635. }).then((res) => {
  636. uni.hideLoading();
  637. node.switchStatus=key
  638. }).catch(error => {
  639. node.switchStatus=!key
  640. uni.showToast({
  641. title: error,
  642. icon: "none"
  643. })
  644. })
  645. },
  646. switchBtnApi(node,key){
  647. uni.showModal({
  648. confirmColor:`${key?'#3CC51F':'red'}`,
  649. confirmText:`${key?'开启':'关闭'}`,
  650. content: `确认是否要"${key?'开启':'关闭'}"${node.name}`,
  651. title: "提示",
  652. success:res=> {
  653. if(res.confirm){
  654. this.switchBtnApiMethod(node,key);
  655. }else{
  656. node.switchStatus=!key
  657. }
  658. }
  659. })
  660. console.log(node,key)
  661. },
  662. getWaterMeterList(){
  663. API_water.waterMeterList().then((response) => {
  664. uni.hideLoading();
  665. this.waterMeterList=response.data.meterList
  666. this.callback()
  667. }).catch(error => {
  668. uni.showToast({
  669. title: error,
  670. icon: "none"
  671. })
  672. })
  673. },
  674. getcomponentsMeterList(){
  675. uni.showLoading({
  676. title: "加载中",
  677. mask: true,
  678. })
  679. //API.componentsMeterList().then((response) => {
  680. uni.hideLoading();
  681. //this.componentsMeterList=response.data.meterList
  682. if(this.componentsMeterList.length){
  683. var index=0;
  684. for(var i in this.componentsMeterList){
  685. var obj=this.componentsMeterList[i]
  686. if(obj.id==this.meterId){
  687. index=i
  688. this.tabsFrom.show1Index=i;
  689. }
  690. }
  691. this.electricity=this.componentsMeterList[index];
  692. this.FormData.meterId=this.componentsMeterList[index].id
  693. this.FormData2.meterId=this.componentsMeterList[index].id
  694. this.title=this.componentsMeterList[index].name
  695. // {
  696. // label: '全部类型',
  697. // value: '',
  698. // }
  699. this.tabsFrom.selector1=[]
  700. this.tabsFrom.selector1=this.componentsMeterList.map(item=>{
  701. return {
  702. label:item.name,
  703. value:item.id
  704. }
  705. })
  706. this.getMeterDetails();
  707. this.getTimeSlotStatistics()
  708. this.getElectricityStatistics()
  709. }else{
  710. }
  711. //this.getWaterMeterList()
  712. // }).catch(error => {
  713. // uni.showToast({
  714. // title: error,
  715. // icon: "none"
  716. // })
  717. // })
  718. },
  719. selector2confirm(e){
  720. this.tabsFrom.show2Text=e.year+"年"+e.month+"月"
  721. this.tabsFrom.show2Index=e.year+"-"+e.month
  722. if(e.day){
  723. this.tabsFrom.show2Text+=e.day+"日"
  724. this.tabsFrom.show2Index+='-'+e.day
  725. this.queryDate(this.tabsFrom.show2Index,true)
  726. }else{
  727. this.queryDate(this.tabsFrom.show2Index,false)
  728. }
  729. },
  730. selector2reset(e){
  731. console.log(e)
  732. this.tabsFrom.show2Text='全部时间'
  733. this.tabsFrom.show2Index='';
  734. if(this.params.day){
  735. this.FormData2.queryDate=parseUnixTime(new Date(), '{y}-{m}-{d}')
  736. this.getTimeSlotStatistics()
  737. }else{
  738. this.oldvalue="4";
  739. this.selector2cancel()
  740. }
  741. },
  742. // 选中某个单选框时,由radio时触发
  743. radioChange(e) {
  744. //console.log(e);
  745. },
  746. // 选中任一radio时,由radio-group触发
  747. selector2cancel(){
  748. this.value=this.oldvalue;
  749. // this.FormData.type=this.value
  750. // this.getElectricityStatistics()
  751. },
  752. radioGroupChange(e) {
  753. console.log(e);
  754. this.oldvalue= this.FormData.type;
  755. this.FormData.type=e
  756. if(e==10){
  757. this.tabsFrom.show2=true
  758. this.params.day=false
  759. }else{
  760. this.getElectricityStatistics()
  761. }
  762. }
  763. }
  764. };
  765. </script>
  766. <style lang="scss" scoped>
  767. page {
  768. padding-bottom: 100rpx;
  769. }
  770. .background-padding-bottom{
  771. padding-bottom: 100rpx;
  772. }
  773. .background {
  774. background-color: rgba(22, 119, 255, 1);
  775. ::v-deep.u-border-bottom:after {
  776. border: none;
  777. }
  778. .u-nav-slot {
  779. margin-right: 32rpx;
  780. .img {
  781. width: 48rpx;
  782. height: 48rpx;
  783. vertical-align: middle;
  784. }
  785. }
  786. }
  787. .background::after {
  788. content: '';
  789. position: absolute;
  790. width: 160%;
  791. height: 80px;
  792. background-color: rgba(22, 119, 255, 1);
  793. left: -30%;
  794. border-radius: 0 0 50% 50%;
  795. }
  796. // // 日期
  797. .date-box {
  798. display: flex;
  799. align-items: center;
  800. justify-content: space-between;
  801. margin: 24rpx 32rpx;
  802. .item {
  803. border-radius: 8px;
  804. background-color: rgba(255, 255, 255, 0.1);
  805. border: 1px solid rgba(255, 255, 255, 0.15);
  806. width: 120rpx;
  807. height: 120rpx;
  808. color: #fff;
  809. text-align: center;
  810. display: flex;
  811. flex-direction: column;
  812. justify-content: center;
  813. align-items: center;
  814. .date {
  815. font-size: 40rpx;
  816. }
  817. .dot{
  818. width: 10rpx;
  819. height: 10rpx;
  820. background-color: rgba(255,150,0,1);
  821. border-radius: 999px;
  822. bottom: -5rpx;
  823. left: 50%;
  824. transform: translateX(-50%);
  825. }
  826. }
  827. .item-today {
  828. background-color: rgba(255, 255, 255, 1);
  829. position: relative;
  830. .date {
  831. color: rgba(22, 119, 255, 1);
  832. }
  833. .week {
  834. color: rgba(16, 16, 16, 1);
  835. }
  836. }
  837. }
  838. // 用电量
  839. .electricity-consumption {
  840. background-color: #fff;
  841. padding: 40rpx 32rpx 0rpx;
  842. border-radius: 8px;
  843. margin: -48rpx 32rpx 0;
  844. position: relative;
  845. border: 1px solid rgba(255,255,255,1);
  846. background: linear-gradient(180deg, rgba(187,216,255,1) 0%,rgba(255,255,255,1) 63%);
  847. // 统计
  848. .statistics-content{
  849. display: flex;
  850. align-items: center;
  851. justify-content: space-between;
  852. .statistics-item{
  853. width: 300rpx;
  854. padding: 24rpx 0 24rpx 24rpx;
  855. border-radius: 8px;
  856. box-shadow: 0px 0px 8px 0px rgba(22,119,255,0.3);
  857. background-color: #fff;
  858. }
  859. .item-title{
  860. color: rgba(22,119,255,1);
  861. font-size: 32rpx;
  862. display: flex;
  863. align-items: center;
  864. font-weight: bold;
  865. .img{
  866. width: 32rpx;
  867. height: 32rpx;
  868. vertical-align: middle;
  869. margin-right: 4rpx;
  870. }
  871. }
  872. .item-title2{
  873. color: rgba(129,97,255,1);
  874. }
  875. .item-value{
  876. color: rgba(16,16,16,1);
  877. font-size: 48rpx;
  878. font-weight: bold;
  879. margin-top: 8rpx;
  880. overflow: hidden;
  881. white-space: nowrap;
  882. text-overflow: ellipsis;
  883. text{
  884. display: inline-block;
  885. width: 80%;
  886. margin-right: 4rpx;
  887. }
  888. }
  889. }
  890. .title{
  891. display: flex;
  892. justify-content: space-between;
  893. .titleUnit{
  894. color: rgba(16,16,16,1);
  895. font-size: 36rpx;
  896. }
  897. .titleElectricity{
  898. color:#333333 100%;
  899. font-size: 28rpx;
  900. .spanradius{
  901. width: 20rpx;
  902. height: 20rpx;
  903. background-color: #FF7B00 ;
  904. color: #FF7B00 ;
  905. margin-right: 4rpx;
  906. border-radius: 50%; /* 将正方形变成圆形 */
  907. display: inline-block;
  908. }
  909. .normal{
  910. background-color: #00B962 ;
  911. color: #00B962 ;
  912. }
  913. }
  914. }
  915. .degree{
  916. display: flex;
  917. margin-top: 32rpx;
  918. .item{
  919. margin-right: 6rpx;
  920. text-align: center;
  921. .item-text{
  922. color: rgba(16,16,16,1);
  923. }
  924. .item-number{
  925. margin-top: 24rpx;
  926. width: 72rpx;
  927. height: 96rpx;
  928. background-color: rgba(16,16,16,1);
  929. color: #fff;
  930. font-size: 72rpx;
  931. }
  932. .decimal{
  933. background-color: #900005;
  934. }
  935. }
  936. }
  937. // .tab {
  938. // width: 240rpx;
  939. // height: 0;
  940. // border-width: 0px 48rpx 72rpx 0px;
  941. // border-radius: 8px 8px 0 0;
  942. // border-style: none solid solid none;
  943. // border-color: transparent transparent #fff;
  944. // position: absolute;
  945. // top: -72rpx;
  946. // left: 0rpx;
  947. // right: 0rpx;
  948. // color: #101010;
  949. // color: rgba(16, 16, 16, 1);
  950. // text-align: center;
  951. // line-height: 72rpx;
  952. // z-index: 999;
  953. // text-indent: 16rpx;
  954. // }
  955. // .tab2 {
  956. // width: 240rpx;
  957. // height: 0;
  958. // border-width: 0px 48rpx 72rpx 0px;
  959. // border-radius: 8px 8px 0 0;
  960. // border-style: none solid solid none;
  961. // border-color: transparent transparent #D4DBE4;
  962. // position: absolute;
  963. // top: -72rpx;
  964. // left: 210rpx;
  965. // right: 0rpx;
  966. // color: #777777;
  967. // text-align: center;
  968. // line-height: 72rpx;
  969. // text-indent: 16rpx;
  970. // }
  971. .radio {
  972. margin-top: 24rpx;
  973. padding-left: 8rpx;
  974. ::v-deep.u-radio {
  975. margin-bottom: 8px;
  976. min-width: 25% !important;
  977. }
  978. ::v-deep.u-radio__label{
  979. margin-left: 24rpx;
  980. font-size: 28rpx; ;
  981. }
  982. }
  983. }
  984. //各时段用电量
  985. .electricity-chart {
  986. margin: 24rpx 32rpx;
  987. padding: 40rpx 0rpx;
  988. background-color: #fff;
  989. border-radius: 8px;
  990. .title {
  991. display: flex;
  992. align-items: center;
  993. justify-content: space-between;
  994. padding: 0 32rpx;
  995. margin-bottom: 40rpx;
  996. .icon {
  997. width: 36rpx;
  998. height: 36rpx;
  999. background-color: rgba(22, 119, 255, 1);
  1000. border: 6px solid rgba(182, 212, 255, 1);
  1001. border-radius: 100px;
  1002. }
  1003. .text {
  1004. display: flex;
  1005. align-items: center;
  1006. color: rgba(51, 51, 51, 1);
  1007. font-size: 36rpx;
  1008. margin-left: 16rpx;
  1009. }
  1010. .queryDayClass{
  1011. border: 1px solid #999;
  1012. border-radius: 3px;
  1013. padding: 4rpx 8rpx;
  1014. }
  1015. }
  1016. .chart {
  1017. width: 100%;
  1018. //height: 440rpx;
  1019. .img {
  1020. width: 100%;
  1021. height: 440rpx;
  1022. }
  1023. }
  1024. }
  1025. // 设备信息弹窗
  1026. .equipment-popup {
  1027. .content {
  1028. padding: 32rpx;
  1029. .headline {
  1030. color: rgba(16, 16, 16, 1);
  1031. font-size: 36rpx;
  1032. text-align: center;
  1033. font-weight: bold;
  1034. margin-bottom: 24rpx;
  1035. }
  1036. .infos {
  1037. padding-bottom: 100rpx;
  1038. .item:last-of-type {
  1039. border: none;
  1040. }
  1041. .item {
  1042. display: flex;
  1043. align-items: center;
  1044. line-height: 48rpx;
  1045. padding: 24rpx 0;
  1046. border-bottom: 1px solid #cccccc;
  1047. .item-title {
  1048. color: rgba(51, 51, 51, 1);
  1049. width: 200rpx;
  1050. }
  1051. .item-value {
  1052. color: #666666;
  1053. flex: 1;
  1054. margin-left: 16rpx;
  1055. display: flex;
  1056. align-items: center;
  1057. justify-content: space-between;
  1058. .img{
  1059. width: 32rpx;
  1060. height: 32rpx;
  1061. transform: rotate(90deg);
  1062. margin-left: 96rpx;
  1063. }
  1064. }
  1065. }
  1066. }
  1067. .get {
  1068. height: 80rpx;
  1069. line-height: 80rpx;
  1070. border-radius: 4px;
  1071. background-color: rgba(22, 119, 255, 1);
  1072. color: rgba(255, 255, 255, 1);
  1073. font-size: 32rpx;
  1074. }
  1075. }
  1076. }
  1077. // 异常
  1078. .abnormal {
  1079. margin: 24rpx 32rpx;
  1080. padding: 40rpx 32rpx;
  1081. background-color: #fff;
  1082. border-radius: 8px;
  1083. .headline {
  1084. display: flex;
  1085. align-items: center;
  1086. justify-content: space-between;
  1087. }
  1088. .title {
  1089. display: flex;
  1090. align-items: center;
  1091. .icon {
  1092. width: 36rpx;
  1093. height: 36rpx;
  1094. background-color: rgba(22, 119, 255, 1);
  1095. border: 6px solid rgba(182, 212, 255, 1);
  1096. border-radius: 100px;
  1097. }
  1098. .text {
  1099. color: rgba(51, 51, 51, 1);
  1100. font-size: 36rpx;
  1101. margin-left: 16rpx;
  1102. }
  1103. }
  1104. .more {
  1105. color: #838383;
  1106. font-size: 24rpx
  1107. }
  1108. .details {
  1109. margin-top: 40rpx;
  1110. .item {
  1111. display: flex;
  1112. align-items: center;
  1113. justify-content: space-between;
  1114. margin-top: 32rpx;
  1115. .name {
  1116. color: rgba(51, 51, 51, 1);
  1117. }
  1118. .time {
  1119. color: rgba(119, 119, 119, 1);
  1120. font-size: 24rpx;
  1121. }
  1122. }
  1123. }
  1124. }
  1125. // 能源监测
  1126. .energy-inspection,.data-analysis {
  1127. margin: 24rpx 32rpx;
  1128. padding: 40rpx 32rpx;
  1129. background-color: #fff;
  1130. border-radius: 8px;
  1131. .title {
  1132. display: flex;
  1133. align-items: center;
  1134. .text {
  1135. color: rgba(51, 51, 51, 1);
  1136. font-size: 36rpx;
  1137. margin-left: 16rpx;
  1138. }
  1139. }
  1140. .grid {
  1141. .icon {
  1142. width: 128rpx;
  1143. height: 128rpx;
  1144. border-radius: 12px;
  1145. background-color: rgba(35, 186, 178, 1);
  1146. display: flex;
  1147. align-items: center;
  1148. justify-content: center;
  1149. margin-bottom: 16rpx;
  1150. .img {
  1151. width: 80rpx;
  1152. height: 80rpx;
  1153. }
  1154. }
  1155. .icon2{
  1156. background-color: rgba(42,186,72,1);
  1157. }
  1158. .icon3{
  1159. background-color: rgba(78,96,246,1);
  1160. }
  1161. .icon4{
  1162. background-color: rgba(22,119,255,1);
  1163. }
  1164. .icon5{
  1165. background-color: rgba(35,186,178,1);
  1166. }
  1167. .icon6{
  1168. background-color: rgba(42,186,72,1);
  1169. }
  1170. .icon7{
  1171. background-color: rgba(22,119,255,1);
  1172. }
  1173. .icon8{
  1174. background-color: rgba(35,186,178,1);
  1175. }
  1176. .grid-text {
  1177. color: #333333;
  1178. }
  1179. }
  1180. }
  1181. .icon-title{
  1182. width: 36rpx;
  1183. height: 36rpx;
  1184. background-color: rgba(182, 212, 255, 1);
  1185. border: 6px solid rgba(22, 119, 255, 1);
  1186. border-radius: 100px;
  1187. }
  1188. .equipment-information {
  1189. margin: 24rpx 32rpx;
  1190. padding: 40rpx 0rpx;
  1191. background-color: #fff;
  1192. border-radius: 8px;
  1193. .title {
  1194. display: flex;
  1195. align-items: center;
  1196. padding: 0 32rpx;
  1197. margin-bottom: 40rpx;
  1198. .text {
  1199. display: flex;
  1200. align-items: center;
  1201. color: rgba(51, 51, 51, 1);
  1202. font-size: 36rpx;
  1203. margin-left: 16rpx;
  1204. font-weight: bold;
  1205. }
  1206. .date {
  1207. margin-left: auto;
  1208. }
  1209. .more {
  1210. color: #838383;
  1211. font-size: 24rpx;
  1212. margin-left: auto;
  1213. }
  1214. }
  1215. .chart {
  1216. width: 100%;
  1217. height: 440rpx;
  1218. .img {
  1219. width: 100%;
  1220. height: 440rpx;
  1221. }
  1222. }
  1223. .infos {
  1224. padding: 0 32rpx;
  1225. display: flex;
  1226. justify-content: space-between;
  1227. text-align: center;
  1228. .border {
  1229. margin: auto 0;
  1230. height: 70rpx;
  1231. width: 2rpx;
  1232. background-color: rgba(204, 204, 204, 1);
  1233. ;
  1234. }
  1235. .item-title {
  1236. color: rgba(119, 119, 119, 1);
  1237. }
  1238. .item-value {
  1239. color: rgba(16, 16, 16, 1);
  1240. font-size: 32rpx;
  1241. margin-top: 16rpx;
  1242. }
  1243. }
  1244. }
  1245. // 远程控制电源开关
  1246. .control{
  1247. display: flex;
  1248. align-items: center;
  1249. justify-content: space-between;
  1250. margin: 24rpx 32rpx;
  1251. padding: 40rpx 32rpx;
  1252. background-color: #fff;
  1253. border-radius: 8px;
  1254. .text{
  1255. color: rgba(51,51,51,1);
  1256. font-size: 36rpx;
  1257. font-weight: bold;
  1258. }
  1259. .icon{
  1260. img{
  1261. width: 64rpx;
  1262. height: 64rpx;
  1263. }
  1264. }
  1265. }
  1266. </style>