feat: 新增「喝什么」场景,支持奶茶/咖啡/酒吧等饮品店搜索
引入场景系统(SceneType),首页增加「吃什么」「喝什么」切换 Tab, 不同场景使用不同的高德 POI 类型、热门标签、价格区间和全链路文案。 场景信息存储在房间数据中,邀请/分享/匹配结果等页面自动适配。
This commit is contained in:
@@ -67,6 +67,7 @@ export async function buildRoomStatus(
|
||||
locked: data.locked,
|
||||
users: data.users,
|
||||
userProfiles,
|
||||
scene: data.scene,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
import type { SceneType } from "@/types";
|
||||
|
||||
export interface SceneConfig {
|
||||
key: SceneType;
|
||||
label: string;
|
||||
emoji: string;
|
||||
poiTypes: string;
|
||||
defaultImage: string;
|
||||
hotTags: readonly string[];
|
||||
priceOptions: readonly { label: string; value: string }[];
|
||||
tagLabel: string;
|
||||
tagPlaceholder: string;
|
||||
loadingText: string;
|
||||
emptyError: string;
|
||||
subtitle: string;
|
||||
inviteText: string;
|
||||
shareTitle: string;
|
||||
shareText: string;
|
||||
qrSubtitle: string;
|
||||
}
|
||||
|
||||
const SCENE_CONFIGS: Record<SceneType, SceneConfig> = {
|
||||
eat: {
|
||||
key: "eat",
|
||||
label: "吃什么",
|
||||
emoji: "🍜",
|
||||
poiTypes: "050000",
|
||||
defaultImage:
|
||||
"https://images.unsplash.com/photo-1517248135467-4c7edcad34c4?w=800&q=80",
|
||||
hotTags: ["火锅", "日料", "烧烤", "西餐", "川菜", "咖啡甜品", "小吃快餐"],
|
||||
priceOptions: [
|
||||
{ label: "不限", value: "any" },
|
||||
{ label: "¥50以下", value: "under50" },
|
||||
{ label: "¥50-100", value: "50to100" },
|
||||
{ label: "¥100+", value: "over100" },
|
||||
],
|
||||
tagLabel: "美食",
|
||||
tagPlaceholder: "想吃什么?(留空则不限)",
|
||||
loadingText: "正在搜索周边美食...",
|
||||
emptyError: "附近没有找到餐厅,试试扩大搜索范围或换个菜系",
|
||||
subtitle: "和朋友一起滑卡片,再也不用纠结吃什么",
|
||||
inviteText: "有人邀请你一起选餐厅",
|
||||
shareTitle: "别说随便啦,来滑卡片决定吃什么!",
|
||||
shareText: "我建好房间了,快点开链接一起选餐厅,滑中同一家就去吃!",
|
||||
qrSubtitle: "让朋友扫码加入房间,一起滑卡片选餐厅",
|
||||
},
|
||||
drink: {
|
||||
key: "drink",
|
||||
label: "喝什么",
|
||||
emoji: "🧋",
|
||||
poiTypes: "050301|050302|050303|050400",
|
||||
defaultImage:
|
||||
"https://images.unsplash.com/photo-1556679343-c7306c1976bc?w=800&q=80",
|
||||
hotTags: ["奶茶", "咖啡", "酒吧", "果茶", "甜品", "茶馆", "鸡尾酒"],
|
||||
priceOptions: [
|
||||
{ label: "不限", value: "any" },
|
||||
{ label: "¥20以下", value: "under20" },
|
||||
{ label: "¥20-50", value: "20to50" },
|
||||
{ label: "¥50+", value: "over50" },
|
||||
],
|
||||
tagLabel: "饮品",
|
||||
tagPlaceholder: "想喝什么?(留空则不限)",
|
||||
loadingText: "正在搜索周边饮品店...",
|
||||
emptyError: "附近没有找到饮品店,试试扩大搜索范围或换个类型",
|
||||
subtitle: "和朋友一起滑卡片,再也不用纠结喝什么",
|
||||
inviteText: "有人邀请你一起选饮品店",
|
||||
shareTitle: "别说随便啦,来滑卡片决定喝什么!",
|
||||
shareText: "我建好房间了,快点开链接一起选店,滑中同一家就去喝!",
|
||||
qrSubtitle: "让朋友扫码加入房间,一起滑卡片选店",
|
||||
},
|
||||
};
|
||||
|
||||
export const SCENES: SceneType[] = ["eat", "drink"];
|
||||
|
||||
export function getSceneConfig(scene: SceneType): SceneConfig {
|
||||
return SCENE_CONFIGS[scene];
|
||||
}
|
||||
+5
-2
@@ -1,5 +1,5 @@
|
||||
import { prisma } from "./prisma";
|
||||
import { Restaurant } from "@/types";
|
||||
import { Restaurant, SceneType } from "@/types";
|
||||
|
||||
const ROOM_TTL_MS = 24 * 60 * 60 * 1000; // 24 hours
|
||||
|
||||
@@ -12,6 +12,7 @@ export interface RoomData {
|
||||
creatorId: string;
|
||||
locked: boolean;
|
||||
kickedUsers: string[];
|
||||
scene: SceneType;
|
||||
}
|
||||
|
||||
function generateRoomId(): string {
|
||||
@@ -28,6 +29,7 @@ function normalize(raw: Partial<RoomData>): RoomData {
|
||||
creatorId: raw.creatorId ?? "",
|
||||
locked: raw.locked ?? false,
|
||||
kickedUsers: raw.kickedUsers ?? [],
|
||||
scene: raw.scene ?? "eat",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -51,7 +53,7 @@ async function cleanupExpiredRooms() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function createRoom(restaurants: Restaurant[], creatorId: string): Promise<string> {
|
||||
export async function createRoom(restaurants: Restaurant[], creatorId: string, scene: SceneType = "eat"): Promise<string> {
|
||||
await cleanupExpiredRooms();
|
||||
|
||||
const data: RoomData = {
|
||||
@@ -63,6 +65,7 @@ export async function createRoom(restaurants: Restaurant[], creatorId: string):
|
||||
creatorId,
|
||||
locked: false,
|
||||
kickedUsers: [],
|
||||
scene,
|
||||
};
|
||||
|
||||
const expiresAt = new Date(Date.now() + ROOM_TTL_MS);
|
||||
|
||||
Reference in New Issue
Block a user