feat(assoc): v4.0.1 合伙人关联码、分佣账单与 H5 用户管理
订单佣金只认关联用户;合伙人备注写入独立表;H5 增加用户管理与首页统计。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { View, Text, Input } from '@tarojs/components';
|
||||
|
||||
type OrderQtyControlsProps = {
|
||||
value: number;
|
||||
unitLabel: string;
|
||||
onChange: (next: number) => void;
|
||||
};
|
||||
|
||||
const MAX_QTY = 999;
|
||||
|
||||
function parseQty(raw: string): number | null {
|
||||
const n = parseInt(String(raw).replace(/\D/g, ''), 10);
|
||||
if (!Number.isFinite(n)) return null;
|
||||
return Math.min(MAX_QTY, Math.max(1, n));
|
||||
}
|
||||
|
||||
/** 下单数量:加减 + 手动输入,旁注单位(瓶/箱) */
|
||||
export default function OrderQtyControls({ value, unitLabel, onChange }: OrderQtyControlsProps) {
|
||||
const [draft, setDraft] = useState(String(value));
|
||||
|
||||
useEffect(() => {
|
||||
setDraft(String(value));
|
||||
}, [value]);
|
||||
|
||||
function current(): number {
|
||||
return parseQty(draft) ?? value;
|
||||
}
|
||||
|
||||
function commit() {
|
||||
const next = parseQty(draft);
|
||||
if (next == null) {
|
||||
setDraft(String(value));
|
||||
return;
|
||||
}
|
||||
setDraft(String(next));
|
||||
if (next !== value) onChange(next);
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="order-qty-row">
|
||||
<Text>购买数量</Text>
|
||||
<View className="order-qty-controls">
|
||||
<View className="order-qty-btn" onClick={() => onChange(Math.max(1, current() - 1))}>
|
||||
<Text>−</Text>
|
||||
</View>
|
||||
<Input
|
||||
className="order-qty-input"
|
||||
type="number"
|
||||
maxlength={3}
|
||||
value={draft}
|
||||
onInput={(e) => setDraft(String(e.detail.value ?? ''))}
|
||||
onBlur={commit}
|
||||
onConfirm={commit}
|
||||
/>
|
||||
<Text className="order-qty-unit">{unitLabel}</Text>
|
||||
<View className="order-qty-btn" onClick={() => onChange(Math.min(MAX_QTY, current() + 1))}>
|
||||
<Text>+</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user