orderDetails.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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="openFlag == '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="openFlag == '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>
  105. <view class="bottom-btn-wrap"
  106. v-if="(orderInfo.payStatus == 0 || orderInfo.payStatus == 2 || orderInfo.payStatus == 3) && openFlag !== 'open'">
  107. <view class="bottom-btn" @click="goPay(orderId)">去支付</view>
  108. </view>
  109. <view class="bottom-btn-wrap" v-if="openFlag === 'open' && orderInfo.payStatus == 1">
  110. <view class="bottom-btn" @click="jumpOrderList()">返回订单页</view>
  111. </view>
  112. <!-- 支付方式 -->
  113. <PaymentMethod :payWayPop="payWayPop" :exportFlag="exportFlag" :curOrderList="orderList" :jumpUrl="jumpUrl"
  114. @closePaymentMethod="closePaymentMethod"></PaymentMethod>
  115. <!-- 加载中遮罩 -->
  116. <u-mask :show="loadingMask">
  117. <view class="loading-warp">
  118. <view class="loading-icon">
  119. <u-loading mode="flower" size="50"></u-loading>
  120. </view>
  121. <view class="loading-text">
  122. <text>订单支付状态查询中...</text>
  123. </view>
  124. </view>
  125. </u-mask>
  126. <u-toast ref="uToast" />
  127. </view>
  128. </template>
  129. <script>
  130. import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue'
  131. export default {
  132. components: {
  133. PaymentMethod
  134. },
  135. data() {
  136. return {
  137. orderId: null,
  138. openFlag: null,
  139. polyOrderId: null,
  140. // 订单信息
  141. orderInfo: {},
  142. // 立即支付弹框
  143. payWayPop: false,
  144. // 订单列表,一般长度为1的数组
  145. orderList: [],
  146. // 重定向页面
  147. jumpUrl: location.href + '&type=open',
  148. loadingMask: false,
  149. exportFlag: false,
  150. }
  151. },
  152. onLoad(page) {
  153. this.orderId = page?.orderId
  154. // 该标识判断是否是从支付完成页面回调回来
  155. this.openFlag = page?.type
  156. this.polyOrderId = page?.polyOrderId
  157. if (this.orderId) {
  158. // 如果type标识和支付订单id同时存在,证明需要执行轮询判断支付状态,否则直接查询
  159. if (this.openFlag && this.polyOrderId) {
  160. this.loadingMask = true
  161. this.handlePayStatus(this.polyOrderId)
  162. let time = 0
  163. this.timer = setInterval(() => {
  164. time++
  165. this.handlePayStatus(this.polyOrderId, this.openFlag)
  166. // 超过60s直接清除轮询
  167. if (time === 60) {
  168. clearInterval(this.timer)
  169. }
  170. }, 1000)
  171. } else {
  172. this.handleGetOrderinfo(this.orderId, this.openFlag)
  173. }
  174. }
  175. },
  176. methods: {
  177. jumpOrderList() {
  178. this.$u.route({
  179. url: 'pages/center/order/order'
  180. })
  181. },
  182. /**
  183. * 通过订单id去获取订单信息
  184. * */
  185. handleGetOrderinfo(orderId, openFlag) {
  186. if (openFlag == 'road') {
  187. this.$u.api.getOrderDetail({
  188. id: orderId
  189. })
  190. .then(res => {
  191. if (res.code === 200) {
  192. this.orderInfo = res.data
  193. console.log(this.orderInfo)
  194. } else {
  195. this.$refs.uToast.show({
  196. title: res.msg,
  197. type: 'error'
  198. })
  199. }
  200. })
  201. } else {
  202. this.$u.api.getRoomOrderDetail({
  203. id: orderId
  204. })
  205. .then(res => {
  206. if (res.code === 200) {
  207. this.orderInfo = res.data
  208. console.log(this.orderInfo)
  209. } else {
  210. this.$refs.uToast.show({
  211. title: res.msg,
  212. type: 'error'
  213. })
  214. }
  215. })
  216. }
  217. },
  218. /**
  219. * 查询支付状态
  220. * @param { String } orderId
  221. */
  222. handlePayStatus(orderId) {
  223. this.$u.api.getOrderInfo({
  224. orderId
  225. }).then(res => {
  226. if (res.code === 200) {
  227. if (res.data.payStatus === 1 || res.data.payStatus === 3) {
  228. this.loadingMask = false
  229. clearInterval(this.timer);
  230. this.handleGetOrderinfo(this.orderId, this.openFlag)
  231. }
  232. } else {
  233. this.$refs.uToast.show({
  234. title: res.msg,
  235. type: 'error'
  236. })
  237. this.loadingMask = false
  238. clearInterval(this.timer);
  239. }
  240. }).catch(() => {
  241. this.loadingMask = false
  242. clearInterval(this.timer);
  243. })
  244. },
  245. goPay(orderId) {
  246. this.orderList = []
  247. this.orderList.push(orderId)
  248. if (this.openFlag == 'park') {
  249. this.exportFlag = true
  250. } else {
  251. this.exportFlag = false
  252. }
  253. if (this.orderList.length > 0) {
  254. this.payWayPop = true
  255. } else {
  256. this.$refs.uToast.show({
  257. title: '当前订单编号不存在,请重新进入当前页面!',
  258. type: 'warning'
  259. })
  260. }
  261. },
  262. /**
  263. * 关闭支付方式弹框
  264. * */
  265. closePaymentMethod() {
  266. this.payWayPop = false
  267. }
  268. },
  269. filters: {
  270. verifyPaySource(value) {
  271. if (value === 0) {
  272. return '现金支付'
  273. } else if (value === 1) {
  274. return '微信支付'
  275. } else if (value === 2) {
  276. return '支付宝支付'
  277. } else if (value === 3) {
  278. return '贵州银行快捷支付'
  279. } else if (value === 4) {
  280. return '贵州银行扫码支付'
  281. } else if (value === 5) {
  282. return '贵州银行被扫支付'
  283. } else if (value === 6) {
  284. return '贵州银行无感支付'
  285. } else {
  286. return '其他'
  287. }
  288. }
  289. },
  290. destroyed() {
  291. if (this.timer) {
  292. clearInterval(this.timer)
  293. }
  294. }
  295. }
  296. </script>
  297. <style lang="scss" scoped>
  298. @import "./orderDetails.scss";
  299. </style>