geomagnetismLock.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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" :pursueType="pursueType" @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. pursueType: '',
  111. is_pay: false
  112. }
  113. },
  114. onLoad(page) {
  115. if (page.orderId) {
  116. this.orderId = page?.orderId
  117. this.spaceId = page?.orderId
  118. this.payeeId = page?.payeeId
  119. this.polyOrderId = page?.polyOrderId
  120. this.pursueType = page?.pursueType
  121. this.isBack = page?.isBack
  122. } else {
  123. this.tipsMsg = page.msg || '参数丢失!';
  124. this.parkingLockStatus = 2
  125. }
  126. },
  127. onShow() {
  128. if (this.orderId) {
  129. this.getOrderDetails(this.spaceId, this.orderId, this.payeeId)
  130. if (this.polyOrderId && this.isBack == 1) {
  131. this.timer = setInterval(() => {
  132. this.show = true
  133. this.handlePayStatus(this.polyOrderId)
  134. }, 1000)
  135. }
  136. } else {
  137. this.show = false
  138. }
  139. },
  140. onUnload() {
  141. if (this.timer) {
  142. clearInterval(this.timer)
  143. }
  144. },
  145. methods: {
  146. /**
  147. * 反复查询支付状态
  148. * @param { String } orderId
  149. */
  150. handlePayStatus(orderId) {
  151. this.$u.api.getOrderInfo({
  152. orderId
  153. }).then(res => {
  154. if (res.code === 200) {
  155. if (res.data.payStatus === 1 || res.data.payStatus === 3) {
  156. this.show = false
  157. clearInterval(this.timer);
  158. this.is_pay = false
  159. uni.showModal({
  160. title: '提示',
  161. content: '支付成功,返回首页',
  162. showCancel: false,
  163. success: (res) => {
  164. if (res.confirm) {
  165. uni.switchTab({
  166. url: '/pages/index/index'
  167. })
  168. }
  169. }
  170. });
  171. } else if (res.data.payStatus === 2) {
  172. this.is_pay = true
  173. }
  174. } else {
  175. this.show = false
  176. clearInterval(this.timer);
  177. this.$refs.uToast.show({
  178. title: res.msg,
  179. type: 'error',
  180. });
  181. }
  182. }).catch(() => {
  183. this.show = false
  184. clearInterval(this.timer);
  185. })
  186. },
  187. /**
  188. * 立即支付
  189. */
  190. payMoney() {
  191. this.payWayPop = true
  192. },
  193. /**
  194. * 查询订单信息
  195. * @param { String } spaceId 车位ID
  196. * @param { String } orderId 订单id
  197. * @param { String } payeeId 收费员ID
  198. */
  199. getOrderDetails(spaceId, orderId, payeeId) {
  200. this.$u.api.geomaLockDetailsApi({
  201. spaceId,
  202. orderId,
  203. payeeId
  204. }).then(res => {
  205. if (res.code === 200 && res.data.id) {
  206. this.payeeName = res.data.payeeName
  207. this.parkingLockStatus = 1
  208. this.orderInfo = res.data
  209. this.show = false
  210. if (res.data.payStatus == 0 || res.data.payStatus == 2) {
  211. this.is_pay = true
  212. } else if (res.data.payStatus == 1) {
  213. this.is_pay = false
  214. uni.showModal({
  215. title: '提示',
  216. content: '订单已支付,返回首页',
  217. showCancel: false,
  218. success: function(res) {
  219. if (res.confirm) {
  220. uni.switchTab({
  221. url: '/pages/index/index'
  222. })
  223. }
  224. }
  225. });
  226. }
  227. if (res.data.payAmount == 0) {
  228. this.is_pay = false
  229. }
  230. } else {
  231. this.$refs.uToast.show({
  232. title: res.msg || '订单无数据',
  233. type: 'error',
  234. });
  235. }
  236. })
  237. },
  238. /**
  239. * 关闭支付弹框
  240. */
  241. closePaymentMethod() {
  242. this.payWayPop = false
  243. }
  244. }
  245. }
  246. </script>
  247. <style lang="scss" scoped>
  248. @import './geomagnetismLock.scss';
  249. </style>