orderDetails.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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. <view class="addr">{{ orderInfo.roadName }}</view>
  6. <view class="pay-amount" v-if="orderInfo.payAmount">-{{ orderInfo.payAmount }}</view>
  7. <view class="pay-amount" v-else>{{ orderInfo.payAmount }}</view>
  8. <u-cell-group :border="false">
  9. <u-cell-item title="车牌号" :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.vehicleNo" />
  10. <u-cell-item
  11. title="优惠总金额"
  12. :arrow="false"
  13. :border-bottom="false"
  14. :border-top="false"
  15. :value="(orderInfo.preferentialAmount ? orderInfo.preferentialAmount.toFixed(2) : 0) + ' 元'"
  16. />
  17. </u-cell-group>
  18. <!-- 路段显示 -->
  19. <u-cell-group v-if="orderType == 'road'">
  20. <u-cell-item title="订单编号 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.orderId" />
  21. <template v-if="orderInfo.deviceType == 1">
  22. <u-cell-item title="入场时间 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.inTime" />
  23. <u-cell-item title="出场时间 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.outTime" />
  24. </template>
  25. <template v-else>
  26. <u-cell-item title="开始计费 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.inTime" />
  27. <u-cell-item title="结束计费 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.outTime" />
  28. </template>
  29. <template v-if="orderInfo.deviceType !== 2">
  30. <u-cell-item
  31. title="免费时长 "
  32. :arrow="false"
  33. :border-bottom="false"
  34. :border-top="false"
  35. :value="orderInfo.freeDuration || `0天0时${free_time}分0秒`"
  36. />
  37. </template>
  38. <template v-else>
  39. <u-cell-item
  40. title="免费时长 "
  41. :arrow="false"
  42. :border-bottom="false"
  43. :border-top="false"
  44. :value="orderInfo.freeDuration || `0天0时${free_time}分0秒`"
  45. />
  46. </template>
  47. <u-cell-item title="计费时长 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.calcDuration" />
  48. <u-cell-item title="累计停车时长 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.duration" />
  49. <u-cell-item
  50. v-if="orderInfo.createTime"
  51. title="订单创建时间 "
  52. :arrow="false"
  53. :border-bottom="false"
  54. :border-top="false"
  55. :value="orderInfo.createTime"
  56. />
  57. <u-cell-item
  58. v-if="orderInfo.payTime"
  59. title="支付时间 "
  60. :arrow="false"
  61. :border-bottom="false"
  62. :border-top="false"
  63. :value="orderInfo.payTime"
  64. />
  65. <u-cell-item
  66. v-if="orderInfo.payStatus == 1"
  67. title="缴费方式 "
  68. :arrow="false"
  69. :border-bottom="false"
  70. :border-top="false"
  71. :value="orderInfo.paySource | verifyPaySource"
  72. />
  73. </u-cell-group>
  74. <!-- 停车场时长 -->
  75. <u-cell-group v-if="orderType == 'park'">
  76. <u-cell-item title="订单编号 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.orderId" />
  77. <template v-if="orderInfo.deviceType == 1">
  78. <u-cell-item title="入场通道 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.roadwayName" />
  79. <u-cell-item title="入场时间 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.inTime" />
  80. <u-cell-item title="出场通道 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.outRoadwayName" />
  81. <u-cell-item title="出场时间 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.outTime" />
  82. </template>
  83. <template v-else>
  84. <u-cell-item title="开始计费 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.inTime" />
  85. <u-cell-item title="结束计费 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.outTime" />
  86. </template>
  87. <template v-if="orderInfo.deviceType == 1">
  88. <u-cell-item
  89. title="免费时长 "
  90. :arrow="false"
  91. :border-bottom="false"
  92. :border-top="false"
  93. :value="orderInfo.freeDuration || `0天0时${free_time}分0秒`"
  94. />
  95. </template>
  96. <template v-else>
  97. <u-cell-item
  98. title="免费时长 "
  99. :arrow="false"
  100. :border-bottom="false"
  101. :border-top="false"
  102. :value="orderInfo.freeDuration || `0天0时${free_time}分0秒`"
  103. />
  104. </template>
  105. <u-cell-item title="计费时长 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.calcDuration" />
  106. <u-cell-item title="累计停车时长 " :arrow="false" :border-bottom="false" :border-top="false" :value="orderInfo.duration" />
  107. <u-cell-item
  108. v-if="orderInfo.createTime"
  109. title="订单创建时间 "
  110. :arrow="false"
  111. :border-bottom="false"
  112. :border-top="false"
  113. :value="orderInfo.createTime"
  114. />
  115. <u-cell-item
  116. v-if="orderInfo.payTime"
  117. title="支付时间 "
  118. :arrow="false"
  119. :border-bottom="false"
  120. :border-top="false"
  121. :value="orderInfo.payTime"
  122. />
  123. <u-cell-item
  124. v-if="orderInfo.payStatus == 1"
  125. title="缴费方式 "
  126. :arrow="false"
  127. :border-bottom="false"
  128. :border-top="false"
  129. :value="orderInfo.paySource | verifyPaySource"
  130. />
  131. </u-cell-group>
  132. <!-- 地磁订单金额为0并且未支付 -->
  133. <view class v-if="orderInfo.deviceType == 1 && orderInfo.payAmount == 0 && orderInfo.payStatus !== 1"
  134. >提示:可寻找附近的收费员打印小票并扫码出场</view
  135. >
  136. </view>
  137. <!-- 地磁显示支付按钮条件 支付状态(0-未支付,2-支付中,3-支付失败)并且订单金额不能为0 -->
  138. <template v-if="orderInfo.deviceType === 1 && orderInfo.payStatus !== 1 && openFlag !== 'open'">
  139. <view class="bottom-btn-wrap" v-if="Number(orderInfo.payAmount) !== 0">
  140. <view class="bottom-btn" @click="goPay(orderId)">去支付</view>
  141. </view>
  142. <view class="bottom-btn-wrap" v-else-if="Number(orderInfo.payAmount) === 0">
  143. <view class="tips">提示:可寻找附近的收费员打印小票并扫码出场</view>
  144. </view>
  145. </template>
  146. <!-- 其他显示支付按钮条件 支付状态(0-未支付,2-支付中,3-支付失败) 订单类型非停车场 -->
  147. <template v-else-if="orderInfo.deviceType !== 1 && orderInfo.payStatus !== 1 && openFlag !== 'open' && orderType !== 'park'">
  148. <view class="bottom-btn-wrap">
  149. <view class="bottom-btn" @click="goPay(orderId)">去支付</view>
  150. </view>
  151. </template>
  152. <!-- 订单类型停车场 订单状态欠费未缴 orderStatus为2 -->
  153. <template v-else-if="orderInfo.deviceType !== 1 && orderType === 'park' && Number(orderInfo.orderStatus) === 2">
  154. <view class="bottom-btn-wrap">
  155. <view class="bottom-btn" @click="goPay(orderId)">去支付</view>
  156. </view>
  157. </template>
  158. <view class="bottom-btn-wrap" v-if="openFlag === 'open' && orderInfo.payStatus == 1">
  159. <view class="bottom-btn" @click="jumpOrderList()">返回订单页</view>
  160. </view>
  161. <!-- 支付方式 -->
  162. <!-- <PaymentMethod
  163. :payWayPop="payWayPop"
  164. :exportFlag="exportFlag"
  165. :curOrderList="orderList"
  166. :jumpUrl="jumpUrl"
  167. @closePaymentMethod="closePaymentMethod"
  168. /> -->
  169. <!-- 加载中遮罩 -->
  170. <u-mask :show="loadingMask">
  171. <view class="loading-warp">
  172. <view class="loading-icon">
  173. <u-loading mode="flower" size="50"></u-loading>
  174. </view>
  175. <view class="loading-text">
  176. <text>订单支付状态查询中...</text>
  177. </view>
  178. </view>
  179. </u-mask>
  180. <ChoosePayment
  181. ref="choosePayment"
  182. :exportFlag="exportFlag"
  183. :curOrderList="orderList"
  184. :jumpUrl="jumpUrl"
  185. @closePaymentMethod="closePaymentMethod"
  186. />
  187. <u-toast ref="uToast" />
  188. </view>
  189. </template>
  190. <script>
  191. // import PaymentMethod from '@/pages/paymentMethod/paymentMethod.vue';
  192. import ChoosePayment from '@/pages/choosePayment/choosePayment.vue';
  193. export default {
  194. components: {
  195. // PaymentMethod,
  196. ChoosePayment
  197. },
  198. data() {
  199. return {
  200. orderId: null,
  201. // 用来区分是支付完成返回的标识
  202. openFlag: null,
  203. polyOrderId: null,
  204. // 订单信息
  205. orderInfo: {},
  206. // 立即支付弹框
  207. payWayPop: false,
  208. // 订单列表,一般长度为1的数组
  209. orderList: [],
  210. // 重定向页面
  211. jumpUrl: location.href + '&type=open',
  212. loadingMask: false,
  213. exportFlag: false,
  214. // 订单类型 road 路段 park 停车场
  215. orderType: 'road'
  216. };
  217. },
  218. onLoad(page) {
  219. this.orderId = page?.orderId;
  220. // 该标识判断是否是从支付完成页面回调回来
  221. this.openFlag = page?.type;
  222. this.orderType = page?.orderType;
  223. this.polyOrderId = page?.polyOrderId;
  224. if (this.orderId) {
  225. // 如果type标识和支付订单id同时存在,证明需要执行轮询判断支付状态,否则直接查询
  226. if (this.openFlag && this.polyOrderId) {
  227. this.loadingMask = true;
  228. this.handlePayStatus(this.polyOrderId);
  229. let time = 0;
  230. this.timer = setInterval(() => {
  231. time++;
  232. this.handlePayStatus(this.polyOrderId);
  233. // 超过60s直接清除轮询
  234. if (time === 60) {
  235. clearInterval(this.timer);
  236. }
  237. }, 1000);
  238. } else {
  239. this.handleGetOrderinfo(this.orderId, this.orderType);
  240. }
  241. }
  242. },
  243. methods: {
  244. jumpOrderList() {
  245. this.$u.route({
  246. url: 'pages/center/order/order'
  247. });
  248. },
  249. /**
  250. * 通过订单id去获取订单信息
  251. * */
  252. handleGetOrderinfo(orderId, orderType) {
  253. if (orderType == 'road') {
  254. this.$u.api
  255. .getOrderDetail({
  256. id: orderId
  257. })
  258. .then((res) => {
  259. if (res.code === 200) {
  260. this.orderInfo = res.data;
  261. } else {
  262. this.$refs.uToast.show({
  263. title: res.msg,
  264. type: 'error'
  265. });
  266. }
  267. });
  268. } else {
  269. this.$u.api
  270. .getRoomOrderDetail({
  271. id: orderId
  272. })
  273. .then((res) => {
  274. if (res.code === 200) {
  275. this.orderInfo = res.data;
  276. } else {
  277. this.$refs.uToast.show({
  278. title: res.msg,
  279. type: 'error'
  280. });
  281. }
  282. });
  283. }
  284. },
  285. /**
  286. * 查询支付状态
  287. * @param { String } orderId
  288. */
  289. handlePayStatus(orderId) {
  290. this.$u.api
  291. .getOrderInfo({
  292. orderId
  293. })
  294. .then((res) => {
  295. if (res.code === 200) {
  296. if (res.data.payStatus === 1 || res.data.payStatus === 3) {
  297. this.loadingMask = false;
  298. clearInterval(this.timer);
  299. this.handleGetOrderinfo(this.orderId, this.orderType);
  300. }
  301. } else {
  302. this.$refs.uToast.show({
  303. title: res.msg,
  304. type: 'error'
  305. });
  306. this.loadingMask = false;
  307. clearInterval(this.timer);
  308. }
  309. })
  310. .catch(() => {
  311. this.loadingMask = false;
  312. clearInterval(this.timer);
  313. });
  314. },
  315. goPay(orderId) {
  316. this.orderList = [];
  317. this.orderList.push(orderId);
  318. if (this.orderType == 'park') {
  319. this.exportFlag = true;
  320. } else {
  321. this.exportFlag = false;
  322. }
  323. if (this.orderList.length > 0) {
  324. // this.payWayPop = true;
  325. this.$nextTick(() => {
  326. this.$refs['choosePayment'].openPopup({ ...this.orderInfo }, 'single', this.orderType === 'road' ? 'road' : 'parking');
  327. });
  328. } else {
  329. this.$refs.uToast.show({
  330. title: '当前订单编号不存在,请重新进入当前页面!',
  331. type: 'warning'
  332. });
  333. }
  334. },
  335. /**
  336. * 关闭支付方式弹框
  337. * */
  338. closePaymentMethod() {
  339. this.payWayPop = false;
  340. }
  341. },
  342. filters: {
  343. verifyPaySource(value) {
  344. if (value === 0) {
  345. return '现金支付';
  346. } else if (value === 1) {
  347. return '微信支付';
  348. } else if (value === 2) {
  349. return '支付宝支付';
  350. } else if (value === 3) {
  351. return '贵州银行快捷支付';
  352. } else if (value === 4) {
  353. return '贵州银行扫码支付';
  354. } else if (value === 5) {
  355. return '贵州银行被扫支付';
  356. } else if (value === 6) {
  357. return '贵州银行无感支付';
  358. } else {
  359. return '其他';
  360. }
  361. }
  362. },
  363. destroyed() {
  364. if (this.timer) {
  365. clearInterval(this.timer);
  366. }
  367. }
  368. };
  369. </script>
  370. <style lang="scss" scoped>
  371. @import './orderDetails.scss';
  372. </style>