parkingLock.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <view class="parking-lock">
  3. <view class="Jump">
  4. <view class="Jump-btn" @click="jumpArrears"> 欠费补缴 </view>
  5. </view>
  6. <!-- 车位锁 -->
  7. <view class="parking-lock-box">
  8. <!-- 车位锁支付 -->
  9. <template v-if="parkingLockStatus === 1">
  10. <view class="parking-lock-pay">
  11. <view class="parking-lock-title">支付停车费</view>
  12. <view class="parking-lock-tips">请您确认停车费用,确认后请支付费用,结束停车。谢谢您的使用!</view>
  13. <view class="parking-lock-info">
  14. <view class="parking-lock-info-item">
  15. <view>停车场名称</view>
  16. <view>{{ orderInfo.roadName }}</view>
  17. </view>
  18. <view class="parking-lock-info-item">
  19. <view>停车泊位</view>
  20. <view>{{ orderInfo.spaceName }}</view>
  21. </view>
  22. <view class="parking-lock-info-item">
  23. <view>开始计费</view>
  24. <view>{{ orderInfo.inTime }}</view>
  25. </view>
  26. <view class="parking-lock-info-item">
  27. <view>结束计费</view>
  28. <view>{{ orderInfo.outTime }}</view>
  29. </view>
  30. <view class="parking-lock-info-item">
  31. <view>免费时长</view>
  32. <view>{{ orderInfo.freeDuration || `0天0时${free_time}分0秒` }}</view>
  33. </view>
  34. <view class="parking-lock-info-item">
  35. <view>计费时长</view>
  36. <view>{{ orderInfo.calcDuration || 0 }}</view>
  37. </view>
  38. <view class="parking-lock-info-item">
  39. <view>累计停车时长</view>
  40. <view>{{ orderInfo.duration || 0 }}</view>
  41. </view>
  42. <view class="parking-lock-info-item">
  43. <view>应缴金额</view>
  44. <view class="really-money">{{ orderInfo.payAmount || 0 }} 元</view>
  45. </view>
  46. <view class="parking-lock-info-item">
  47. <view>订单编号</view>
  48. <view>{{ orderInfo.orderId }}</view>
  49. </view>
  50. </view>
  51. <view class="parking-lock-pay-btn">
  52. <button type="default" @click="payMoney">立即支付</button>
  53. </view>
  54. <view class="parking-lock-pay-attention">
  55. <text>
  56. 温馨提示:车辆计费前您有{{ orderInfo.freeDurationNum / 60 }}分钟免费停车时长,{{
  57. orderInfo.freeDurationNum / 60
  58. }}分钟过后则升板锁车开始计费。
  59. </text>
  60. </view>
  61. </view>
  62. </template>
  63. <!-- 车位锁开始状态 -->
  64. <template v-else-if="parkingLockStatus === 2">
  65. <view class="parking-lock-begin">
  66. <view class="parking-lock-begin-box">
  67. <view class="parking-lock-begin-bg">
  68. <image src="../../static/img/parking-lock-bg.png" mode=""></image>
  69. </view>
  70. </view>
  71. <view class="parking-lock-begin-info">车位锁正在动作,还未到位</view>
  72. </view>
  73. </template>
  74. <!-- 车位锁正在状态 -->
  75. <template v-else-if="parkingLockStatus === 3">
  76. <view class="parking-lock-loading">
  77. <view class="parking-lock-loading-box">
  78. <view class="parking-lock-loading-bg">
  79. <image src="../../static/img/parking-lock-bg.png" mode=""></image>
  80. </view>
  81. </view>
  82. <view class="parking-lock-loading-info">开锁中,请等待!</view>
  83. </view>
  84. </template>
  85. <!-- 开锁完成 -->
  86. <template v-else-if="parkingLockStatus === 4">
  87. <view class="parking-lock-success">
  88. <view class="parking-lock-success-box">
  89. <image src="../../static/img/parking-lock-achieve.png" mode=""></image>
  90. </view>
  91. <view class="parking-lock-success-info">开锁已完成</view>
  92. <view class="parking-lock-success-button">
  93. <button @click="cancel">返回</button>
  94. </view>
  95. </view>
  96. </template>
  97. <template v-else-if="parkingLockStatus === 5">
  98. <view class="parking-lock-pay">
  99. <view class="parking-lock-tips">{{ tipsMsg }}</view>
  100. </view>
  101. </template>
  102. <!-- 支付方式 -->
  103. <ChoosePayment ref="choosePayment" :curOrderList="orderList" :deviceNo="deviceNo" :jumpUrl="jumpUrl" />
  104. <!-- 订单查询加载弹框 -->
  105. <u-popup v-model="show" mode="center" border-radius="14" width="200rpx" height="200rpx">
  106. <view class="loadingSelect">订单查询中...</view>
  107. <view class="spinner">
  108. <view class="rect1"></view>
  109. <view class="rect2"></view>
  110. <view class="rect3"></view>
  111. <view class="rect4"></view>
  112. <view class="rect5"></view>
  113. </view>
  114. </u-popup>
  115. </view>
  116. <!-- 广告轮播 -->
  117. <ad-banner/>
  118. <!-- 参数丢失弹框 -->
  119. <parmas-loss-pop :show="lossPopShow" />
  120. <!-- 页面报错弹框 -->
  121. <page-error-pop :show="pageErrorShow" :tipText="pageErrorTxt" @pageErrorPopClose="pageErrorPopClose" />
  122. <u-toast ref="uToast" />
  123. </view>
  124. </template>
  125. <script>
  126. import getUrlParams from '@/utils/getUrlParams.js';
  127. import ChoosePayment from '@/pages/choosePayment/choosePayment.vue';
  128. import AdBanner from '@/components/ad-banner/ad-banner.vue';
  129. import ParmasLossPop from '@/components/params-loss-pop/params-loss-pop.vue';
  130. import PageErrorPop from '@/components/page-error-pop/page-error-pop.vue';
  131. export default {
  132. components: {
  133. ChoosePayment,
  134. AdBanner,
  135. ParmasLossPop
  136. },
  137. data() {
  138. return {
  139. // 车位锁状态 1:支付 2:开始开锁 3:开锁中 4:开锁完成
  140. parkingLockStatus: 0,
  141. // 支付方式选择弹框
  142. payWayPop: false,
  143. // 订单编号
  144. orderList: [],
  145. // 提示信息
  146. tipsMsg: null,
  147. // 设备编号
  148. deviceNo: null,
  149. // 设备状态轮询
  150. timer: null,
  151. // 订单状态查询轮询
  152. timer1: null,
  153. // 订单信息
  154. orderInfo: {},
  155. // 订单id
  156. orderId: null,
  157. // 重定向地址
  158. jumpUrl: location.href + '&isBack=1',
  159. // 订单查询中弹框显示
  160. show: false,
  161. // 是否为返回标识
  162. isBack: '',
  163. // 预支付订单
  164. polyOrderId: '',
  165. lossPopShow: false,
  166. pageErrorShow: false,
  167. pageErrorTxt: ''
  168. };
  169. },
  170. onLoad(page) {
  171. if (page.orderId) {
  172. this.getOrderDetails(page.orderId);
  173. this.orderList = [];
  174. this.orderId = page.orderId;
  175. this.orderList.push(page.orderId);
  176. this.deviceNo = page.deviceNo;
  177. this.isBack = page?.isBack;
  178. this.polyOrderId = page?.polyOrderId;
  179. } else if (page.msg) {
  180. this.tipsMsg = page?.msg;
  181. this.parkingLockStatus = 5;
  182. } else {
  183. this.lossPopShow = true;
  184. }
  185. },
  186. onShow() {
  187. if (this.orderId) {
  188. if (this.polyOrderId && this.isBack == 1) {
  189. this.timer1 = setInterval(() => {
  190. this.show = true;
  191. this.handlePayStatus(this.polyOrderId);
  192. }, 2000);
  193. }
  194. } else {
  195. this.show = false;
  196. }
  197. },
  198. onUnload() {
  199. if (this.timer) {
  200. clearInterval(this.timer);
  201. }
  202. if (this.timer1) {
  203. clearInterval(this.timer1);
  204. }
  205. },
  206. methods: {
  207. /**
  208. * 跳转欠费页面
  209. * @date 2023-02-22
  210. * @returns {any}
  211. */
  212. jumpArrears() {
  213. uni.navigateTo({
  214. url: '../center/order/order?orderStatus=2'
  215. });
  216. },
  217. /**
  218. * 反复查询支付状态
  219. * @param { String } orderId
  220. */
  221. handlePayStatus(orderId) {
  222. this.$u.api
  223. .getOrderInfo({
  224. orderId
  225. })
  226. .then((res) => {
  227. if (res.code === 200) {
  228. if (res.data.payStatus === 1 || res.data.payStatus === 3) {
  229. this.show = false;
  230. clearInterval(this.timer1);
  231. this.getOrderDetails(this.orderId);
  232. }
  233. } else {
  234. this.show = false;
  235. clearInterval(this.timer1);
  236. this.$refs.uToast.show({
  237. title: res.msg,
  238. type: 'error'
  239. });
  240. }
  241. })
  242. .catch(() => {
  243. this.show = false;
  244. clearInterval(this.timer1);
  245. });
  246. },
  247. /**
  248. * 立即支付
  249. * @date 2023-02-22
  250. * @returns {any}
  251. */
  252. payMoney() {
  253. this.$nextTick(() => {
  254. this.$refs['choosePayment'].openPopup({ ...this.orderInfo }, 'single', 'road');
  255. });
  256. },
  257. /**
  258. * 根据订单id查询订单信息
  259. * @date 2023-02-22
  260. * @param {any} id
  261. * @returns {any}
  262. */
  263. getOrderDetails(id) {
  264. this.$u.api
  265. .getOrderDetail({
  266. id
  267. })
  268. .then((res) => {
  269. if (res.code === 200 && res.data.id) {
  270. this.parkingLockStatus = 1;
  271. // 获取页面完整url
  272. const local = window.location.href;
  273. // 截取url中的isBack
  274. let isBack = getUrlParams(local, 'isBack');
  275. // 如果没有isBack,则去请求
  276. if (!isBack) {
  277. clearInterval(this.timer1);
  278. }
  279. this.orderInfo = res.data;
  280. if (res.data.payStatus === 1) {
  281. clearInterval(this.timer1);
  282. this.checkEqupment();
  283. }
  284. } else {
  285. this.pageErrorShow = true;
  286. this.pageErrorTxt = res.msg || '订单无数据'
  287. if (this.timer1) {
  288. clearInterval(this.timer1);
  289. }
  290. }
  291. })
  292. .catch(() => {
  293. if (this.timer1) {
  294. clearInterval(this.timer1);
  295. }
  296. });
  297. },
  298. // 检测设备
  299. checkEqupment() {
  300. this.timer = setInterval(() => {
  301. this.getEqumentStatus(this.deviceNo);
  302. }, 1000);
  303. },
  304. // 查询设备状态
  305. getEqumentStatus(orderNo) {
  306. this.$u.api
  307. .getEquomentInfo({
  308. orderNo
  309. })
  310. .then((res) => {
  311. if (res.code === 200) {
  312. if (res.data.deviceStatus == 0) {
  313. this.parkingLockStatus = 4;
  314. clearInterval(this.timer);
  315. } else if (res.data.deviceStatus == 1 || res.data.deviceStatus == 5) {
  316. this.parkingLockStatus = 2;
  317. } else if (res.data.deviceStatus == 6) {
  318. this.parkingLockStatus = 3;
  319. }
  320. } else {
  321. clearInterval(this.timer);
  322. }
  323. })
  324. .catch(() => {
  325. clearInterval(this.timer);
  326. });
  327. },
  328. // 返回首页
  329. cancel() {
  330. uni.switchTab({
  331. url: '/pages/index/index'
  332. });
  333. },
  334. pageErrorPopClose() {
  335. this.pageErrorShow = false;
  336. }
  337. }
  338. };
  339. </script>
  340. <style lang="scss" scoped>
  341. @import './parkingLock.scss';
  342. .Jump {
  343. display: flex;
  344. justify-content: flex-end;
  345. background-color: #f6f6ff;
  346. &-btn {
  347. color: rgb(0, 140, 255);
  348. padding: 20rpx 30rpx;
  349. }
  350. }
  351. </style>