parkingRecord.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. components: {
  47. 'u-button': () => import('@/uni_modules/uview-ui/components/u-button/u-button'),
  48. 'u-search': () => import('@/uni_modules/uview-ui/components/u-search/u-search'),
  49. },
  50. data() {
  51. return {
  52. list: [],
  53. testName:"",
  54. listForm: {
  55. name: "",
  56. pageIndex: 1,
  57. pageSize: 20,
  58. recordsTotal: 1,
  59. }
  60. };
  61. },
  62. onLoad() {
  63. this.getList()
  64. },
  65. onReachBottom() {
  66. if (this.list.length < this.listForm.recordsTotal) {
  67. this.myLoadmore();
  68. }
  69. },
  70. methods: {
  71. testBtn(){
  72. this.listForm.name=this.testName;
  73. this.list=[]
  74. this.listForm.pageIndex=1
  75. this.getList()
  76. },
  77. showTime(time){
  78. if(time){
  79. return time.substr(5).replace('-','.')
  80. }else{
  81. return ''
  82. }
  83. },
  84. getTime(item){
  85. if(item.startTime&&item.endTime){
  86. var stime=newDate(item.startTime)
  87. var etime=newDate(item.endTime)
  88. //etime=new Date()
  89. var k=(etime.getTime()-stime.getTime())/1000/60
  90. var H=k/60
  91. var fen=k%(60)
  92. var str="";
  93. if(k>60){
  94. str+=parseInt(H)+'小时'
  95. }
  96. if(fen==0&&str!=''){
  97. }else{
  98. str+=parseInt(fen)+'分钟'
  99. }
  100. return str
  101. }else{
  102. return '已完成'
  103. }
  104. },
  105. myLoadmore() {
  106. this.listForm.pageIndex += 1;
  107. this.getList()
  108. },
  109. getList() {
  110. uni.showLoading({
  111. title: "加载中",
  112. mask: true,
  113. })
  114. API.recordList(this.listForm).then((res) => {
  115. var list = []
  116. if (this.listForm.pageIndex == 1) {
  117. list = res.data.data;
  118. } else {
  119. list = [
  120. ...list,
  121. ...res.data.data
  122. ];
  123. }
  124. this.list = res.data.data
  125. uni.hideLoading();
  126. }).catch(error => {
  127. uni.hideLoading();
  128. uni.showToast({
  129. title: error,
  130. icon: "none"
  131. })
  132. })
  133. }
  134. }
  135. }
  136. </script>
  137. <style>
  138. page {
  139. background-color: rgba(242, 244, 246, 1);
  140. }
  141. </style>
  142. <style lang="scss" scoped >
  143. ::v-deep .u-content{
  144. width: 380% !important;
  145. }
  146. .search {
  147. padding: 16rpx 32rpx;
  148. background: #fff;
  149. .searchBox {
  150. display: flex;
  151. align-items: center;
  152. background: #F2F2F2;
  153. padding: 1px 16rpx;
  154. border-radius: 8px;
  155. justify-content: space-between;
  156. }
  157. }
  158. .body2{
  159. .item{
  160. display: flex;
  161. justify-content: space-between;
  162. align-items: center;
  163. background: #fff;
  164. padding:24rpx 32rpx;
  165. border-top: 1px solid rgba(232,232,232,1);
  166. .data{
  167. .view1{
  168. color: rgba(16,16,16,1);
  169. font-size: 36rpx;
  170. font-weight: bold;
  171. }
  172. .view3{
  173. color: rgba(119,119,119,1);
  174. font-size: 28rpx;
  175. }
  176. }
  177. .goto{
  178. display: flex;
  179. font-size: 32rpx;
  180. }
  181. .status1{
  182. color:#FF5100
  183. }
  184. .status2{
  185. color: rgba(22,119,255,1);
  186. }
  187. }
  188. }
  189. </style>