orderDetails.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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.outTime"
  50. ></u-cell-item>
  51. <u-cell-item
  52. title="停车时长 "
  53. :arrow="false"
  54. :border-bottom="false"
  55. :border-top="false"
  56. :value="orderInfo.duration"
  57. ></u-cell-item>
  58. <u-cell-item
  59. title="免费时长 "
  60. :arrow="false"
  61. :border-bottom="false"
  62. :border-top="false"
  63. :value="orderInfo.duration"
  64. ></u-cell-item>
  65. <u-cell-item
  66. title="计费时长 "
  67. :arrow="false"
  68. :border-bottom="false"
  69. :border-top="false"
  70. :value="orderInfo.duration"
  71. ></u-cell-item>
  72. <u-cell-item
  73. v-if="orderInfo.createTime"
  74. title="订单创建时间 "
  75. :arrow="false"
  76. :border-bottom="false"
  77. :border-top="false"
  78. :value="orderInfo.createTime"
  79. ></u-cell-item>
  80. <u-cell-item
  81. v-if="orderInfo.payTime"
  82. title="支付时间 "
  83. :arrow="false"
  84. :border-bottom="false"
  85. :border-top="false"
  86. :value="orderInfo.payTime"
  87. ></u-cell-item>
  88. <u-cell-item
  89. v-if="orderInfo.payStatus == 1"
  90. title="缴费方式 "
  91. :arrow="false"
  92. :border-bottom="false"
  93. :border-top="false"
  94. :value="orderInfo.paySource | verifyPaySource"
  95. ></u-cell-item>
  96. </u-cell-group>
  97. </view>
  98. <view
  99. class="bottom-btn-wrap"
  100. v-if="(orderInfo.payStatus == 0 || orderInfo.payStatus == 2 || orderInfo.payStatus == 3) && openFlag !== 'open'"
  101. >
  102. <view class="bottom-btn" @click="goPay(orderId)">去支付</view>
  103. </view>
  104. <view
  105. class="bottom-btn-wrap"
  106. v-if="openFlag === 'open' && orderInfo.payStatus == 1"
  107. >
  108. <view class="bottom-btn" @click="jumpOrderList()">返回订单页</view>
  109. </view>
  110. <!-- 支付方式 -->
  111. <PaymentMethod
  112. :payWayPop="payWayPop"
  113. :curOrderList="orderList"
  114. :jumpUrl="jumpUrl"
  115. @closePaymentMethod="closePaymentMethod"
  116. ></PaymentMethod>
  117. <!-- 加载中遮罩 -->
  118. <u-mask :show="loadingMask">
  119. <view class="loading-warp">
  120. <view class="loading-icon">
  121. <u-loading mode="flower" size="50"></u-loading>
  122. </view>
  123. <view class="loading-text">
  124. <text>订单支付状态查询中...</text>
  125. </view>
  126. </view>
  127. </u-mask>
  128. <u-toast ref="uToast" />
  129. </view>
  130. </template>
  131. <script>
  132. import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue'
  133. export default {
  134. components: {
  135. PaymentMethod
  136. },
  137. data () {
  138. return {
  139. orderId: null,
  140. openFlag: null,
  141. // 订单信息
  142. orderInfo: {},
  143. // 立即支付弹框
  144. payWayPop: false,
  145. // 订单列表,一般长度为1的数组
  146. orderList: [],
  147. // 重定向页面
  148. jumpUrl: location.href + '&type=open',
  149. loadingMask: false
  150. }
  151. },
  152. onLoad (page) {
  153. const orderId = page?.orderId
  154. // 该标识判断是否是从支付完成页面回调回来
  155. const openFlag = page?.type
  156. if (orderId) {
  157. this.orderId = orderId
  158. // 如果标识存在,证明需要执行轮询判断支付状态,否则直接查询
  159. if (openFlag && openFlag === 'open') {
  160. this.openFlag = openFlag
  161. this.loadingMask = true
  162. this.handleGetOrderinfo(orderId, openFlag)
  163. let time = 0
  164. this.timer = setInterval(() => {
  165. time ++
  166. this.handleGetOrderinfo(orderId, openFlag)
  167. // 超过60s直接清除轮询
  168. if (time === 60) {
  169. clearInterval(this.timer)
  170. }
  171. }, 1000)
  172. } else {
  173. this.handleGetOrderinfo(orderId)
  174. }
  175. }
  176. },
  177. methods: {
  178. jumpOrderList() {
  179. this.$u.route({
  180. url: 'pages/center/order/order'
  181. })
  182. },
  183. /**
  184. * 通过订单id去获取订单信息
  185. * */
  186. handleGetOrderinfo (orderId, openFlag) {
  187. this.$u.api.getOrderDetail({ id: orderId })
  188. .then(res => {
  189. if (res.code === 200) {
  190. this.orderInfo = res.data
  191. if (openFlag === 'open') {
  192. if (res.data.payStatus === 1 || res.data.payStatus === 3) {
  193. this.loadingMask = false
  194. clearInterval(this.timer)
  195. }
  196. }
  197. } else {
  198. this.$refs.uToast.show({
  199. title: res.msg,
  200. type: 'error'
  201. })
  202. }
  203. })
  204. .catch(() => {
  205. this.$refs.uToast.show({
  206. title: '程序错误!',
  207. type: 'error'
  208. })
  209. })
  210. },
  211. goPay (orderId) {
  212. this.orderList = []
  213. this.orderList.push(orderId)
  214. if (this.orderList.length > 0) {
  215. this.payWayPop = true
  216. } else {
  217. this.$refs.uToast.show({
  218. title: '当前订单编号不存在,请重新进入当前页面!',
  219. type: 'warning'
  220. })
  221. }
  222. },
  223. /**
  224. * 关闭支付方式弹框
  225. * */
  226. closePaymentMethod () {
  227. this.payWayPop = false
  228. }
  229. },
  230. filters: {
  231. verifyPaySource (value) {
  232. if (value === 0) {
  233. return '现金支付'
  234. } else if (value === 1) {
  235. return '微信支付'
  236. } else if (value === 2) {
  237. return '支付宝支付'
  238. } else if (value === 3) {
  239. return '贵州银行快捷支付'
  240. } else if (value === 4) {
  241. return '贵州银行扫码支付'
  242. } else if (value === 5) {
  243. return '贵州银行被扫支付'
  244. } else if (value === 6) {
  245. return '贵州银行无感支付'
  246. } else {
  247. return ''
  248. }
  249. }
  250. },
  251. destroyed() {
  252. if (this.timer) {
  253. clearInterval(this.timer)
  254. }
  255. }
  256. }
  257. </script>
  258. <style lang="scss" scoped>
  259. @import "./orderDetails.scss";
  260. </style>