update pay ui

This commit is contained in:
2025-12-13 16:30:50 +08:00
parent ed9d49da01
commit 4ccd43f025
17 changed files with 67 additions and 43 deletions

View File

@@ -44,6 +44,7 @@ import { logger } from '../../utils/logger';
import { useAuth } from '../../contexts/AuthContext';
import { useSubscriptionEvents } from '../../hooks/useSubscriptionEvents';
import { subscriptionConfig, themeColors } from '../../views/Pages/Account/subscription-content';
import { getApiBase } from '../../utils/apiConfig';
// 计费周期选择器组件 - 移动端垂直布局(年付在上),桌面端水平布局
interface CycleSelectorProps {
@@ -207,8 +208,8 @@ export default function SubscriptionContentNew() {
// 优先使用 sessionStorage 中的 orderId否则使用 order_no 查询
const orderId = sessionStorage.getItem('alipay_order_id');
const statusUrl = orderId
? `/api/payment/alipay/order/${orderId}/status`
: `/api/payment/alipay/order-by-no/${orderNo}/status`;
? `${getApiBase()}/api/payment/alipay/order/${orderId}/status`
: `${getApiBase()}/api/payment/alipay/order-by-no/${orderNo}/status`;
const response = await fetch(statusUrl, {
credentials: 'include',
@@ -261,7 +262,7 @@ export default function SubscriptionContentNew() {
const fetchSubscriptionPlans = async () => {
try {
logger.debug('SubscriptionContentNew', '正在获取订阅套餐');
const response = await fetch('/api/subscription/plans');
const response = await fetch(`${getApiBase()}/api/subscription/plans`);
if (response.ok) {
const data = await response.json();
@@ -324,7 +325,7 @@ export default function SubscriptionContentNew() {
? promoCodeValue.trim()
: null;
const response = await fetch('/api/subscription/calculate-price', {
const response = await fetch(`${getApiBase()}/api/subscription/calculate-price`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -430,7 +431,7 @@ export default function SubscriptionContentNew() {
// 检查是否为免费升级(剩余价值足够抵扣新套餐价格)
if (price === 0 && priceInfo?.is_upgrade) {
const response = await fetch('/api/subscription/free-upgrade', {
const response = await fetch(`${getApiBase()}/api/subscription/free-upgrade`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -479,8 +480,8 @@ export default function SubscriptionContentNew() {
// 根据支付方式选择不同的 API
const apiUrl = paymentMethod === 'alipay'
? '/api/payment/alipay/create-order'
: '/api/payment/create-order';
? `${getApiBase()}/api/payment/alipay/create-order`
: `${getApiBase()}/api/payment/create-order`;
// 检测是否为移动端设备
const userAgent = navigator.userAgent;
@@ -615,8 +616,8 @@ export default function SubscriptionContentNew() {
const startAutoPaymentCheck = (orderId: string, method: 'wechat' | 'alipay' = 'wechat') => {
// 根据支付方式选择不同的状态查询 API
const statusApiUrl = method === 'alipay'
? `/api/payment/alipay/order/${orderId}/status`
: `/api/payment/order/${orderId}/status`;
? `${getApiBase()}/api/payment/alipay/order/${orderId}/status`
: `${getApiBase()}/api/payment/order/${orderId}/status`;
const checkInterval = setInterval(async () => {
try {
@@ -666,8 +667,8 @@ export default function SubscriptionContentNew() {
// 根据订单的支付方式选择不同的查询 API
const orderPaymentMethod = (paymentOrder as any).payment_method || paymentMethod;
const statusApiUrl = orderPaymentMethod === 'alipay'
? `/api/payment/alipay/order/${(paymentOrder as any).id}/status`
: `/api/payment/order/${(paymentOrder as any).id}/status`;
? `${getApiBase()}/api/payment/alipay/order/${(paymentOrder as any).id}/status`
: `${getApiBase()}/api/payment/order/${(paymentOrder as any).id}/status`;
const response = await fetch(statusApiUrl, {
credentials: 'include',