orderDetails.vue 8.1 KB

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