parkingLock.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <!-- 车位锁 -->
  3. <view class="parking-lock">
  4. <!-- 车位锁支付 -->
  5. <view class="parking-lock-pay" v-if="parkingLockStatus === 1">
  6. <view class="parking-lock-title">支付停车费</view>
  7. <view class="parking-lock-tips">请您确认停车费用,确认后请支付费用,结束停车。谢谢您的使用!</view>
  8. <view class="parking-lock-info">
  9. <view class="parking-lock-info-item">
  10. <view>停车场名称</view>
  11. <view>{{orderInfo.roadName}}</view>
  12. </view>
  13. <view class="parking-lock-info-item">
  14. <view>停车泊位</view>
  15. <view>{{orderInfo.spaceName}}</view>
  16. </view>
  17. <view class="parking-lock-info-item">
  18. <view>入场时间</view>
  19. <view>{{orderInfo.inTime}}</view>
  20. </view>
  21. <view class="parking-lock-info-item">
  22. <view>出场时间</view>
  23. <view>{{orderInfo.outTime}}</view>
  24. </view>
  25. <view class="parking-lock-info-item">
  26. <view>停车时长</view>
  27. <view>{{orderInfo.duration}}</view>
  28. </view>
  29. <!-- <view class="parking-lock-info-item">
  30. <view>合计金额</view>
  31. <view>{{orderInfo.totalAmount}} 元</view>
  32. </view>
  33. <view class="parking-lock-info-item">
  34. <view>优惠金额</view>
  35. <view>{{orderInfo.preferentialAmount}} 元</view>
  36. </view> -->
  37. <view class="parking-lock-info-item">
  38. <view>应缴金额</view>
  39. <view class="really-money">{{orderInfo.payAmount}} 元</view>
  40. </view>
  41. </view>
  42. <view class="parking-lock-pay-btn">
  43. <button type="default" @click="payMoney">立即支付</button>
  44. </view>
  45. </view>
  46. <!-- 车位锁开始状态 -->
  47. <view class="parking-lock-begin" v-else-if="parkingLockStatus === 2">
  48. <view class="parking-lock-begin-box">
  49. <view class="parking-lock-begin-bg">
  50. <image src="../../static/img/parking-lock-bg.png" mode=""></image>
  51. </view>
  52. </view>
  53. <view class="parking-lock-begin-info">车位锁正在动作,还未到位</view>
  54. </view>
  55. <!-- 车位锁正在状态 -->
  56. <view class="parking-lock-loading" v-else-if="parkingLockStatus === 3">
  57. <view class="parking-lock-loading-box">
  58. <view class="parking-lock-loading-bg">
  59. <image src="../../static/img/parking-lock-bg.png" mode=""></image>
  60. </view>
  61. </view>
  62. <view class="parking-lock-loading-info">开锁中,请等待!</view>
  63. </view>
  64. <!-- 开锁完成 -->
  65. <view class="parking-lock-success" v-else-if="parkingLockStatus === 4">
  66. <view class="parking-lock-success-box">
  67. <image src="../../static/img/parking-lock-achieve.png" mode=""></image>
  68. </view>
  69. <view class="parking-lock-success-info">开锁已完成</view>
  70. <view class="parking-lock-success-button">
  71. <button @click="cancel">返回</button>
  72. </view>
  73. </view>
  74. <view class="parking-lock-pay" v-else-if="parkingLockStatus === 5">
  75. <view class="parking-lock-tips">{{tipsMsg}}</view>
  76. </view>
  77. <!-- 支付方式 -->
  78. <PaymentMethod
  79. :payWayPop="payWayPop"
  80. :curOrderList="orderList"
  81. :deviceNo="deviceNo"
  82. :jumpUrl="jumpUrl"
  83. @closePaymentMethod="closePaymentMethod"></PaymentMethod>
  84. <u-toast ref="uToast" />
  85. <u-popup v-model="show" mode="center" border-radius="14" width="200rpx" height="200rpx">
  86. <view class="loadingSelect">订单查询中...</view>
  87. <view class="spinner">
  88. <view class="rect1"></view>
  89. <view class="rect2"></view>
  90. <view class="rect3"></view>
  91. <view class="rect4"></view>
  92. <view class="rect5"></view>
  93. </view>
  94. </u-popup>
  95. </view>
  96. </template>
  97. <script>
  98. import getUrlParams from "../../utils/getUrlParams.js";
  99. import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue'
  100. export default {
  101. components: {
  102. PaymentMethod
  103. },
  104. data() {
  105. return {
  106. // 车位锁状态 1:支付 2:开始开锁 3:开锁中 4:开锁完成
  107. parkingLockStatus: 1,
  108. // 支付方式选择弹框
  109. payWayPop: false,
  110. // 订单编号
  111. orderList: [],
  112. // 提示信息
  113. tipsMsg: null,
  114. // 设备编号
  115. deviceNo: null,
  116. // 轮询
  117. timer: null,
  118. timer1: null,
  119. // 订单信息
  120. orderInfo: {},
  121. // 订单id
  122. orderId: null,
  123. // 重定向地址
  124. jumpUrl: location.href + '&isBack=1',
  125. show: true
  126. }
  127. },
  128. onLoad(page) {
  129. if (page.orderId) {
  130. this.getOrderDetails(page.orderId)
  131. this.orderList = []
  132. this.orderId = page.orderId
  133. this.orderList.push(page.orderId)
  134. this.deviceNo = page.deviceNo
  135. } else {
  136. this.tipsMsg = page.msg
  137. this.parkingLockStatus = 5
  138. }
  139. },
  140. onShow() {
  141. if(this.orderId){
  142. this.timer1 = setInterval(() => {
  143. // uni.showLoading({
  144. // title: '订单查询中'
  145. // });
  146. this.show = true
  147. this.getOrderDetails(this.orderId)
  148. }, 2000)
  149. }else{
  150. this.show = false
  151. }
  152. },
  153. onHide() {
  154. if (this.timer) {
  155. clearInterval(this.timer)
  156. }
  157. if (this.timer1) {
  158. clearInterval(this.timer1)
  159. }
  160. },
  161. methods: {
  162. payMoney() {
  163. this.payWayPop = true
  164. },
  165. // 查询订单信息
  166. getOrderDetails(id) {
  167. // uni.showLoading({
  168. // title: '订单查询中'
  169. // });
  170. this.$u.api.getOrderDetail({id: id})
  171. .then(res => {
  172. console.log(res)
  173. if (res.code === 200) {
  174. // 获取页面完整url
  175. const local = window.location.href
  176. // 获取url后面的参数
  177. const locationLocaturl = window.location.search;
  178. // 截取url中的isBack
  179. let isBack = getUrlParams(local, "isBack");
  180. console.log('isBack',isBack);
  181. console.log('isBack',isBack == null || isBack != '1');
  182. // 如果没有isBack,则去请求
  183. if (!isBack) {
  184. // uni.hideLoading();
  185. this.show = false
  186. clearInterval(this.timer1)
  187. }
  188. this.orderInfo = res.data
  189. if (res.data.payStatus === 1) {
  190. // uni.hideLoading();
  191. this.show = false
  192. clearInterval(this.timer1)
  193. this.checkEqupment()
  194. }
  195. }
  196. })
  197. },
  198. // 检测设备
  199. checkEqupment() {
  200. this.timer = setInterval(() => {
  201. this.getEqumentStatus(this.deviceNo)
  202. }, 1000)
  203. },
  204. // 查询设备状态
  205. getEqumentStatus(orderNo) {
  206. console.log(orderNo)
  207. this.$u.api.getEquomentInfo({orderNo: orderNo})
  208. .then(res => {
  209. if (res.code === 200) {
  210. console.log(res.data)
  211. if (res.data.deviceStatus === 0) {
  212. this.parkingLockStatus = 4
  213. clearInterval(this.timer)
  214. } else if (res.data.deviceStatus === 1 || res.data.deviceStatus === 5) {
  215. this.parkingLockStatus = 2
  216. } else if (res.data.deviceStatus === 6) {
  217. this.parkingLockStatus = 3
  218. }
  219. }
  220. })
  221. },
  222. // 返回首页
  223. cancel() {
  224. uni.switchTab({
  225. url: '/pages/index/index'
  226. })
  227. },
  228. closePaymentMethod() {
  229. this.payWayPop = false
  230. }
  231. }
  232. }
  233. </script>
  234. <style lang="scss" scoped>
  235. @import './parkingLock.scss';
  236. </style>