parkingLock.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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. this.timer1 = setInterval(() => {
  142. // uni.showLoading({
  143. // title: '订单查询中'
  144. // });
  145. this.show = true
  146. this.getOrderDetails(this.orderId)
  147. }, 2000)
  148. },
  149. onHide() {
  150. if (this.timer) {
  151. clearInterval(this.timer)
  152. }
  153. if (this.timer1) {
  154. clearInterval(this.timer1)
  155. }
  156. },
  157. methods: {
  158. payMoney() {
  159. this.payWayPop = true
  160. },
  161. // 查询订单信息
  162. getOrderDetails(id) {
  163. // uni.showLoading({
  164. // title: '订单查询中'
  165. // });
  166. this.$u.api.getOrderDetail({id: id})
  167. .then(res => {
  168. console.log(res)
  169. if (res.code === 200) {
  170. // 获取页面完整url
  171. const local = window.location.href
  172. // 获取url后面的参数
  173. const locationLocaturl = window.location.search;
  174. // 截取url中的isBack
  175. let isBack = getUrlParams(local, "isBack");
  176. console.log('isBack',isBack);
  177. console.log('isBack',isBack == null || isBack != '1');
  178. // 如果没有isBack,则去请求
  179. if (!isBack) {
  180. // uni.hideLoading();
  181. this.show = false
  182. clearInterval(this.timer1)
  183. }
  184. this.orderInfo = res.data
  185. if (res.data.payStatus === 1) {
  186. // uni.hideLoading();
  187. this.show = false
  188. clearInterval(this.timer1)
  189. this.checkEqupment()
  190. }
  191. }
  192. })
  193. },
  194. // 检测设备
  195. checkEqupment() {
  196. this.timer = setInterval(() => {
  197. this.getEqumentStatus(this.deviceNo)
  198. }, 1000)
  199. },
  200. // 查询设备状态
  201. getEqumentStatus(orderNo) {
  202. console.log(orderNo)
  203. this.$u.api.getEquomentInfo({orderNo: orderNo})
  204. .then(res => {
  205. if (res.code === 200) {
  206. console.log(res.data)
  207. if (res.data.deviceStatus === 0) {
  208. this.parkingLockStatus = 4
  209. clearInterval(this.timer)
  210. } else if (res.data.deviceStatus === 1 || res.data.deviceStatus === 5) {
  211. this.parkingLockStatus = 2
  212. } else if (res.data.deviceStatus === 6) {
  213. this.parkingLockStatus = 3
  214. }
  215. }
  216. })
  217. },
  218. // 返回首页
  219. cancel() {
  220. uni.switchTab({
  221. url: '/pages/index/index'
  222. })
  223. },
  224. closePaymentMethod() {
  225. this.payWayPop = false
  226. }
  227. }
  228. }
  229. </script>
  230. <style lang="scss" scoped>
  231. @import './parkingLock.scss';
  232. </style>