Files
hejiu/common/mock-data.js
T
cg fabbb167cf feat(circle): 添加酒友圈社交模块
- 新增酒友圈、圈子详情、发布动态、好友列表、活动创建等页面配置
- 添加酒友圈相关API接口,包括动态、评论、好友、活动等功能
- 实现模拟数据用于前端开发和测试
- 创建评论项、空状态、活动卡片、动态卡片、好友项等组件
- 编写酒友圈模块详细的接口文档,定义数据结构和业务规则
2026-07-20 22:53:04 +08:00

332 lines
11 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: '昨天' }
]
}
// 模拟酒局活动
export const MOCK_EVENTS = [
{
id: 'evt001',
title: '周五夜·老地方火锅局',
organizer: { id: 'f001', nickname: '老张', avatar: '' },
time: '2026-07-25 19:00',
location: '渝味晓宇火锅(解放碑店)',
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(国贸店)',
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: '望京啤酒花园',
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(三里屯)',
maxPeople: 4,
joined: 4,
participants: [],
status: 'ended',
note: '已圆满结束,下次再约',
isJoined: false,
isOrganizer: false
}
]