water.vue 32 KB

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