parkingLock.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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: true,
  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 {
  166. this.tipsMsg = page.msg || '参数丢失!';
  167. this.parkingLockStatus = 5;
  168. }
  169. },
  170. onShow() {
  171. if (this.orderId) {
  172. if (this.polyOrderId && this.isBack == 1) {
  173. this.timer1 = setInterval(() => {
  174. this.show = true;
  175. this.handlePayStatus(this.polyOrderId);
  176. }, 2000);
  177. }
  178. } else {
  179. this.show = false;
  180. }
  181. },
  182. onUnload() {
  183. if (this.timer) {
  184. clearInterval(this.timer);
  185. }
  186. if (this.timer1) {
  187. clearInterval(this.timer1);
  188. }
  189. },
  190. methods: {
  191. /**
  192. * 跳转欠费页面
  193. * @date 2023-02-22
  194. * @returns {any}
  195. */
  196. jumpArrears() {
  197. uni.navigateTo({
  198. url: '../center/order/order?orderStatus=2'
  199. });
  200. },
  201. /**
  202. * 反复查询支付状态
  203. * @param { String } orderId
  204. */
  205. handlePayStatus(orderId) {
  206. this.$u.api
  207. .getOrderInfo({
  208. orderId
  209. })
  210. .then((res) => {
  211. if (res.code === 200) {
  212. if (res.data.payStatus === 1 || res.data.payStatus === 3) {
  213. this.show = false;
  214. clearInterval(this.timer1);
  215. this.getOrderDetails(this.orderId);
  216. }
  217. } else {
  218. this.show = false;
  219. clearInterval(this.timer1);
  220. this.$refs.uToast.show({
  221. title: res.msg,
  222. type: 'error'
  223. });
  224. }
  225. })
  226. .catch(() => {
  227. this.show = false;
  228. clearInterval(this.timer1);
  229. });
  230. },
  231. /**
  232. * 立即支付
  233. * @date 2023-02-22
  234. * @returns {any}
  235. */
  236. payMoney() {
  237. this.$nextTick(() => {
  238. this.$refs['choosePayment'].openPopup({ ...this.orderInfo }, 'single', 'road');
  239. });
  240. },
  241. /**
  242. * 根据订单id查询订单信息
  243. * @date 2023-02-22
  244. * @param {any} id
  245. * @returns {any}
  246. */
  247. getOrderDetails(id) {
  248. this.$u.api
  249. .getOrderDetail({
  250. id
  251. })
  252. .then((res) => {
  253. if (res.code === 200 && res.data.id) {
  254. this.parkingLockStatus = 1;
  255. // 获取页面完整url
  256. const local = window.location.href;
  257. // 获取url后面的参数
  258. const locationLocaturl = window.location.search;
  259. // 截取url中的isBack
  260. let isBack = getUrlParams(local, 'isBack');
  261. // 如果没有isBack,则去请求
  262. if (!isBack) {
  263. // uni.hideLoading();
  264. this.show = false;
  265. clearInterval(this.timer1);
  266. }
  267. this.orderInfo = res.data;
  268. if (res.data.payStatus === 1) {
  269. this.show = false;
  270. clearInterval(this.timer1);
  271. this.checkEqupment();
  272. }
  273. } else {
  274. this.$refs.uToast.show({
  275. title: res.msg || '订单无数据',
  276. type: 'error'
  277. });
  278. this.show = false;
  279. if (this.timer1) {
  280. clearInterval(this.timer1);
  281. }
  282. }
  283. })
  284. .catch(() => {
  285. this.show = false;
  286. if (this.timer1) {
  287. clearInterval(this.timer1);
  288. }
  289. });
  290. },
  291. // 检测设备
  292. checkEqupment() {
  293. this.timer = setInterval(() => {
  294. this.getEqumentStatus(this.deviceNo);
  295. }, 1000);
  296. },
  297. // 查询设备状态
  298. getEqumentStatus(orderNo) {
  299. this.$u.api
  300. .getEquomentInfo({
  301. orderNo
  302. })
  303. .then((res) => {
  304. if (res.code === 200) {
  305. if (res.data.deviceStatus == 0) {
  306. this.parkingLockStatus = 4;
  307. clearInterval(this.timer);
  308. } else if (res.data.deviceStatus == 1 || res.data.deviceStatus == 5) {
  309. this.parkingLockStatus = 2;
  310. } else if (res.data.deviceStatus == 6) {
  311. this.parkingLockStatus = 3;
  312. }
  313. } else {
  314. clearInterval(this.timer);
  315. }
  316. })
  317. .catch(() => {
  318. clearInterval(this.timer);
  319. });
  320. },
  321. // 返回首页
  322. cancel() {
  323. uni.switchTab({
  324. url: '/pages/index/index'
  325. });
  326. }
  327. }
  328. };
  329. </script>
  330. <style lang="scss" scoped>
  331. @import './parkingLock.scss';
  332. .Jump {
  333. display: flex;
  334. justify-content: flex-end;
  335. background-color: #f6f6ff;
  336. &-btn {
  337. color: rgb(0, 140, 255);
  338. padding: 20rpx 30rpx;
  339. }
  340. }
  341. </style>