chargeList.vue 3.4 KB

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