feat(collectCode): 更新支付功能
- 使用 codeAuthStore 替代 authStore - 修改支付相关变量和路由 - 在支付成功
This commit is contained in:
parent
09bbd9ae14
commit
4b7a7ce285
@ -1,10 +1,11 @@
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue'
|
||||
import {authStore} from "~/stores/auth/index.js";
|
||||
import {codeAuthStore} from "@/stores-collect-code/auth/index.js";
|
||||
import {useRuntimeConfig} from "#app";
|
||||
import {orderQuery} from "~/api/goods/index.js";
|
||||
const {checkoutSessionUrl,payUid}= authStore()
|
||||
const {codePKey,codePayUid} = codeAuthStore()
|
||||
const config = useRuntimeConfig()
|
||||
|
||||
definePageMeta({
|
||||
layout: 'default',
|
||||
title: 'Stripe支付'
|
||||
@ -20,7 +21,7 @@ const isLoading = ref(false)
|
||||
const showSpinner = ref(false)
|
||||
|
||||
async function initialize() {
|
||||
const clientSecret = checkoutSessionUrl.value
|
||||
const clientSecret = codePKey.value
|
||||
console.log('clientSecret',clientSecret);
|
||||
|
||||
const appearance = {
|
||||
@ -46,13 +47,13 @@ async function handleSubmit(e) {
|
||||
const startPolling = () => {
|
||||
pollTimer = setInterval(async () => {
|
||||
const res = await orderQuery({
|
||||
orderNo: payUid.value
|
||||
orderNo: codePayUid.value
|
||||
})
|
||||
if (res.status === 0) {
|
||||
if (res.data.status !== 3) {
|
||||
clearInterval(pollTimer)
|
||||
clearTimeout(timeoutTimer)
|
||||
window.location.href = `${baseURL}/payment/result?orderNo=${payUid.value}`
|
||||
window.location.href = `${baseURL}/collectCode/payment/result?orderNo=${codePayUid.value}`
|
||||
}
|
||||
}
|
||||
}, 1000)
|
||||
@ -69,7 +70,7 @@ async function handleSubmit(e) {
|
||||
const { error } = await stripe.confirmPayment({
|
||||
elements: elements.value,
|
||||
confirmParams: {
|
||||
return_url: `${baseURL}/payment/result?orderNo=${payUid.value}`,
|
||||
return_url: `${baseURL}/collectCode/payment/result?orderNo=${codePayUid.value}`,
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -19,6 +19,7 @@ const changePayStatus = () => {
|
||||
payStatus.value = payStatus.value === 0 ? 1 : 0
|
||||
}
|
||||
const amount = ref('')
|
||||
const router = useRouter()
|
||||
const confirmPay = async () => {
|
||||
if (payStatus.value === 1 && !amount.value) {
|
||||
message.warning(t('collectCode.payment.enterAmount'))
|
||||
@ -42,6 +43,7 @@ const confirmPay = async () => {
|
||||
if (res.status === 0) {
|
||||
codePKey.value=res.data.checkoutSessionUrl
|
||||
codePayUid.value=res.data.payUid
|
||||
router.push('/collectCode/payment/checkoutPage')
|
||||
// window.location.href = res.data.checkoutSessionUrl
|
||||
console.log('res',res);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user