geomagnetismLock.vue 6.5 KB

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