orderDetails.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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="停车场入口"></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="停车场出口"></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" :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. }
  150. },
  151. onLoad(page) {
  152. this.orderId = page?.orderId
  153. // 该标识判断是否是从支付完成页面回调回来
  154. this.openFlag = page?.type
  155. this.polyOrderId = page?.polyOrderId
  156. if (this.orderId) {
  157. // 如果type标识和支付订单id同时存在,证明需要执行轮询判断支付状态,否则直接查询
  158. if (this.openFlag && this.polyOrderId) {
  159. this.loadingMask = true
  160. this.handlePayStatus(this.polyOrderId)
  161. let time = 0
  162. this.timer = setInterval(() => {
  163. time++
  164. this.handlePayStatus(this.polyOrderId, this.openFlag)
  165. // 超过60s直接清除轮询
  166. if (time === 60) {
  167. clearInterval(this.timer)
  168. }
  169. }, 1000)
  170. } else {
  171. this.handleGetOrderinfo(this.orderId,this.openFlag)
  172. }
  173. }
  174. },
  175. methods: {
  176. jumpOrderList() {
  177. this.$u.route({
  178. url: 'pages/center/order/order'
  179. })
  180. },
  181. /**
  182. * 通过订单id去获取订单信息
  183. * */
  184. handleGetOrderinfo(orderId,openFlag) {
  185. if(openFlag == 'road'){
  186. this.$u.api.getOrderDetail({
  187. id: orderId
  188. })
  189. .then(res => {
  190. if (res.code === 200) {
  191. this.orderInfo = res.data
  192. } else {
  193. this.$refs.uToast.show({
  194. title: res.msg,
  195. type: 'error'
  196. })
  197. }
  198. })
  199. }else{
  200. this.$u.api.getRoomOrderDetail({
  201. id: orderId
  202. })
  203. .then(res => {
  204. if (res.code === 200) {
  205. this.orderInfo = res.data
  206. } else {
  207. this.$refs.uToast.show({
  208. title: res.msg,
  209. type: 'error'
  210. })
  211. }
  212. })
  213. }
  214. },
  215. /**
  216. * 查询支付状态
  217. * @param { String } orderId
  218. */
  219. handlePayStatus(orderId) {
  220. this.$u.api.getOrderInfo({
  221. orderId
  222. }).then(res => {
  223. if (res.code === 200) {
  224. if (res.data.payStatus === 1 || res.data.payStatus === 3) {
  225. this.loadingMask = false
  226. clearInterval(this.timer);
  227. this.handleGetOrderinfo(this.orderId,this.openFlag)
  228. }
  229. } else {
  230. this.$refs.uToast.show({
  231. title: res.msg,
  232. type: 'error'
  233. })
  234. this.loadingMask = false
  235. clearInterval(this.timer);
  236. }
  237. }).catch(() => {
  238. this.loadingMask = false
  239. clearInterval(this.timer);
  240. })
  241. },
  242. goPay(orderId) {
  243. this.orderList = []
  244. this.orderList.push(orderId)
  245. if (this.orderList.length > 0) {
  246. this.payWayPop = true
  247. } else {
  248. this.$refs.uToast.show({
  249. title: '当前订单编号不存在,请重新进入当前页面!',
  250. type: 'warning'
  251. })
  252. }
  253. },
  254. /**
  255. * 关闭支付方式弹框
  256. * */
  257. closePaymentMethod() {
  258. this.payWayPop = false
  259. }
  260. },
  261. filters: {
  262. verifyPaySource(value) {
  263. if (value === 0) {
  264. return '现金支付'
  265. } else if (value === 1) {
  266. return '微信支付'
  267. } else if (value === 2) {
  268. return '支付宝支付'
  269. } else if (value === 3) {
  270. return '贵州银行快捷支付'
  271. } else if (value === 4) {
  272. return '贵州银行扫码支付'
  273. } else if (value === 5) {
  274. return '贵州银行被扫支付'
  275. } else if (value === 6) {
  276. return '贵州银行无感支付'
  277. } else {
  278. return '其他'
  279. }
  280. }
  281. },
  282. destroyed() {
  283. if (this.timer) {
  284. clearInterval(this.timer)
  285. }
  286. }
  287. }
  288. </script>
  289. <style lang="scss" scoped>
  290. @import "./orderDetails.scss";
  291. </style>