orderDetails.vue 7.5 KB

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