parkingLock.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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. <u-toast ref="uToast" />
  117. </view>
  118. </template>
  119. <script>
  120. import getUrlParams from '@/utils/getUrlParams.js';
  121. import ChoosePayment from '@/pages/choosePayment/choosePayment.vue';
  122. export default {
  123. components: {
  124. ChoosePayment
  125. },
  126. data() {
  127. return {
  128. // 车位锁状态 1:支付 2:开始开锁 3:开锁中 4:开锁完成
  129. parkingLockStatus: 0,
  130. // 支付方式选择弹框
  131. payWayPop: false,
  132. // 订单编号
  133. orderList: [],
  134. // 提示信息
  135. tipsMsg: null,
  136. // 设备编号
  137. deviceNo: null,
  138. // 设备状态轮询
  139. timer: null,
  140. // 订单状态查询轮询
  141. timer1: null,
  142. // 订单信息
  143. orderInfo: {},
  144. // 订单id
  145. orderId: null,
  146. // 重定向地址
  147. jumpUrl: location.href + '&isBack=1',
  148. // 订单查询中弹框显示
  149. show: false,
  150. // 是否为返回标识
  151. isBack: '',
  152. // 预支付订单
  153. polyOrderId: ''
  154. };
  155. },
  156. onLoad(page) {
  157. if (page.orderId) {
  158. this.getOrderDetails(page.orderId);
  159. this.orderList = [];
  160. this.orderId = page.orderId;
  161. this.orderList.push(page.orderId);
  162. this.deviceNo = page.deviceNo;
  163. this.isBack = page?.isBack;
  164. this.polyOrderId = page?.polyOrderId;
  165. } else if (page.msg) {
  166. this.tipsMsg = page?.msg;
  167. this.parkingLockStatus = 5;
  168. } else {
  169. uni.showModal({
  170. title: '提示',
  171. content: '参数丢失, 返回首页',
  172. showCancel: false,
  173. success: function (res) {
  174. if (res.confirm) {
  175. uni.switchTab({
  176. url: '/pages/index/index'
  177. });
  178. }
  179. }
  180. });
  181. }
  182. },
  183. onShow() {
  184. if (this.orderId) {
  185. if (this.polyOrderId && this.isBack == 1) {
  186. this.timer1 = setInterval(() => {
  187. this.show = true;
  188. this.handlePayStatus(this.polyOrderId);
  189. }, 2000);
  190. }
  191. } else {
  192. this.show = false;
  193. }
  194. },
  195. onUnload() {
  196. if (this.timer) {
  197. clearInterval(this.timer);
  198. }
  199. if (this.timer1) {
  200. clearInterval(this.timer1);
  201. }
  202. },
  203. methods: {
  204. /**
  205. * 跳转欠费页面
  206. * @date 2023-02-22
  207. * @returns {any}
  208. */
  209. jumpArrears() {
  210. uni.navigateTo({
  211. url: '../center/order/order?orderStatus=2'
  212. });
  213. },
  214. /**
  215. * 反复查询支付状态
  216. * @param { String } orderId
  217. */
  218. handlePayStatus(orderId) {
  219. this.$u.api
  220. .getOrderInfo({
  221. orderId
  222. })
  223. .then((res) => {
  224. if (res.code === 200) {
  225. if (res.data.payStatus === 1 || res.data.payStatus === 3) {
  226. this.show = false;
  227. clearInterval(this.timer1);
  228. this.getOrderDetails(this.orderId);
  229. }
  230. } else {
  231. this.show = false;
  232. clearInterval(this.timer1);
  233. this.$refs.uToast.show({
  234. title: res.msg,
  235. type: 'error'
  236. });
  237. }
  238. })
  239. .catch(() => {
  240. this.show = false;
  241. clearInterval(this.timer1);
  242. });
  243. },
  244. /**
  245. * 立即支付
  246. * @date 2023-02-22
  247. * @returns {any}
  248. */
  249. payMoney() {
  250. this.$nextTick(() => {
  251. this.$refs['choosePayment'].openPopup({ ...this.orderInfo }, 'single', 'road');
  252. });
  253. },
  254. /**
  255. * 根据订单id查询订单信息
  256. * @date 2023-02-22
  257. * @param {any} id
  258. * @returns {any}
  259. */
  260. getOrderDetails(id) {
  261. this.$u.api
  262. .getOrderDetail({
  263. id
  264. })
  265. .then((res) => {
  266. if (res.code === 200 && res.data.id) {
  267. this.parkingLockStatus = 1;
  268. // 获取页面完整url
  269. const local = window.location.href;
  270. // 获取url后面的参数
  271. const locationLocaturl = window.location.search;
  272. // 截取url中的isBack
  273. let isBack = getUrlParams(local, 'isBack');
  274. // 如果没有isBack,则去请求
  275. if (!isBack) {
  276. // uni.hideLoading();
  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.$refs.uToast.show({
  286. title: res.msg || '订单无数据',
  287. type: 'error'
  288. });
  289. if (this.timer1) {
  290. clearInterval(this.timer1);
  291. }
  292. }
  293. })
  294. .catch(() => {
  295. if (this.timer1) {
  296. clearInterval(this.timer1);
  297. }
  298. });
  299. },
  300. // 检测设备
  301. checkEqupment() {
  302. this.timer = setInterval(() => {
  303. this.getEqumentStatus(this.deviceNo);
  304. }, 1000);
  305. },
  306. // 查询设备状态
  307. getEqumentStatus(orderNo) {
  308. this.$u.api
  309. .getEquomentInfo({
  310. orderNo
  311. })
  312. .then((res) => {
  313. if (res.code === 200) {
  314. if (res.data.deviceStatus == 0) {
  315. this.parkingLockStatus = 4;
  316. clearInterval(this.timer);
  317. } else if (res.data.deviceStatus == 1 || res.data.deviceStatus == 5) {
  318. this.parkingLockStatus = 2;
  319. } else if (res.data.deviceStatus == 6) {
  320. this.parkingLockStatus = 3;
  321. }
  322. } else {
  323. clearInterval(this.timer);
  324. }
  325. })
  326. .catch(() => {
  327. clearInterval(this.timer);
  328. });
  329. },
  330. // 返回首页
  331. cancel() {
  332. uni.switchTab({
  333. url: '/pages/index/index'
  334. });
  335. }
  336. }
  337. };
  338. </script>
  339. <style lang="scss" scoped>
  340. @import './parkingLock.scss';
  341. .Jump {
  342. display: flex;
  343. justify-content: flex-end;
  344. background-color: #f6f6ff;
  345. &-btn {
  346. color: rgb(0, 140, 255);
  347. padding: 20rpx 30rpx;
  348. }
  349. }
  350. </style>