orderDetails.vue 11 KB

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