This commit is contained in:
@@ -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 LoginModal from '../components/LoginModal';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import './ProductDetail.css';
|
||||
|
||||
@@ -14,10 +15,11 @@ const ProductDetail = () => {
|
||||
const [product, setProduct] = useState(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
const [loginVisible, setLoginVisible] = useState(false);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const [form] = Form.useForm();
|
||||
|
||||
const { user } = useAuth();
|
||||
const { user, login } = useAuth();
|
||||
|
||||
// 优先从 URL 获取,如果没有则从 localStorage 获取,不再默认绑定 flw666
|
||||
const refCode = searchParams.get('ref') || localStorage.getItem('ref_code');
|
||||
@@ -182,7 +184,13 @@ const ProductDetail = () => {
|
||||
type="primary"
|
||||
size="large"
|
||||
icon={<ShoppingCartOutlined />}
|
||||
onClick={() => setIsModalOpen(true)}
|
||||
onClick={() => {
|
||||
if (!user) {
|
||||
setLoginVisible(true);
|
||||
} else {
|
||||
setIsModalOpen(true);
|
||||
}
|
||||
}}
|
||||
disabled={product.stock === 0}
|
||||
style={{ height: 50, padding: '0 40px', fontSize: 18 }}
|
||||
>
|
||||
@@ -248,6 +256,17 @@ const ProductDetail = () => {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Login Modal */}
|
||||
<LoginModal
|
||||
visible={loginVisible}
|
||||
onClose={() => setLoginVisible(false)}
|
||||
onLoginSuccess={(userData) => {
|
||||
login(userData);
|
||||
setLoginVisible(false);
|
||||
setIsModalOpen(true);
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Order Modal */}
|
||||
<Modal
|
||||
title="填写收货信息"
|
||||
|
||||
Reference in New Issue
Block a user