Showing
2 changed files
with
48 additions
and
18 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-01-15 16:25:51 | 2 | * @Date: 2024-01-15 16:25:51 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-01-22 18:21:18 | 4 | + * @LastEditTime: 2024-01-24 11:32:08 |
| 5 | * @FilePath: /xysBooking/src/views/submit.vue | 5 | * @FilePath: /xysBooking/src/views/submit.vue |
| 6 | * @Description: 预约人员信息 | 6 | * @Description: 预约人员信息 |
| 7 | --> | 7 | --> |
| ... | @@ -117,18 +117,20 @@ const submitBtn = async () => { | ... | @@ -117,18 +117,20 @@ const submitBtn = async () => { |
| 117 | if (!checked_visitors.value.length) { | 117 | if (!checked_visitors.value.length) { |
| 118 | showToast('请先添加参观者') | 118 | showToast('请先添加参观者') |
| 119 | } else { | 119 | } else { |
| 120 | - // TODO: 提交订单跳转到支付页面 | 120 | + // TAG: 提交订单跳转到支付页面 |
| 121 | const { code, data } = await addReserveAPI({ reserve_date: date, begin_time: time.split('-')[0], end_time: time.split('-')[1], person_id_list: JSON.stringify(checked_visitors.value) }); | 121 | const { code, data } = await addReserveAPI({ reserve_date: date, begin_time: time.split('-')[0], end_time: time.split('-')[1], person_id_list: JSON.stringify(checked_visitors.value) }); |
| 122 | if (code) { | 122 | if (code) { |
| 123 | - const { code: prepare_code, data: prepare_data } = await payPrepareAPI({ pay_id: data.pay_id }); | 123 | + const pay_url = `/srv/?f=reserve&a=icbc_pay&pay_id=${data.pay_id}`; |
| 124 | - if (prepare_code) { | 124 | + location.href = pay_url; // 跳转支付页面 |
| 125 | - const { code: callback_code, data: callback_data } = await payCallbackAPI({ pay_id: prepare_data.pay_id, pay_status: 1 }); | 125 | + // const { code: prepare_code, data: prepare_data } = await payPrepareAPI({ pay_id: data.pay_id }); |
| 126 | - if (callback_code) { | 126 | + // if (prepare_code) { |
| 127 | - // TODO:看需求,把跳转页换成等待页面 | 127 | + // const { code: callback_code, data: callback_data } = await payCallbackAPI({ pay_id: prepare_data.pay_id, pay_status: 1 }); |
| 128 | - go('/success', { pay_id: prepare_data.pay_id }); | 128 | + // if (callback_code) { |
| 129 | - // go('/waiting', { pay_id: prepare_data.pay_id }); | 129 | + // // TODO:看需求,把跳转页换成等待页面 |
| 130 | - } | 130 | + // go('/success', { pay_id: prepare_data.pay_id }); |
| 131 | - } | 131 | + // // go('/waiting', { pay_id: prepare_data.pay_id }); |
| 132 | + // } | ||
| 133 | + // } | ||
| 132 | } | 134 | } |
| 133 | } | 135 | } |
| 134 | } | 136 | } | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-01-19 21:57:50 | 2 | * @Date: 2024-01-19 21:57:50 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-01-20 07:01:38 | 4 | + * @LastEditTime: 2024-01-24 14:26:31 |
| 5 | * @FilePath: /xysBooking/src/views/waiting.vue | 5 | * @FilePath: /xysBooking/src/views/waiting.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -14,7 +14,7 @@ | ... | @@ -14,7 +14,7 @@ |
| 14 | <div style="margin: 1rem 0;">支付中...</div> | 14 | <div style="margin: 1rem 0;">支付中...</div> |
| 15 | <div>{{ current.seconds }} s</div> | 15 | <div>{{ current.seconds }} s</div> |
| 16 | <div style="margin: 1.5rem 0; font-size: 0.85rem; color: #A67939; text-align: center; line-height: 2;"> | 16 | <div style="margin: 1.5rem 0; font-size: 0.85rem; color: #A67939; text-align: center; line-height: 2;"> |
| 17 | - 温馨提示:支付可能需要10s左右,请耐心等待<br /> | 17 | + 温馨提示:{{ pay_msg }}<br /> |
| 18 | </div> | 18 | </div> |
| 19 | </div> | 19 | </div> |
| 20 | <div class="go-back-wrapper"> | 20 | <div class="go-back-wrapper"> |
| ... | @@ -33,6 +33,7 @@ import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@ | ... | @@ -33,6 +33,7 @@ import { Cookies, $, _, axios, storeToRefs, mainStore, Toast, useTitle } from '@ |
| 33 | //import { } from '@/composables' | 33 | //import { } from '@/composables' |
| 34 | import { showSuccessToast, showFailToast, showToast } from 'vant'; | 34 | import { showSuccessToast, showFailToast, showToast } from 'vant'; |
| 35 | import { useGo } from '@/hooks/useGo' | 35 | import { useGo } from '@/hooks/useGo' |
| 36 | +import { billPayStatusAPI } from '@/api/index' | ||
| 36 | const $route = useRoute(); | 37 | const $route = useRoute(); |
| 37 | const $router = useRouter(); | 38 | const $router = useRouter(); |
| 38 | useTitle($route.meta.title); | 39 | useTitle($route.meta.title); |
| ... | @@ -47,17 +48,44 @@ const countDown = useCountDown({ | ... | @@ -47,17 +48,44 @@ const countDown = useCountDown({ |
| 47 | countDown.start(); | 48 | countDown.start(); |
| 48 | 49 | ||
| 49 | const current = countDown.current; | 50 | const current = countDown.current; |
| 51 | +const pay_id = $route.query.pay_id; | ||
| 52 | +const pay_msg = ref('支付可能需要10s左右,请耐心等待'); | ||
| 53 | + | ||
| 54 | + | ||
| 55 | +/** | ||
| 56 | + * 3=支付成功,1=待支付,2=支付中,7=支付失败 | ||
| 57 | + */ | ||
| 58 | +const PAY_STATUS = { | ||
| 59 | + PAY: '1', | ||
| 60 | + PAYING: '2', | ||
| 61 | + FAIL: '7', | ||
| 62 | + SUCCESS: '3' | ||
| 63 | +} | ||
| 50 | 64 | ||
| 51 | onMounted(() => { | 65 | onMounted(() => { |
| 52 | - const timer = setInterval(() => { | 66 | + // 重置历史记录 |
| 67 | + window.history.pushState(null, '', location.origin + location.pathname); // 将授权页面替换为根路径或其他合适的路径 | ||
| 68 | + // | ||
| 69 | + const timer = setInterval(async () => { | ||
| 53 | if (!current.value.seconds) { | 70 | if (!current.value.seconds) { |
| 54 | clearInterval(timer); | 71 | clearInterval(timer); |
| 55 | } | 72 | } |
| 56 | - // TODO:轮询支付回调 | 73 | + const { code, data } = await billPayStatusAPI({ pay_id }); |
| 57 | - if (current.value.seconds === 3) { | 74 | + // TAG:轮询支付回调 |
| 58 | - console.warn('支付成功'); | 75 | + switch (data.status) { |
| 76 | + case PAY_STATUS.PAY: | ||
| 77 | + pay_msg.value = '订单待支付'; | ||
| 78 | + break; | ||
| 79 | + case PAY_STATUS.PAYING: | ||
| 80 | + pay_msg.value = '订单支付中'; | ||
| 81 | + break; | ||
| 82 | + case PAY_STATUS.SUCCESS: | ||
| 59 | // 预约成功页面 | 83 | // 预约成功页面 |
| 60 | - // go('/success', { pay_id: 'test' }); | 84 | + go('/success', { pay_id }); |
| 85 | + break; | ||
| 86 | + case PAY_STATUS.FAIL: | ||
| 87 | + pay_msg.value = '订单支付失败'; | ||
| 88 | + break; | ||
| 61 | } | 89 | } |
| 62 | }, 1000); | 90 | }, 1000); |
| 63 | onUnmounted(() => { | 91 | onUnmounted(() => { | ... | ... |
-
Please register or login to post a comment