getout.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <view>
  3. <u-navbar title="车辆出场" title-color="#fff" :custom-back="customBack" :border-bottom="false" back-icon-color="#CCE8FF" :background="{background: '#008CFF' }"></u-navbar>
  4. <u-empty class="u-m-t-80" text="暂无停车" mode="data" v-if="roadspaceList.length == 0"></u-empty>
  5. <view class="roadspace-list wrap">
  6. <view class="roadspace-list-item" :class="{used:item.placeStatus==1}" @click="roadspaceClick(item)" v-for="item in roadspaceList" :key="item.id">
  7. <view class="block">
  8. <view class="block-top">
  9. <u-icon name="car-fill" size="40" color="#fff"></u-icon>
  10. <view class="car-no">{{ item.vehicleNo }}</view>
  11. </view>
  12. <view class="block-bottom">
  13. <u-icon name="clock-fill" size="40" color="#3397FA"></u-icon>
  14. <view class="time">{{ item.inTime | timeago(currentTime)}}</view>
  15. </view>
  16. </view>
  17. <view class="text">{{item.spaceName}}</view>
  18. </view>
  19. <view class="bottom-btn-wrap">
  20. <view class="bottom-btn" @click="openPage('pages/index/index')">返回主页</view>
  21. </view>
  22. </view>
  23. <u-action-sheet :list="actionList" @click="actionClick" v-model="actionShow"></u-action-sheet>
  24. <u-toast ref="uToast" />
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. roadNo:null,//路段编码 ,示例值(RN000000004)
  32. actionList:[
  33. {text: '出场'},
  34. ],
  35. actionShow:false,
  36. roadspaceList:[],
  37. orderInfo:null,
  38. spaceId:null,
  39. currentTime: new Date(), // 获取当前时间
  40. }
  41. },
  42. onShow() {
  43. let that = this;
  44. this.roadNo = this.$store.state.vuex_user?.roadList?.[0].roadNo || '';
  45. this.handleGetRoadspace(this.roadNo);
  46. setInterval(function () {
  47. that.currentTime = new Date()//修改数据让他可以实时更新
  48. }, 1000);
  49. },
  50. methods:{
  51. openPage(path) {
  52. console.log('path',path);
  53. this.$u.route({
  54. url: path
  55. })
  56. },
  57. customBack(){
  58. this.$u.route({
  59. // type:'switchTab',
  60. url: 'pages/index/index'
  61. });
  62. },
  63. handleGetRoadspace(roadNo){
  64. this.$u.api.getRoadspace({roadNo:this.roadNo,placeStatus:1})
  65. .then(res=>{
  66. // this.$refs.uToast.show({
  67. // title: res.msg,
  68. // type: 'success',
  69. // });
  70. this.roadspaceList = res.data;
  71. console.log('handleGetRoadspace',res)
  72. }).catch(err=>{
  73. if(err.errMsg){
  74. this.$refs.uToast.show({
  75. title: '请检查网络',
  76. type: 'error',
  77. });
  78. return false;
  79. };
  80. err.msg&&this.$refs.uToast.show({
  81. title: err.msg,
  82. type: 'error',
  83. });
  84. console.log('handleGetRoadspace ',err)
  85. });
  86. },
  87. roadspaceClick(orderInfo){
  88. this.actionShow = true;
  89. this.orderInfo = orderInfo;
  90. this.spaceId = orderInfo.id;
  91. console.log('orderInfo',orderInfo);
  92. },
  93. actionClick(e){
  94. console.log('actionClick',e);
  95. switch (e){
  96. case 0:
  97. const d = new Date();
  98. this.$u.route({
  99. url: 'pages/getout/getoutpage/getoutpage',
  100. params: {
  101. orderID:this.orderInfo.id,
  102. orderInTime:this.orderInfo.inTime,
  103. orderOutTime:`${d.getFullYear()}-${((d.getMonth()+1)>=10?+(d.getMonth()+1):"0"+(d.getMonth()+1))}-${((d.getDate())>=10?d.getDate():'0'+d.getDate())} ${d.getHours()>=10?d.getHours():'0'+d.getHours()}:${d.getMinutes()>=10?d.getMinutes():'0'+d.getMinutes()}:${d.getSeconds()>=10?d.getSeconds():'0'+d.getSeconds()}`,
  104. orderSpaceName:this.orderInfo.spaceName,
  105. orderVehicleNo:this.orderInfo.vehicleNo
  106. }
  107. });
  108. break;
  109. default:
  110. break;
  111. }
  112. },
  113. },
  114. filters:{
  115. timeago(inTime,currentTime){
  116. var time_start = new Date(inTime.replace(/-/g,'/'));
  117. var clock_start = time_start.getTime();
  118. // console.log('currentTime',this.currentTime)
  119. const formatNumber = (num) => {
  120. num = num.toString()
  121. return num[1] ? num : '0' + num
  122. };
  123. var i_total_secs = Math.round(currentTime.getTime() - clock_start);
  124. //计算出相差天数
  125. var days = Math.floor(i_total_secs / (24 * 3600 * 1000))
  126. //计算出小时数
  127. // var leave1 = i_total_secs % (24 * 3600 * 1000) //计算天数后剩余的毫秒数
  128. // var hours = Math.floor(leave1 / (3600 * 1000))
  129. var hours = Math.floor(i_total_secs / (3600 * 1000))
  130. //计算相差分钟数
  131. var leave2 = i_total_secs % (3600 * 1000) //计算小时数后剩余的毫秒数
  132. var minutes = Math.floor(leave2 / (60 * 1000))
  133. //计算相差秒数
  134. var leave3 = leave2 % (60 * 1000) //计算分钟数后剩余的毫秒数
  135. var seconds = Math.round(leave3 / 1000)
  136. hours = formatNumber(hours);
  137. minutes = formatNumber(minutes);
  138. seconds = formatNumber(seconds);
  139. // console.log(days + '天' + hours + '个小时' + minutes + '分钟' + seconds + '秒');
  140. return hours + ':' + minutes + ':' + seconds
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss">
  146. @import "../parking/parking.scss";
  147. </style>