orderDetails.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. <!-- 路段显示 -->
  17. <u-cell-group v-if="orderType == 'road'">
  18. <u-cell-item title="订单编号 " :arrow="false" :border-bottom="false" :border-top="false"
  19. :value="orderInfo.orderId"></u-cell-item>
  20. <template v-if="orderInfo.deviceType == 1">
  21. <u-cell-item title="入场时间 " :arrow="false" :border-bottom="false" :border-top="false"
  22. :value="orderInfo.inTime"></u-cell-item>
  23. <u-cell-item title="出场时间 " :arrow="false" :border-bottom="false" :border-top="false"
  24. :value="orderInfo.outTime"></u-cell-item>
  25. </template>
  26. <template v-else>
  27. <u-cell-item title="开始计费 " :arrow="false" :border-bottom="false" :border-top="false"
  28. :value="orderInfo.inTime"></u-cell-item>
  29. <u-cell-item title="结束计费 " :arrow="false" :border-bottom="false" :border-top="false"
  30. :value="orderInfo.outTime"></u-cell-item>
  31. </template>
  32. <!-- <u-cell-item
  33. title="停车时长 "
  34. :arrow="false"
  35. :border-bottom="false"
  36. :border-top="false"
  37. :value="orderInfo.duration"
  38. ></u-cell-item> -->
  39. <!-- <u-cell-item
  40. title="免费时长 "
  41. :arrow="false"
  42. :border-bottom="false"
  43. :border-top="false"
  44. :value="orderInfo.freeDuration"
  45. ></u-cell-item> -->
  46. <template v-if="orderInfo.deviceType == 1">
  47. <u-cell-item title="免费时长 " :arrow="false" :border-bottom="false" :border-top="false"
  48. :value="orderInfo.freeDuration"></u-cell-item>
  49. </template>
  50. <template v-else>
  51. <u-cell-item title="免费时长 " :arrow="false" :border-bottom="false" :border-top="false"
  52. value="0天0时15分0秒"></u-cell-item>
  53. </template>
  54. <u-cell-item title="计费时长 " :arrow="false" :border-bottom="false" :border-top="false"
  55. :value="orderInfo.calcDuration"></u-cell-item>
  56. <u-cell-item title="累计停车时长 " :arrow="false" :border-bottom="false" :border-top="false"
  57. :value="orderInfo.duration"></u-cell-item>
  58. <u-cell-item v-if="orderInfo.createTime" title="订单创建时间 " :arrow="false" :border-bottom="false"
  59. :border-top="false" :value="orderInfo.createTime"></u-cell-item>
  60. <u-cell-item v-if="orderInfo.payTime" title="支付时间 " :arrow="false" :border-bottom="false"
  61. :border-top="false" :value="orderInfo.payTime"></u-cell-item>
  62. <u-cell-item v-if="orderInfo.payStatus == 1" title="缴费方式 " :arrow="false" :border-bottom="false"
  63. :border-top="false" :value="orderInfo.paySource | verifyPaySource"></u-cell-item>
  64. </u-cell-group>
  65. <!-- 停车场时长 -->
  66. <u-cell-group v-if="orderType == 'park'">
  67. <u-cell-item title="订单编号 " :arrow="false" :border-bottom="false" :border-top="false"
  68. :value="orderInfo.orderId"></u-cell-item>
  69. <template v-if="orderInfo.deviceType == 1">
  70. <u-cell-item title="入场通道 " :arrow="false" :border-bottom="false" :border-top="false"
  71. :value="orderInfo.roadwayName"></u-cell-item>
  72. <u-cell-item title="入场时间 " :arrow="false" :border-bottom="false" :border-top="false"
  73. :value="orderInfo.inTime"></u-cell-item>
  74. <u-cell-item title="出场通道 " :arrow="false" :border-bottom="false" :border-top="false"
  75. :value="orderInfo.outRoadwayName"></u-cell-item>
  76. <u-cell-item title="出场时间 " :arrow="false" :border-bottom="false" :border-top="false"
  77. :value="orderInfo.outTime"></u-cell-item>
  78. </template>
  79. <template v-else>
  80. <u-cell-item title="开始计费 " :arrow="false" :border-bottom="false" :border-top="false"
  81. :value="orderInfo.inTime"></u-cell-item>
  82. <u-cell-item title="结束计费 " :arrow="false" :border-bottom="false" :border-top="false"
  83. :value="orderInfo.outTime"></u-cell-item>
  84. </template>
  85. <template v-if="orderInfo.deviceType == 1">
  86. <u-cell-item title="免费时长 " :arrow="false" :border-bottom="false" :border-top="false"
  87. :value="orderInfo.freeDuration"></u-cell-item>
  88. </template>
  89. <template v-else>
  90. <u-cell-item title="免费时长 " :arrow="false" :border-bottom="false" :border-top="false"
  91. value="0天0时15分0秒"></u-cell-item>
  92. </template>
  93. <u-cell-item title="计费时长 " :arrow="false" :border-bottom="false" :border-top="false"
  94. :value="orderInfo.calcDuration"></u-cell-item>
  95. <u-cell-item title="累计停车时长 " :arrow="false" :border-bottom="false" :border-top="false"
  96. :value="orderInfo.duration"></u-cell-item>
  97. <u-cell-item v-if="orderInfo.createTime" title="订单创建时间 " :arrow="false" :border-bottom="false"
  98. :border-top="false" :value="orderInfo.createTime"></u-cell-item>
  99. <u-cell-item v-if="orderInfo.payTime" title="支付时间 " :arrow="false" :border-bottom="false"
  100. :border-top="false" :value="orderInfo.payTime"></u-cell-item>
  101. <u-cell-item v-if="orderInfo.payStatus == 1" title="缴费方式 " :arrow="false" :border-bottom="false"
  102. :border-top="false" :value="orderInfo.paySource | verifyPaySource"></u-cell-item>
  103. </u-cell-group>
  104. <view class="" v-if="orderInfo.deviceType == 1 && orderInfo.payAmount == 0">
  105. 提示:可寻找附近的收费员打印小票并扫码出场
  106. </view>
  107. </view>
  108. <!-- 显示支付按钮 -->
  109. <view class="bottom-btn-wrap" v-if="(orderInfo.payStatus == 0 || orderInfo.payStatus == 2 || orderInfo.payStatus == 3)
  110. && openFlag !== 'open'
  111. && (orderInfo.deviceType != 1 && orderInfo.payAmount != 0)">
  112. <view class="bottom-btn" @click="goPay(orderId)">去支付</view>
  113. </view>
  114. <view class="bottom-btn-wrap" v-if="openFlag === 'open' && orderInfo.payStatus == 1">
  115. <view class="bottom-btn" @click="jumpOrderList()">返回订单页</view>
  116. </view>
  117. <!-- 支付方式 -->
  118. <PaymentMethod :payWayPop="payWayPop" :exportFlag="exportFlag" :curOrderList="orderList" :jumpUrl="jumpUrl"
  119. @closePaymentMethod="closePaymentMethod"></PaymentMethod>
  120. <!-- 加载中遮罩 -->
  121. <u-mask :show="loadingMask">
  122. <view class="loading-warp">
  123. <view class="loading-icon">
  124. <u-loading mode="flower" size="50"></u-loading>
  125. </view>
  126. <view class="loading-text">
  127. <text>订单支付状态查询中...</text>
  128. </view>
  129. </view>
  130. </u-mask>
  131. <u-toast ref="uToast" />
  132. </view>
  133. </template>
  134. <script>
  135. import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue'
  136. export default {
  137. components: {
  138. PaymentMethod
  139. },
  140. data() {
  141. return {
  142. orderId: null,
  143. // 用来区分是支付完成返回的标识
  144. openFlag: null,
  145. polyOrderId: null,
  146. // 订单信息
  147. orderInfo: {},
  148. // 立即支付弹框
  149. payWayPop: false,
  150. // 订单列表,一般长度为1的数组
  151. orderList: [],
  152. // 重定向页面
  153. jumpUrl: location.href + '&type=open',
  154. loadingMask: false,
  155. exportFlag: false,
  156. // 订单类型 road 路段 park 停车场
  157. orderType: 'road'
  158. }
  159. },
  160. onLoad(page) {
  161. this.orderId = page?.orderId
  162. // 该标识判断是否是从支付完成页面回调回来
  163. this.openFlag = page?.type
  164. this.orderType = page?.orderType
  165. this.polyOrderId = page?.polyOrderId
  166. if (this.orderId) {
  167. // 如果type标识和支付订单id同时存在,证明需要执行轮询判断支付状态,否则直接查询
  168. if (this.openFlag && this.polyOrderId) {
  169. this.loadingMask = true
  170. this.handlePayStatus(this.polyOrderId)
  171. let time = 0
  172. this.timer = setInterval(() => {
  173. time++
  174. this.handlePayStatus(this.polyOrderId)
  175. // 超过60s直接清除轮询
  176. if (time === 60) {
  177. clearInterval(this.timer)
  178. }
  179. }, 1000)
  180. } else {
  181. this.handleGetOrderinfo(this.orderId, this.orderType)
  182. }
  183. }
  184. },
  185. methods: {
  186. jumpOrderList() {
  187. this.$u.route({
  188. url: 'pages/center/order/order'
  189. })
  190. },
  191. /**
  192. * 通过订单id去获取订单信息
  193. * */
  194. handleGetOrderinfo(orderId, orderType) {
  195. if (orderType == 'road') {
  196. this.$u.api.getOrderDetail({
  197. id: orderId
  198. })
  199. .then(res => {
  200. if (res.code === 200) {
  201. this.orderInfo = res.data
  202. } else {
  203. this.$refs.uToast.show({
  204. title: res.msg,
  205. type: 'error'
  206. })
  207. }
  208. })
  209. } else {
  210. this.$u.api.getRoomOrderDetail({
  211. id: orderId
  212. })
  213. .then(res => {
  214. if (res.code === 200) {
  215. this.orderInfo = res.data
  216. } else {
  217. this.$refs.uToast.show({
  218. title: res.msg,
  219. type: 'error'
  220. })
  221. }
  222. })
  223. }
  224. },
  225. /**
  226. * 查询支付状态
  227. * @param { String } orderId
  228. */
  229. handlePayStatus(orderId) {
  230. this.$u.api.getOrderInfo({
  231. orderId
  232. }).then(res => {
  233. if (res.code === 200) {
  234. if (res.data.payStatus === 1 || res.data.payStatus === 3) {
  235. this.loadingMask = false
  236. clearInterval(this.timer);
  237. this.handleGetOrderinfo(this.orderId, this.orderType)
  238. }
  239. } else {
  240. this.$refs.uToast.show({
  241. title: res.msg,
  242. type: 'error'
  243. })
  244. this.loadingMask = false
  245. clearInterval(this.timer);
  246. }
  247. }).catch(() => {
  248. this.loadingMask = false
  249. clearInterval(this.timer);
  250. })
  251. },
  252. goPay(orderId) {
  253. this.orderList = []
  254. this.orderList.push(orderId)
  255. if (this.orderType == 'park') {
  256. this.exportFlag = true
  257. } else {
  258. this.exportFlag = false
  259. }
  260. if (this.orderList.length > 0) {
  261. this.payWayPop = true
  262. } else {
  263. this.$refs.uToast.show({
  264. title: '当前订单编号不存在,请重新进入当前页面!',
  265. type: 'warning'
  266. })
  267. }
  268. },
  269. /**
  270. * 关闭支付方式弹框
  271. * */
  272. closePaymentMethod() {
  273. this.payWayPop = false
  274. }
  275. },
  276. filters: {
  277. verifyPaySource(value) {
  278. if (value === 0) {
  279. return '现金支付'
  280. } else if (value === 1) {
  281. return '微信支付'
  282. } else if (value === 2) {
  283. return '支付宝支付'
  284. } else if (value === 3) {
  285. return '贵州银行快捷支付'
  286. } else if (value === 4) {
  287. return '贵州银行扫码支付'
  288. } else if (value === 5) {
  289. return '贵州银行被扫支付'
  290. } else if (value === 6) {
  291. return '贵州银行无感支付'
  292. } else {
  293. return '其他'
  294. }
  295. }
  296. },
  297. destroyed() {
  298. if (this.timer) {
  299. clearInterval(this.timer)
  300. }
  301. }
  302. }
  303. </script>
  304. <style lang="scss" scoped>
  305. @import "./orderDetails.scss";
  306. </style>