chargeList.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view>
  3. <u-navbar title="充电记录">
  4. </u-navbar>
  5. <view class="chargeScreen">
  6. <view class="chargeScreen-item">
  7. <p>
  8. <picker mode="date" :value="startDate" :end="endDate" @change="bindDateChange0">
  9. <view class="uni-input">{{startDate}}</view>
  10. </picker>
  11. </p>
  12. <u-icon name="arrow-down-fill" color="#999" size="24"></u-icon>
  13. </view>
  14. <span>至</span>
  15. <view class="chargeScreen-item">
  16. <p>
  17. <picker mode="date" :value="endDate" :start="startDate" @change="bindDateChange1">
  18. <view class="uni-input">{{endDate}}</view>
  19. </picker>
  20. </p>
  21. <u-icon name="arrow-down-fill" color="#999" size="24"></u-icon>
  22. </view>
  23. </view>
  24. <view style="text-align: center;margin-top: 100px" v-if="!list.length">
  25. <img src="@/assets/img/blankpage.png">
  26. <p>暂无充电记录</p>
  27. </view>
  28. <view class="chargeList">
  29. <view v-for="(item ,index) in list" :key="item.id"
  30. @click="gotoUrl('pages/charge/chargeDetails?id='+item.id)"
  31. class="chargeList-item"
  32. >
  33. <view class="chargeList-text">
  34. <p>{{item.createTime}}</p>
  35. <h4>{{item.deviceName}} 通道:{{item.channelNo}}</h4>
  36. </view>
  37. <span>{{isnull(item.actualFee!=null?item.actualFee:item.estimateFee)}}元</span>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import * as API from '@/apis/index.js'
  44. import {parseUnixTime,beforeTimeStamp} from '@/utils/index.js'
  45. export default {
  46. data() {
  47. return {
  48. form:{
  49. },
  50. startDate:'',
  51. endDate:'',
  52. pageIndex: 1,
  53. recordsTotal: 0,
  54. list: [],
  55. }
  56. },
  57. onReachBottom() {
  58. if (this.list.length < this.recordsTotal) {
  59. this.myLoadmore();
  60. }
  61. },
  62. methods: {
  63. isnull(str){
  64. if(!str){
  65. return 0
  66. }else{
  67. return str
  68. }
  69. },
  70. bindDateChange0: function(e) {
  71. this.startDate= e.target.value
  72. this.getList(true)
  73. },
  74. bindDateChange1: function(e) {
  75. this.endDate= e.target.value
  76. this.getList(true)
  77. },
  78. myLoadmore() {
  79. this.pageIndex += 1;
  80. this.getList()
  81. },
  82. getList(bl) {
  83. uni.showLoading({
  84. title: "加载中",
  85. mask: true,
  86. })
  87. if (bl) {
  88. this.list = [];
  89. this.pageIndex = 1;
  90. }
  91. var data = {
  92. startDate:this.startDate,
  93. endDate:this.endDate,
  94. pageIndex: this.pageIndex
  95. };
  96. API.chargingRecordData(data).then((res) => {
  97. this.list = [
  98. ...this.list,
  99. ...res.data.data
  100. ];
  101. this.recordsTotal = res.data.recordsTotal
  102. uni.hideLoading()
  103. }).catch(error => {
  104. uni.showToast({
  105. title: error
  106. })
  107. })
  108. },
  109. onReady() {
  110. this.startDate=parseUnixTime(beforeTimeStamp(5),"{y}-{m}-{d}")
  111. this.endDate=parseUnixTime(new Date(),"{y}-{m}-{d}")
  112. this.getList()
  113. }
  114. }
  115. }
  116. </script>
  117. <style>
  118. page{
  119. background-color: #f7f7f7;
  120. }
  121. </style>
  122. <style lang="scss" scoped>
  123. .chargeScreen{
  124. display: flex;
  125. align-items: center;
  126. justify-content: space-between;
  127. padding: 10px 0;
  128. background-color: #fff;
  129. span{
  130. color:#777;
  131. }
  132. }
  133. .chargeScreen-item{
  134. display: flex;
  135. align-items: center;
  136. flex: 1;
  137. justify-content: center;
  138. p{
  139. color:#777;
  140. margin-right: 5px;
  141. }
  142. }
  143. .chargeList{
  144. margin-top: 10px;
  145. }
  146. .chargeList-item{
  147. display: flex;
  148. align-items: center;
  149. justify-content: space-between;
  150. padding: 15px;
  151. background-color: #fff;
  152. border-bottom: 1px solid #f7f7f7;
  153. h4{
  154. font-weight: normal;
  155. color:#999;
  156. margin-top: 3px;
  157. font-size: 12px;
  158. }
  159. span{
  160. font-size: 20px;
  161. color:#1677FF;
  162. font-weight: bold;
  163. }
  164. }
  165. </style>