water.vue 32 KB

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