index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view>
  3. <ujp-navbar title="充电订单"></ujp-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" :default-time="endDate" @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="@/assets/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.deviceName}}</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.endTime}}</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 ? getPercent(item.chargingMinute): '0秒'}}</p>
  28. <h4 class="oldTextjp2" oldstyle="font-size: 28px;">{{item.actualFee != null ? item.actualFee.toFixed(2) : '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. getPercent(estimateMinute) {
  85. var value="";
  86. var ms =estimateMinute
  87. if (ms > 0) {
  88. var Hour = parseInt(Math.floor(ms / 60 ));
  89. var Fen = parseInt(Math.floor(ms % 60 ));
  90. // value = Hour + "小时" + Fen+"分钟"
  91. if(Hour){
  92. value += Hour + "小时"
  93. }
  94. if(Fen){
  95. value += Fen+"分钟"
  96. }
  97. }
  98. return value;
  99. },
  100. toUrl(item) {
  101. if(item.status == '1') {
  102. uni.navigateTo({
  103. url: '/pages/searchPile/chargeProcess/dcCharging?id=' + item.id
  104. })
  105. } else if (item.status == '4') {
  106. uni.navigateTo({
  107. url: '/pages/searchPile/chargeProcess/dcCharging?id=' + item.id
  108. })
  109. } else {
  110. uni.navigateTo({
  111. url: '/pages/record/details?id=' + item.id
  112. })
  113. }
  114. },
  115. myLoadmore() {
  116. this.pageIndex += 1;
  117. this.getChargeList()
  118. },
  119. textColor(item) {
  120. switch (item.status) {
  121. case '1':
  122. return '#00B962'
  123. break;
  124. case '2':
  125. return '#666666'
  126. break;
  127. case '4':
  128. return '#8161FF'
  129. break;
  130. }
  131. },
  132. textFontSize() {
  133. if(this.elderStatus) {
  134. return '40rpx'
  135. }
  136. },
  137. confirmTime(params) {
  138. if(params.month.slice(0,1) == '0') {
  139. this.month = params.month.slice(1);
  140. } else {
  141. this.month = params.month;
  142. }
  143. this.startDate = params.year + '-' + params.month + '-' + '01';
  144. var day = new Date(params.year, params.month, 0).getDate();
  145. this.endDate = params.year + '-' + params.month + '-' + day;
  146. this.getChargeList(true);
  147. this.show = false;
  148. },
  149. cancelTime() {
  150. this.show = false;
  151. },
  152. getChargeList(bl) {
  153. uni.showLoading({
  154. title: "加载中",
  155. mask: true,
  156. })
  157. if (bl) {
  158. this.chargeList = [];
  159. this.pageIndex = 1;
  160. }
  161. API.chargingRecordData({
  162. pageIndex: this.pageIndex,
  163. startDate: this.startDate,
  164. endDate: this.endDate
  165. }).then((res) => {
  166. uni.hideLoading();
  167. this.chargeList = [
  168. ...this.chargeList,
  169. ...res.data.data
  170. ];
  171. this.recordsTotal = res.data.recordsTotal;
  172. }).catch(error => {
  173. uni.showToast({
  174. title: error,
  175. icon: "none"
  176. })
  177. })
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="scss" scoped>
  183. .carNone{
  184. display: flex;
  185. flex-direction: column;
  186. justify-content: center;
  187. align-items: center;
  188. img{
  189. width: 100%;
  190. height: 100%;
  191. }
  192. p{
  193. margin-top: -60px;
  194. }
  195. }
  196. .recordTime{
  197. height: 44px;
  198. background-color: #fff;
  199. border-bottom: 1px solid #F2F2F2;
  200. display: flex;
  201. align-items: center;
  202. padding: 0 16px;
  203. p{
  204. margin-right: 4px;
  205. }
  206. }
  207. .recordList{
  208. background-color: #fff;
  209. }
  210. .recordList-item{
  211. background-color: #fff;
  212. border-bottom: 1px solid #ededed;
  213. margin-left: 16px;
  214. padding: 16px 16px 16px 0;
  215. .recordList-name{
  216. display: flex;
  217. justify-content: space-between;
  218. align-items: center;
  219. margin-bottom: 12px;
  220. h4{
  221. font-weight: normal;
  222. font-size: 15px;
  223. overflow: hidden;
  224. width: 75%;
  225. text-overflow: ellipsis;
  226. white-space: nowrap;
  227. }
  228. .state1{
  229. color:#8161FF;
  230. }
  231. .state2{
  232. color:#00B962;
  233. }
  234. .state3{
  235. color:#666666;
  236. }
  237. }
  238. .recordList-row{
  239. display: flex;
  240. justify-content: space-between;
  241. align-items: center;
  242. margin-top: 8px;
  243. p{
  244. font-size: 12px;
  245. color:#888;
  246. }
  247. h4{
  248. font-size: 16px;
  249. }
  250. }
  251. }
  252. </style>