orderDetails.vue 9.4 KB

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