roadGateSystem.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <!-- 道闸 -->
  3. <view class="parking-lock">
  4. <!-- 道闸支付 -->
  5. <template v-if="parkingLockStatus === 1">
  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">{{ orderInfo.vehicleNo }}</view>
  13. </view>
  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>{{ '入口1' }}</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>{{ '出口1' }}</view>
  29. </view>
  30. <view class="parking-lock-info-item">
  31. <view>出场时间</view>
  32. <view>{{ orderInfo.outTime }}</view>
  33. </view>
  34. <view class="parking-lock-info-item">
  35. <view>免费时长</view>
  36. <!-- <view>{{ orderInfo.freeDuration || '0天0时15分0秒' }}</view> -->
  37. <view>{{ `0天0时${free_time}分0秒` }}</view>
  38. </view>
  39. <view class="parking-lock-info-item">
  40. <view>计费时长</view>
  41. <view>{{ orderInfo.calcDuration || 0 }}</view>
  42. </view>
  43. <view class="parking-lock-info-item">
  44. <view>累计停车时长</view>
  45. <view>{{ orderInfo.duration || 0 }}</view>
  46. </view>
  47. <view class="parking-lock-info-item">
  48. <view>应缴金额</view>
  49. <view class="really-money">{{ orderInfo.payAmount || 0 }} 元</view>
  50. </view>
  51. <view class="parking-lock-info-item">
  52. <view>订单编号</view>
  53. <view>{{ orderInfo.orderId }}</view>
  54. </view>
  55. </view>
  56. <view class="parking-lock-pay-btn" v-if="is_pay">
  57. <button type="default" @click="payMoney">立即支付</button>
  58. </view>
  59. </view>
  60. </template>
  61. <template v-else-if="parkingLockStatus === 2">
  62. <view class="parking-lock-pay">
  63. <view class="parking-lock-tips">{{ tipsMsg }}</view>
  64. </view>
  65. </template>
  66. <!-- 支付方式 -->
  67. <PaymentMethod
  68. :payWayPop="payWayPop"
  69. :curOrderList="[orderId]"
  70. :jumpUrl="jumpUrl"
  71. :payeeId="payeeId"
  72. :payeeName="payeeName"
  73. :vehicleNo="orderInfo.vehicleNo"
  74. @closePaymentMethod="closePaymentMethod"
  75. >
  76. </PaymentMethod>
  77. <u-popup v-model="show" mode="center" border-radius="14" width="200rpx" height="200rpx">
  78. <view class="loadingSelect">订单查询中...</view>
  79. <view class="spinner">
  80. <view class="rect1"></view>
  81. <view class="rect2"></view>
  82. <view class="rect3"></view>
  83. <view class="rect4"></view>
  84. <view class="rect5"></view>
  85. </view>
  86. </u-popup>
  87. <u-toast ref="uToast" />
  88. </view>
  89. </template>
  90. <script>
  91. import getUrlParams from '../../utils/getUrlParams.js';
  92. import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue';
  93. export default {
  94. components: {
  95. PaymentMethod
  96. },
  97. data() {
  98. return {
  99. // 车位锁状态 1:需支付 2:查询失败返回提醒
  100. parkingLockStatus: 0,
  101. // 支付方式选择弹框
  102. payWayPop: false,
  103. // 订单编号
  104. orderList: [],
  105. // 提示信息
  106. tipsMsg: null,
  107. // 轮询
  108. timer: null,
  109. // 订单信息
  110. orderInfo: {},
  111. // 订单id
  112. orderId: null,
  113. // 重定向地址
  114. jumpUrl: location.href + '&isBack=1',
  115. show: true,
  116. isBack: '',
  117. polyOrderId: '',
  118. // 地磁
  119. spaceId: '',
  120. payeeId: '',
  121. payeeName: '',
  122. is_pay: false
  123. };
  124. },
  125. onLoad(page) {
  126. if (page.orderId) {
  127. this.orderId = page?.orderId;
  128. this.spaceId = page?.spaceId;
  129. this.payeeId = page?.payeeId;
  130. this.polyOrderId = page?.polyOrderId;
  131. this.isBack = page?.isBack;
  132. } else {
  133. this.tipsMsg = page.msg || '参数丢失!';
  134. // this.parkingLockStatus = 2
  135. uni.showModal({
  136. title: '提示',
  137. content: (page.msg || '参数丢失') + ',返回首页',
  138. showCancel: false,
  139. success: (res) => {
  140. if (res.confirm) {
  141. uni.switchTab({
  142. url: '/pages/index/index'
  143. });
  144. }
  145. }
  146. });
  147. }
  148. },
  149. onShow() {
  150. if (this.orderId) {
  151. this.getOrderDetails(this.spaceId, this.orderId, this.payeeId);
  152. if (this.polyOrderId && this.isBack == 1) {
  153. this.timer = setInterval(() => {
  154. this.show = true;
  155. this.handlePayStatus(this.polyOrderId);
  156. }, 1000);
  157. }
  158. } else {
  159. this.show = false;
  160. }
  161. },
  162. onUnload() {
  163. if (this.timer) {
  164. clearInterval(this.timer);
  165. }
  166. },
  167. methods: {
  168. /**
  169. * 反复查询支付状态
  170. * @param { String } orderId
  171. */
  172. handlePayStatus(orderId) {
  173. this.$u.api
  174. .getOrderInfo({
  175. orderId
  176. })
  177. .then((res) => {
  178. if (res.code === 200) {
  179. if (res.data.payStatus === 1 || res.data.payStatus === 3) {
  180. this.show = false;
  181. clearInterval(this.timer);
  182. this.is_pay = false;
  183. uni.showModal({
  184. title: '提示',
  185. content: '支付成功,返回首页',
  186. showCancel: false,
  187. success: (res) => {
  188. if (res.confirm) {
  189. uni.switchTab({
  190. url: '/pages/index/index'
  191. });
  192. }
  193. }
  194. });
  195. } else if (res.data.payStatus === 2) {
  196. this.is_pay = true;
  197. }
  198. } else {
  199. this.show = false;
  200. clearInterval(this.timer);
  201. this.$refs.uToast.show({
  202. title: res.msg,
  203. type: 'error'
  204. });
  205. }
  206. })
  207. .catch(() => {
  208. this.show = false;
  209. clearInterval(this.timer);
  210. });
  211. },
  212. /**
  213. * 立即支付
  214. */
  215. payMoney() {
  216. this.payWayPop = true;
  217. },
  218. /**
  219. * 查询订单信息
  220. * @param { String } spaceId 车位ID
  221. * @param { String } orderId 订单id
  222. * @param { String } payeeId 收费员ID
  223. */
  224. getOrderDetails(spaceId, orderId, payeeId) {
  225. this.$u.api
  226. .geomaLockDetailsApi({
  227. spaceId,
  228. orderId,
  229. payeeId
  230. })
  231. .then((res) => {
  232. if (res.code === 200 && res.data.id) {
  233. this.payeeName = res.data.payeeName;
  234. this.parkingLockStatus = 1;
  235. this.orderInfo = res.data;
  236. this.show = false;
  237. if (res.data.payStatus == 0 || res.data.payStatus == 2) {
  238. this.is_pay = true;
  239. } else if (res.data.payStatus == 1) {
  240. this.is_pay = false;
  241. uni.showModal({
  242. title: '提示',
  243. content: '订单已支付,返回首页',
  244. showCancel: false,
  245. success: function (res) {
  246. if (res.confirm) {
  247. uni.switchTab({
  248. url: '/pages/index/index'
  249. });
  250. }
  251. }
  252. });
  253. }
  254. } else {
  255. this.$refs.uToast.show({
  256. title: res.msg || '订单无数据',
  257. type: 'error'
  258. });
  259. }
  260. })
  261. .catch((err) => {
  262. this.show = false;
  263. });
  264. },
  265. /**
  266. * 关闭支付弹框
  267. */
  268. closePaymentMethod() {
  269. this.payWayPop = false;
  270. }
  271. }
  272. };
  273. </script>
  274. <style lang="scss" scoped>
  275. @import './roadGateSystem.scss';
  276. </style>