index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. pageIndex: 1,
  55. recordsTotal: 0,
  56. }
  57. },
  58. onReady() {
  59. var date = new Date();
  60. this.month = date.getMonth() + 1;
  61. var year = date.getFullYear();
  62. var day = new Date(year, this.month, 0).getDate();
  63. var monthN = this.month;
  64. if(monthN >= 1 && monthN <= 9) {
  65. monthN = "0" + monthN;
  66. }
  67. this.startDate = year + '-' + monthN + '-' + '01';
  68. this.endDate = year + '-' + monthN + '-' + day;
  69. this.getChargeList();
  70. },
  71. onReachBottom() {
  72. if (this.chargeList.length < this.recordsTotal) {
  73. this.myLoadmore();
  74. }
  75. },
  76. methods: {
  77. myLoadmore() {
  78. this.pageIndex += 1;
  79. this.getChargeList()
  80. },
  81. textColor(item) {
  82. switch (item.status) {
  83. case '1':
  84. return '#00B962'
  85. break;
  86. case '2':
  87. return '#666666'
  88. break;
  89. case '4':
  90. return '#8161FF'
  91. break;
  92. }
  93. },
  94. confirmTime(params) {
  95. if(params.month.slice(0,1) == '0') {
  96. this.month = params.month.slice(1);
  97. } else {
  98. this.month = params.month;
  99. }
  100. this.startDate = params.year + '-' + params.month + '-' + '01';
  101. var day = new Date(params.year, params.month, 0).getDate();
  102. this.endDate = params.year + '-' + params.month + '-' + day;
  103. this.getChargeList(true);
  104. this.show = false;
  105. },
  106. cancelTime() {
  107. this.show = false;
  108. },
  109. getChargeList(bl) {
  110. uni.showLoading({
  111. title: "加载中",
  112. mask: true,
  113. })
  114. if (bl) {
  115. this.chargeList = [];
  116. this.pageIndex = 1;
  117. }
  118. API.chargingRecordData({
  119. pageIndex: this.pageIndex,
  120. startDate: this.startDate,
  121. endDate: this.endDate
  122. }).then((res) => {
  123. uni.hideLoading();
  124. this.chargeList = [
  125. ...this.chargeList,
  126. ...res.data.data
  127. ];
  128. this.recordsTotal = res.data.recordsTotal;
  129. }).catch(error => {
  130. uni.showToast({
  131. title: error,
  132. icon: "none"
  133. })
  134. })
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .carNone{
  141. display: flex;
  142. flex-direction: column;
  143. justify-content: center;
  144. align-items: center;
  145. img{
  146. width: 100%;
  147. height: 100%;
  148. }
  149. p{
  150. margin-top: -60px;
  151. }
  152. }
  153. .recordTime{
  154. height: 44px;
  155. background-color: #fff;
  156. border-bottom: 1px solid #F2F2F2;
  157. display: flex;
  158. align-items: center;
  159. padding: 0 16px;
  160. p{
  161. margin-right: 4px;
  162. }
  163. }
  164. .recordList{
  165. background-color: #fff;
  166. }
  167. .recordList-item{
  168. background-color: #fff;
  169. border-bottom: 1px solid #ededed;
  170. margin-left: 16px;
  171. padding: 16px 16px 16px 0;
  172. .recordList-name{
  173. display: flex;
  174. justify-content: space-between;
  175. align-items: center;
  176. margin-bottom: 12px;
  177. h4{
  178. font-weight: normal;
  179. font-size: 15px;
  180. overflow: hidden;
  181. width: 75%;
  182. text-overflow: ellipsis;
  183. white-space: nowrap;
  184. }
  185. .state1{
  186. color:#8161FF;
  187. }
  188. .state2{
  189. color:#00B962;
  190. }
  191. .state3{
  192. color:#666666;
  193. }
  194. }
  195. .recordList-row{
  196. display: flex;
  197. justify-content: space-between;
  198. align-items: center;
  199. margin-top: 8px;
  200. p{
  201. color:#888;
  202. }
  203. h4{
  204. font-size: 16px;
  205. }
  206. }
  207. }
  208. </style>