update pay ui
This commit is contained in:
@@ -37,6 +37,7 @@ import VerificationCodeInput from './VerificationCodeInput';
|
||||
import WechatRegister from './WechatRegister';
|
||||
import { setCurrentUser } from '../../mocks/data/users';
|
||||
import { logger } from '../../utils/logger';
|
||||
import { getApiBase } from '../../utils/apiConfig';
|
||||
import { useAuthEvents } from '../../hooks/useAuthEvents';
|
||||
|
||||
// 统一配置对象
|
||||
@@ -186,7 +187,7 @@ export default function AuthFormContent() {
|
||||
purpose: config.api.purpose
|
||||
};
|
||||
|
||||
const response = await fetch('/api/auth/send-verification-code', {
|
||||
const response = await fetch(`${getApiBase()}/api/auth/send-verification-code`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -300,7 +301,7 @@ export default function AuthFormContent() {
|
||||
};
|
||||
|
||||
// 调用API(根据模式选择不同的endpoint
|
||||
const response = await fetch('/api/auth/login-with-code', {
|
||||
const response = await fetch(`${getApiBase()}/api/auth/login-with-code`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
@@ -20,6 +20,7 @@ import CitationMark from '@components/Citation/CitationMark';
|
||||
import CitedContent from '@components/Citation/CitedContent';
|
||||
import { processCitationData } from '@utils/citationUtils';
|
||||
import { logger } from '@utils/logger';
|
||||
import { getApiBase } from '@utils/apiConfig';
|
||||
import './InvestmentCalendar.css';
|
||||
|
||||
const { TabPane } = Tabs;
|
||||
@@ -153,7 +154,7 @@ const InvestmentCalendar = () => {
|
||||
const code = codes[i];
|
||||
const originalCode = normalizedStocks[i].code; // 使用归一化后的代码作为key
|
||||
try {
|
||||
const response = await fetch(`/api/market/trade/${code}?days=1`);
|
||||
const response = await fetch(`${getApiBase()}/api/market/trade/${code}?days=1`);
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
if (data.success && data.data && data.data.length > 0) {
|
||||
|
||||
@@ -53,6 +53,7 @@ import {
|
||||
FaChevronDown,
|
||||
FaChevronUp,
|
||||
} from 'react-icons/fa';
|
||||
import { getApiBase } from '../../utils/apiConfig';
|
||||
|
||||
export default function SubscriptionContent() {
|
||||
// Auth context
|
||||
@@ -129,7 +130,7 @@ export default function SubscriptionContent() {
|
||||
const fetchSubscriptionPlans = async () => {
|
||||
try {
|
||||
logger.debug('SubscriptionContent', '正在获取订阅套餐');
|
||||
const response = await fetch('/api/subscription/plans');
|
||||
const response = await fetch(`${getApiBase()}/api/subscription/plans`);
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
@@ -175,7 +176,7 @@ export default function SubscriptionContent() {
|
||||
validPromoCode
|
||||
});
|
||||
|
||||
const response = await fetch('/api/subscription/calculate-price', {
|
||||
const response = await fetch(`${getApiBase()}/api/subscription/calculate-price`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -307,7 +308,7 @@ export default function SubscriptionContent() {
|
||||
orderId: null // Will be set after order creation
|
||||
});
|
||||
|
||||
const response = await fetch('/api/payment/create-order', {
|
||||
const response = await fetch(`${getApiBase()}/api/payment/create-order`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -379,7 +380,7 @@ export default function SubscriptionContent() {
|
||||
|
||||
const checkInterval = setInterval(async () => {
|
||||
try {
|
||||
const response = await fetch(`/api/payment/order/${orderId}/status`, {
|
||||
const response = await fetch(`${getApiBase()}/api/payment/order/${orderId}/status`, {
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
@@ -456,7 +457,7 @@ export default function SubscriptionContent() {
|
||||
|
||||
setForceUpdating(true);
|
||||
try {
|
||||
const response = await fetch(`/api/payment/order/${paymentOrder.id}/force-update`, {
|
||||
const response = await fetch(`${getApiBase()}/api/payment/order/${paymentOrder.id}/force-update`, {
|
||||
method: 'POST',
|
||||
credentials: 'include'
|
||||
});
|
||||
@@ -517,7 +518,7 @@ export default function SubscriptionContent() {
|
||||
|
||||
setCheckingPayment(true);
|
||||
try {
|
||||
const response = await fetch(`/api/payment/order/${paymentOrder.id}/status`, {
|
||||
const response = await fetch(`${getApiBase()}/api/payment/order/${paymentOrder.id}/status`, {
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user