Files
hejiu/common/mock-data.js
T
cg 99723497fa rename(app): 将应用名称从"干杯日记"更改为"碰盏日记"
- 替换所有文件中的品牌名称引用,包括App.vue、pages.json、uni.scss等
- 更新全局样式、导航栏标题和组件中的文案显示
- 修改分享功能中的应用名称显示
- 调整聊天页面的输入栏键盘适配逻辑
- 在多个页面组件中添加事件发射声明以支持交互功能
2026-07-21 22:20:08 +08:00

384 lines
15 KiB
JavaScript

/* 碰盏日记 - Mock 数据 */
import { formatDate, calcStandardCups, unitToMl } from './utils'
// 模拟用户数据
export const MOCK_USER = {
id: 'user_001',
nickname: '酒友小王',
avatar: '',
preferences: {
favoriteCategories: ['baijiu', 'beer'],
frequency: 'often'
},
joinedAt: '2026-01-15'
}
// 生成过去一个月的模拟打卡记录
export function generateMockRecords() {
const records = []
const today = new Date()
// 预设一些打卡日
const drinkDays = [0, 1, 3, 5, 6, 8, 10, 12, 13, 15, 17, 19, 20, 22, 24, 25, 27, 29]
const abstainDays = [2, 4, 7, 9, 11, 14, 16, 18, 21, 23, 26, 28]
const drinkTemplates = [
{
drinks: [{ category: 'baijiu', brand: '茅台', product: '飞天茅台53度', amount: 100, unit: 'ml', degree: 53 }],
food: { category: 'hotpot', name: '重庆老火锅' },
feeling: 'tipsy'
},
{
drinks: [
{ category: 'beer', brand: '青岛啤酒', product: '经典', amount: 2, unit: 'bottle', degree: 4.3 },
],
food: { category: 'bbq', name: '烤串配毛豆' },
feeling: 'buzzed'
},
{
drinks: [{ category: 'wine', brand: '奔富', product: 'Bin 389', amount: 2, unit: 'cup', degree: 14.5 }],
food: { category: 'western', name: '牛排' },
feeling: 'tipsy'
},
{
drinks: [
{ category: 'baijiu', brand: '五粮液', product: '普五52度', amount: 150, unit: 'ml', degree: 52 },
{ category: 'beer', brand: '雪花', product: '勇闯天涯', amount: 1, unit: 'bottle', degree: 3.3 }
],
food: { category: 'stirfry', name: '水煮鱼+回锅肉' },
feeling: 'drunk'
},
{
drinks: [{ category: 'whisky', brand: '麦卡伦', product: '12年雪莉桶', amount: 3, unit: 'shot', degree: 40 }],
food: { category: 'snack', name: '坚果拼盘' },
feeling: 'tipsy'
},
{
drinks: [{ category: 'beer', brand: '百威', product: '经典', amount: 3, unit: 'bottle', degree: 5.0 }],
food: { category: 'seafood', name: '小龙虾' },
feeling: 'buzzed'
},
{
drinks: [{ category: 'fruit', brand: '梅见', product: '青梅酒', amount: 200, unit: 'ml', degree: 12 }],
food: { category: 'japanese', name: '刺身拼盘' },
feeling: 'tipsy'
}
]
drinkDays.forEach(daysAgo => {
const date = new Date(today)
date.setDate(date.getDate() - daysAgo)
const dateStr = formatDate(date, 'YYYY-MM-DD')
const template = drinkTemplates[daysAgo % drinkTemplates.length]
const standardCupsTotal = template.drinks.reduce((sum, d) => {
const ml = unitToMl(d.amount, d.unit)
return sum + calcStandardCups(ml, d.degree)
}, 0)
records.push({
id: `record_${daysAgo}`,
date: dateStr,
mode: 'drank',
drinks: template.drinks.map(d => ({ ...d, categoryId: d.category })),
food: template.food,
feeling: template.feeling,
photos: [],
visibility: 'friends',
standardCupsTotal: Math.round(standardCupsTotal * 100) / 100,
createdAt: date.toISOString()
})
})
abstainDays.forEach(daysAgo => {
const date = new Date(today)
date.setDate(date.getDate() - daysAgo)
const dateStr = formatDate(date, 'YYYY-MM-DD')
records.push({
id: `record_abs_${daysAgo}`,
date: dateStr,
mode: 'abstain',
drinks: [],
food: null,
feeling: null,
photos: [],
visibility: 'private',
standardCupsTotal: 0,
createdAt: date.toISOString()
})
})
return records.sort((a, b) => new Date(b.date) - new Date(a.date))
}
// 初始化并缓存Mock数据
export function initMockData() {
const records = generateMockRecords()
uni.setStorageSync('drink_records', JSON.stringify(records))
uni.setStorageSync('user_info', JSON.stringify(MOCK_USER))
uni.setStorageSync('is_first_launch', 'true')
return records
}
// 获取记录
export function getRecords() {
const data = uni.getStorageSync('drink_records')
if (data) {
try { return JSON.parse(data) } catch (e) { return [] }
}
return initMockData()
}
// 添加记录
export function addRecord(record) {
const records = getRecords()
record.id = `record_${Date.now()}`
record.createdAt = new Date().toISOString()
records.unshift(record)
uni.setStorageSync('drink_records', JSON.stringify(records))
return record
}
// 获取用户信息
export function getUserInfo() {
const data = uni.getStorageSync('user_info')
if (data) {
try { return JSON.parse(data) } catch (e) { return MOCK_USER }
}
return MOCK_USER
}
// ==========================================
// 酒友圈 Mock 数据
// ==========================================
// 模拟酒友列表
export const MOCK_FRIENDS = [
{ id: 'f001', nickname: '老张', avatar: '', lastDrink: '昨晚喝了飞天茅台', lastDrinkTime: '2小时前', online: true },
{ id: 'f002', nickname: '酒仙李白', avatar: '', lastDrink: '青岛啤酒×3', lastDrinkTime: '5小时前', online: true },
{ id: 'f003', nickname: '小红', avatar: '', lastDrink: '梅见青梅酒', lastDrinkTime: '昨天', online: false },
{ id: 'f004', nickname: '阿伟', avatar: '', lastDrink: '百威经典×2', lastDrinkTime: '昨天', online: false },
{ id: 'f005', nickname: '品酒师Tony', avatar: '', lastDrink: '麦卡伦12年', lastDrinkTime: '3天前', online: true },
{ id: 'f006', nickname: '醉翁之意', avatar: '', lastDrink: '奔富Bin389', lastDrinkTime: '3天前', online: false }
]
// 模拟好友请求
export const MOCK_FRIEND_REQUESTS = [
{ id: 'req001', userId: 'u101', nickname: '夜猫子', avatar: '', message: '一起喝过酒,加个好友', time: '1小时前' },
{ id: 'req002', userId: 'u102', nickname: '杯中物', avatar: '', message: '酒友圈看到你的动态', time: '3小时前' }
]
// 模拟动态信息流
export const MOCK_FEEDS = [
{
id: 'feed001',
userId: 'f001',
nickname: '老张',
avatar: '',
time: '2小时前',
text: '今晚和几个老兄弟整了瓶飞天,配重庆火锅,巴适得很!',
drinks: [{ category: 'baijiu', name: '飞天茅台53度', amount: '100ml' }],
feeling: 'tipsy',
images: [],
likes: 12,
liked: false,
comments: 3
},
{
id: 'feed002',
userId: 'f002',
nickname: '酒仙李白',
avatar: '',
time: '5小时前',
text: '夏天就是要冰啤酒配小龙虾,三瓶百威下肚,人生圆满。',
drinks: [{ category: 'beer', name: '百威经典', amount: '3瓶' }],
feeling: 'buzzed',
images: [],
likes: 8,
liked: true,
comments: 5
},
{
id: 'feed003',
userId: 'f003',
nickname: '小红',
avatar: '',
time: '昨天 21:30',
text: '第一次尝试青梅酒,酸酸甜甜的,适合女生微醺~',
drinks: [{ category: 'fruit', name: '梅见青梅酒', amount: '200ml' }],
feeling: 'tipsy',
images: [],
likes: 15,
liked: false,
comments: 7
},
{
id: 'feed004',
userId: 'f005',
nickname: '品酒师Tony',
avatar: '',
time: '昨天 19:00',
text: '麦卡伦12年雪莉桶,闻香有太妃糖和干果的气息,入口丝滑。推荐搭配黑巧克力。',
drinks: [{ category: 'whisky', name: '麦卡伦12年', amount: '3 shot' }],
feeling: 'tipsy',
images: [],
likes: 22,
liked: false,
comments: 4
},
{
id: 'feed005',
userId: 'f004',
nickname: '阿伟',
avatar: '',
time: '前天 20:15',
text: '公司团建,五粮液配水煮鱼,喝到位了。明天又要搬砖...',
drinks: [{ category: 'baijiu', name: '五粮液普五52度', amount: '150ml' }, { category: 'beer', name: '雪花勇闯天涯', amount: '1瓶' }],
feeling: 'drunk',
images: [],
likes: 6,
liked: false,
comments: 2
}
]
// 模拟评论数据
export const MOCK_COMMENTS = {
feed001: [
{ id: 'c001', userId: 'f002', nickname: '酒仙李白', avatar: '', content: '茅台配火锅,土豪啊老张!', time: '1小时前' },
{ id: 'c002', userId: 'f003', nickname: '小红', avatar: '', content: '看着就馋了,下次带上我', time: '45分钟前' },
{ id: 'c003', userId: 'f005', nickname: '品酒师Tony', avatar: '', content: '飞天53度确实是经典,好酒!', time: '30分钟前' }
],
feed002: [
{ id: 'c004', userId: 'f001', nickname: '老张', avatar: '', content: '夏天标配!', time: '4小时前' },
{ id: 'c005', userId: 'f004', nickname: '阿伟', avatar: '', content: '小龙虾哪买的?看着不错', time: '3小时前' }
],
feed003: [
{ id: 'c006', userId: 'f001', nickname: '老张', avatar: '', content: '梅见确实适合入门', time: '昨天' },
{ id: 'c007', userId: 'f002', nickname: '酒仙李白', avatar: '', content: '下次试试蜜桃味', time: '昨天' }
]
}
// ==========================================
// 私信 Mock 数据
// ==========================================
// 模拟会话列表
export const MOCK_CONVERSATIONS = [
{ id: 'conv_001', friendId: 'f001', nickname: '老张', avatar: '', lastMessage: '今晚一起喝点?', lastTime: '10:32', unread: 2, online: true },
{ id: 'conv_002', friendId: 'f002', nickname: '酒仙李白', avatar: '', lastMessage: '那批啤酒链接发你了', lastTime: '昨天', unread: 0, online: true },
{ id: 'conv_003', friendId: 'f003', nickname: '小红', avatar: '', lastMessage: '梅见那个确实好喝!', lastTime: '周一', unread: 1, online: false },
{ id: 'conv_004', friendId: 'f005', nickname: '品酒师Tony', avatar: '', lastMessage: '下次品鉴会带你一个', lastTime: '上周', unread: 0, online: true }
]
// 模拟聊天记录(按 conversationId 分组)
export const MOCK_MESSAGES = {
conv_001: [
{ id: 'msg_101', conversationId: 'conv_001', senderId: 'f001', receiverId: 'user_001', type: 'text', content: '在吗?', timestamp: 1721556000000, status: 'read' },
{ id: 'msg_102', conversationId: 'conv_001', senderId: 'user_001', receiverId: 'f001', type: 'text', content: '在的,怎么了老张', timestamp: 1721556060000, status: 'read' },
{ id: 'msg_103', conversationId: 'conv_001', senderId: 'f001', receiverId: 'user_001', type: 'text', content: '搞了瓶飞天,一个人喝没意思', timestamp: 1721556120000, status: 'read' },
{ id: 'msg_104', conversationId: 'conv_001', senderId: 'user_001', receiverId: 'f001', type: 'text', content: '哟,茅台!几点?', timestamp: 1721556180000, status: 'read' },
{ id: 'msg_105', conversationId: 'conv_001', senderId: 'f001', receiverId: 'user_001', type: 'text', content: '老地方,7点', timestamp: 1721556240000, status: 'read' },
{ id: 'msg_106', conversationId: 'conv_001', senderId: 'f001', receiverId: 'user_001', type: 'text', content: '今晚一起喝点?', timestamp: 1721556300000, status: 'delivered' }
],
conv_002: [
{ id: 'msg_201', conversationId: 'conv_002', senderId: 'user_001', receiverId: 'f002', type: 'text', content: '上次你说的那个精酿啤酒叫什么来着', timestamp: 1721470000000, status: 'read' },
{ id: 'msg_202', conversationId: 'conv_002', senderId: 'f002', receiverId: 'user_001', type: 'text', content: '熊猫精酿,蜂蜜艾尔', timestamp: 1721470060000, status: 'read' },
{ id: 'msg_203', conversationId: 'conv_002', senderId: 'f002', receiverId: 'user_001', type: 'text', content: '那批啤酒链接发你了', timestamp: 1721470120000, status: 'read' }
],
conv_003: [
{ id: 'msg_301', conversationId: 'conv_003', senderId: 'f003', receiverId: 'user_001', type: 'text', content: '你动态里那个梅见好喝吗?', timestamp: 1721380000000, status: 'read' },
{ id: 'msg_302', conversationId: 'conv_003', senderId: 'user_001', receiverId: 'f003', type: 'text', content: '超好喝!酸酸甜甜,推荐原味', timestamp: 1721380060000, status: 'read' },
{ id: 'msg_303', conversationId: 'conv_003', senderId: 'f003', receiverId: 'user_001', type: 'text', content: '梅见那个确实好喝!', timestamp: 1721380120000, status: 'delivered' }
],
conv_004: [
{ id: 'msg_401', conversationId: 'conv_004', senderId: 'f005', receiverId: 'user_001', type: 'text', content: '下周有个威士忌品鉴会,来不来?', timestamp: 1721290000000, status: 'read' },
{ id: 'msg_402', conversationId: 'conv_004', senderId: 'user_001', receiverId: 'f005', type: 'text', content: '可以啊,都有什么酒?', timestamp: 1721290060000, status: 'read' },
{ id: 'msg_403', conversationId: 'conv_004', senderId: 'f005', receiverId: 'user_001', type: 'text', content: '麦卡伦、格兰菲迪、百富,三款12年', timestamp: 1721290120000, status: 'read' },
{ id: 'msg_404', conversationId: 'conv_004', senderId: 'f005', receiverId: 'user_001', type: 'text', content: '下次品鉴会带你一个', timestamp: 1721290180000, status: 'read' }
]
}
// 模拟酒局活动
export const MOCK_EVENTS = [
{
id: 'evt001',
title: '周五夜·老地方火锅局',
organizer: { id: 'f001', nickname: '老张', avatar: '' },
time: '2026-07-25 19:00',
location: '渝味晓宇火锅(解放碑店)',
address: '重庆市渝中区解放碑步行街88号',
latitude: 29.5580,
longitude: 106.5780,
maxPeople: 8,
joined: 5,
participants: [
{ id: 'f001', nickname: '老张', avatar: '' },
{ id: 'f002', nickname: '酒仙李白', avatar: '' },
{ id: 'f003', nickname: '小红', avatar: '' },
{ id: 'f004', nickname: '阿伟', avatar: '' },
{ id: 'f005', nickname: '品酒师Tony', avatar: '' }
],
status: 'open',
note: '自带酒水,AA制餐费',
isJoined: false,
isOrganizer: false
},
{
id: 'evt002',
title: '威士忌品鉴之夜',
organizer: { id: 'f005', nickname: '品酒师Tony', avatar: '' },
time: '2026-07-27 20:00',
location: 'Malt Bar(国贸店)',
address: '北京市朝阳区建国门外大街1号国贸商城B1',
latitude: 39.9087,
longitude: 116.4605,
maxPeople: 6,
joined: 3,
participants: [
{ id: 'f005', nickname: '品酒师Tony', avatar: '' },
{ id: 'f001', nickname: '老张', avatar: '' },
{ id: 'f006', nickname: '醉翁之意', avatar: '' }
],
status: 'open',
note: '品鉴3款单一麦芽,费用AA',
isJoined: true,
isOrganizer: false
},
{
id: 'evt003',
title: '啤酒花园烧烤趴',
organizer: { id: 'f002', nickname: '酒仙李白', avatar: '' },
time: '2026-07-20 18:00',
location: '望京啤酒花园',
address: '北京市朝阳区望京街9号',
latitude: 39.9959,
longitude: 116.4767,
maxPeople: 12,
joined: 10,
participants: [],
status: 'ongoing',
note: '畅饮模式,不醉不归',
isJoined: false,
isOrganizer: false
},
{
id: 'evt004',
title: '红酒配牛排·优雅之夜',
organizer: { id: 'f003', nickname: '小红', avatar: '' },
time: '2026-07-15 19:30',
location: 'The Grill(三里屯)',
address: '北京市朝阳区三里屯路19号',
latitude: 39.9325,
longitude: 116.4536,
maxPeople: 4,
joined: 4,
participants: [],
status: 'ended',
note: '已圆满结束,下次再约',
isJoined: false,
isOrganizer: false
}
]