feat: 套餐折叠、小程序 staging API、首页去筛选、企微日志权限

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-03 20:17:52 +08:00
parent ac2f9f4793
commit ffa753707b
9 changed files with 558 additions and 261 deletions
+3 -41
View File
@@ -24,7 +24,6 @@ import { capturePromoSceneAndTouchScan } from '../../lib/promo';
import { getProductMainImage } from '../../lib/product-images';
import {
canBuyOnline,
canCrossCity,
canPickupOnSite,
normalizeFulfillmentFlags,
} from '../../lib/product-fulfillment';
@@ -49,22 +48,6 @@ type Product = {
allowCrossCityDelivery?: boolean;
};
type FulfillmentFilter = 'ALL' | 'ONLINE' | 'CROSS_CITY' | 'ON_SITE';
const FULFILLMENT_FILTERS: Array<{ key: FulfillmentFilter; label: string }> = [
{ key: 'ALL', label: '全部' },
{ key: 'ONLINE', label: '线上' },
{ key: 'CROSS_CITY', label: '跨城' },
{ key: 'ON_SITE', label: '现场' },
];
function matchFulfillmentFilter(p: Product, filter: FulfillmentFilter): boolean {
if (filter === 'ALL') return true;
if (filter === 'ONLINE') return canBuyOnline(p);
if (filter === 'CROSS_CITY') return canCrossCity(p);
return canPickupOnSite(p);
}
type MiniHomeConfig = {
banners: string[];
footerUrl: string | null;
@@ -87,7 +70,6 @@ function aromaSectionId(key: AromaKey) {
export default function HomePage() {
const [activeAroma, setActiveAroma] = useState<AromaKey>('QINGXIANG');
const [fulfillmentFilter, setFulfillmentFilter] = useState<FulfillmentFilter>('ALL');
const [products, setProducts] = useState<Product[]>([]);
const [loading, setLoading] = useState(true);
const [displayCity, setDisplayCity] = useState('郑州市');
@@ -205,23 +187,18 @@ export default function HomePage() {
Taro.navigateTo({ url: returnPath });
}
const filteredProducts = useMemo(
() => products.filter((p) => matchFulfillmentFilter(p, fulfillmentFilter)),
[products, fulfillmentFilter],
);
const productsByAroma = useMemo(() => {
const map: Record<AromaKey, Product[]> = {
QINGXIANG: [],
JIANGXIANG: [],
NONGXIANG: [],
};
for (const p of filteredProducts) {
for (const p of products) {
const key = p.aromaType as AromaKey;
if (key in map) map[key].push(p);
}
return map;
}, [filteredProducts]);
}, [products]);
const banners = miniHome.banners;
const footerUrl = miniHome.footerUrl;
@@ -377,28 +354,13 @@ export default function HomePage() {
<Text className="home-aroma-city">{displayCity}</Text>
</View>
<View className="home-fulfillment-filters">
{FULFILLMENT_FILTERS.map((f) => (
<Text
key={f.key}
className={`home-fulfillment-chip${fulfillmentFilter === f.key ? ' home-fulfillment-chip--active' : ''}`}
onClick={() => setFulfillmentFilter(f.key)}
>
{f.label}
</Text>
))}
</View>
<View className="home-product-list">
{loading ? <View className="home-empty"></View> : null}
{!loading && products.length === 0 ? (
<View className="home-empty"></View>
) : null}
{!loading && products.length > 0 && filteredProducts.length === 0 ? (
<View className="home-empty"></View>
) : null}
{!loading &&
filteredProducts.length > 0 &&
products.length > 0 &&
AROMA_TABS.map((t) => {
const list = productsByAroma[t.key];
return (