index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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="toUrl(item)">
  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.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. <u-divider v-if="chargeList.length == recordsTotal && recordsTotal != 0" style="margin-top: 10px;background-color: #F2F4F4;">已经到底了</u-divider>
  34. </view>
  35. </template>
  36. <script>
  37. import * as API from '@/apis/index.js'
  38. export default {
  39. data() {
  40. return {
  41. params: {
  42. year: true,
  43. month: true,
  44. day: false,
  45. hour: false,
  46. minute: false,
  47. second: false,
  48. timestamp: true,
  49. },
  50. show: false,
  51. month: '',
  52. startDate: '',
  53. endDate: '',
  54. chargeList: [],
  55. pageIndex: 1,
  56. recordsTotal: 0,
  57. elderStatus: false,
  58. }
  59. },
  60. onReady() {
  61. var date = new Date();
  62. this.month = date.getMonth() + 1;
  63. var year = date.getFullYear();
  64. var day = new Date(year, this.month, 0).getDate();
  65. var monthN = this.month;
  66. if(monthN >= 1 && monthN <= 9) {
  67. monthN = "0" + monthN;
  68. }
  69. this.startDate = year + '-' + monthN + '-' + '01';
  70. this.endDate = year + '-' + monthN + '-' + day;
  71. this.getChargeList();
  72. if(this.carhelp.get("getElderModeClass") == "长辈模式") {
  73. this.elderStatus = true;
  74. } else {
  75. this.elderStatus = false;
  76. }
  77. },
  78. onReachBottom() {
  79. if (this.chargeList.length < this.recordsTotal) {
  80. this.myLoadmore();
  81. }
  82. },
  83. methods: {
  84. toUrl(item) {
  85. if(item.status == '1') {
  86. uni.navigateTo({
  87. url: '/pages/searchPile/chargeProcess/dcCharging?id=' + item.id
  88. })
  89. } else if (item.status == '4') {
  90. uni.navigateTo({
  91. url: '/pages/searchPile/chargeProcess/dcCharging?id=' + item.id
  92. })
  93. } else {
  94. uni.navigateTo({
  95. url: '/pages/record/details?id=' + item.id
  96. })
  97. }
  98. },
  99. myLoadmore() {
  100. this.pageIndex += 1;
  101. this.getChargeList()
  102. },
  103. textColor(item) {
  104. switch (item.status) {
  105. case '1':
  106. return '#00B962'
  107. break;
  108. case '2':
  109. return '#666666'
  110. break;
  111. case '4':
  112. return '#8161FF'
  113. break;
  114. }
  115. },
  116. textFontSize() {
  117. if(this.elderStatus) {
  118. return '20px'
  119. }
  120. },
  121. confirmTime(params) {
  122. if(params.month.slice(0,1) == '0') {
  123. this.month = params.month.slice(1);
  124. } else {
  125. this.month = params.month;
  126. }
  127. this.startDate = params.year + '-' + params.month + '-' + '01';
  128. var day = new Date(params.year, params.month, 0).getDate();
  129. this.endDate = params.year + '-' + params.month + '-' + day;
  130. this.getChargeList(true);
  131. this.show = false;
  132. },
  133. cancelTime() {
  134. this.show = false;
  135. },
  136. getChargeList(bl) {
  137. uni.showLoading({
  138. title: "加载中",
  139. mask: true,
  140. })
  141. if (bl) {
  142. this.chargeList = [];
  143. this.pageIndex = 1;
  144. }
  145. API.chargingRecordData({
  146. pageIndex: this.pageIndex,
  147. startDate: this.startDate,
  148. endDate: this.endDate
  149. }).then((res) => {
  150. uni.hideLoading();
  151. this.chargeList = [
  152. ...this.chargeList,
  153. ...res.data.data
  154. ];
  155. this.recordsTotal = res.data.recordsTotal;
  156. }).catch(error => {
  157. uni.showToast({
  158. title: error,
  159. icon: "none"
  160. })
  161. })
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. .carNone{
  168. display: flex;
  169. flex-direction: column;
  170. justify-content: center;
  171. align-items: center;
  172. img{
  173. width: 100%;
  174. height: 100%;
  175. }
  176. p{
  177. margin-top: -60px;
  178. }
  179. }
  180. .recordTime{
  181. height: 44px;
  182. background-color: #fff;
  183. border-bottom: 1px solid #F2F2F2;
  184. display: flex;
  185. align-items: center;
  186. padding: 0 16px;
  187. p{
  188. margin-right: 4px;
  189. }
  190. }
  191. .recordList{
  192. background-color: #fff;
  193. }
  194. .recordList-item{
  195. background-color: #fff;
  196. border-bottom: 1px solid #ededed;
  197. margin-left: 16px;
  198. padding: 16px 16px 16px 0;
  199. .recordList-name{
  200. display: flex;
  201. justify-content: space-between;
  202. align-items: center;
  203. margin-bottom: 12px;
  204. h4{
  205. font-weight: normal;
  206. font-size: 15px;
  207. overflow: hidden;
  208. width: 75%;
  209. text-overflow: ellipsis;
  210. white-space: nowrap;
  211. }
  212. .state1{
  213. color:#8161FF;
  214. }
  215. .state2{
  216. color:#00B962;
  217. }
  218. .state3{
  219. color:#666666;
  220. }
  221. }
  222. .recordList-row{
  223. display: flex;
  224. justify-content: space-between;
  225. align-items: center;
  226. margin-top: 8px;
  227. p{
  228. font-size: 12px;
  229. color:#888;
  230. }
  231. h4{
  232. font-size: 16px;
  233. }
  234. }
  235. }
  236. </style>