parkingRecord.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <view class="jpmain ">
  3. <view class="top">
  4. <view class="search">
  5. <view class="searchBox">
  6. <u-search shape="square" placeholder="搜索停车场" v-model="testName" :show-action="false" :animation="true"></u-search>
  7. <u-button type="primary" size="mini" @click="testBtn">搜素</u-button>
  8. </view>
  9. </view>
  10. </view>
  11. <view class="body2">
  12. <view class="item" v-for="(item,i) in list"
  13. @click="gotoUrl('pages/information/parkingInfo?id='+item.id)"
  14. :key="i">
  15. <view class="data">
  16. <view class="view1">
  17. {{item.parkingName}} {{item.lockName}}
  18. </view>
  19. <view class="view2">
  20. </view>
  21. <view class="view3">
  22. {{showTime(item.startTime)}}
  23. <template v-if="item.status!=0">
  24. {{item.endTime?'-'+showTime(item.endTime):'-当前'}}
  25. </template>
  26. </view>
  27. </view>
  28. <view class="goto " :class="'status'+item.status">
  29. {{item.status==2?getTime(item):''}}
  30. {{item.status==1?'使用中':''}}
  31. {{item.status==0?'启动中':''}}
  32. <u-icon name="arrow-right" size="24" style="margin-left: 8rpx;" color="#BBBBBB"></u-icon>
  33. </view>
  34. </view>
  35. </view>
  36. <u-divider color="#B6BDC3" :isnone="list.length==0"
  37. >已经到底了</u-divider>
  38. </view>
  39. </template>
  40. <script>
  41. import * as API from '@/apis/pagejs/index.js'
  42. import {
  43. newDate,
  44. } from '@/apis/utils'
  45. export default {
  46. data() {
  47. return {
  48. list: [],
  49. testName:"",
  50. listForm: {
  51. name: "",
  52. pageIndex: 1,
  53. pageSize: 20,
  54. recordsTotal: 1,
  55. }
  56. };
  57. },
  58. onLoad() {
  59. this.getList()
  60. },
  61. onReachBottom() {
  62. if (this.list.length < this.listForm.recordsTotal) {
  63. this.myLoadmore();
  64. }
  65. },
  66. methods: {
  67. testBtn(){
  68. this.listForm.name=this.testName;
  69. this.list=[]
  70. this.listForm.pageIndex=1
  71. this.getList()
  72. },
  73. showTime(time){
  74. if(time){
  75. return time.substr(5).replace('-','.')
  76. }else{
  77. return ''
  78. }
  79. },
  80. getTime(item){
  81. if(item.startTime&&item.endTime){
  82. var stime=newDate(item.startTime)
  83. var etime=newDate(item.endTime)
  84. //etime=new Date()
  85. var k=(etime.getTime()-stime.getTime())/1000/60
  86. var H=k/60
  87. var fen=k%(60)
  88. var str="";
  89. if(k>60){
  90. str+=parseInt(H)+'小时'
  91. }
  92. if(fen==0&&str!=''){
  93. }else{
  94. str+=parseInt(fen)+'分钟'
  95. }
  96. return str
  97. }else{
  98. return '已完成'
  99. }
  100. },
  101. myLoadmore() {
  102. this.listForm.pageIndex += 1;
  103. this.getList()
  104. },
  105. getList() {
  106. uni.showLoading({
  107. title: "加载中",
  108. mask: true,
  109. })
  110. API.recordList(this.listForm).then((res) => {
  111. var list = []
  112. if (this.listForm.pageIndex == 1) {
  113. list = res.data.data;
  114. } else {
  115. list = [
  116. ...list,
  117. ...res.data.data
  118. ];
  119. }
  120. this.list = res.data.data
  121. uni.hideLoading();
  122. }).catch(error => {
  123. uni.hideLoading();
  124. uni.showToast({
  125. title: error,
  126. icon: "none"
  127. })
  128. })
  129. }
  130. }
  131. }
  132. </script>
  133. <style>
  134. page {
  135. background-color: rgba(242, 244, 246, 1);
  136. }
  137. </style>
  138. <style lang="scss" scoped >
  139. ::v-deep .u-content{
  140. width: 380% !important;
  141. }
  142. .search {
  143. padding: 16rpx 32rpx;
  144. background: #fff;
  145. .searchBox {
  146. display: flex;
  147. align-items: center;
  148. background: #F2F2F2;
  149. padding: 1px 16rpx;
  150. border-radius: 8px;
  151. justify-content: space-between;
  152. }
  153. }
  154. .body2{
  155. .item{
  156. display: flex;
  157. justify-content: space-between;
  158. align-items: center;
  159. background: #fff;
  160. padding:24rpx 32rpx;
  161. border-top: 1px solid rgba(232,232,232,1);
  162. .data{
  163. .view1{
  164. color: rgba(16,16,16,1);
  165. font-size: 36rpx;
  166. font-weight: bold;
  167. }
  168. .view3{
  169. color: rgba(119,119,119,1);
  170. font-size: 28rpx;
  171. }
  172. }
  173. .goto{
  174. display: flex;
  175. font-size: 32rpx;
  176. }
  177. .status1{
  178. color:#FF5100
  179. }
  180. .status2{
  181. color: rgba(22,119,255,1);
  182. }
  183. }
  184. }
  185. </style>