|
|
@@ -54,10 +54,10 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
- <!-- 标签 -->
|
|
|
- <view class="food-tags">
|
|
|
- <view v-for="(tag, tagIndex) in item.tags" :key="tagIndex" class="food-tag" :class="tag.type">
|
|
|
- {{ tag.text }}
|
|
|
+ <!-- 标签:招牌橙底白字,其他黑底白字(与 FoodCard/foodDetail 一致) -->
|
|
|
+ <view class="food-tags" v-if="item.tags && item.tags.length">
|
|
|
+ <view v-for="(tag, tagIndex) in item.tags" :key="tagIndex" class="food-tag"
|
|
|
+ :class="{ 'food-tag--signature': (tag.text || '').includes('招牌') }">{{ tag.text }}
|
|
|
</view>
|
|
|
</view>
|
|
|
|
|
|
@@ -98,8 +98,28 @@ const storeInfo = ref({});
|
|
|
const foodList = ref([]);
|
|
|
|
|
|
function normalizeHomeCuisine(item) {
|
|
|
- const tags = item?.tags ?? [];
|
|
|
- const tagArr = Array.isArray(tags) ? tags : [];
|
|
|
+ const raw = item?.tags ?? item?.tagList ?? item?.tagNames ?? item?.labels ?? item?.tag ?? [];
|
|
|
+ let tagArr = [];
|
|
|
+ if (Array.isArray(raw)) tagArr = raw;
|
|
|
+ else if (raw && typeof raw === 'object') tagArr = Array.isArray(raw.list) ? raw.list : Array.isArray(raw.items) ? raw.items : [];
|
|
|
+ else if (typeof raw === 'string') {
|
|
|
+ const trimmed = raw.trim();
|
|
|
+ if (trimmed.startsWith('[')) {
|
|
|
+ try {
|
|
|
+ const parsed = JSON.parse(trimmed);
|
|
|
+ tagArr = Array.isArray(parsed) ? parsed : trimmed ? [trimmed] : [];
|
|
|
+ } catch {
|
|
|
+ tagArr = trimmed ? trimmed.split(/[,,、\s]+/).map(s => s.trim()).filter(Boolean) : [];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tagArr = trimmed ? trimmed.split(/[,,、\s]+/).map(s => s.trim()).filter(Boolean) : [];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const tagArrNormalized = tagArr.map((t) => {
|
|
|
+ if (t == null) return { text: '', type: 'normal' };
|
|
|
+ if (typeof t === 'string') return { text: t, type: 'normal' };
|
|
|
+ return { text: t?.text ?? t?.tagName ?? t?.name ?? t?.label ?? '', type: t?.type ?? 'normal' };
|
|
|
+ }).filter((t) => t.text !== '' && t.text != null);
|
|
|
const images = item?.images;
|
|
|
const imageUrl = Array.isArray(images) ? images[0] : images;
|
|
|
return {
|
|
|
@@ -107,7 +127,7 @@ function normalizeHomeCuisine(item) {
|
|
|
image: imageUrl ?? item?.cuisineImage ?? item?.image ?? 'img/icon/shop.png',
|
|
|
name: item?.cuisineName ?? item?.name ?? '',
|
|
|
sales: item?.monthlySales ?? item?.sales ?? 0,
|
|
|
- tags: tagArr.map((t) => (typeof t === 'string' ? { text: t, type: 'normal' } : { text: t?.text ?? t?.tagName ?? '', type: t?.type ?? 'normal' })),
|
|
|
+ tags: tagArrNormalized,
|
|
|
description: item?.description ?? item?.desc ?? '',
|
|
|
dishReview: item?.dishReview ?? item?.description ?? item?.desc ?? '',
|
|
|
price: item?.totalPrice ?? item?.unitPrice ?? item?.price ?? ''
|
|
|
@@ -427,14 +447,11 @@ onLoad(async (options) => {
|
|
|
font-size: 22rpx;
|
|
|
color: #FFFFFF;
|
|
|
line-height: 1.2;
|
|
|
+ background: #2E2E2E;
|
|
|
|
|
|
- &.signature {
|
|
|
+ &--signature {
|
|
|
background: linear-gradient(90deg, #FCB13F 0%, #FC793D 100%);
|
|
|
}
|
|
|
-
|
|
|
- &.spicy {
|
|
|
- background: #2E2E2E;
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|