meter.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="meter-index">
  3. <view class="meter-box">
  4. <view class="title">{{title}}</view>
  5. <view class="sub-title">{{space}}</view>
  6. <view class="meter-box-content">
  7. <view class="meter-box-list">
  8. <view class="content-item">
  9. <view class="content-item-title">
  10. <view class="content-item-icon">
  11. <uni-icons type="icon-jinriyongdianliang" custom-prefix="iconfont" size="26"
  12. color="#577ff5">
  13. </uni-icons>
  14. </view>
  15. <view class="label">今日用电量</view>
  16. </view>
  17. <view class="content-item-article">
  18. <text class="number">6.86</text>
  19. <text class="unit">kwh</text>
  20. </view>
  21. </view>
  22. <view class="content-item">
  23. <view class="content-item-title">
  24. <view class="content-item-icon">
  25. <uni-icons type="icon-zongyongdianliang" custom-prefix="iconfont" size="26"
  26. color="#577ff5">
  27. </uni-icons>
  28. </view>
  29. <view class="label">当月用电量</view>
  30. </view>
  31. <view class="content-item-article">
  32. <text class="number">122.23</text>
  33. <text class="unit">kwh</text>
  34. </view>
  35. </view>
  36. <view class="content-item">
  37. <view class="content-item-title">
  38. <view class="content-item-icon">
  39. <uni-icons type="icon-dianchidianliang" custom-prefix="iconfont" size="18"
  40. color="#577ff5">
  41. </uni-icons>
  42. </view>
  43. <view class="label">电池电量</view>
  44. </view>
  45. <view class="content-item-article">
  46. <text class="number">98</text>
  47. <text class="unit">%</text>
  48. </view>
  49. </view>
  50. </view>
  51. <image class="meter-image"
  52. src="https://file-node.oss-cn-shanghai.aliyuncs.com/youji/9819ac743e2e44f58dbd58787bee2848">
  53. </image>
  54. </view>
  55. </view>
  56. <view class="common-charts">
  57. <view class="common-chart-title">历史用电量</view>
  58. <view class="common-chart-box">
  59. <u-echart ref="echart"></u-echart>
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import uEchart from './uEchart.vue'
  66. export default {
  67. props: ['title', 'space'],
  68. data() {
  69. return {
  70. }
  71. },
  72. mounted() {
  73. setTimeout(() => {
  74. this.$refs.echart.initCharts({
  75. type: 'line',
  76. categories: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月'],
  77. series: [{
  78. name: '用电量',
  79. data: [86, 122, 93, 98, 91, 88, 95, 102, 110, 80]
  80. }],
  81. animation: true,
  82. background: "#FFFFFF",
  83. color: ["#1890FF"],
  84. padding: [10, 0, 0, 0],
  85. enableScroll: false,
  86. legend: {
  87. show: false
  88. },
  89. xAxis: {
  90. disableGrid: true
  91. },
  92. yAxis: {
  93. gridType: "dash",
  94. dashLength: 2
  95. },
  96. extra: {
  97. line: {
  98. type: "straight",
  99. width: 2,
  100. activeType: "hollow"
  101. }
  102. }
  103. })
  104. }, 500)
  105. },
  106. components: {
  107. uEchart
  108. },
  109. }
  110. </script>
  111. <style lang="scss">
  112. .meter-index {
  113. padding: 30rpx;
  114. .meter-box {
  115. background: #fff;
  116. padding: 30rpx;
  117. border-radius: 16rpx;
  118. box-shadow: 0px 1px 12px rgba(3, 3, 3, 0.08);
  119. .title {
  120. font-size: 40rpx;
  121. font-weight: 500;
  122. }
  123. .sub-title {
  124. font-size: 24rpx;
  125. color: $uni-secondary-color;
  126. font-weight: 200;
  127. }
  128. .meter-box-content {
  129. display: flex;
  130. align-items: center;
  131. padding: 80rpx 0 40rpx 0;
  132. }
  133. .meter-box-list {
  134. flex: 1;
  135. width: 0;
  136. overflow: hidden;
  137. }
  138. .content-item {
  139. margin-bottom: 20rpx;
  140. }
  141. .content-item-title {
  142. display: flex;
  143. align-items: center;
  144. .content-item-icon {
  145. width: 60rpx;
  146. height: 60rpx;
  147. text-align: center;
  148. line-height: 60rpx;
  149. }
  150. .label {
  151. font-size: 24rpx;
  152. font-weight: 300;
  153. margin-left: 10rpx;
  154. }
  155. }
  156. .content-item-article {
  157. display: flex;
  158. align-items: flex-end;
  159. padding-left: 70rpx;
  160. padding-top: 10rpx;
  161. .number {
  162. font-size: 40rpx;
  163. line-height: 40rpx;
  164. }
  165. .unit {
  166. color: $uni-secondary-color;
  167. margin-left: 8rpx;
  168. font-size: 24rpx;
  169. }
  170. }
  171. .meter-image {
  172. width: 200rpx;
  173. height: 200rpx;
  174. margin-right: 40rpx;
  175. }
  176. }
  177. }
  178. </style>