orderDetails.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <view class="wrap">
  3. <view class="order-info">
  4. <u-image
  5. class="order-info-img"
  6. width="90rpx"
  7. height="90rpx"
  8. src="../../../../static/img/position.png"
  9. ></u-image>
  10. <view class="addr">{{ orderInfo.roadName }}</view>
  11. <view class="pay-amount" v-if="orderInfo.payAmount">-{{ orderInfo.payAmount }}</view>
  12. <view class="pay-amount" v-else>{{ orderInfo.payAmount }}</view>
  13. <u-cell-group :border="false">
  14. <u-cell-item
  15. title="车牌号"
  16. :arrow="false"
  17. :border-bottom="false"
  18. :border-top="false"
  19. :value="orderInfo.vehicleNo"
  20. ></u-cell-item>
  21. <u-cell-item
  22. title="优惠总金额"
  23. :arrow="false"
  24. :border-bottom="false"
  25. :border-top="false"
  26. :value="(orderInfo.preferentialAmount ? orderInfo.preferentialAmount.toFixed(2) : 0) + ' 元'"
  27. ></u-cell-item>
  28. </u-cell-group>
  29. <u-cell-group>
  30. <u-cell-item
  31. title="订单编号 "
  32. :arrow="false"
  33. :border-bottom="false"
  34. :border-top="false"
  35. :value="orderInfo.orderId"
  36. ></u-cell-item>
  37. <u-cell-item
  38. title="入场时间 "
  39. :arrow="false"
  40. :border-bottom="false"
  41. :border-top="false"
  42. :value="orderInfo.inTime"
  43. ></u-cell-item>
  44. <u-cell-item
  45. title="停车时长 "
  46. :arrow="false"
  47. :border-bottom="false"
  48. :border-top="false"
  49. :value="orderInfo.duration"
  50. ></u-cell-item>
  51. <u-cell-item
  52. title="出场时间 "
  53. :arrow="false"
  54. :border-bottom="false"
  55. :border-top="false"
  56. :value="orderInfo.outTime"
  57. ></u-cell-item>
  58. <u-cell-item
  59. v-if="orderInfo.createTime"
  60. title="订单创建时间 "
  61. :arrow="false"
  62. :border-bottom="false"
  63. :border-top="false"
  64. :value="orderInfo.createTime"
  65. ></u-cell-item>
  66. <u-cell-item
  67. v-if="orderInfo.payTime"
  68. title="支付时间 "
  69. :arrow="false"
  70. :border-bottom="false"
  71. :border-top="false"
  72. :value="orderInfo.payTime"
  73. ></u-cell-item>
  74. <u-cell-item
  75. v-if="orderInfo.payStatus == 1"
  76. title="缴费方式 "
  77. :arrow="false"
  78. :border-bottom="false"
  79. :border-top="false"
  80. :value="orderInfo.paySource | verifyPaySource"
  81. ></u-cell-item>
  82. </u-cell-group>
  83. </view>
  84. <view
  85. class="bottom-btn-wrap"
  86. v-if="orderInfo.payStatus == 0 || orderInfo.payStatus == 2 || orderInfo.payStatus == 3"
  87. >
  88. <view class="bottom-btn" @click="goPay(orderId)">去支付</view>
  89. </view>
  90. <!-- 支付方式 -->
  91. <PaymentMethod
  92. :payWayPop="payWayPop"
  93. :curOrderList="orderList"
  94. :jumpUrl="jumpUrl"
  95. @closePaymentMethod="closePaymentMethod"
  96. ></PaymentMethod>
  97. <u-toast ref="uToast" />
  98. </view>
  99. </template>
  100. <script>
  101. import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue'
  102. export default {
  103. components: {
  104. PaymentMethod
  105. },
  106. data () {
  107. return {
  108. orderId: null,
  109. // 订单信息
  110. orderInfo: {},
  111. // 立即支付弹框
  112. payWayPop: false,
  113. // 订单列表,一般长度为1的数组
  114. orderList: [],
  115. // 重定向页面
  116. jumpUrl: location.href + '&type=open'
  117. }
  118. },
  119. onLoad (page) {
  120. const orderId = page?.orderId
  121. // 该标识判断是否是从支付完成页面回调回来
  122. const openFlag = page?.type
  123. if (orderId) {
  124. this.orderId = orderId
  125. // 如果标识存在,证明需要执行轮询判断支付状态,否则直接查询
  126. if (openFlag && openFlag === 'open') {
  127. this.handleGetOrderinfo(orderId, openFlag)
  128. let time = 0
  129. this.timer = setInterval(() => {
  130. time ++
  131. this.handleGetOrderinfo(orderId, openFlag)
  132. // 超过60s直接清除轮询
  133. if (time === 60) {
  134. clearInterval(this.timer)
  135. }
  136. }, 1000)
  137. } else {
  138. this.handleGetOrderinfo(orderId)
  139. }
  140. }
  141. },
  142. methods: {
  143. /**
  144. * 通过订单id去获取订单信息
  145. * */
  146. handleGetOrderinfo (orderId, openFlag) {
  147. this.$u.api.getOrderDetail({ id: orderId })
  148. .then(res => {
  149. if (res.code === 200) {
  150. this.orderInfo = res.data
  151. if (openFlag === 'open') {
  152. if (res.data.payStatus === 1 || res.data.payStatus === 3) {
  153. clearInterval(this.timer)
  154. }
  155. }
  156. } else {
  157. this.$refs.uToast.show({
  158. title: res.msg,
  159. type: 'error'
  160. })
  161. }
  162. })
  163. .catch(() => {
  164. this.$refs.uToast.show({
  165. title: '程序错误!',
  166. type: 'error'
  167. })
  168. })
  169. },
  170. goPay (orderId) {
  171. this.orderList = []
  172. this.orderList.push(orderId)
  173. if (this.orderList.length > 0) {
  174. this.payWayPop = true
  175. } else {
  176. this.$refs.uToast.show({
  177. title: '当前订单编号不存在,请重新进入当前页面!',
  178. type: 'warning'
  179. })
  180. }
  181. },
  182. /**
  183. * 关闭支付方式弹框
  184. * */
  185. closePaymentMethod () {
  186. this.payWayPop = false
  187. }
  188. },
  189. filters: {
  190. verifyPaySource (value) {
  191. if (value === 0) {
  192. return '现金支付'
  193. } else if (value === 1) {
  194. return '微信支付'
  195. } else if (value === 2) {
  196. return '支付宝支付'
  197. } else if (value === 3) {
  198. return '贵州银行快捷支付'
  199. } else if (value === 4) {
  200. return '贵州银行扫码支付'
  201. } else if (value === 5) {
  202. return '贵州银行被扫支付'
  203. } else {
  204. return ''
  205. }
  206. }
  207. },
  208. destroyed() {
  209. if (this.timer) {
  210. clearInterval(this.timer)
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped>
  216. @import "./orderDetails.scss";
  217. </style>