orderDetails.vue 8.4 KB

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