index.vue 5.5 KB

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