index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='能耗管理' bgColor='transparent'></cus-header>
  4. <image class="bg" :src="imgBase+'storage/home_bg.png'" mode="widthFix"></image>
  5. <div class="top">
  6. <div class="pre line">
  7. <div class="left">
  8. <div class="tip">今日用电(kwh)</div>
  9. <div class="num">{{'9,879'}}</div>
  10. </div>
  11. <div class="right">
  12. <image :src="imgBase+'home/nhgl_today.png'"></image>
  13. </div>
  14. </div>
  15. <div class="pre">
  16. <div class="left">
  17. <div class="tip">本月用电(kwh)</div>
  18. <div class="num">{{'89,879'}}</div>
  19. </div>
  20. <div class="right">
  21. <image :src="imgBase+'home/nhgl_month.png'"></image>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="card">
  26. <div class="title">用电量统计</div>
  27. <div class="chart">
  28. <div class="select">
  29. <div class="month">按月</div>
  30. <div class="year" @tap="show = true">
  31. <text>{{year}}年</text>
  32. <u-icon name="arrow-down" color="#86909C" size="26"></u-icon>
  33. </div>
  34. </div>
  35. <l-echart ref="chartRef" :canvas2d="true" @finished="initChart"></l-echart>
  36. </div>
  37. <div class="list" v-if="list.length">
  38. <div class="item" v-for="(item,index) in list" :key="index">
  39. <div class="left">
  40. <div class="date">{{item.date}}</div>
  41. <div class="place">位置:{{item.place}}</div>
  42. </div>
  43. <div class="right">{{item.kwh}}</div>
  44. </div>
  45. </div>
  46. </div>
  47. <u-picker :show="show" :columns="columns" title="年份" @cancel="show = false;" @confirm="yearConfirm"></u-picker>
  48. </view>
  49. </template>
  50. <script>
  51. import * as echarts from '@/pagesHome/components/lime-echart/static/echarts.min.js'
  52. import lEchart from '@/pagesHome/components/lime-echart/components/l-echart/l-echart.vue'
  53. export default {
  54. components:{
  55. lEchart
  56. },
  57. data(){
  58. return {
  59. year:new Date().getFullYear()-1,
  60. show:false,
  61. columns:(function(){
  62. let years = [];
  63. let cy = new Date().getFullYear();
  64. for(let i=cy;i>cy-10;i--){
  65. years.push(i)
  66. }
  67. return [years];
  68. })(),
  69. list:[
  70. {
  71. date:'2024年12月',
  72. place:'B#',
  73. kwh:'2408.23kwh'
  74. },
  75. {
  76. date:'2024年11月',
  77. place:'B#',
  78. kwh:'2408.23kwh'
  79. },
  80. {
  81. date:'2024年10月',
  82. place:'B#',
  83. kwh:'2408.23kwh'
  84. },
  85. {
  86. date:'2024年09月',
  87. place:'B#',
  88. kwh:'2408.23kwh'
  89. },
  90. {
  91. date:'2024年08月',
  92. place:'B#',
  93. kwh:'2408.23kwh'
  94. },
  95. {
  96. date:'2024年07月',
  97. place:'B#',
  98. kwh:'2408.23kwh'
  99. },
  100. {
  101. date:'2024年06月',
  102. place:'B#',
  103. kwh:'2408.23kwh'
  104. },
  105. {
  106. date:'2024年05月',
  107. place:'B#',
  108. kwh:'2408.23kwh'
  109. },
  110. {
  111. date:'2024年04月',
  112. place:'B#',
  113. kwh:'2408.23kwh'
  114. },
  115. {
  116. date:'2024年03月',
  117. place:'B#',
  118. kwh:'2408.23kwh'
  119. },
  120. {
  121. date:'2024年02月',
  122. place:'B#',
  123. kwh:'2408.23kwh'
  124. },
  125. {
  126. date:'2024年01月',
  127. place:'B#',
  128. kwh:'2408.23kwh'
  129. }
  130. ]
  131. }
  132. },
  133. methods:{
  134. async initChart(){
  135. const chart = await this.$refs.chartRef.init(echarts);
  136. let option = {
  137. title: {
  138. text: '数量',
  139. textStyle:{
  140. fontSize:16,
  141. color:'#86909C'
  142. }
  143. },
  144. xAxis: {
  145. type: 'category',
  146. data: (function(){
  147. let months = [];
  148. for (let i=1;i<=12;i++) {
  149. months.push(i+'月')
  150. }
  151. return months;
  152. })()
  153. },
  154. yAxis: {
  155. type: 'value'
  156. },
  157. tooltip: {
  158. trigger: 'axis',
  159. axisPointer: {
  160. type: 'cross',
  161. label: {
  162. backgroundColor: '#6a7985'
  163. }
  164. }
  165. },
  166. grid: {
  167. left: '1%',
  168. right: '1%',
  169. bottom: '5%',
  170. top: '20%',
  171. containLabel: true
  172. },
  173. series: [
  174. {
  175. name:'用电量',
  176. data: (function(){
  177. let data = [];
  178. for (let i=1;i<=12;i++) {
  179. data.push(Math.random()*1200)
  180. }
  181. return data;
  182. })(),
  183. type: 'line',
  184. lineStyle:{
  185. color:'#198CFF',
  186. width: 3
  187. },
  188. symbol:'none',
  189. areaStyle: {
  190. color:'rgba(25,140,255,.4)'
  191. },
  192. smooth: true
  193. }
  194. ]
  195. };
  196. chart.setOption(option);
  197. },
  198. yearConfirm(e){
  199. this.year = e.value[0];
  200. this.show = false;
  201. }
  202. }
  203. }
  204. </script>
  205. <style scoped lang="less">
  206. .page{
  207. width: 100%;
  208. padding: 0 24rpx 20rpx;
  209. box-sizing: border-box;
  210. background: #F4F8FB;
  211. .bg{
  212. width: 100%;
  213. position: fixed;
  214. top: 0;
  215. left: 0;
  216. z-index: 0;
  217. }
  218. .top{
  219. padding: 40rpx 0;
  220. background: #FFFFFF;
  221. border-radius: 16rpx;
  222. display: flex;
  223. position: relative;
  224. margin-top: 20rpx;
  225. .pre{
  226. width: 50%;
  227. padding: 0 24rpx;
  228. box-sizing: border-box;
  229. position: relative;
  230. display: flex;
  231. align-items: center;
  232. justify-content: space-between;
  233. &.line::after{
  234. content: '';
  235. width: 1rpx;
  236. height: 100rpx;
  237. background: #EFEFEF;
  238. position: absolute;
  239. right: 0;
  240. top: 50%;
  241. margin-top: -50rpx;
  242. }
  243. .left{
  244. .tip{
  245. font-family: PingFangSC, PingFang SC;
  246. font-weight: 400;
  247. font-size: 24rpx;
  248. color: #657588;
  249. line-height: 28rpx;
  250. text-align: left;
  251. }
  252. .num{
  253. font-family: D-DIN, D-DIN;
  254. font-weight: bold;
  255. font-size: 48rpx;
  256. color: #1D2129;
  257. line-height: 48rpx;
  258. text-align: left;
  259. margin-top: 16rpx;
  260. }
  261. }
  262. .right{
  263. width: 80rpx;
  264. height: 80rpx;
  265. image{
  266. width: 100%;
  267. height: 100%;
  268. }
  269. }
  270. }
  271. }
  272. .card{
  273. margin-top: 20rpx;
  274. background: #FFFFFF;
  275. border-radius: 16rpx;
  276. padding: 40rpx 24rpx;
  277. position: relative;
  278. .title{
  279. font-family: PingFang-SC, PingFang-SC;
  280. font-weight: bold;
  281. font-size: 36rpx;
  282. color: #1D2129;
  283. line-height: 36rpx;
  284. }
  285. .chart{
  286. position: relative;
  287. .select{
  288. width: 226rpx;
  289. height: 48rpx;
  290. border-radius: 6rpx;
  291. border: 1rpx solid #ECECEC;
  292. display: flex;
  293. position: absolute;
  294. right: 0;
  295. top: 0;
  296. z-index: 999;
  297. .month{
  298. width: 87rpx;
  299. height: 48rpx;
  300. border-right: 1rpx solid #ECECEC;
  301. font-family: PingFangSC, PingFang SC;
  302. font-weight: 400;
  303. font-size: 24rpx;
  304. color: #198CFF;
  305. line-height: 48rpx;
  306. text-align: center;
  307. }
  308. .year{
  309. width: calc(100% - 88rpx);
  310. display: flex;
  311. align-items: center;
  312. justify-content: center;
  313. text{
  314. font-family: PingFangSC, PingFang SC;
  315. font-weight: 400;
  316. font-size: 24rpx;
  317. color: #86909C;
  318. line-height: 24rpx;
  319. margin-right: 10rpx;
  320. }
  321. }
  322. }
  323. }
  324. .list{
  325. .item{
  326. width: 100%;
  327. padding: 31rpx 0;
  328. display: flex;
  329. align-items: center;
  330. justify-content: space-between;
  331. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #EFEFEF;
  332. .left{
  333. .date{
  334. font-family: PingFang-SC, PingFang-SC;
  335. font-weight: bold;
  336. font-size: 30rpx;
  337. color: #1D2129;
  338. line-height: 36rpx;
  339. }
  340. .place{
  341. font-family: PingFangSC, PingFang SC;
  342. font-weight: 400;
  343. font-size: 24rpx;
  344. color: #999999;
  345. line-height: 24rpx;
  346. margin-top: 14rpx;
  347. }
  348. }
  349. .right{
  350. font-family: PingFangSC, PingFang SC;
  351. font-weight: 400;
  352. font-size: 30rpx;
  353. color: #1D2129;
  354. line-height: 36rpx;
  355. text-align: right;
  356. }
  357. }
  358. }
  359. }
  360. }
  361. </style>