orderDetails.vue 8.4 KB

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