parkexport.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <!-- 地磁 -->
  3. <view class="parking-lock">
  4. <!-- 地磁支付 -->
  5. <template v-if="infoData">
  6. <view class="parking-lock-pay">
  7. <view class="parking-lock-title">支付停车费</view>
  8. <view class="parking-lock-tips">请您确认停车费用,确认后请支付费用,结束停车。谢谢您的使用!</view>
  9. <view class="parking-lock-info">
  10. <view class="parking-lock-info-item">
  11. <view>车牌号</view>
  12. <view class="weight vehicle-no">{{ infoData.vehicleNo }}</view>
  13. </view>
  14. <view class="parking-lock-info-item">
  15. <view>停车场名称</view>
  16. <view class="weight">{{ infoData.parkingName }}</view>
  17. </view>
  18. <view class="parking-lock-info-item">
  19. <view>入场车道</view>
  20. <view class="weight">{{ infoData.entranceName }}</view>
  21. </view>
  22. <view class="parking-lock-info-item">
  23. <view>入场时间</view>
  24. <view class="weight">{{ infoData.inTime }}</view>
  25. </view>
  26. <view class="parking-lock-info-item">
  27. <view>出场车道</view>
  28. <view class="weight">{{ infoData.outEntranceName }}</view>
  29. </view>
  30. <view class="parking-lock-info-item">
  31. <view>出场时间</view>
  32. <view class="weight">{{ infoData.outTime }}</view>
  33. </view>
  34. <!-- <view class="parking-lock-info-item">
  35. <view>通道名称</view>
  36. <view class="weight">{{infoData.roadwayName}}</view>
  37. </view> -->
  38. <view class="parking-lock-info-item">
  39. <view>免费时长</view>
  40. <view class="weight">{{ infoData.freeDuration || `0天0时${free_time}分0秒` }}</view>
  41. </view>
  42. <view class="parking-lock-info-item">
  43. <view class="weight">计费时长</view>
  44. <view class="weight">{{ infoData.calcDuration }}</view>
  45. </view>
  46. <view class="parking-lock-info-item">
  47. <view>累计停车时长</view>
  48. <view class="weight">{{ infoData.duration }}</view>
  49. </view>
  50. <view class="parking-lock-info-item">
  51. <view>应收金额</view>
  52. <view class="weight">{{ infoData.totalAmount }}元</view>
  53. </view>
  54. <view class="parking-lock-info-item">
  55. <view>订单编号</view>
  56. <view class="weight">{{ infoData.id }}</view>
  57. </view>
  58. </view>
  59. <view class="parking-lock-pay-btn">
  60. <button type="default" v-if="isPay" @click="onEntraceClick">支付出场</button>
  61. <button type="default" v-else @click="jumpHome('/pages/index/index')">支付成功,返回首页</button>
  62. </view>
  63. </view>
  64. </template>
  65. <template v-else>
  66. <view class="parking-lock-info">
  67. <view class="parking-lock-info-item-1">
  68. <view>{{ tipTxt }}</view>
  69. </view>
  70. </view>
  71. </template>
  72. <!-- 支付方式 -->
  73. <ChoosePayment
  74. v-if="choosePayment"
  75. ref="choosePayment"
  76. :payWayPop="payWayPop"
  77. :curOrderList="orderList"
  78. :jumpUrl="jumpUrl"
  79. :exportFlag="true"
  80. :sanPay="true"
  81. @closePaymentMethod="closePaymentMethod"
  82. />
  83. <!-- 广告轮播 -->
  84. <ad-banner />
  85. <u-toast ref="uToast" />
  86. </view>
  87. </template>
  88. <script>
  89. import ChoosePayment from '@/pages/choosePayment/choosePayment.vue';
  90. import AdBanner from '@/components/ad-banner/ad-banner.vue';
  91. export default {
  92. components: {
  93. ChoosePayment,
  94. AdBanner
  95. },
  96. data() {
  97. return {
  98. intoInfo: {
  99. parkNo: '',
  100. roadwayNo: '',
  101. polyOrderId: '',
  102. isBack: 0,
  103. },
  104. payWayPop: false, // 支付弹框
  105. infoData: undefined, // 订单信息
  106. orderList: [], // 支付订单列表
  107. jumpUrl: location.href + '&isBack=1', // 回调地址
  108. timer: null, // 轮询
  109. isPay: false, // 支付按钮显示
  110. choosePayment: false,
  111. tipTxt: '出口无车辆'
  112. };
  113. },
  114. onLoad(page) {
  115. this.intoInfo.parkNo = page?.parkNo;
  116. this.intoInfo.roadwayNo = page?.roadwayNo;
  117. this.intoInfo.polyOrderId = page?.polyOrderId;
  118. this.intoInfo.isBack = page?.isBack;
  119. },
  120. onShow() {
  121. this.getOrderDetails(this.intoInfo.parkNo, this.intoInfo.roadwayNo);
  122. if (this.intoInfo.polyOrderId && this.intoInfo.isBack == 1) {
  123. uni.showLoading({
  124. title: '订单状态查询中...'
  125. });
  126. this.timer = setInterval(() => {
  127. this.handlePayStatus(this.intoInfo.polyOrderId);
  128. }, 1000);
  129. }
  130. },
  131. onUnload() {
  132. clearInterval(this.timer);
  133. },
  134. methods: {
  135. /**
  136. * 立即支付
  137. */
  138. onEntraceClick() {
  139. this.choosePayment = true;
  140. this.$nextTick(() => {
  141. this.$refs['choosePayment'].openPopup({ ...this.infoData }, 'single', 'parking');
  142. });
  143. },
  144. /**
  145. * 反复查询支付状态
  146. * @param { String } orderId
  147. */
  148. handlePayStatus(orderId) {
  149. this.$u.api
  150. .getOrderStateExportApi({
  151. orderId
  152. })
  153. .then((res) => {
  154. if (res.code === 200) {
  155. if (res.data.payStatus === 1 || res.data.payStatus === 3) {
  156. clearInterval(this.timer);
  157. uni.hideLoading();
  158. this.getOrderDetails(this.intoInfo.parkNo, this.intoInfo.roadwayNo);
  159. } else if (res.data.payStatus === 2) {
  160. this.isPay = true;
  161. uni.hideLoading();
  162. }
  163. } else {
  164. clearInterval(this.timer);
  165. uni.hideLoading();
  166. this.$refs.uToast.show({
  167. title: res.msg || '支付失败!',
  168. type: 'error'
  169. });
  170. }
  171. })
  172. .catch(() => {
  173. uni.hideLoading();
  174. clearInterval(this.timer);
  175. });
  176. },
  177. /**
  178. * 查询订单信息
  179. * @param { String } parkNo 停车场编号
  180. * @param { String } roadwayNo 出口编号
  181. */
  182. getOrderDetails(parkNo, roadwayNo) {
  183. uni.showLoading({
  184. title: '订单查询中...'
  185. });
  186. this.$u.api
  187. .getDetailExportApi({
  188. parkNo,
  189. roadwayNo
  190. })
  191. .then((res) => {
  192. if (res.code === 200) {
  193. this.infoData = res.data;
  194. this.orderList = [res.data.id];
  195. if (res.data.orderStatus == 2 || res.data.orderStatus == 3) {
  196. this.isPay = true;
  197. } else {
  198. this.isPay = false;
  199. }
  200. } else {
  201. this.$refs.uToast.show({
  202. title: res.msg || '订单无数据',
  203. type: 'error'
  204. });
  205. }
  206. uni.hideLoading();
  207. })
  208. .catch((err) => {
  209. this.tipTxt = err?.msg ?? '出口无车辆'
  210. uni.hideLoading();
  211. });
  212. },
  213. /**
  214. * 关闭支付弹框
  215. */
  216. closePaymentMethod() {
  217. this.choosePayment = false;
  218. },
  219. jumpHome(url) {
  220. uni.switchTab({
  221. url: url
  222. });
  223. }
  224. }
  225. };
  226. </script>
  227. <style lang="scss" scoped>
  228. @import './parkexport.scss';
  229. </style>