parkexport.vue 6.6 KB

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