This commit is contained in:
jeremygan2021
2026-02-12 12:03:39 +08:00
parent 752b7caf71
commit ba78470052
18 changed files with 560 additions and 156 deletions

View File

@@ -4,6 +4,7 @@ import { Button, Row, Col, Tag, Statistic, Modal, Form, Input, InputNumber, mess
import { ShoppingCartOutlined, SafetyCertificateOutlined, ThunderboltOutlined, EyeOutlined, StarOutlined } from '@ant-design/icons';
import { getConfigs, createOrder, nativePay } from '../api';
import ModelViewer from '../components/ModelViewer';
import { useAuth } from '../context/AuthContext';
import './ProductDetail.css';
const ProductDetail = () => {
@@ -16,9 +17,22 @@ const ProductDetail = () => {
const [submitting, setSubmitting] = useState(false);
const [form] = Form.useForm();
const { user } = useAuth();
// 优先从 URL 获取,如果没有则从 localStorage 获取,不再默认绑定 flw666
const refCode = searchParams.get('ref') || localStorage.getItem('ref_code');
useEffect(() => {
// 自动填充用户信息
if (user) {
form.setFieldsValue({
phone_number: user.phone_number,
// 如果后端返回了地址信息,这里也可以填充
// shipping_address: user.shipping_address
});
}
}, [isModalOpen, user]); // 当弹窗打开或用户状态变化时填充
useEffect(() => {
console.log('[ProductDetail] Current ref_code:', refCode);
}, [refCode]);