feat: audit diff, mock SMS 999888, env photos, proxy pay lock, mini-user UX
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useCallback, useMemo, useRef, useState } from 'react';
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { View, Text, Image, Swiper, SwiperItem } from '@tarojs/components';
|
||||
import Taro, {
|
||||
useDidShow,
|
||||
@@ -200,6 +200,18 @@ export default function HomePage() {
|
||||
return map;
|
||||
}, [products]);
|
||||
|
||||
const visibleAromaTabs = useMemo(
|
||||
() => AROMA_TABS.filter((t) => productsByAroma[t.key].length > 0),
|
||||
[productsByAroma],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (loading || visibleAromaTabs.length === 0) return;
|
||||
if (!visibleAromaTabs.some((t) => t.key === activeAroma)) {
|
||||
setActiveAroma(visibleAromaTabs[0].key);
|
||||
}
|
||||
}, [loading, visibleAromaTabs, activeAroma]);
|
||||
|
||||
const banners = miniHome.banners;
|
||||
const footerUrl = miniHome.footerUrl;
|
||||
|
||||
@@ -246,18 +258,18 @@ export default function HomePage() {
|
||||
if (now - lastScrollSyncAtRef.current < 80) return;
|
||||
lastScrollSyncAtRef.current = now;
|
||||
const query = Taro.createSelectorQuery();
|
||||
AROMA_TABS.forEach((t) => {
|
||||
visibleAromaTabs.forEach((t) => {
|
||||
query.select(`#${aromaSectionId(t.key)}`).boundingClientRect();
|
||||
});
|
||||
query.exec((rects) => {
|
||||
if (!Array.isArray(rects) || rects.length === 0) return;
|
||||
let next: AromaKey = AROMA_TABS[0].key;
|
||||
for (let i = 0; i < AROMA_TABS.length; i++) {
|
||||
let next: AromaKey = visibleAromaTabs[0]?.key ?? AROMA_TABS[0].key;
|
||||
for (let i = 0; i < visibleAromaTabs.length; i++) {
|
||||
const rect = rects[i] as { top?: number } | null;
|
||||
if (!rect || rect.top == null) continue;
|
||||
// 区块顶进入导航下方一带时视为当前香型
|
||||
if (rect.top <= AROMA_NAV_OFFSET_PX + 24) {
|
||||
next = AROMA_TABS[i].key;
|
||||
next = visibleAromaTabs[i].key;
|
||||
}
|
||||
}
|
||||
setActiveAroma((prev) => (prev === next ? prev : next));
|
||||
@@ -341,7 +353,7 @@ export default function HomePage() {
|
||||
|
||||
<View className="home-aroma-nav">
|
||||
<View className="home-aroma-tabs">
|
||||
{AROMA_TABS.map((t) => (
|
||||
{visibleAromaTabs.map((t) => (
|
||||
<Text
|
||||
key={t.key}
|
||||
className={`home-aroma-tab${activeAroma === t.key ? ' home-aroma-tab--active' : ''}`}
|
||||
@@ -361,16 +373,12 @@ export default function HomePage() {
|
||||
) : null}
|
||||
{!loading &&
|
||||
products.length > 0 &&
|
||||
AROMA_TABS.map((t) => {
|
||||
visibleAromaTabs.map((t) => {
|
||||
const list = productsByAroma[t.key];
|
||||
return (
|
||||
<View key={t.key} id={aromaSectionId(t.key)} className="home-aroma-section">
|
||||
<Text className="home-aroma-section-title">{t.label}</Text>
|
||||
{list.length === 0 ? (
|
||||
<View className="home-empty home-empty--section">该香型暂未上线</View>
|
||||
) : (
|
||||
list.map((p) => renderProductCard(p))
|
||||
)}
|
||||
{list.map((p) => renderProductCard(p))}
|
||||
</View>
|
||||
);
|
||||
})}
|
||||
|
||||
Reference in New Issue
Block a user