refactor(payment): 重构支付页面 URL
- 引入 useRuntimeConfig() 以获取环境变量- 使用 Nuxt 配置中的 API_BASE_URL 替代 window.location.origin - 更新 return_url 为绝对路径,确保在不同环境中的一致性
This commit is contained in:
parent
bed0e6c4be
commit
bbb191651e
@ -1,6 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import {authStore} from "~/stores/auth/index.js";
|
import {authStore} from "~/stores/auth/index.js";
|
||||||
|
import {useRuntimeConfig} from "#app";
|
||||||
const {checkoutSessionUrl,payUid}= authStore()
|
const {checkoutSessionUrl,payUid}= authStore()
|
||||||
const config = useRuntimeConfig()
|
const config = useRuntimeConfig()
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
@ -10,7 +11,7 @@ definePageMeta({
|
|||||||
console.log('config.public.NUXT_PUBLIC_PKEY',config.public.NUXT_PUBLIC_PKEY);
|
console.log('config.public.NUXT_PUBLIC_PKEY',config.public.NUXT_PUBLIC_PKEY);
|
||||||
const stripe = Stripe(config.public.NUXT_PUBLIC_PKEY)
|
const stripe = Stripe(config.public.NUXT_PUBLIC_PKEY)
|
||||||
|
|
||||||
|
const baseURL = config.public.NUXT_PUBLIC_API_BASE
|
||||||
const items = [{ id: "xl-tshirt", amount: 1000 }]
|
const items = [{ id: "xl-tshirt", amount: 1000 }]
|
||||||
const elements = ref(null)
|
const elements = ref(null)
|
||||||
const paymentMessage = ref('')
|
const paymentMessage = ref('')
|
||||||
@ -41,7 +42,7 @@ async function handleSubmit(e) {
|
|||||||
const { error } = await stripe.confirmPayment({
|
const { error } = await stripe.confirmPayment({
|
||||||
elements: elements.value,
|
elements: elements.value,
|
||||||
confirmParams: {
|
confirmParams: {
|
||||||
return_url: `${window.location.origin}/payment/result?orderNo=${payUid.value}`,
|
return_url: `${baseURL}/payment/result?orderNo=${payUid.value}`,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user