electricity.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470
  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">
  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. };
  359. },
  360. props:{
  361. showtab:false,
  362. },
  363. onLoad(op) {
  364. this.init(op)
  365. // for(var i =4;i>=0;i--){
  366. // var time=new Date(beforeTimeStamp(i,new Date()));
  367. // this.topDate.push({
  368. // num:time.getDate(),
  369. // week:i==0?'今日':getWeek(time),
  370. // today:i,
  371. // queryDate:parseUnixTime(time, '{y}-{m}-{d}')
  372. // })
  373. // }
  374. // console.log( this.topDate)
  375. },
  376. beforeDestroy() {
  377. this.clearTimer(); // 组件销毁前清除定时器
  378. this.intervalReady=false;
  379. console.log( "组件销毁前清除定时器")
  380. },
  381. methods: {
  382. initSet(id,list){
  383. this.meterId=id
  384. this.componentsMeterList=list;
  385. },
  386. init(){
  387. this.current=0
  388. this.endYear=new Date().getFullYear()
  389. this.FormData.queryDate=parseUnixTime(new Date(), '{y}-{m}-{d}')
  390. this.FormData2.queryDate=parseUnixTime(new Date(), '{y}-{m}-{d}')
  391. this.FormData.type=4
  392. this.getcomponentsMeterList();
  393. },
  394. clearTimer() {
  395. if (this.intervalId) {
  396. clearInterval(this.intervalId); // 清除定时器
  397. this.intervalId = null; // 重置定时器ID
  398. }
  399. },
  400. startInterval(){
  401. this.clearTimer(); // 组件销毁前清除定时器
  402. this.intervalId = setInterval(() => {
  403. // 每隔5秒运行的代码
  404. console.log('这段代码每隔5秒运行一次');
  405. this.getTimeSlotStatistics(true)
  406. this.getElectricityStatistics(true)
  407. }, 60*1000);
  408. },
  409. titleCk(){
  410. if(this.componentsMeterList.length>1){
  411. this.tabsFrom.show1=true
  412. }
  413. },
  414. selector1confirm(e){
  415. var index=e[0]
  416. this.tabsFrom.show1Index=index
  417. this.tabsFrom.show1Text=this.tabsFrom.selector1[index].label
  418. this.title=this.tabsFrom.selector1[index].label
  419. this.FormData.meterId=this.tabsFrom.selector1[index].value
  420. this.FormData.queryDate=parseUnixTime(new Date(), '{y}-{m}-{d}')
  421. this.FormData2.meterId=this.tabsFrom.selector1[index].value
  422. this.FormData2.queryDate=parseUnixTime(new Date(), '{y}-{m}-{d}')
  423. this.FormData.type=4
  424. this.value="4"
  425. this.electricity=this.componentsMeterList[index]
  426. this.getMeterDetails()
  427. this.getTimeSlotStatistics()
  428. this.getElectricityStatistics()
  429. },
  430. callback(){
  431. if(this.componentsMeterList.length==0&&this.waterMeterList.length==0){
  432. uni.showModal({
  433. title:"提示",
  434. content:"未绑定设备,请联系管理员!",
  435. showCancel:false,
  436. success() {
  437. uni.navigateBack()
  438. }
  439. })
  440. }
  441. },
  442. queryDate(queryTime,day){
  443. if(day){
  444. this.FormData2.queryDate=queryTime;
  445. //this.FormData2.type =day?"9":"10"
  446. //this.value="-1"
  447. this.getTimeSlotStatistics()
  448. }else{
  449. this.FormData.queryDate=queryTime+"-01";
  450. this.FormData.type ="10"
  451. //this.value="-1"
  452. this.list[5].name = queryTime;
  453. this.getElectricityStatistics()
  454. }
  455. },
  456. getElectricityStatistics(interval){
  457. // if(!this.intervalReady){
  458. // return
  459. // }
  460. if(!interval){
  461. uni.showLoading({
  462. title: "加载中",
  463. mask: true,
  464. })
  465. }
  466. var obj={
  467. ...this.FormData
  468. }
  469. if(obj.type!=10){
  470. this.list[5].name = '指定月份';
  471. }
  472. API.electricityStatistics(obj).then((response) => {
  473. if(!interval){
  474. uni.hideLoading();
  475. }
  476. this.showTop = [0, 0, 0, 0, 0, 0, 0, 0]
  477. var electricity = response.data.kwhMap.kwh+"";
  478. this.electricityNum = response.data.kwhMap.kwh;
  479. this.fee = response.data.kwhMap.fee;
  480. if (electricity) {
  481. var sz = electricity.split(".")
  482. var str1 = sz[0];
  483. var str2 = [];
  484. if (sz.length > 1) {
  485. str2 = sz[1];
  486. this.showTop[7] = str2[0];
  487. }
  488. var j = 0;
  489. for (var i in str1) {
  490. if (i != undefined) {
  491. this.showTop[6 - str1.length + j + 1] = str1[i]
  492. }
  493. j++;
  494. }
  495. this.$forceUpdate()
  496. }
  497. //this.componentsMeterList=response.data.meterList
  498. if(!interval){
  499. this.startInterval(); // 组件挂载后开始间隔
  500. }
  501. }).catch(error => {
  502. uni.showToast({
  503. title: error,
  504. icon: "none"
  505. })
  506. })
  507. },
  508. getMeterDetails(){
  509. API.meterDetails({
  510. meterId:this.FormData.meterId
  511. }).then((response) => {
  512. this.meterDetail=response.data.meter;
  513. }).catch(error => {
  514. uni.showToast({
  515. title: error,
  516. icon: "none"
  517. })
  518. })
  519. },
  520. getTimeSlotStatistics(interval){
  521. if(!interval){
  522. uni.showLoading({
  523. title: "加载中",
  524. mask: true,
  525. })
  526. }
  527. this.queryDay=parseUnixTime(newDate(this.FormData2.queryDate), '{y}年{m}月{d}日');
  528. API.timeSlotStatistics(this.FormData2).then((response) => {
  529. if(!interval){
  530. uni.hideLoading();
  531. }
  532. this.hourMap=response.data.hourMap
  533. this.sumQuantity=response.data.kwhMap.kwh
  534. this.sumFee=response.data.kwhMap.fee
  535. this.getPle(this.hourMap,interval)
  536. }).catch(error => {
  537. uni.showToast({
  538. title: error,
  539. icon: "none"
  540. })
  541. })
  542. },
  543. getPle(list,interval){
  544. if (!this.myChart) {
  545. this.myChart = echarts.init(document.getElementById('pieEcharts'),null,{
  546. width:uni.upx2px(700),height:uni.upx2px(480)
  547. });
  548. }
  549. if(!interval){
  550. this.myChart.clear();
  551. }
  552. var data1=[];
  553. var data2=[];
  554. for(var i in list){
  555. data1.push(i)
  556. data2.push(list[i].kwh)
  557. }
  558. var axisLabel={
  559. rotate:40,
  560. interval:0,
  561. textStyle: {
  562. color: "#333"
  563. }
  564. }
  565. if(data1.length<4){
  566. axisLabel={
  567. interval:0,
  568. textStyle: {
  569. color: "#333"
  570. },
  571. }
  572. }
  573. var headitemby=""
  574. var showkey = "";
  575. var option = {
  576. tooltip: {
  577. trigger: 'axis',
  578. formatter: (value) => {
  579. var name = value[0].name;
  580. var obj=list[name]
  581. var text= `<p>${name}</p>`
  582. if(obj.electricityPrice!=undefined){
  583. text+=`<p>电价:${obj.electricityPrice}元/度</p>`
  584. }
  585. if(obj.kwh!=undefined){
  586. text+=`<p>电量:${obj.kwh}度</p>`
  587. }
  588. if(obj.amount!=undefined){
  589. text+=` <p>电费:${obj.amount}元</p>`
  590. }
  591. return text
  592. }
  593. },
  594. grid: {
  595. top: 20,
  596. left: 5,
  597. right: 10,
  598. bottom: 20,
  599. containLabel: true
  600. },
  601. xAxis: {
  602. type: 'category',
  603. data: data1,
  604. axisLabel: axisLabel,
  605. },
  606. yAxis: {
  607. type: 'value',
  608. },
  609. series: [
  610. {
  611. name: '电量',
  612. data: data2,
  613. type: 'bar',
  614. label: {
  615. show: true,
  616. position: 'top',
  617. color: '#5C7BD9'
  618. }
  619. }
  620. ]
  621. }
  622. console.log(option)
  623. this.myChart.setOption(option);
  624. },
  625. switchBtnApiMethod(node,key){
  626. uni.showLoading({
  627. title: "加载中",
  628. mask: true,
  629. })
  630. API.remoteSwitch({
  631. meterId:node.id,
  632. enabled:key
  633. }).then((res) => {
  634. uni.hideLoading();
  635. node.switchStatus=key
  636. }).catch(error => {
  637. uni.showToast({
  638. title: error,
  639. icon: "none"
  640. })
  641. })
  642. },
  643. switchBtnApi(node,key){
  644. uni.showModal({
  645. confirmColor:`${key?'#3CC51F':'red'}`,
  646. confirmText:`${key?'开启':'关闭'}`,
  647. content: `确认是否要"${key?'开启':'关闭'}"${node.name}`,
  648. title: "提示",
  649. success:res=> {
  650. if(res.confirm){
  651. this.switchBtnApiMethod(node,key);
  652. }else{
  653. node.switchStatus=!key
  654. }
  655. }
  656. })
  657. console.log(node,key)
  658. },
  659. getWaterMeterList(){
  660. API_water.waterMeterList().then((response) => {
  661. uni.hideLoading();
  662. this.waterMeterList=response.data.meterList
  663. this.callback()
  664. }).catch(error => {
  665. uni.showToast({
  666. title: error,
  667. icon: "none"
  668. })
  669. })
  670. },
  671. getcomponentsMeterList(){
  672. uni.showLoading({
  673. title: "加载中",
  674. mask: true,
  675. })
  676. //API.componentsMeterList().then((response) => {
  677. uni.hideLoading();
  678. //this.componentsMeterList=response.data.meterList
  679. if(this.componentsMeterList.length){
  680. var index=0;
  681. for(var i in this.componentsMeterList){
  682. var obj=this.componentsMeterList[i]
  683. if(obj.id==this.meterId){
  684. index=i
  685. this.tabsFrom.show1Index=i;
  686. }
  687. }
  688. this.electricity=this.componentsMeterList[index];
  689. this.FormData.meterId=this.componentsMeterList[index].id
  690. this.FormData2.meterId=this.componentsMeterList[index].id
  691. this.title=this.componentsMeterList[index].name
  692. // {
  693. // label: '全部类型',
  694. // value: '',
  695. // }
  696. this.tabsFrom.selector1=[]
  697. this.tabsFrom.selector1=this.componentsMeterList.map(item=>{
  698. return {
  699. label:item.name,
  700. value:item.id
  701. }
  702. })
  703. this.getMeterDetails();
  704. this.getTimeSlotStatistics()
  705. this.getElectricityStatistics()
  706. }else{
  707. }
  708. //this.getWaterMeterList()
  709. // }).catch(error => {
  710. // uni.showToast({
  711. // title: error,
  712. // icon: "none"
  713. // })
  714. // })
  715. },
  716. selector2confirm(e){
  717. this.tabsFrom.show2Text=e.year+"年"+e.month+"月"
  718. this.tabsFrom.show2Index=e.year+"-"+e.month
  719. if(e.day){
  720. this.tabsFrom.show2Text+=e.day+"日"
  721. this.tabsFrom.show2Index+='-'+e.day
  722. this.queryDate(this.tabsFrom.show2Index,true)
  723. }else{
  724. this.queryDate(this.tabsFrom.show2Index,false)
  725. }
  726. },
  727. selector2reset(e){
  728. console.log(e)
  729. this.tabsFrom.show2Text='全部时间'
  730. this.tabsFrom.show2Index='';
  731. if(this.params.day){
  732. this.FormData2.queryDate=parseUnixTime(new Date(), '{y}-{m}-{d}')
  733. this.getTimeSlotStatistics()
  734. }else{
  735. this.oldvalue="4";
  736. this.selector2cancel()
  737. }
  738. },
  739. // 选中某个单选框时,由radio时触发
  740. radioChange(e) {
  741. //console.log(e);
  742. },
  743. // 选中任一radio时,由radio-group触发
  744. selector2cancel(){
  745. this.value=this.oldvalue;
  746. // this.FormData.type=this.value
  747. // this.getElectricityStatistics()
  748. },
  749. radioGroupChange(e) {
  750. console.log(e);
  751. this.oldvalue= this.FormData.type;
  752. this.FormData.type=e
  753. if(e==10){
  754. this.tabsFrom.show2=true
  755. this.params.day=false
  756. }else{
  757. this.getElectricityStatistics()
  758. }
  759. }
  760. }
  761. };
  762. </script>
  763. <style lang="scss" scoped>
  764. page {
  765. padding-bottom: 100rpx;
  766. }
  767. .background-padding-bottom{
  768. padding-bottom: 100rpx;
  769. }
  770. .background {
  771. background-color: rgba(22, 119, 255, 1);
  772. /deep/.u-border-bottom:after {
  773. border: none;
  774. }
  775. .u-nav-slot {
  776. margin-right: 32rpx;
  777. .img {
  778. width: 48rpx;
  779. height: 48rpx;
  780. vertical-align: middle;
  781. }
  782. }
  783. }
  784. .background::after {
  785. content: '';
  786. position: absolute;
  787. width: 160%;
  788. height: 80px;
  789. background-color: rgba(22, 119, 255, 1);
  790. left: -30%;
  791. border-radius: 0 0 50% 50%;
  792. }
  793. // // 日期
  794. .date-box {
  795. display: flex;
  796. align-items: center;
  797. justify-content: space-between;
  798. margin: 24rpx 32rpx;
  799. .item {
  800. border-radius: 8px;
  801. background-color: rgba(255, 255, 255, 0.1);
  802. border: 1px solid rgba(255, 255, 255, 0.15);
  803. width: 120rpx;
  804. height: 120rpx;
  805. color: #fff;
  806. text-align: center;
  807. display: flex;
  808. flex-direction: column;
  809. justify-content: center;
  810. align-items: center;
  811. .date {
  812. font-size: 40rpx;
  813. }
  814. .dot{
  815. width: 10rpx;
  816. height: 10rpx;
  817. background-color: rgba(255,150,0,1);
  818. border-radius: 999px;
  819. bottom: -5rpx;
  820. left: 50%;
  821. transform: translateX(-50%);
  822. }
  823. }
  824. .item-today {
  825. background-color: rgba(255, 255, 255, 1);
  826. position: relative;
  827. .date {
  828. color: rgba(22, 119, 255, 1);
  829. }
  830. .week {
  831. color: rgba(16, 16, 16, 1);
  832. }
  833. }
  834. }
  835. // 用电量
  836. .electricity-consumption {
  837. background-color: #fff;
  838. padding: 40rpx 32rpx 0rpx;
  839. border-radius: 8px;
  840. margin: -48rpx 32rpx 0;
  841. position: relative;
  842. border: 1px solid rgba(255,255,255,1);
  843. background: linear-gradient(180deg, rgba(187,216,255,1) 0%,rgba(255,255,255,1) 63%);
  844. // 统计
  845. .statistics-content{
  846. display: flex;
  847. align-items: center;
  848. justify-content: space-between;
  849. .statistics-item{
  850. width: 300rpx;
  851. padding: 24rpx 0 24rpx 24rpx;
  852. border-radius: 8px;
  853. box-shadow: 0px 0px 8px 0px rgba(22,119,255,0.3);
  854. background-color: #fff;
  855. }
  856. .item-title{
  857. color: rgba(22,119,255,1);
  858. font-size: 32rpx;
  859. display: flex;
  860. align-items: center;
  861. font-weight: bold;
  862. .img{
  863. width: 32rpx;
  864. height: 32rpx;
  865. vertical-align: middle;
  866. margin-right: 4rpx;
  867. }
  868. }
  869. .item-title2{
  870. color: rgba(129,97,255,1);
  871. }
  872. .item-value{
  873. color: rgba(16,16,16,1);
  874. font-size: 48rpx;
  875. font-weight: bold;
  876. margin-top: 8rpx;
  877. overflow: hidden;
  878. white-space: nowrap;
  879. text-overflow: ellipsis;
  880. text{
  881. display: inline-block;
  882. width: 80%;
  883. margin-right: 4rpx;
  884. }
  885. }
  886. }
  887. .title{
  888. display: flex;
  889. justify-content: space-between;
  890. .titleUnit{
  891. color: rgba(16,16,16,1);
  892. font-size: 36rpx;
  893. }
  894. .titleElectricity{
  895. color:#333333 100%;
  896. font-size: 28rpx;
  897. .spanradius{
  898. width: 20rpx;
  899. height: 20rpx;
  900. background-color: #FF7B00 ;
  901. color: #FF7B00 ;
  902. margin-right: 4rpx;
  903. border-radius: 50%; /* 将正方形变成圆形 */
  904. display: inline-block;
  905. }
  906. .normal{
  907. background-color: #00B962 ;
  908. color: #00B962 ;
  909. }
  910. }
  911. }
  912. .degree{
  913. display: flex;
  914. margin-top: 32rpx;
  915. .item{
  916. margin-right: 6rpx;
  917. text-align: center;
  918. .item-text{
  919. color: rgba(16,16,16,1);
  920. }
  921. .item-number{
  922. margin-top: 24rpx;
  923. width: 72rpx;
  924. height: 96rpx;
  925. background-color: rgba(16,16,16,1);
  926. color: #fff;
  927. font-size: 72rpx;
  928. }
  929. .decimal{
  930. background-color: #900005;
  931. }
  932. }
  933. }
  934. // .tab {
  935. // width: 240rpx;
  936. // height: 0;
  937. // border-width: 0px 48rpx 72rpx 0px;
  938. // border-radius: 8px 8px 0 0;
  939. // border-style: none solid solid none;
  940. // border-color: transparent transparent #fff;
  941. // position: absolute;
  942. // top: -72rpx;
  943. // left: 0rpx;
  944. // right: 0rpx;
  945. // color: #101010;
  946. // color: rgba(16, 16, 16, 1);
  947. // text-align: center;
  948. // line-height: 72rpx;
  949. // z-index: 999;
  950. // text-indent: 16rpx;
  951. // }
  952. // .tab2 {
  953. // width: 240rpx;
  954. // height: 0;
  955. // border-width: 0px 48rpx 72rpx 0px;
  956. // border-radius: 8px 8px 0 0;
  957. // border-style: none solid solid none;
  958. // border-color: transparent transparent #D4DBE4;
  959. // position: absolute;
  960. // top: -72rpx;
  961. // left: 210rpx;
  962. // right: 0rpx;
  963. // color: #777777;
  964. // text-align: center;
  965. // line-height: 72rpx;
  966. // text-indent: 16rpx;
  967. // }
  968. .radio {
  969. margin-top: 24rpx;
  970. padding-left: 8rpx;
  971. /deep/.u-radio {
  972. margin-bottom: 8px;
  973. min-width: 25% !important;
  974. }
  975. /deep/.u-radio__label{
  976. margin-left: 24rpx;
  977. font-size: 28rpx; ;
  978. }
  979. }
  980. }
  981. //各时段用电量
  982. .electricity-chart {
  983. margin: 24rpx 32rpx;
  984. padding: 40rpx 0rpx;
  985. background-color: #fff;
  986. border-radius: 8px;
  987. .title {
  988. display: flex;
  989. align-items: center;
  990. justify-content: space-between;
  991. padding: 0 32rpx;
  992. margin-bottom: 40rpx;
  993. .icon {
  994. width: 36rpx;
  995. height: 36rpx;
  996. background-color: rgba(22, 119, 255, 1);
  997. border: 6px solid rgba(182, 212, 255, 1);
  998. border-radius: 100px;
  999. }
  1000. .text {
  1001. display: flex;
  1002. align-items: center;
  1003. color: rgba(51, 51, 51, 1);
  1004. font-size: 36rpx;
  1005. margin-left: 16rpx;
  1006. }
  1007. .queryDayClass{
  1008. border: 1px solid #999;
  1009. border-radius: 3px;
  1010. padding: 4rpx 8rpx;
  1011. }
  1012. }
  1013. .chart {
  1014. width: 100%;
  1015. //height: 440rpx;
  1016. .img {
  1017. width: 100%;
  1018. height: 440rpx;
  1019. }
  1020. }
  1021. }
  1022. // 设备信息弹窗
  1023. .equipment-popup {
  1024. .content {
  1025. padding: 32rpx;
  1026. .headline {
  1027. color: rgba(16, 16, 16, 1);
  1028. font-size: 36rpx;
  1029. text-align: center;
  1030. font-weight: bold;
  1031. margin-bottom: 24rpx;
  1032. }
  1033. .infos {
  1034. padding-bottom: 100rpx;
  1035. .item:last-of-type {
  1036. border: none;
  1037. }
  1038. .item {
  1039. display: flex;
  1040. align-items: center;
  1041. line-height: 48rpx;
  1042. padding: 24rpx 0;
  1043. border-bottom: 1px solid #cccccc;
  1044. .item-title {
  1045. color: rgba(51, 51, 51, 1);
  1046. width: 200rpx;
  1047. }
  1048. .item-value {
  1049. color: #666666;
  1050. flex: 1;
  1051. margin-left: 16rpx;
  1052. display: flex;
  1053. align-items: center;
  1054. justify-content: space-between;
  1055. .img{
  1056. width: 32rpx;
  1057. height: 32rpx;
  1058. transform: rotate(90deg);
  1059. margin-left: 96rpx;
  1060. }
  1061. }
  1062. }
  1063. }
  1064. .get {
  1065. height: 80rpx;
  1066. line-height: 80rpx;
  1067. border-radius: 4px;
  1068. background-color: rgba(22, 119, 255, 1);
  1069. color: rgba(255, 255, 255, 1);
  1070. font-size: 32rpx;
  1071. }
  1072. }
  1073. }
  1074. // 异常
  1075. .abnormal {
  1076. margin: 24rpx 32rpx;
  1077. padding: 40rpx 32rpx;
  1078. background-color: #fff;
  1079. border-radius: 8px;
  1080. .headline {
  1081. display: flex;
  1082. align-items: center;
  1083. justify-content: space-between;
  1084. }
  1085. .title {
  1086. display: flex;
  1087. align-items: center;
  1088. .icon {
  1089. width: 36rpx;
  1090. height: 36rpx;
  1091. background-color: rgba(22, 119, 255, 1);
  1092. border: 6px solid rgba(182, 212, 255, 1);
  1093. border-radius: 100px;
  1094. }
  1095. .text {
  1096. color: rgba(51, 51, 51, 1);
  1097. font-size: 36rpx;
  1098. margin-left: 16rpx;
  1099. }
  1100. }
  1101. .more {
  1102. color: #838383;
  1103. font-size: 24rpx
  1104. }
  1105. .details {
  1106. margin-top: 40rpx;
  1107. .item {
  1108. display: flex;
  1109. align-items: center;
  1110. justify-content: space-between;
  1111. margin-top: 32rpx;
  1112. .name {
  1113. color: rgba(51, 51, 51, 1);
  1114. }
  1115. .time {
  1116. color: rgba(119, 119, 119, 1);
  1117. font-size: 24rpx;
  1118. }
  1119. }
  1120. }
  1121. }
  1122. // 能源监测
  1123. .energy-inspection,.data-analysis {
  1124. margin: 24rpx 32rpx;
  1125. padding: 40rpx 32rpx;
  1126. background-color: #fff;
  1127. border-radius: 8px;
  1128. .title {
  1129. display: flex;
  1130. align-items: center;
  1131. .text {
  1132. color: rgba(51, 51, 51, 1);
  1133. font-size: 36rpx;
  1134. margin-left: 16rpx;
  1135. }
  1136. }
  1137. .grid {
  1138. .icon {
  1139. width: 128rpx;
  1140. height: 128rpx;
  1141. border-radius: 12px;
  1142. background-color: rgba(35, 186, 178, 1);
  1143. display: flex;
  1144. align-items: center;
  1145. justify-content: center;
  1146. margin-bottom: 16rpx;
  1147. .img {
  1148. width: 80rpx;
  1149. height: 80rpx;
  1150. }
  1151. }
  1152. .icon2{
  1153. background-color: rgba(42,186,72,1);
  1154. }
  1155. .icon3{
  1156. background-color: rgba(78,96,246,1);
  1157. }
  1158. .icon4{
  1159. background-color: rgba(22,119,255,1);
  1160. }
  1161. .icon5{
  1162. background-color: rgba(35,186,178,1);
  1163. }
  1164. .icon6{
  1165. background-color: rgba(42,186,72,1);
  1166. }
  1167. .icon7{
  1168. background-color: rgba(22,119,255,1);
  1169. }
  1170. .icon8{
  1171. background-color: rgba(35,186,178,1);
  1172. }
  1173. .grid-text {
  1174. color: #333333;
  1175. }
  1176. }
  1177. }
  1178. .icon-title{
  1179. width: 36rpx;
  1180. height: 36rpx;
  1181. background-color: rgba(182, 212, 255, 1);
  1182. border: 6px solid rgba(22, 119, 255, 1);
  1183. border-radius: 100px;
  1184. }
  1185. .equipment-information {
  1186. margin: 24rpx 32rpx;
  1187. padding: 40rpx 0rpx;
  1188. background-color: #fff;
  1189. border-radius: 8px;
  1190. .title {
  1191. display: flex;
  1192. align-items: center;
  1193. padding: 0 32rpx;
  1194. margin-bottom: 40rpx;
  1195. .text {
  1196. display: flex;
  1197. align-items: center;
  1198. color: rgba(51, 51, 51, 1);
  1199. font-size: 36rpx;
  1200. margin-left: 16rpx;
  1201. font-weight: bold;
  1202. }
  1203. .date {
  1204. margin-left: auto;
  1205. }
  1206. .more {
  1207. color: #838383;
  1208. font-size: 24rpx;
  1209. margin-left: auto;
  1210. }
  1211. }
  1212. .chart {
  1213. width: 100%;
  1214. height: 440rpx;
  1215. .img {
  1216. width: 100%;
  1217. height: 440rpx;
  1218. }
  1219. }
  1220. .infos {
  1221. padding: 0 32rpx;
  1222. display: flex;
  1223. justify-content: space-between;
  1224. text-align: center;
  1225. .border {
  1226. margin: auto 0;
  1227. height: 70rpx;
  1228. width: 2rpx;
  1229. background-color: rgba(204, 204, 204, 1);
  1230. ;
  1231. }
  1232. .item-title {
  1233. color: rgba(119, 119, 119, 1);
  1234. }
  1235. .item-value {
  1236. color: rgba(16, 16, 16, 1);
  1237. font-size: 32rpx;
  1238. margin-top: 16rpx;
  1239. }
  1240. }
  1241. }
  1242. // 远程控制电源开关
  1243. .control{
  1244. display: flex;
  1245. align-items: center;
  1246. justify-content: space-between;
  1247. margin: 24rpx 32rpx;
  1248. padding: 40rpx 32rpx;
  1249. background-color: #fff;
  1250. border-radius: 8px;
  1251. .text{
  1252. color: rgba(51,51,51,1);
  1253. font-size: 36rpx;
  1254. font-weight: bold;
  1255. }
  1256. .icon{
  1257. img{
  1258. width: 64rpx;
  1259. height: 64rpx;
  1260. }
  1261. }
  1262. }
  1263. </style>