云链智安app
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136
  1. <template>
  2. <!-- <image src="/static/grf.gif" mode=""></image> -->
  3. <dLoading :status="loading" v-if="loading"></dLoading>
  4. <view class="container" v-if="!loading">
  5. <!-- <image class="swiper-item"
  6. src="https://esos-iot.bjdexn.cn/myminio/project/88861a6c1aa243878d02c3502bf8e2ab.jpg"
  7. mode="aspectFill"></image> -->
  8. <view class="container_navbar">
  9. <view class="container_top">
  10. </view>
  11. <uni-nav-bar color="#222" :border="false" :shadow="false" :fixed="true"
  12. backgroundColor="rgba(255, 255, 255, 0.3)" shadow left-icon="left" title="" @clickLeft="onclickLeft" />
  13. </view>
  14. <image class="account_numberimage" :src="URL" mode="aspectFill"></image>
  15. <view class="electricityprice">
  16. <view class="electricityprice_box">
  17. <view class="electricityprice_box1">
  18. {{$t('electricityprice.title')}}
  19. </view>
  20. <view class="electricityprice_box2">
  21. <view class="electricity_left">
  22. <text class="testbox">&#xe65b;</text>
  23. {{$t('electricityprice.area')}}
  24. </view>
  25. <view class="electricity_right">
  26. <picker @change="bindPickerChange" :value="arrayindex" range-key="provincename" :range="array"
  27. v-if="array.length > 0">
  28. <view class="uni-input">{{array[arrayindex].provincename}}
  29. <icon :type="value" size="26" />
  30. <text class="test">&#xe606;</text>
  31. </view>
  32. </picker>
  33. </view>
  34. </view>
  35. <view class="electricityprice_box2">
  36. <view class="electricity_left">
  37. <text class="testbox">&#xe631;</text>
  38. {{$t('electricityprice.electricity')}}
  39. </view>
  40. <view class="electricity_right">
  41. <picker @change="bindelectricity" :value="categoryindex" range-key="categoryname"
  42. :range="electricity" v-if="electricity.length > 0">
  43. <view class="uni-input">
  44. <view class="uni-electricity">{{electricity[categoryindex].categoryname}}</view>
  45. <icon :type="value" size="26" />
  46. <text class="test">&#xe606;</text>
  47. </view>
  48. </picker>
  49. </view>
  50. </view>
  51. <view class="electricityprice_box2">
  52. <view class="electricity_left">
  53. <text class="testbox">&#xe7a4;</text>
  54. {{$t('electricityprice.voltagelevel')}}
  55. </view>
  56. <view class="electricity_right">
  57. <picker @change="bindlevel" :value="levelindex" range-key="levelname" :range="voltage"
  58. v-if="voltage.length > 0">
  59. <view class="uni-input">{{voltage[levelindex].levelname}}
  60. <icon :type="value" size="26" />
  61. <text class="test">&#xe606;</text>
  62. </view>
  63. </picker>
  64. </view>
  65. </view>
  66. <view class="electricityprice_box2">
  67. <view class="electricity_left">
  68. <text class="testbox">&#xe679;</text>
  69. {{$t('electricityprice.selectdate')}}
  70. </view>
  71. <view class="electricity_right">
  72. <view class="datecalendar_2" @click="Dateselection">
  73. {{date}}
  74. <text class="test">&#xe606;</text>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. <view class="toptabbar">
  81. <view class="month">
  82. {{$t('electricityprice.monthlytime')}}
  83. <view class="month_box">
  84. <view class="month_title">
  85. <view class="month_title1">
  86. <view class="month_title111">
  87. {{$t('electricityprice.periodtime')}}
  88. </view>
  89. <view class="month_title11">
  90. {{$t('electricityprice.timesharing')}}
  91. </view>
  92. <view class="month_title11">
  93. {{$t('electricityprice.electricityprice')}}
  94. </view>
  95. </view>
  96. <view class="month_title2" v-for="item in chongdiandata.zuihoud.monthlyelectricityprice"
  97. key="index">
  98. <view class="month_title222">
  99. {{item.profit}}
  100. </view>
  101. <view class="month_title22">
  102. {{item.time}}
  103. </view>
  104. <view class="month_title22">
  105. {{item.value==0?'--':(item.value*1).toFixed(4)}}
  106. </view>
  107. </view>
  108. </view>
  109. <!-- 图表 -->
  110. <view class="qiun_data">
  111. <qiun-data-charts type="area" :opts="opts" :chartData="chartData" />
  112. </view>
  113. </view>
  114. </view>
  115. <!-- <view class="month">
  116. 五一节假日
  117. <view class="month_box">
  118. <view class="month_title">
  119. <view class="month_title1">
  120. <view class="month_title111">
  121. 时段
  122. </view>
  123. <view class="month_title11">
  124. 分时
  125. </view>
  126. <view class="month_title11">
  127. 电价
  128. </view>
  129. </view>
  130. <view class="month_title2" v-for="item in chongdiandata.holiday.monthlyelectricityprice" key="index">
  131. <view class="month_title222">
  132. {{item.profit}}
  133. </view>
  134. <view class="month_title22">
  135. {{item.time}}
  136. </view>
  137. <view class="month_title22">
  138. {{item.value||'--'}}
  139. </view>
  140. </view>
  141. </view>
  142. <view class="qiun_data">
  143. <qiun-data-charts type="area" :opts="opts51" :chartData="chartData51" />
  144. </view>
  145. </view>
  146. </view> -->
  147. <view class="month">
  148. <view class="Capacityneeded">
  149. {{$t('electricityprice.Trend')}}
  150. </view>
  151. <view class="month_box">
  152. <view class="month_title">
  153. <view class="month_title1">
  154. <view class="month_title11" v-for="item in chongdiandata.zuihoud.averageelectricityprice">
  155. {{item.profit}}
  156. </view>
  157. </view>
  158. <view class="month_title2">
  159. <view class="month_title22" v-for="item in chongdiandata.zuihoud.averageelectricityprice">
  160. {{item.value==0?'--': (item.value*1).toFixed(4)}}
  161. </view>
  162. </view>
  163. </view>
  164. <!-- 图表 -->
  165. <view class="qiun_data">
  166. <!-- <view class="qiun_title">
  167. {{tabIndex==0?$t('device.batteryStatus')+'(kWh)':$t('device.earnings')+'(元)'}}
  168. </view> -->
  169. <qiun-data-charts type="line" :opts="lineopts" :chartData="linechart" />
  170. </view>
  171. <view class="qiun_datatitle">
  172. {{$t('electricityprice.Spread')}}:{{(chongdiandata.zuihoud.max.provincemax.value*1).toFixed(6)}} 元/kWh
  173. </view>
  174. <view class="qiun_data">
  175. <view class="qiun_title">
  176. {{$t('electricityprice.monthly')}}
  177. </view>
  178. <qiun-data-charts type="column" :opts="optscolumn" :ontouch="true" :chartData="chartcolumn" />
  179. </view>
  180. </view>
  181. </view>
  182. <view class="month">
  183. <view class="Capacityneeded">
  184. {{$t('electricityprice.capacitycharge')}}
  185. </view>
  186. <view class="month_title">
  187. <view class="month_title1">
  188. <view class="month_title111">
  189. {{$t('electricityprice.electricitys')}}
  190. </view>
  191. <view class="month_title11">
  192. {{$t('electricityprice.energyCharge')}}
  193. </view>
  194. </view>
  195. <view class="month_title2">
  196. <view class="month_title222">
  197. {{$t('electricityprice.demandcharge')}}
  198. </view>
  199. <view class="month_title22">
  200. {{chongdiandata.zuihoud.pricechart.capacity==0?' -- ' :chongdiandata.zuihoud.pricechart.capacity}}{{$t('electricityprice.kVAmonth')}}
  201. </view>
  202. </view>
  203. <view class="month_title2">
  204. <view class="month_title222">
  205. {{$t('electricityprice.capacityprice')}}
  206. </view>
  207. <view class="month_title22">
  208. {{chongdiandata.zuihoud.pricechart.xucapacity==0?' -- ' :chongdiandata.zuihoud.pricechart.xucapacity}}{{$t('electricityprice.kWh_')}}
  209. </view>
  210. </view>
  211. </view>
  212. </view>
  213. <!-- 日用电价走势 -->
  214. <view class="month">
  215. <view class="Capacityneeded">
  216. {{$t('electricityprice.Profile')}}
  217. </view>
  218. <view class="Daysbox">
  219. <!-- <view class="Daystext" v-for="item in resultDays.daysArray" key="item">
  220. {{item}}
  221. </view> -->
  222. <top-tabbar :tabIndex="tabIndex" :tabBars="resultDays.daysArray" @toggleToptab="toggleTab"
  223. selectedBottomColor="#30c58d" selectedTextColor="#343434" textColor="#7d7e80"
  224. bgColor="#ffffff"></top-tabbar>
  225. </view>
  226. <view class="month_box">
  227. <view class="month_title">
  228. <view class="month_title1">
  229. <view class="month_title11" v-for="item in chongdiandata.zuihoud.averageelectricityprice">
  230. {{item.profit}}
  231. </view>
  232. </view>
  233. <view class="month_title2">
  234. <view class="month_title22" v-for="item in chongdiandata.zuihoud.averageelectricityprice">
  235. {{item.value==0?'--':(item.value*1).toFixed(4)}}
  236. </view>
  237. </view>
  238. </view>
  239. <!-- -->
  240. <view class="qiun_data">
  241. <qiun-data-charts type="line" :opts="daylineopts" :chartData="daylinechart" />
  242. </view>
  243. </view>
  244. </view>
  245. </view>
  246. <KDatePicker v-model="show" type="month" :modelValue="date" :defaultValue="date" :is-disabled="isDisabled" @change="handleChange"
  247. formatter="YYYY-MM" />
  248. </view>
  249. </template>
  250. <!-- -->
  251. <script>
  252. import request from '@/utils/request';
  253. import topTabbar from '@/components/top-tabbar.vue';
  254. import KDatePicker from '@/components/k-date-picker/KDatePicker.vue';
  255. import dLoading from '@/uni_modules/d-loading/components/d-loading/d-loading.vue'
  256. import {
  257. getMonthRange,
  258. getDays
  259. } from '@/utils/date.js';
  260. export default {
  261. components: {
  262. KDatePicker, // 注册组件
  263. topTabbar,
  264. dLoading
  265. },
  266. data() {
  267. return {
  268. URL:'https://esos-iot.bjdexn.cn/myminio/project/891e77523d9e4abcb5c86f0b65ea68be.png',
  269. arrayindex: 0,
  270. categoryindex: 0,
  271. levelindex: 0,
  272. array: [],
  273. electricity: [],
  274. voltage: [],
  275. provinceid: '',
  276. categoryid: '',
  277. levelid: '',
  278. show: false,
  279. date: '',
  280. provincename: '',
  281. categoryname: '',
  282. jianfengname: '',
  283. chongdiandata: [],
  284. opts51: {
  285. },
  286. chartData51: {
  287. categories: [],
  288. series: []
  289. },
  290. opts: {
  291. },
  292. chartData: {
  293. categories: [],
  294. series: []
  295. },
  296. linechart: {},
  297. lineopts: {
  298. color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#9A60B4"],
  299. padding: [15, 20, 0, 0],
  300. enableScroll: false,
  301. dataLabel: false, // 关闭数据标签
  302. legend: {
  303. show: true,
  304. position: "bottom",
  305. lineHeight: 24
  306. },
  307. xAxis: {
  308. disableGrid: false,
  309. boundaryGap: 'justify', // 柱子紧贴坐标轴
  310. fontSize: 10
  311. },
  312. yAxis: {
  313. gridType: "dash",
  314. dashLength: 2,
  315. data: [{
  316. min: 0,
  317. tofix: 1
  318. }],
  319. fontSize: 10
  320. },
  321. },
  322. daylinechart: {},
  323. daylineopts: {
  324. color: ["#B2D5CB"],
  325. padding: [15, 20, 0, 0],
  326. enableScroll: false,
  327. backgroundColor: "#B2D5CB",
  328. dataPointShape: false, // 关闭数据点
  329. dataLabel: false, // 关闭数据标签
  330. legend: {
  331. show: false
  332. },
  333. xAxis: {
  334. disableGrid: true,
  335. labelCount: 6, // 显示全部24小时标签
  336. rotate: 0, // 标签旋转45度
  337. fontSize: 10
  338. },
  339. yAxis: {
  340. gridType: "dash",
  341. dashLength: 2,
  342. fontSize: 10,
  343. data: [{
  344. min: 0,
  345. tofix: 1
  346. }],
  347. },
  348. extra: {
  349. line: {
  350. type: "step",
  351. width: 2,
  352. activeType: "hollow"
  353. }
  354. }
  355. },
  356. optscolumn: {
  357. color: ["#B2D5CB"],
  358. padding: [15, 10, 0, 0],
  359. backgroundColor: "#B2D5CB",
  360. dataLabel: false, // 关闭数据标签
  361. legend: {
  362. show: false
  363. },
  364. xAxis: {
  365. disableGrid: true,
  366. labelCount: 24, // 显示全部24小时标签
  367. rotate: 0, // 标签旋转45度
  368. fontSize: 10
  369. },
  370. yAxis: {
  371. gridType: "dash",
  372. dashLength: 2,
  373. fontSize: 10,
  374. data: [{
  375. min: 0,
  376. tofix: 1
  377. }],
  378. },
  379. extra: {
  380. line: {
  381. type: "straight",
  382. activeType: "hollow",
  383. },
  384. column: {
  385. width: 18,
  386. barBorderRadius: [2, 2, 0, 0],
  387. },
  388. }
  389. },
  390. chartcolumn: {},
  391. electricitypricechart: [],
  392. resultDays: [],
  393. tabIndex: 0,
  394. dayresults: [],
  395. loading:true
  396. }
  397. },
  398. async onLoad() {
  399. // this.loading = true
  400. const monthRange = getMonthRange()
  401. this.date = monthRange.firstDay.substring(0, 7)
  402. await this.getelectricityprice()
  403. await this.getuseelectricity()
  404. await this.getvoltage()
  405. await this.getchongdian()
  406. this.resultDays = getDays(this.date.substring(0, 4), this.date.substring(5, 7))
  407. await this.getdayresult()
  408. },
  409. mounted() {
  410. },
  411. methods: {
  412. onclickLeft() {
  413. uni.navigateBack({
  414. delta: 1 // 返回的页面数,默认为1
  415. });
  416. },
  417. // 地区
  418. async getelectricityprice() {
  419. try {
  420. const response = await request({
  421. url: `/tdengineyuanshi/selectprovince`,
  422. method: 'POST',
  423. header: {
  424. 'Content-Type': 'application/x-www-form-urlencoded'
  425. }
  426. });
  427. this.array = response.data;
  428. this.provincename = this.array[0].provincename
  429. this.provinceid = this.array[0].provinceid
  430. } catch (error) {
  431. console.error('登录失败:', error);
  432. }
  433. },
  434. async bindPickerChange(e) {
  435. console.log('picker发送选择改变,携带值为', e.detail.value)
  436. this.arrayindex = e.detail.value
  437. this.provincename = this.array[e.detail.value].provincename
  438. this.provinceid = this.array[e.detail.value].provinceid
  439. await this.getuseelectricity()
  440. await this.getvoltage()
  441. await this.getchongdian()
  442. await this.getdayresult()
  443. },
  444. // 用电分类
  445. async getuseelectricity() {
  446. try {
  447. let data = {
  448. provinceId: this.provinceid
  449. }
  450. const response = await request({
  451. url: `/tdengineyuanshi/selectcategory`,
  452. method: 'POST',
  453. data: data,
  454. header: {
  455. 'Content-Type': 'application/x-www-form-urlencoded'
  456. }
  457. });
  458. this.electricity = response.data;
  459. const sortOrder = {
  460. "大工业用电·两部制": 1,
  461. "一般工商业·两部制": 2,
  462. "一般工商业·单一制": 3
  463. };
  464. this.electricity.sort((a, b) => {
  465. return sortOrder[a.categoryname] - sortOrder[b.categoryname];
  466. });
  467. this.categoryindex = 0;
  468. this.categoryname = this.electricity[0].categoryname;
  469. this.categoryid = this.electricity[0].categoryid
  470. } catch (error) {
  471. console.error('登录失败:', error);
  472. }
  473. },
  474. async bindelectricity(e) {
  475. console.log('picker发送选择改变,携带值为', e.detail.value)
  476. this.categoryindex = e.detail.value
  477. this.categoryname = this.electricity[e.detail.value].categoryname
  478. this.categoryid = this.electricity[e.detail.value].categoryid
  479. await this.getvoltage()
  480. await this.getchongdian()
  481. await this.getdayresult()
  482. },
  483. // 电压等级
  484. async getvoltage() {
  485. try {
  486. let data = {
  487. categoryid: this.categoryid,
  488. year: this.date.substring(0, 4),
  489. month: this.date.substring(5, 7)
  490. }
  491. const response = await request({
  492. url: `/tdengineyuanshi/selectlevelid`,
  493. method: 'POST',
  494. data: data,
  495. header: {
  496. 'Content-Type': 'application/x-www-form-urlencoded'
  497. }
  498. });
  499. this.levelindex = 0
  500. this.voltage = response.data;
  501. this.levelid = this.voltage[0].levelid
  502. this.jianfengname = this.voltage[0].levelname
  503. } catch (error) {
  504. console.error('登录失败:', error);
  505. }
  506. },
  507. async bindlevel(e) {
  508. console.log('picker发送选择改变,携带值为', e.detail.value)
  509. this.levelindex = e.detail.value
  510. this.levelid = this.voltage[e.detail.value].levelid
  511. this.jianfengname = this.voltage[e.detail.value].levelname
  512. await this.getchongdian()
  513. await this.getdayresult()
  514. },
  515. // 月度电价查询方法
  516. async getchongdian() {
  517. this.loading = true
  518. try {
  519. let data = {
  520. provincename: this.provincename,
  521. categoryname: this.categoryname,
  522. jianfengname: this.jianfengname,
  523. year: this.date.substring(0, 4),
  524. month: this.date.substring(5, 7)
  525. }
  526. const response = await request({
  527. url: `/tdengineyuanshi/chongdian`,
  528. method: 'POST',
  529. data: data,
  530. header: {
  531. 'Content-Type': 'application/x-www-form-urlencoded'
  532. }
  533. });
  534. this.chongdiandata = response.data
  535. // this.electricitypricechart = this.chongdiandata.pricechart.electricitypricechart
  536. // 数据预处理
  537. if (this.chongdiandata.zuihoud.pricechart.electricitypricechart.length > 0) {
  538. this.electricitypricechart = this.chongdiandata.zuihoud.pricechart.electricitypricechart.map(
  539. item => ({
  540. ...item,
  541. // 保持 startTime 和 endTime 为字符串格式
  542. startTime: item.startTime,
  543. endTime: item.endTime,
  544. value: item.value ? parseFloat(item.value) : 0
  545. }));
  546. this.processElectricityPriceChart();
  547. } else {
  548. this.electricitypricechart = [{
  549. endTime: "08:00",
  550. profit: "谷期",
  551. startTime: "00:00",
  552. value: "0.3186",
  553. }]
  554. }
  555. // 准备图表数据
  556. setTimeout(() => {
  557. let month = [];
  558. let monthvalue = [];
  559. for (let index = 0; index < this.chongdiandata.zuihoud.max.provinceListmax
  560. .length; index++) {
  561. month.push(this.date.substring(2, 4) + '/' + (index + 1));
  562. if (index == this.chongdiandata.zuihoud.max.provinceListmax.length - 1) {
  563. monthvalue.push({
  564. "value": this.chongdiandata.zuihoud.max.provinceListmax[index]
  565. .value.substring(0, 8),
  566. "color": "#007545"
  567. });
  568. } else {
  569. monthvalue.push((this.chongdiandata.zuihoud.max.provinceListmax[index].value)
  570. .substring(0, 8));
  571. }
  572. }
  573. this.chartcolumn = {
  574. categories: month,
  575. series: [{
  576. name: '电价',
  577. data: monthvalue
  578. }]
  579. };
  580. }, 500);
  581. } catch (error) {
  582. console.error('登录失败:', error);
  583. }
  584. },
  585. processElectricityPriceChart() {
  586. const hours = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5, 9, 9.5, 10, 10.5,
  587. 11, 11.5, 12, 12.5, 13, 13.5, 14, 14.5, 15, 15.5, 16, 16.5, 17, 17.5, 18, 18.5, 19, 19.5, 20, 20.5,
  588. 21, 21.5, 22, 22.5, 23, 23.5, 24
  589. ];
  590. const seriesTemplates = [{
  591. name: "谷期",
  592. data: new Array(49).fill(null)
  593. },
  594. {
  595. name: "平期",
  596. data: new Array(49).fill(null)
  597. },
  598. {
  599. name: "峰期",
  600. data: new Array(49).fill(null)
  601. },
  602. {
  603. name: "尖期",
  604. data: new Array(49).fill(null)
  605. },
  606. {
  607. name: "深谷",
  608. data: new Array(49).fill(null)
  609. }
  610. ];
  611. // 填充电价数据
  612. this.electricitypricechart.forEach(rate => {
  613. const series = seriesTemplates.find(s => s.name.includes(rate.profit));
  614. if (series) {
  615. // 确保 startTime 和 endTime 是字符串
  616. const startTime = String(rate.startTime);
  617. const endTime = String(rate.endTime);
  618. // 处理可能缺少冒号的情况
  619. const startTimeParts = startTime.includes(':') ? startTime.split(':') : [startTime, '00'];
  620. const endTimeParts = endTime.includes(':') ? endTime.split(':') : [endTime, '00'];
  621. // 计算开始和结束的半小时索引
  622. const startIndex = parseInt(startTimeParts[0]) * 2 + (startTimeParts[1] === '30' ? 1 : 0);
  623. const endIndex = parseInt(endTimeParts[0]) * 2 + (endTimeParts[1] === '30' ? 1 : 0);
  624. // 填充数据(不包含结束点)
  625. for (let i = startIndex; i <= endIndex; i++) {
  626. series.data[i] = rate.value === 0 ? null : rate.value;
  627. }
  628. }
  629. });
  630. // 过滤空系列
  631. const filteredSeries = seriesTemplates.filter(series =>
  632. series.data.some(value => value !== null)
  633. );
  634. // 提取可见标签
  635. const allTimePoints = new Set([0, 24]); // 确保包含0点和24点
  636. this.electricitypricechart.forEach(item => {
  637. // 转换为半小时索引并转回小时表示
  638. const startTime = String(item.startTime);
  639. const endTime = String(item.endTime);
  640. const startParts = startTime.includes(':') ? startTime.split(':') : [startTime, '00'];
  641. const endParts = endTime.includes(':') ? endTime.split(':') : [endTime, '00'];
  642. const startHour = parseInt(startParts[0]) + (startParts[1] === '30' ? 0.5 : 0);
  643. const endHour = parseInt(endParts[0]) + (endParts[1] === '30' ? 0.5 : 0);
  644. allTimePoints.add(startHour);
  645. allTimePoints.add(endHour);
  646. });
  647. // 转换为数组并排序
  648. const visibleLabels = Array.from(allTimePoints).sort((a, b) => a - b);
  649. this.getServerData();
  650. this.loading = false
  651. // 准备图表数据
  652. setTimeout(() => {
  653. // 图表配置
  654. this.opts = {
  655. padding: [15, 10, 0, 0],
  656. dataLabel: false,
  657. dataPointShape: false,
  658. enableScroll: false,
  659. legend: {
  660. show: true,
  661. position: "bottom",
  662. lineHeight: 25
  663. },
  664. xAxis: {
  665. disableGrid: true,
  666. boundaryGap: 'justify',
  667. data: visibleLabels,
  668. format: "timedemo",
  669. fontSize: 10
  670. },
  671. yAxis: {
  672. gridType: "dash",
  673. dashLength: 2,
  674. fontSize: 10,
  675. data: [{
  676. min: 0,
  677. tofix: 1
  678. }]
  679. }
  680. };
  681. // 设置图表数据
  682. this.chartData = {
  683. categories: hours, // X 轴数据是半小时间隔
  684. series: filteredSeries
  685. };
  686. }, 500);
  687. },
  688. isDisabled(value) {
  689. return value > new Date().getTime()
  690. },
  691. handleChange(value) {
  692. this.date = value
  693. this.show = false
  694. this.getchongdian()
  695. this.resultDays = getDays(this.date.substring(0, 4), this.date.substring(5, 7))
  696. this.getdayresult()
  697. },
  698. Dateselection(e) {
  699. console.log(this.date);
  700. this.show = true;
  701. },
  702. // 月度电价走势
  703. getServerData() {
  704. // 生成月份标签 - 假设this.date是"2025"
  705. let month = [];
  706. for (let index = 0; index < this.chongdiandata.zuihoud.electricitypricetrend.length; index++) {
  707. month.push(this.date.substring(2, 4) + '/' + (index + 1));
  708. }
  709. let res = {
  710. categories: month, // 使用动态生成的月份
  711. series: [{
  712. name: "谷期",
  713. data: new Array(month.length).fill(null)
  714. },
  715. {
  716. name: "平期",
  717. data: new Array(month.length).fill(null)
  718. },
  719. {
  720. name: "峰期",
  721. data: new Array(month.length).fill(null)
  722. },
  723. {
  724. name: "尖期",
  725. data: new Array(month.length).fill(null)
  726. },
  727. {
  728. name: "深谷",
  729. data: new Array(month.length).fill(null)
  730. }
  731. ]
  732. };
  733. // 填充电价数据
  734. this.chongdiandata.zuihoud.electricitypricetrend.forEach((rateGroup, groupIndex) => {
  735. rateGroup.forEach(rateItem => {
  736. const series = res.series.find(s => s.name.includes(rateItem.profit));
  737. if (series) {
  738. // 使用groupIndex作为月份索引,因为数据是按月份顺序排列的
  739. // 将value转换为数字,空值或无效值设为null
  740. const value = rateItem.value ? parseFloat(rateItem.value) : null;
  741. series.data[groupIndex] = value === 0 ? null : value;
  742. }
  743. });
  744. });
  745. // 过滤没有数据的图例
  746. res.series = res.series.filter(series => {
  747. return series.data.some(value => value !== null);
  748. });
  749. // 模拟从服务器获取数据时的延时
  750. setTimeout(() => {
  751. this.linechart = JSON.parse(JSON.stringify(res));
  752. }, 500);
  753. },
  754. // 切换标签
  755. toggleTab(index) {
  756. this.tabIndex = index;
  757. this.getdayresult()
  758. },
  759. // 日用天查询
  760. async getdayresult() {
  761. try {
  762. let data = {
  763. provincename: this.provincename,
  764. categoryname: this.categoryname,
  765. jianfengname: this.jianfengname,
  766. year: this.date.substring(0, 4),
  767. month: this.date.substring(5, 7),
  768. day: this.tabIndex + 1
  769. }
  770. const response = await request({
  771. url: `/tdengineyuanshi/xiaoshi`,
  772. method: 'POST',
  773. data: data,
  774. header: {
  775. 'Content-Type': 'application/x-www-form-urlencoded'
  776. }
  777. });
  778. this.dayresults = response.data
  779. let month = [];
  780. let monthvalue = [];
  781. for (let index = 0; index < this.dayresults.length; index++) {
  782. month.push(this.dayresults[index].time);
  783. monthvalue.push(this.dayresults[index].profit);
  784. }
  785. setTimeout(() => {
  786. this.daylinechart = {
  787. categories: month,
  788. series: [{
  789. name: '电价',
  790. data: monthvalue
  791. }]
  792. };
  793. }, 500);
  794. } catch (error) {
  795. console.error('登录失败:', error);
  796. }
  797. },
  798. }
  799. }
  800. </script>
  801. <!-- -->
  802. <style scoped>
  803. .uni-page {
  804. width: 100%;
  805. height: 100%;
  806. }
  807. .container_grf{
  808. width: 100%;
  809. height:100vh;
  810. display: flex;
  811. flex-direction: column;
  812. align-items: center;
  813. justify-content: center;
  814. /* background-color:rgba(18, 124, 199, 1); */
  815. background-color: #fff;
  816. }
  817. .container {
  818. /* background: linear-gradient(to bottom, #007545 -40%, #f0f5f5 40%, #f0f5f5 100%); */
  819. background-color: #f0f5f5;
  820. box-sizing: border-box;
  821. display: flex;
  822. flex-direction: column;
  823. /* background-image: url('https://esos-iot.bjdexn.cn/myminio/project/88861a6c1aa243878d02c3502bf8e2ab.jpg'); */
  824. /* background-image: url('https://esos-iot.bjdexn.cn/myminio/project/891e77523d9e4abcb5c86f0b65ea68be.png'); */
  825. background-size: 100% auto;
  826. background-repeat: no-repeat;
  827. }
  828. .container_navbar{
  829. width: 100%;
  830. position: fixed;
  831. top: 0rpx;
  832. left: 0rpx;
  833. padding: 0rpx;
  834. z-index: 1;
  835. }
  836. .container_top{
  837. width: 100%;
  838. height: 40rpx;
  839. background-color:rgba(255, 255, 255, 0.5);
  840. }
  841. .account_numberimage {
  842. width: 100%;
  843. padding: 0rpx;
  844. margin-top: -30rpx;
  845. }
  846. .swiper-item {
  847. width: 100%;
  848. overflow: auto;
  849. }
  850. .electricityprice {
  851. width: 100%;
  852. padding: 0rpx 20rpx;
  853. display: flex;
  854. justify-content: center;
  855. box-sizing: border-box;
  856. }
  857. .electricityprice_box {
  858. width: 100%;
  859. height: 420rpx;
  860. background-color: #fff;
  861. border-radius: 8rpx;
  862. padding: 0rpx 20rpx;
  863. }
  864. .electricityprice_box1 {
  865. width: 100%;
  866. font-size: 30rpx;
  867. padding: 20rpx 0rpx;
  868. display: flex;
  869. justify-content: center;
  870. border-bottom: 1rpx #f0f5f5 solid;
  871. }
  872. .electricityprice_box2 {
  873. display: flex;
  874. justify-content: space-between;
  875. padding: 20rpx 0rpx;
  876. border-bottom: 1rpx #f0f5f5 solid;
  877. box-sizing: border-box;
  878. }
  879. .electricity_left {
  880. font-size: 26rpx;
  881. }
  882. /* */
  883. @font-face {
  884. font-family: 'iconfont';
  885. /* Project id 4935042 */
  886. src: url('http://at.alicdn.com/t/c/font_4935042_gsrxcrmdcz.woff2?t=1748497918806') format('woff2'),
  887. url('http://at.alicdn.com/t/c/font_4935042_gsrxcrmdcz.woff?t=1748497918806') format('woff'),
  888. url('http://at.alicdn.com/t/c/font_4935042_gsrxcrmdcz.ttf?t=1748497918806') format('truetype');
  889. /* src: url('@/font/iconfont.woff2?t=1748497918806') format('woff2'),
  890. url('@/font/iconfont.woff?t=1748497918806') format('woff'),
  891. url('@/font/iconfont.ttf?t=1748497918806') format('truetype'); */
  892. }
  893. .test {
  894. font-family: iconfont;
  895. margin-left: 20rpx;
  896. }
  897. .testbox {
  898. font-family: iconfont;
  899. margin-left: 32rpx;
  900. margin-right: 10rpx;
  901. }
  902. .electricity_right {
  903. display: flex;
  904. font-size: 26rpx;
  905. }
  906. .toptabbar {
  907. width: 100%;
  908. padding: 10rpx 20rpx;
  909. padding-top: 0rpx;
  910. box-sizing: border-box;
  911. }
  912. .month {
  913. width: 100%;
  914. background-color: #fff;
  915. border-radius: 8rpx;
  916. display: flex;
  917. flex-direction: column;
  918. /* justify-content: center; */
  919. align-items: center;
  920. padding: 10rpx 20rpx;
  921. box-sizing: border-box;
  922. margin-top: 20rpx;
  923. }
  924. .month_box {
  925. width: 100%;
  926. margin-top: 20rpx;
  927. }
  928. .datecalendar_2 {
  929. align-items: center;
  930. justify-content: center;
  931. font-size: 28rpx;
  932. }
  933. .month_title {
  934. width: 100%;
  935. display: flex;
  936. flex-direction: column;
  937. }
  938. .month_title1 {
  939. display: flex;
  940. font-size: 26rpx;
  941. font-weight: 600;
  942. }
  943. .month_title11 {
  944. width: 100%;
  945. height: 60rpx;
  946. display: flex;
  947. justify-content: center;
  948. align-items: center;
  949. background-color: aliceblue;
  950. border: 1rpx #f0f5f5 solid;
  951. }
  952. .month_title111 {
  953. width: 300rpx;
  954. height: 60rpx;
  955. display: flex;
  956. justify-content: center;
  957. align-items: center;
  958. background-color: aliceblue;
  959. border: 1rpx #f0f5f5 solid;
  960. }
  961. .month_title2 {
  962. display: flex;
  963. font-size: 24rpx;
  964. }
  965. .month_title22 {
  966. width: 100%;
  967. height: 60rpx;
  968. display: flex;
  969. align-items: center;
  970. justify-content: center;
  971. border: 1rpx #f0f5f5 solid;
  972. }
  973. .month_title222 {
  974. width: 300rpx;
  975. height: 60rpx;
  976. display: flex;
  977. align-items: center;
  978. justify-content: center;
  979. border: 1rpx #f0f5f5 solid;
  980. }
  981. .qiun_data {
  982. width: 100%;
  983. margin-top: 20rpx;
  984. overflow: auto;
  985. box-sizing: border-box;
  986. background-color: #f5f5f5;
  987. border-radius: 8rpx;
  988. }
  989. .qiun_title {
  990. height: 12%;
  991. font-size: 26rpx;
  992. margin-left: 20rpx;
  993. margin-top: 10rpx;
  994. }
  995. .Capacityneeded {
  996. font-size: 28rpx;
  997. margin: 20rpx 20rpx;
  998. }
  999. .qiun_datatitle {
  1000. font-size: 24rpx;
  1001. margin-top: 20rpx;
  1002. }
  1003. .Daysbox {
  1004. width: 100%;
  1005. display: flex;
  1006. overflow: hidden;
  1007. overflow-x: auto;
  1008. }
  1009. .Daystext {
  1010. width: 100rpx;
  1011. height: 40rpx;
  1012. }
  1013. /deep/ .uni-scroll-view-content {
  1014. width: 100%;
  1015. overflow: auto;
  1016. }
  1017. /deep/ .uni-top-tabbar .uni-swiper-tab .swiper-tab-list {
  1018. width: 80rpx;
  1019. }
  1020. .uni-input{
  1021. display: flex;
  1022. }
  1023. .uni-electricity{
  1024. width: 350rpx;
  1025. /* flex: 1; */
  1026. text-align: right;
  1027. overflow: auto;
  1028. overflow: hidden;
  1029. text-overflow: ellipsis;
  1030. white-space: nowrap;
  1031. }
  1032. </style>