electricityDetails.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view>
  3. <u-navbar title="用电详情" title-color="#101010">
  4. <view class="slot" slot="right" @click="toBillingRules">
  5. 计费规则
  6. </view>
  7. </u-navbar>
  8. <view class="background">
  9. <!-- 用电记录 -->
  10. <view class="details">
  11. <view class="headline">
  12. {{month}}月用电记录
  13. </view>
  14. <view class="infos">
  15. <view class="infos-item">
  16. <view class="item-title">
  17. 用电量
  18. </view>
  19. <view class="item-value">
  20. {{kwhMap.kwh}}度
  21. </view>
  22. </view>
  23. <view class="infos-item">
  24. <view class="item-title">
  25. 电费
  26. </view>
  27. <view class="item-value">
  28. {{kwhMap.fee}}元
  29. </view>
  30. </view>
  31. <view class="infos-item" v-if="meterPhase=='3' && chargeType=='2'">
  32. <view class="item-title">
  33. 峰时用电 ({{kwhMap.fengPrice}}元/度)
  34. </view>
  35. <view class="item-value">
  36. {{kwhMap.fengKwh}}度 {{kwhMap.fengFee}}元
  37. </view>
  38. </view>
  39. <view class="infos-item" v-if="meterPhase=='3' && chargeType=='2'">
  40. <view class="item-title">
  41. 谷时用电 ({{kwhMap.guPrice}}元/度)
  42. </view>
  43. <view class="item-value">
  44. {{kwhMap.guKwh}}度 {{kwhMap.guFee}}元
  45. </view>
  46. </view>
  47. <view class="infos-item" v-if="meterPhase=='3' && chargeType=='2'">
  48. <view class="item-title">
  49. 平时用电 ({{kwhMap.pingPrice}}元/度)
  50. </view>
  51. <view class="item-value">
  52. {{kwhMap.pingKwh}}度 {{kwhMap.pingFee}}元
  53. </view>
  54. </view>
  55. <view class="infos-item" v-if="meterPhase=='3' && chargeType=='2'" >
  56. <view class="item-title">
  57. 尖时用电 ({{kwhMap.jianPrice}}元/度)
  58. </view>
  59. <view class="item-value">
  60. {{kwhMap.jianKwh}}度 {{kwhMap.jianFee}}元
  61. </view>
  62. </view>
  63. <view class="infos-item">
  64. <view class="item-title">
  65. 用户
  66. </view>
  67. <view class="item-value">
  68. {{name}}
  69. </view>
  70. </view>
  71. </view>
  72. <!-- 折线图 -->
  73. <view class="chat-box">
  74. <view class="title">
  75. {{month}}月 用电量趋势
  76. </view>
  77. <view class="chat">
  78. <view id="barEcharts" style="min-height:322rpx;">
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <button class="back" @click="toBack">返回</button>
  84. </view>
  85. </view>
  86. </template>
  87. <script>
  88. import * as API_electricityMeter from '@/apis/pagejs/electricityMeter.js'
  89. import * as echarts from 'echarts';
  90. export default {
  91. data() {
  92. return {
  93. myChart: null,
  94. queryDate: '',
  95. meterId: '',
  96. graphMap: {},
  97. kwhMap: {},
  98. month: '',
  99. name: '',
  100. meterPhase: '',
  101. chargeType: ''
  102. }
  103. },
  104. onLoad(op) {
  105. if(op.id) {
  106. this.meterId = op.id;
  107. this.queryDate = op.queryDate;
  108. this.month = parseInt(this.queryDate.slice(5));
  109. this.getElectricityConsumptionDetails();
  110. }
  111. },
  112. methods: {
  113. getElectricityConsumptionDetails() {
  114. uni.showLoading({
  115. title: "加载中",
  116. mask: true,
  117. })
  118. API_electricityMeter.electricityConsumptionDetails({
  119. meterId: this.meterId,
  120. queryDate: this.queryDate+'-01'
  121. }).then((res) => {
  122. uni.hideLoading();
  123. this.graphMap = res.data.graphMap;
  124. this.kwhMap = res.data.kwhMap;
  125. this.name = res.data.name;
  126. this.meterPhase = res.data.meterPhase;
  127. this.chargeType = res.data.chargeType;
  128. this.getBarCharts(this.graphMap);
  129. }).catch(error => {
  130. uni.showToast({
  131. title: error,
  132. icon: "none"
  133. })
  134. })
  135. },
  136. getBarCharts(list) {
  137. if (!this.myChart) {
  138. this.myChart = echarts.init(document.getElementById('barEcharts'), null, {
  139. width: uni.upx2px(666),
  140. height: uni.upx2px(322)
  141. });
  142. }
  143. this.myChart.clear();
  144. var data1 = [];
  145. var data2 = [];
  146. for (var i in list) {
  147. data1.push(i+'日');
  148. data2.push(list[i].kwh);
  149. }
  150. var axisLabel = {
  151. rotate: 40,
  152. interval: 0,
  153. textStyle: {
  154. color: "#333"
  155. }
  156. }
  157. if (data1.length < 7) {
  158. axisLabel = {
  159. interval: 0,
  160. textStyle: {
  161. color: "#333"
  162. },
  163. }
  164. } else {
  165. axisLabel.interval = 2;
  166. }
  167. var headitemby = "";
  168. var showkey = "";
  169. var option = {
  170. tooltip: {
  171. trigger: 'axis',
  172. axisPointer: {
  173. type: 'shadow'
  174. }
  175. },
  176. grid: {
  177. top: '6%',
  178. left: '3%',
  179. right: '8%',
  180. bottom: '8%',
  181. containLabel: true
  182. },
  183. xAxis: {
  184. type: 'category',
  185. data: data1,
  186. axisLabel: axisLabel,
  187. },
  188. yAxis: {
  189. type: 'value',
  190. },
  191. series: [{
  192. name: '电量',
  193. data: data2,
  194. type: 'bar',
  195. // label: {
  196. // show: true,
  197. // position: 'top',
  198. // color: '#5C7BD9'
  199. // }
  200. }]
  201. }
  202. this.myChart.setOption(option);
  203. },
  204. toBack() {
  205. uni.navigateBack();
  206. },
  207. toBillingRules() {
  208. var date = this.queryDate;
  209. uni.navigateTo({
  210. url: '/pages/equipmentDataMonitoring/billingRules?id='+this.meterId+'&queryDate='+date
  211. })
  212. }
  213. }
  214. }
  215. </script>
  216. <style lang="scss" scoped>
  217. .background {
  218. height: 400rpx;
  219. padding-top: 32rpx;
  220. background: linear-gradient(180deg, rgba(203, 234, 255, 1) 0%, rgba(203, 234, 255, 0) 100%);
  221. // 用电记录
  222. .details {
  223. background-color: #fff;
  224. border-radius: 8px;
  225. padding: 32rpx;
  226. margin: 0rpx 32rpx;
  227. .headline {
  228. color: rgb(16, 16, 16);
  229. font-size: 40rpx;
  230. text-align: center;
  231. }
  232. .infos {
  233. margin-top: 32rpx;
  234. border-bottom: 1px solid rgba(241, 241, 241, 1);
  235. .infos-item {
  236. display: flex;
  237. align-items: center;
  238. justify-content: space-between;
  239. margin-bottom: 24rpx;
  240. .item-title {
  241. color: rgba(51, 51, 51, 1);
  242. }
  243. .item-value {
  244. color: rgba(16, 16, 16, 1);
  245. }
  246. }
  247. }
  248. }
  249. // 折线图
  250. .chat-box {
  251. border-radius: 8px;
  252. background: linear-gradient(180deg, rgba(214, 238, 255, 1) 0%, rgba(208, 236, 236, 0) 100%);
  253. .title {
  254. color: rgba(16, 16, 16, 1);
  255. padding: 24rpx;
  256. }
  257. .chat-box {
  258. width: 100%;
  259. height: 322rpx;
  260. .img {
  261. width: 100%;
  262. height: 100%;
  263. }
  264. }
  265. }
  266. }
  267. // 返回
  268. .back {
  269. border: 1px solid rgba(205, 205, 205, 1);
  270. line-height: 88rpx;
  271. background-color: rgba(255, 255, 255, 1);
  272. color: rgba(119, 119, 119, 1);
  273. font-size: 32rpx;
  274. margin: 32rpx;
  275. }
  276. </style>