index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <view>
  3. <u-navbar title="充电订单"></u-navbar>
  4. <view class="record">
  5. <view class="recordTime oldTextjp2" oldstyle="font-size: 18px;" @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 class="oldTextjp2" oldstyle="font-size: 18px;">暂无充电订单</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 class="oldTextjp" oldstyle="font-size: 20px;">{{item.stationName}}/{{item.deviceNo}}</h4>
  18. <span class="state1" :style="{color : textColor(item),fontSize: textFontSize()}">{{item.statusText}}</span>
  19. </view>
  20. <view class="recordList-row">
  21. <p :style="elderStatus ? 'font-size: 14px' : ''">开始时间:{{item.status == '0' || item.status == '4' ? '暂未开始' : item.createTime}}</p>
  22. </view>
  23. <view class="recordList-row">
  24. <p :style="elderStatus ? 'font-size: 14px' : ''">充电电量:{{item.electricQuantity != null ? item.electricQuantity/10000 : '0.000'}}度</p>
  25. </view>
  26. <view class="recordList-row">
  27. <p :style="elderStatus ? 'font-size: 14px' : ''">充电时长:{{item.chargingMinute != null ? item.chargingMinute+'分钟' : '00分00秒'}}</p>
  28. <h4 class="oldTextjp2" oldstyle="font-size: 28px;">{{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. elderStatus: false,
  57. }
  58. },
  59. onReady() {
  60. var date = new Date();
  61. this.month = date.getMonth() + 1;
  62. var year = date.getFullYear();
  63. var day = new Date(year, this.month, 0).getDate();
  64. var monthN = this.month;
  65. if(monthN >= 1 && monthN <= 9) {
  66. monthN = "0" + monthN;
  67. }
  68. this.startDate = year + '-' + monthN + '-' + '01';
  69. this.endDate = year + '-' + monthN + '-' + day;
  70. this.getChargeList();
  71. if(this.carhelp.get("getElderModeClass") == "长辈模式") {
  72. this.elderStatus = true;
  73. } else {
  74. this.elderStatus = false;
  75. }
  76. },
  77. onReachBottom() {
  78. if (this.chargeList.length < this.recordsTotal) {
  79. this.myLoadmore();
  80. }
  81. },
  82. methods: {
  83. myLoadmore() {
  84. this.pageIndex += 1;
  85. this.getChargeList()
  86. },
  87. textColor(item) {
  88. switch (item.status) {
  89. case '1':
  90. return '#00B962'
  91. break;
  92. case '2':
  93. return '#666666'
  94. break;
  95. case '4':
  96. return '#8161FF'
  97. break;
  98. }
  99. },
  100. textFontSize() {
  101. if(this.elderStatus) {
  102. return '20px'
  103. }
  104. },
  105. confirmTime(params) {
  106. if(params.month.slice(0,1) == '0') {
  107. this.month = params.month.slice(1);
  108. } else {
  109. this.month = params.month;
  110. }
  111. this.startDate = params.year + '-' + params.month + '-' + '01';
  112. var day = new Date(params.year, params.month, 0).getDate();
  113. this.endDate = params.year + '-' + params.month + '-' + day;
  114. this.getChargeList(true);
  115. this.show = false;
  116. },
  117. cancelTime() {
  118. this.show = false;
  119. },
  120. getChargeList(bl) {
  121. uni.showLoading({
  122. title: "加载中",
  123. mask: true,
  124. })
  125. if (bl) {
  126. this.chargeList = [];
  127. this.pageIndex = 1;
  128. }
  129. API.chargingRecordData({
  130. pageIndex: this.pageIndex,
  131. startDate: this.startDate,
  132. endDate: this.endDate
  133. }).then((res) => {
  134. uni.hideLoading();
  135. this.chargeList = [
  136. ...this.chargeList,
  137. ...res.data.data
  138. ];
  139. this.recordsTotal = res.data.recordsTotal;
  140. }).catch(error => {
  141. uni.showToast({
  142. title: error,
  143. icon: "none"
  144. })
  145. })
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. .carNone{
  152. display: flex;
  153. flex-direction: column;
  154. justify-content: center;
  155. align-items: center;
  156. img{
  157. width: 100%;
  158. height: 100%;
  159. }
  160. p{
  161. margin-top: -60px;
  162. }
  163. }
  164. .recordTime{
  165. height: 44px;
  166. background-color: #fff;
  167. border-bottom: 1px solid #F2F2F2;
  168. display: flex;
  169. align-items: center;
  170. padding: 0 16px;
  171. p{
  172. margin-right: 4px;
  173. }
  174. }
  175. .recordList{
  176. background-color: #fff;
  177. }
  178. .recordList-item{
  179. background-color: #fff;
  180. border-bottom: 1px solid #ededed;
  181. margin-left: 16px;
  182. padding: 16px 16px 16px 0;
  183. .recordList-name{
  184. display: flex;
  185. justify-content: space-between;
  186. align-items: center;
  187. margin-bottom: 12px;
  188. h4{
  189. font-weight: normal;
  190. font-size: 15px;
  191. overflow: hidden;
  192. width: 75%;
  193. text-overflow: ellipsis;
  194. white-space: nowrap;
  195. }
  196. .state1{
  197. color:#8161FF;
  198. }
  199. .state2{
  200. color:#00B962;
  201. }
  202. .state3{
  203. color:#666666;
  204. }
  205. }
  206. .recordList-row{
  207. display: flex;
  208. justify-content: space-between;
  209. align-items: center;
  210. margin-top: 8px;
  211. p{
  212. font-size: 12px;
  213. color:#888;
  214. }
  215. h4{
  216. font-size: 16px;
  217. }
  218. }
  219. }
  220. </style>