orderDetails.vue 9.3 KB

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