parkingLock.vue 11 KB

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