index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <view>
  3. <u-navbar title="充电订单"></u-navbar>
  4. <view class="record">
  5. <view class="recordTime" @click="show = true">
  6. <u-picker mode="time" v-model="show" :params="params" @confirm="confirmTime" @cancel="cancelTime"></u-picker>
  7. <p>{{month}}月</p>
  8. <u-icon name="arrow-down-s-fill" custom-prefix="custom-icon" color="#B3B3B3" size="32"></u-icon>
  9. </view>
  10. <view class="carNone" v-if="chargeList.length == 0">
  11. <img src="static/img/暂无数据-缺省页.png" alt="">
  12. <p>暂无充电订单</p>
  13. </view>
  14. <view class="recordList" v-if="chargeList.length > 0">
  15. <view class="recordList-item" v-for="(item,index) in chargeList" :key="item.id" @click="gotoUrl('pages/record/details?id=' + item.id)">
  16. <view class="recordList-name">
  17. <h4>{{item.stationName}}/{{item.deviceNo}}</h4>
  18. <span class="state1" :style="{color : textColor(item)}">{{item.statusText}}</span>
  19. </view>
  20. <view class="recordList-row">
  21. <p>开始时间:{{item.status == '0' || item.status == '4' ? '暂未开始' : item.createTime}}</p>
  22. </view>
  23. <view class="recordList-row">
  24. <p>充电电量:{{item.electricQuantity != null ? item.electricQuantity/10000 : '0.000'}}度</p>
  25. </view>
  26. <view class="recordList-row">
  27. <p>充电时长:{{item.chargingMinute != null ? item.chargingMinute+'分' : '00分00秒'}}</p>
  28. <h4>{{item.actualFee != null ? item.actualFee : '0.00'}}</h4>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import * as API from '@/apis/index.js'
  37. export default {
  38. data() {
  39. return {
  40. params: {
  41. year: true,
  42. month: true,
  43. day: false,
  44. hour: false,
  45. minute: false,
  46. second: false,
  47. timestamp: true,
  48. },
  49. show: false,
  50. month: '',
  51. startDate: '',
  52. endDate: '',
  53. chargeList: []
  54. }
  55. },
  56. onReady() {
  57. var date = new Date();
  58. this.month = date.getMonth() + 1;
  59. var year = date.getFullYear();
  60. var day = new Date(year, this.month, 0).getDate();
  61. var monthN = this.month;
  62. if(monthN >= 1 && monthN <= 9) {
  63. monthN = "0" + monthN;
  64. }
  65. this.startDate = year + '-' + monthN + '-' + '01';
  66. this.endDate = year + '-' + monthN + '-' + day;
  67. this.getChargeList();
  68. },
  69. methods: {
  70. textColor(item) {
  71. switch (item.status) {
  72. case '1':
  73. return '#00B962'
  74. break;
  75. case '2':
  76. return '#666666'
  77. break;
  78. case '4':
  79. return '#8161FF'
  80. break;
  81. }
  82. },
  83. confirmTime(params) {
  84. if(params.month.slice(0,1) == '0') {
  85. this.month = params.month.slice(1);
  86. } else {
  87. this.month = params.month;
  88. }
  89. this.startDate = params.year + '-' + params.month + '-' + '01';
  90. var day = new Date(params.year, params.month, 0).getDate();
  91. this.endDate = params.year + '-' + params.month + '-' + day;
  92. this.getChargeList();
  93. this.show = false;
  94. },
  95. cancelTime() {
  96. this.show = false;
  97. },
  98. getChargeList() {
  99. uni.showLoading({
  100. title: "加载中",
  101. mask: true,
  102. })
  103. API.chargingRecordData({
  104. startDate: this.startDate,
  105. endDate: this.endDate
  106. }).then((res) => {
  107. uni.hideLoading();
  108. this.chargeList = res.data.data;
  109. }).catch(error => {
  110. uni.showToast({
  111. title: error,
  112. icon: "none"
  113. })
  114. })
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .carNone{
  121. display: flex;
  122. flex-direction: column;
  123. justify-content: center;
  124. align-items: center;
  125. img{
  126. width: 100%;
  127. height: 100%;
  128. }
  129. p{
  130. margin-top: -60px;
  131. }
  132. }
  133. .recordTime{
  134. height: 44px;
  135. background-color: #fff;
  136. border-bottom: 1px solid #F2F2F2;
  137. display: flex;
  138. align-items: center;
  139. padding: 0 16px;
  140. p{
  141. margin-right: 4px;
  142. }
  143. }
  144. .recordList{
  145. background-color: #fff;
  146. }
  147. .recordList-item{
  148. background-color: #fff;
  149. border-bottom: 1px solid #ededed;
  150. margin-left: 16px;
  151. padding: 16px 16px 16px 0;
  152. .recordList-name{
  153. display: flex;
  154. justify-content: space-between;
  155. align-items: center;
  156. margin-bottom: 12px;
  157. h4{
  158. font-weight: normal;
  159. font-size: 15px;
  160. overflow: hidden;
  161. width: 75%;
  162. text-overflow: ellipsis;
  163. white-space: nowrap;
  164. }
  165. .state1{
  166. color:#8161FF;
  167. }
  168. .state2{
  169. color:#00B962;
  170. }
  171. .state3{
  172. color:#666666;
  173. }
  174. }
  175. .recordList-row{
  176. display: flex;
  177. justify-content: space-between;
  178. align-items: center;
  179. margin-top: 8px;
  180. p{
  181. color:#888;
  182. }
  183. h4{
  184. font-size: 16px;
  185. }
  186. }
  187. }
  188. </style>