parkingLock.vue 6.8 KB

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