orderDetail.vue 12 KB

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