getout.vue 4.3 KB

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