getout.vue 4.9 KB

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