orderDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. <template>
  2. <view class="container">
  3. <image class="banner" src="@/static/images/mine/back.png" mode="aspectFill" />
  4. <!-- 内容区域 -->
  5. <view class="content">
  6. <view v-if="info.payState === 1&&info.byState===3" class="status">
  7. <wd-icon name="clock" color="#001713" size="22" />
  8. 未乘车
  9. </view>
  10. <view v-if="info.payState === 1&&info.byState===2" class="status">
  11. <wd-icon name="check-outline" color="#001713" size="22" />
  12. 已乘车
  13. </view>
  14. <view v-if="info.payState === 0" class="status">
  15. <wd-icon name="money-circle" color="#001713" size="22" />
  16. 待支付
  17. </view>
  18. <view v-if="info.payState === 3" class="status">
  19. <wd-icon name="file-excel" color="#001713" size="22" />
  20. 已取消
  21. </view>
  22. <view v-if="statusValue === '预约失败'" class="status">
  23. <wd-icon name="warning" color="#001713" size="22" />
  24. 预约失败
  25. </view>
  26. <!-- 提示区域 -->
  27. <view class="tips">
  28. <image class="tips_img" src="@/static/images/orderDetail/tips.png" mode="aspectFill" />
  29. <view class="tips_text" v-if="(info.payState === 1&&info.byState===3)||(info.payState === 1&&info.byState===1)">
  30. 您已成功预约【 <text>{{info.ciDate}} {{info.route_end}}</text>】大巴班次~请于发车前 15 分钟到达乘车点(<text>{{getRouteParts(info.route_end).prefix}}</text>),凭订单二维码检票乘车
  31. </view>
  32. <view class="tips_text" v-if="info.payState === 0">
  33. 您的大巴预约订单尚未支付,为了不影响正常出行,订单将为您保留15分钟,超时自动取消~快点击【立即支付】,及时处理吧!
  34. </view>
  35. <view class="tips_text" v-if="info.payState === 1&&info.byState===2">
  36. 您的行程已顺利结束,墨轩约车感谢您的使用!期待下次再见!
  37. </view>
  38. <view class="tips_text" v-if="info.payState === 3">
  39. 订单已取消,欢迎您再次预约,祝一天好心情!
  40. </view>
  41. </view>
  42. <!-- 详情区域 -->
  43. <view class="detail">
  44. <view class="carMsg">
  45. <view class="carMsg_time">{{info.ciDate}}</view>
  46. <view :class="(info.payState === 0 ||info.byState === 3||info.byState === 1)?'carMsg_number':'carMsg_number1'">车牌:{{info.car_number}}</view>
  47. <view :class="(info.payState === 0 ||info.byState === 3||info.byState === 1)?'carMsg_volume':'carMsg_volume1'">容量:{{info.contain}}座</view>
  48. <image class="carMsg_line" src="@/static/images/chooseCar/line.png" mode="aspectFill" />
  49. <view class="carMsg_start">{{getRouteParts(info.route_end).prefix}}</view>
  50. <view class="carMsg_end">{{getRouteParts(info.route_end).suffix}}</view>
  51. </view>
  52. <!-- 二维码区域 -->
  53. <view class="code" v-if="(info.payState === 1&&info.byState===3)||(info.payState === 1&&info.byState===1)">
  54. <!-- 跟随页面滚动是开发者工具的bug,真机没有问题 -->
  55. <uv-qrcode ref="qrcode" size="180" :value="info.id"></uv-qrcode>
  56. </view>
  57. <view class="info">
  58. <view>预约号:{{info.row_num}}</view>
  59. <view>扫码时间段:13:50 - 16:20</view>
  60. <view>下单时间:{{info.createTime}}</view>
  61. <view :class="(info.payState === 0 ||info.byState === 3||info.byState === 1)?'info_price':'info_price1'">
  62. <view>支付金额:</view>
  63. <view>
  64. <text class="text">¥</text>
  65. {{info.payAmount}}
  66. </view>
  67. </view>
  68. <view class="box_bottom">
  69. <view class="bottom_time"></view>
  70. <view v-if="info.payState==1 &&info.state!=4">
  71. <view class="bottom_btns" v-if="info.byState==3||info.byState==2">
  72. <view class="btn_item pay">退款</view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <!-- 支付区域 -->
  80. <view class="pay" v-if="info.payState === 0">
  81. <view class="pay_left">
  82. ¥
  83. <text class="text">{{info.payAmount}}</text>
  84. </view>
  85. <view class="pay_btn" @click="handlePay(info.orderNo)">立即支付</view>
  86. </view>
  87. <!-- 退款 -->
  88. <view v-if="info.payState==1 &&info.state!=4">
  89. <view class="pay" v-if="info.byState==3||info.byState==1">
  90. <view class="pay_left">
  91. ¥
  92. <text class="text">{{info.payAmount}}</text>
  93. </view>
  94. <view class="pay_btn" @click="tuiPay(info)">退款</view>
  95. </view>
  96. </view>
  97. </view>
  98. <!-- 选择付款方式弹窗区域 -->
  99. <wd-popup v-model="popShow_pay" position="bottom" safe-area-inset-bottom :close-on-click-modal="false">
  100. <view class="pop_pay">
  101. <view class="pay_title">选择付款方式</view>
  102. <view class="pay_close" @click="handleClose">
  103. <wd-icon name="close-bold" color="#ABA6A6" size="22"></wd-icon>
  104. </view>
  105. <!-- 支付方式列表区域 -->
  106. <view class="pay_list">
  107. <!-- 每一个支付方式区域 -->
  108. <view class="list_item" v-for="(item, index) in payList" :key="index">
  109. <view class="item_left">
  110. <image class="img" :src="item.icon" mode="aspectFill"></image>
  111. {{ item.text }}
  112. </view>
  113. <view class="item_right">
  114. <radio style="scale: 0.8" color="#FF8205" :checked="item.isCheck" @click="togglePay(item)" />
  115. </view>
  116. </view>
  117. </view>
  118. <!-- 立即付款按钮区域 -->
  119. <view class="pay_btn" @click="payTime">立即付款</view>
  120. </view>
  121. </wd-popup>
  122. </template>
  123. <script setup>
  124. import { onLoad } from '@dcloudio/uni-app'
  125. import { ref } from 'vue'
  126. import { myRequest } from '@/utils/api.ts'
  127. // 用户信息
  128. const info = ref()
  129. // 用户信息
  130. const userInfo = uni.getStorageSync('carUserInfo')
  131. // 付款方式弹窗显示隐藏控制
  132. const popShow_pay = ref(false)
  133. // 支付方式列表
  134. const payList = ref([
  135. {
  136. text: '微信支付',
  137. icon: '/static/images/pay/wx.png',
  138. isCheck: false
  139. },
  140. {
  141. text: '电子交通卡支付',
  142. icon: '/static/images/pay/card.png',
  143. isCheck: false
  144. }
  145. ])
  146. // 选中的支付方式
  147. const selectedPay = ref(null);
  148. //继续支付订单
  149. const orderNo = ref('');
  150. // 截取箭头前后的文字
  151. const getRouteParts = (str) => {
  152. if (str && typeof str === 'string') {
  153. const parts = str.split('→');
  154. return {
  155. prefix: parts[0] || '', // 箭头前的文字
  156. suffix: parts[1] || '' // 箭头后的文字
  157. };
  158. }
  159. return { prefix: '', suffix: '' };
  160. };
  161. onLoad((options) => {
  162. if (options.info) {
  163. info.value = JSON.parse(decodeURIComponent(options.info))
  164. console.log(info.value,'单')
  165. }
  166. })
  167. // 点击支付按钮回调
  168. const handlePay = (item) => {
  169. popShow_pay.value = true
  170. orderNo.value=item
  171. }
  172. // 点击弹窗关闭按钮回调
  173. const handleClose = () => {
  174. popShow_pay.value = false
  175. }
  176. // 切换支付方式(单选逻辑)
  177. const togglePay = (item) => {
  178. // 先重置所有支付方式为未选中
  179. payList.value.forEach(pay => {
  180. pay.isCheck = false;
  181. });
  182. // 标记当前点击的支付方式为选中
  183. item.isCheck = true;
  184. selectedPay.value = item; // 同步选中的支付方式
  185. };
  186. //立即支付
  187. const payTime = () => {
  188. if (!selectedPay.value) {
  189. uni.showModal({
  190. content:'请选择支付方式'
  191. })
  192. return;
  193. }
  194. if(selectedPay.value.text=='微信支付'){
  195. payWei()
  196. }else if(selectedPay.value.text=='电子交通卡支付'){
  197. }
  198. }
  199. //微信支付
  200. const payWei = async () => {
  201. const res = await myRequest({
  202. url: '/tAppcontinuePay.action',
  203. // method: 'POST', // 明确指定请求方法为POST
  204. data: {
  205. order_num:orderNo.value,
  206. }
  207. })
  208. if(res.code==200){
  209. payParams.value = res.data; // 存储微信支付所需参数
  210. invokeWechatPay(); // 调起支付
  211. }else{
  212. uni.showToast({ title: res.message });
  213. }
  214. }
  215. // 调起微信支付
  216. const invokeWechatPay = () => {
  217. uni.requestPayment({
  218. ...payParams.value,
  219. success: (res) => {
  220. uni.showToast({ title: '支付成功' });
  221. // 支付成功后逻辑(如跳转到订单详情)
  222. setTimeout(function() {
  223. getMyData()
  224. }, 1000)
  225. },
  226. fail: (err) => {
  227. uni.showToast({ title: '支付失败', icon: 'none' });
  228. console.error('支付失败', err);
  229. }
  230. });
  231. };
  232. //点击退款
  233. const tuiPay = async (item) => {
  234. const res = await myRequest({
  235. url: '/tApprefund.action',
  236. // method: 'POST', // 明确指定请求方法为POST
  237. data: {
  238. order_num:item.orderNo,
  239. id:item.id
  240. }
  241. })
  242. if(res.code==200){
  243. uni.showToast({ title: '退款成功' });
  244. setTimeout(function() {
  245. uni.switchTab({
  246. url:'/pages/order/order'
  247. })
  248. }, 1000)
  249. }else{
  250. uni.showToast({ title: res.message });
  251. }
  252. }
  253. </script>
  254. <style lang="scss" scoped>
  255. .container {
  256. position: relative;
  257. height: 100vh;
  258. color: #001713;
  259. background-color: #fff;
  260. overflow-y: auto;
  261. .banner {
  262. width: 100%;
  263. height: 482rpx;
  264. }
  265. .content {
  266. position: absolute;
  267. top: 100rpx;
  268. box-sizing: border-box;
  269. padding: 0 30rpx 260rpx;
  270. width: 100%;
  271. .status {
  272. font-size: 48rpx;
  273. }
  274. .tips {
  275. display: flex;
  276. align-items: center;
  277. box-sizing: border-box;
  278. padding: 30rpx;
  279. margin-top: 26rpx;
  280. margin-bottom: 20rpx;
  281. box-shadow: 0px 3px 6px #ccc;
  282. background-color: #fff;
  283. .tips_img {
  284. width: 56rpx;
  285. height: 74rpx;
  286. }
  287. .tips_text {
  288. flex: 1;
  289. margin-left: 16rpx;
  290. line-height: 40rpx;
  291. font-size: 28rpx;
  292. color: #001713;
  293. }
  294. }
  295. .detail {
  296. padding: 0 30rpx 40rpx;
  297. box-shadow: 0px 3px 6px #ccc;
  298. background-color: #fff;
  299. .carMsg {
  300. position: relative;
  301. width: 100%;
  302. height: 250rpx;
  303. font-size: 32rpx;
  304. color: #001713;
  305. .carMsg_time {
  306. position: absolute;
  307. top: 36rpx;
  308. font-size: 36rpx;
  309. color: #001713;
  310. }
  311. .carMsg_number {
  312. position: absolute;
  313. top: 44rpx;
  314. right: 0;
  315. font-size: 24rpx;
  316. color: #f86818;
  317. }
  318. .carMsg_number1{
  319. position: absolute;
  320. top: 44rpx;
  321. right: 0;
  322. font-size: 24rpx;
  323. color: #001713;
  324. }
  325. .carMsg_volume {
  326. position: absolute;
  327. top: 86rpx;
  328. right: 0;
  329. font-size: 24rpx;
  330. color: #f86818;
  331. }
  332. .carMsg_volume1{
  333. position: absolute;
  334. top: 86rpx;
  335. right: 0;
  336. font-size: 24rpx;
  337. color: #001713;
  338. }
  339. .carMsg_line {
  340. position: absolute;
  341. top: 128rpx;
  342. left: 0;
  343. width: 14rpx;
  344. height: 88rpx;
  345. }
  346. .carMsg_start {
  347. position: absolute;
  348. top: 106rpx;
  349. left: 40rpx;
  350. width: 460rpx;
  351. }
  352. .carMsg_end {
  353. position: absolute;
  354. top: 185rpx;
  355. left: 40rpx;
  356. width: 460rpx;
  357. }
  358. }
  359. .code {
  360. display: flex;
  361. align-items: center;
  362. justify-content: center;
  363. height: 540rpx;
  364. border-top: 2rpx dotted #ff8205;
  365. }
  366. .info {
  367. padding: 40rpx 0 0;
  368. line-height: 50rpx;
  369. font-size: 28rpx;
  370. border-top: 2rpx solid #ebecf1;
  371. .info_price {
  372. display: flex;
  373. align-items: center;
  374. justify-content: space-between;
  375. font-size: 32rpx;
  376. color: #ff8205;
  377. .text {
  378. font-size: 24rpx;
  379. }
  380. }
  381. .info_price2 {
  382. display: flex;
  383. align-items: center;
  384. justify-content: space-between;
  385. font-size: 32rpx;
  386. color: #001713;
  387. .text {
  388. font-size: 24rpx;
  389. }
  390. }
  391. }
  392. }
  393. }
  394. .pay {
  395. position: fixed;
  396. bottom: 0;
  397. display: flex;
  398. align-items: center;
  399. justify-content: space-between;
  400. box-sizing: border-box;
  401. padding: 0 30rpx;
  402. width: 100%;
  403. height: 240rpx;
  404. color: #dc2626;
  405. box-shadow: 0px -3px 6px #ccc;
  406. background-color: #fff;
  407. .pay_left {
  408. font-size: 36rpx;
  409. .text {
  410. font-size: 48rpx;
  411. }
  412. }
  413. .pay_btn {
  414. display: flex;
  415. align-items: center;
  416. justify-content: center;
  417. width: 272rpx;
  418. height: 94rpx;
  419. font-size: 36rpx;
  420. color: #ff8205;
  421. border-radius: 64rpx;
  422. border: 2rpx solid #ff8205;
  423. }
  424. }
  425. }
  426. // 选择付款方式弹窗
  427. .pop_pay {
  428. height: 566rpx;
  429. color: #001713;
  430. font-size: 28rpx;
  431. .pay_title {
  432. display: flex;
  433. align-items: center;
  434. justify-content: center;
  435. height: 80rpx;
  436. font-size: 32rpx;
  437. border-bottom: 18rpx solid #ff8205;
  438. }
  439. .pay_close {
  440. position: absolute;
  441. top: 24rpx;
  442. right: 42rpx;
  443. }
  444. .pay_list {
  445. box-sizing: border-box;
  446. padding: 55rpx 0;
  447. display: flex;
  448. flex-direction: column;
  449. justify-content: space-between;
  450. height: 265rpx;
  451. .list_item {
  452. display: flex;
  453. align-items: center;
  454. justify-content: space-between;
  455. box-sizing: border-box;
  456. padding: 0 32rpx 0 46rpx;
  457. .item_left {
  458. display: flex;
  459. align-items: center;
  460. .img {
  461. margin-right: 26rpx;
  462. width: 54rpx;
  463. height: 54rpx;
  464. }
  465. }
  466. .item_right {
  467. }
  468. }
  469. }
  470. .pay_btn {
  471. display: flex;
  472. align-items: center;
  473. justify-content: center;
  474. margin: auto;
  475. width: 720rpx;
  476. height: 94rpx;
  477. font-size: 36rpx;
  478. color: #fff;
  479. border-radius: 50rpx;
  480. background-color: #ff8205;
  481. }
  482. }
  483. </style>