parkexport.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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">{{ 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. <u-toast ref="uToast" />
  84. </view>
  85. </template>
  86. <script>
  87. import ChoosePayment from '@/pages/choosePayment/choosePayment.vue';
  88. export default {
  89. components: {
  90. ChoosePayment
  91. },
  92. data() {
  93. return {
  94. intoInfo: {
  95. parkNo: '',
  96. roadwayNo: '',
  97. polyOrderId: '',
  98. isBack: 0
  99. },
  100. payWayPop: false, // 支付弹框
  101. infoData: undefined, // 订单信息
  102. orderList: [], // 支付订单列表
  103. jumpUrl: location.href + '&isBack=1', // 回调地址
  104. timer: null, // 轮询
  105. isPay: false, // 支付按钮显示
  106. choosePayment: false,
  107. tipTxt: '出口无车辆'
  108. };
  109. },
  110. onLoad(page) {
  111. this.intoInfo.parkNo = page?.parkNo;
  112. this.intoInfo.roadwayNo = page?.roadwayNo;
  113. this.intoInfo.polyOrderId = page?.polyOrderId;
  114. this.intoInfo.isBack = page?.isBack;
  115. },
  116. onShow() {
  117. this.getOrderDetails(this.intoInfo.parkNo, this.intoInfo.roadwayNo);
  118. if (this.intoInfo.polyOrderId && this.intoInfo.isBack == 1) {
  119. uni.showLoading({
  120. title: '订单状态查询中...'
  121. });
  122. this.timer = setInterval(() => {
  123. this.handlePayStatus(this.intoInfo.polyOrderId);
  124. }, 1000);
  125. }
  126. },
  127. onUnload() {
  128. clearInterval(this.timer);
  129. },
  130. methods: {
  131. /**
  132. * 立即支付
  133. */
  134. onEntraceClick() {
  135. this.choosePayment = true;
  136. this.$nextTick(() => {
  137. this.$refs['choosePayment'].openPopup({ ...this.infoData }, 'single', 'parking');
  138. });
  139. },
  140. /**
  141. * 反复查询支付状态
  142. * @param { String } orderId
  143. */
  144. handlePayStatus(orderId) {
  145. this.$u.api
  146. .getOrderStateExportApi({
  147. orderId
  148. })
  149. .then((res) => {
  150. if (res.code === 200) {
  151. if (res.data.payStatus === 1 || res.data.payStatus === 3) {
  152. clearInterval(this.timer);
  153. uni.hideLoading();
  154. this.getOrderDetails(this.intoInfo.parkNo, this.intoInfo.roadwayNo);
  155. } else if (res.data.payStatus === 2) {
  156. this.isPay = true;
  157. uni.hideLoading();
  158. }
  159. } else {
  160. clearInterval(this.timer);
  161. uni.hideLoading();
  162. this.$refs.uToast.show({
  163. title: res.msg || '支付失败!',
  164. type: 'error'
  165. });
  166. }
  167. })
  168. .catch(() => {
  169. uni.hideLoading();
  170. clearInterval(this.timer);
  171. });
  172. },
  173. /**
  174. * 查询订单信息
  175. * @param { String } parkNo 停车场编号
  176. * @param { String } roadwayNo 出口编号
  177. */
  178. getOrderDetails(parkNo, roadwayNo) {
  179. uni.showLoading({
  180. title: '订单查询中...'
  181. });
  182. this.$u.api
  183. .getDetailExportApi({
  184. parkNo,
  185. roadwayNo
  186. })
  187. .then((res) => {
  188. if (res.code === 200) {
  189. this.infoData = res.data;
  190. this.orderList = [res.data.id];
  191. if (res.data.orderStatus == 2 || res.data.orderStatus == 3) {
  192. this.isPay = true;
  193. } else {
  194. this.isPay = false;
  195. }
  196. } else {
  197. this.$refs.uToast.show({
  198. title: res.msg || '订单无数据',
  199. type: 'error'
  200. });
  201. }
  202. uni.hideLoading();
  203. })
  204. .catch((err) => {
  205. this.tipTxt = err?.msg ?? '出口无车辆'
  206. uni.hideLoading();
  207. });
  208. },
  209. /**
  210. * 关闭支付弹框
  211. */
  212. closePaymentMethod() {
  213. this.choosePayment = false;
  214. },
  215. jumpHome(url) {
  216. uni.switchTab({
  217. url: url
  218. });
  219. }
  220. }
  221. };
  222. </script>
  223. <style lang="scss" scoped>
  224. @import './parkexport.scss';
  225. </style>