water.vue 32 KB

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