v3.5.4版本提交
CI / verify (pull_request) Waiting to run

This commit is contained in:
2026-08-21 15:48:15 +08:00
parent 26334ed072
commit a01217539c
32 changed files with 2278 additions and 147 deletions
+63 -5
View File
@@ -58,6 +58,7 @@ export default function ProxyOrderPage() {
const [regionCodes, setRegionCodes] = useState<string[]>(draft0.regionCodes);
const [addressDetail, setAddressDetail] = useState(draft0.addressDetail);
const [productId, setProductId] = useState(draft0.productId);
const [skuId, setSkuId] = useState('');
const [quantity, setQuantity] = useState(draft0.quantity);
const [promoCodeId, setPromoCodeId] = useState(draft0.promoCodeId);
const [deliveryMode, setDeliveryMode] = useState<PartnerProxyDeliveryMode>(draft0.deliveryMode);
@@ -156,9 +157,37 @@ export default function ProxyOrderPage() {
]);
const selectedProduct = options?.products.find((p) => p.id === productId);
const allowOnline = selectedProduct ? selectedProduct.allowOnlinePurchase !== false : true;
const allowOnSite = !!selectedProduct?.allowOnSitePickup;
const allowCrossCity = selectedProduct ? selectedProduct.allowCrossCityDelivery !== false : true;
const skuOptions = (selectedProduct?.skus ?? []).filter((s) => s.status === 'ON_SALE');
const selectedSku =
skuOptions.find((s) => s.id === skuId) ||
skuOptions.find((s) => s.id === selectedProduct?.defaultSkuId) ||
skuOptions[0];
const allowOnline = selectedSku
? selectedSku.allowOnlinePurchase !== false
: selectedProduct
? selectedProduct.allowOnlinePurchase !== false
: true;
const allowOnSite = selectedSku
? !!selectedSku.allowOnSitePickup
: !!selectedProduct?.allowOnSitePickup;
const allowCrossCity = selectedSku
? selectedSku.allowCrossCityDelivery !== false
: selectedProduct
? selectedProduct.allowCrossCityDelivery !== false
: true;
useEffect(() => {
if (!selectedProduct) return;
const def =
skuOptions.find((s) => s.id === selectedProduct.defaultSkuId) ||
skuOptions.find((s) => s.isDefault) ||
skuOptions[0];
if (def && (!skuId || !skuOptions.some((s) => s.id === skuId))) {
setSkuId(def.id);
if (def.saleUnit === 'BOX') setQuantity(1);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [productId, selectedProduct?.id, options]);
useEffect(() => {
if (!selectedProduct) return;
@@ -184,6 +213,7 @@ export default function ProxyOrderPage() {
productId,
quantity,
deliveryMode,
skuId: skuId || undefined,
receiverCity: deliveryMode === 'ADDRESS' ? region?.city || undefined : undefined,
receiverDistrict: deliveryMode === 'ADDRESS' ? region?.district || undefined : undefined,
}),
@@ -200,7 +230,7 @@ export default function ProxyOrderPage() {
.finally(() => setPreviewLoading(false));
}, 300);
return () => clearTimeout(timer);
}, [productId, quantity, deliveryMode, region?.city, region?.district]);
}, [productId, skuId, quantity, deliveryMode, region?.city, region?.district]);
function validateForm(): string | null {
if (!/^1\d{10}$/.test(phone.trim())) return '请输入有效手机号';
@@ -359,6 +389,7 @@ export default function ProxyOrderPage() {
productId,
quantity,
promoCodeId: promoCodeId || undefined,
skuId: skuId || undefined,
};
setSubmitting(true);
@@ -524,8 +555,35 @@ export default function ProxyOrderPage() {
</button>
</section>
{skuOptions.length > 1 || selectedProduct?.specEnabled ? (
<section className="partner-form-section">
<label className="partner-form-label"></label>
<div className="partner-input-wrap">
<select
className="partner-input"
value={skuId}
onChange={(e) => {
const id = e.target.value;
setSkuId(id);
const sku = skuOptions.find((s) => s.id === id);
if (sku?.saleUnit === 'BOX') setQuantity(1);
}}
>
{skuOptions.map((s) => (
<option key={s.id} value={s.id}>
{s.specText || '默认'} · ¥{fmtMoney(s.price)} ·{' '}
{s.saleUnit === 'BOX' ? `${s.bottlesPerUnit}瓶/箱` : '瓶'}
</option>
))}
</select>
</div>
</section>
) : null}
<section className="partner-form-section">
<label className="partner-form-label"></label>
<label className="partner-form-label">
{selectedSku?.saleUnit === 'BOX' ? '数量(箱)' : '数量(瓶)'}
</label>
<div className="partner-input-wrap">
<input
className="partner-input"