@@ -79,6 +79,12 @@ type Store = {
|
||||
parentId?: string | null;
|
||||
parent?: { name?: string } | null;
|
||||
} | null;
|
||||
categories?: {
|
||||
id?: string;
|
||||
name?: string;
|
||||
parentId?: string | null;
|
||||
parent?: { name?: string } | null;
|
||||
}[] | null;
|
||||
};
|
||||
|
||||
type RecentRedeem = {
|
||||
@@ -406,12 +412,15 @@ export default function StoreDetailPage() {
|
||||
|
||||
<View className="store-detail-title-row">
|
||||
<Text className="store-detail-name">{store.name}</Text>
|
||||
{storeCategoryTags(store, categoryTree).map((tag) => (
|
||||
<Text key={tag} className="store-detail-tag">
|
||||
{tag}
|
||||
</Text>
|
||||
))}
|
||||
</View>
|
||||
{(() => {
|
||||
const categoryLabels = storeCategoryTags(store, categoryTree);
|
||||
return categoryLabels.length ? (
|
||||
<View className="store-detail-tags-row">
|
||||
<Text className="store-detail-category-line">{categoryLabels.join('、')}</Text>
|
||||
</View>
|
||||
) : null;
|
||||
})()}
|
||||
<View className="store-detail-rating-row">
|
||||
<View className="store-detail-stars">
|
||||
{[1, 2, 3, 4, 5].map((n) => (
|
||||
|
||||
@@ -42,7 +42,7 @@ import {
|
||||
toWeappShareTimeline,
|
||||
} from '../../lib/wechat-share';
|
||||
import BenefitSloganBar from '../../components/BenefitSloganBar';
|
||||
import { storeCategoryTags, storeStarCount } from '../../lib/store-display';
|
||||
import { storeCategoryTags, storeLeafCategoryIds, storeStarCount } from '../../lib/store-display';
|
||||
import openBadgeImg from '../../assets/icons/store-open-badge.png';
|
||||
|
||||
type Store = {
|
||||
@@ -66,6 +66,12 @@ type Store = {
|
||||
parentId?: string | null;
|
||||
parent?: { name?: string } | null;
|
||||
} | null;
|
||||
categories?: {
|
||||
id?: string;
|
||||
name?: string;
|
||||
parentId?: string | null;
|
||||
parent?: { name?: string } | null;
|
||||
}[] | null;
|
||||
tags?: unknown;
|
||||
rating?: number | string | null;
|
||||
latitude?: number | string | null;
|
||||
@@ -288,14 +294,21 @@ export default function StoresPage() {
|
||||
|
||||
function matchesCategory(store: Store): boolean {
|
||||
if (!category.parentId) return true;
|
||||
const storeCatId = String(store.categoryId || store.category?.id || '');
|
||||
const storeParentId = String(store.category?.parentId || '');
|
||||
if (category.childId) {
|
||||
return storeCatId === category.childId;
|
||||
const leafIds = storeLeafCategoryIds(store);
|
||||
const parentIds = new Set<string>();
|
||||
if (Array.isArray(store.categories)) {
|
||||
for (const cat of store.categories) {
|
||||
if (cat.parentId) parentIds.add(String(cat.parentId));
|
||||
}
|
||||
}
|
||||
if (storeParentId && storeParentId === category.parentId) return true;
|
||||
const legacyParent = String(store.category?.parentId || '');
|
||||
if (legacyParent) parentIds.add(legacyParent);
|
||||
if (category.childId) {
|
||||
return leafIds.includes(category.childId);
|
||||
}
|
||||
if ([...parentIds].some((id) => id === category.parentId)) return true;
|
||||
const siblings = childIdsByParent.get(category.parentId) ?? [];
|
||||
return siblings.includes(storeCatId);
|
||||
return leafIds.some((id) => siblings.includes(id));
|
||||
}
|
||||
|
||||
const filtered = useMemo(() => {
|
||||
@@ -461,14 +474,10 @@ export default function StoresPage() {
|
||||
<Text className="store-card-name">{s.name}</Text>
|
||||
</View>
|
||||
{(() => {
|
||||
const tags = storeCategoryTags(s, categoryTree);
|
||||
return tags.length ? (
|
||||
<View className="store-card-tags">
|
||||
{tags.map((tag) => (
|
||||
<Text key={tag} className="store-card-tag">
|
||||
{tag}
|
||||
</Text>
|
||||
))}
|
||||
const categoryLabels = storeCategoryTags(s, categoryTree);
|
||||
return categoryLabels.length ? (
|
||||
<View className="store-card-category-wrap">
|
||||
<Text className="store-card-category-text">{categoryLabels.join('、')}</Text>
|
||||
</View>
|
||||
) : null;
|
||||
})()}
|
||||
|
||||
Reference in New Issue
Block a user