orderDetails.vue 6.6 KB

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