refactor(data): 全面移除小程序写死的演示/兜底数据,测试数据统一落库

- 删除无引用的 common/mock.js;登录页与个人中心的演示账号改为 DB 配置 demo_accounts + /api/auth/demo-accounts、/api/auth/demo-login(签发真实 token)

- 移除订单/活动/大神/动态/推广/工作台/门票/充值/举报等页面的演示列表与假兜底;新增真实空态

- 修复伪造成功:活动调价、评价回复、核销、海报保存、图片上传失败、提现/核销固定 1001、随机开黑房号、随机即时匹配、假语音播放等

- 服务端移除 101/2006 合成用户与合成大神兜底、移除默认服务包虚构价格;演示账号清单可在后台关闭

- 111 套件/733 用例全绿;已部署 20261021_162041,demo-accounts/demo-login 实测通过
这个提交包含在:
xcbyy
2026-10-21 16:21:10 +08:00
父节点 77aa4cb50b
当前提交 16f6419cba
共有 30 个文件被更改,包括 661 次插入 和 1366 次删除

查看文件

@@ -245,7 +245,7 @@ const normalizeCommentItem = (item) => {
...item,
author: (isMyComment && cur.nickname)
? cur.nickname
: ((item.author && item.author !== '电竞玩家 (我)') ? item.author : (cur.nickname || '同城局长')),
: ((item.author && item.author !== '电竞玩家 (我)') ? item.author : (cur.nickname || '同城用户')),
avatar: (isMyComment && cur.avatar)
? cur.avatar
: ((item.avatar && !item.avatar.includes('photo-1535713875002-d1d0cf377fde'))
@@ -342,19 +342,7 @@ const loadComments = async (id) => {
loadingComments.value = true;
try {
const list = await getPostComments(id);
if (list && list.length > 0) {
commentsList.value = list.map(normalizeCommentItem);
} else {
commentsList.value = [
{
id: `cmt_seed_${id}`,
author: (post.value && post.value.author) || '小甜橙',
avatar: (post.value && post.value.avatar) || 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=120',
content: '欢迎各位小伙伴在评论区留言约伴!一起开黑/探店~',
createdAt: '刚刚'
}
];
}
commentsList.value = Array.isArray(list) ? list.map(normalizeCommentItem) : [];
} catch (_) {
commentsList.value = [];
} finally {
@@ -378,10 +366,8 @@ const openAuthorProfile = (target) => {
const authorName = target.author || target.nickname || '同城达人';
let targetId = target.expertId || target.companionId || target.userId;
if (!targetId) {
if (authorName === '小甜橙') targetId = 2005;
else if (authorName.includes('暗影刺客')) targetId = 2004;
else if (authorName === '苏苏学姐') targetId = 2006;
else targetId = target.id || 101;
uni.showToast({ title: '该用户信息不完整', icon: 'none' });
return;
}
const authorSnapshot = {
id: targetId,
@@ -391,8 +377,8 @@ const openAuthorProfile = (target) => {
rankTag: target.tag || '同城认证达人',
levelTag: '实名认证',
game: target.category === 'game' ? '车队开黑' : (target.category === 'highlight' ? '战绩高光' : '同城搭子'),
city: target.location || '北京市 · 朝阳/海淀',
bio: target.content || '热爱同城探店与组局开黑,欢迎一起约伴同行!',
city: target.location || '',
bio: target.content || '',
photos: Array.isArray(target.images) && target.images.length > 0 ? target.images : [target.avatar || DEFAULT_USER_AVATAR]
};
uni.setStorageSync('ACTIVE_AUTHOR_PROFILE', authorSnapshot);
@@ -481,7 +467,7 @@ const sendComment = async () => {
? currentUserProfile.value
: await syncCurrentUserProfile();
const uid = Number(profile.id || uni.getStorageSync('userId')) || 1001;
const authorName = profile.nickname || '同城局长';
const authorName = profile.nickname || '同城用户';
const authorAvatar = profile.avatar || DEFAULT_USER_AVATAR;
try {
@@ -537,7 +523,7 @@ const handleJoinParty = () => {
? currentUserProfile.value
: await syncCurrentUserProfile();
const uid = Number(profile.id || uni.getStorageSync('userId')) || 1001;
const applicantName = profile.nickname || '同城局长';
const applicantName = profile.nickname || '同城用户';
const applicantAvatar = profile.avatar || DEFAULT_USER_AVATAR;
try {
await applyPostParty(post.value.id, {

查看文件

@@ -59,6 +59,10 @@
<!-- 动态信息流列表 -->
<view class="posts-list">
<view v-if="filteredPosts.length === 0" class="posts-empty">
<text class="posts-empty-title">还没有动态</text>
<text class="posts-empty-desc">发第一条同城搭子动态,约上附近的小伙伴</text>
</view>
<view
v-for="(post, index) in filteredPosts"
:key="post.id"
@@ -399,7 +403,7 @@ import { ICONS } from '@/common/icons.js';
import { getCurrentThemeKey, applyThemeToNativeUI } from '@/common/theme.js';
import { ensureLoginOrRedirect } from '@/common/role.js';
import { getNavBarInfo } from '@/common/nav.js';
import { getPosts, createPost, deletePost, likePost, viewPost, getPostComments, addPostComment, applyPostParty, getPostApplies, handlePostApply, uploadImage, getPlatformConfigs, getUserProfile } from '@/common/api.js';
import { getPosts, createPost, deletePost, likePost, viewPost, getPostComments, addPostComment, applyPostParty, getPostApplies, handlePostApply, uploadImage, getPlatformConfigs, getUserProfile, normalizeUserId } from '@/common/api.js';
const DEFAULT_USER_AVATAR = 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=120';
const isLoading = ref(true);
@@ -529,7 +533,7 @@ onUnmounted(() => {
const loadRemotePosts = async () => {
try {
const list = await getPosts(currentTab.value);
if (list && list.length > 0) {
{
let localLikedIds = uni.getStorageSync('COMMUNITY_LIKED_POST_IDS') || [];
if (!Array.isArray(localLikedIds)) localLikedIds = [];
let localAppliedIds = uni.getStorageSync('COMMUNITY_APPLIED_POST_IDS') || [];
@@ -537,7 +541,7 @@ const loadRemotePosts = async () => {
let viewsMap = uni.getStorageSync('COMMUNITY_POST_VIEWS_MAP') || {};
if (typeof viewsMap !== 'object' || viewsMap === null) viewsMap = {};
posts.value = list.map(item => {
posts.value = (list || []).map(item => {
const strId = String(item.id);
const serverStatus = item.myApplyStatus || null;
const isApplied = serverStatus ? (serverStatus !== 'REJECTED') : localAppliedIds.includes(strId);
@@ -610,75 +614,8 @@ const syncInitialPostStates = (rawPosts) => {
};
const syncInitialLikedState = syncInitialPostStates;
const posts = ref(syncInitialPostStates([
{
id: 1,
userId: 2005,
author: '小甜橙',
avatar: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=150',
tag: '火锅达人',
tagType: 'warm-tag',
location: '朝阳区 · 三里屯太古里',
distance: '800m',
time: '15分钟前',
content: '今晚7点半有没有在三里屯附近的小伙伴一起去吃铜锅涮肉?已预订包间,目前已有2人,再来2个饭搭子AA!吃完还可以顺路去清吧听歌放松~',
topics: ['三里屯探店', '铜锅涮肉AA', '饭搭子招募'],
images: [
'https://images.unsplash.com/photo-1555396273-367ea4eb4db5?w=500',
'https://images.unsplash.com/photo-1517248135467-4c7edcad34c4?w=500'
],
actionText: '加入车队',
likes: 42,
liked: false,
comments: 8,
views: 310,
category: 'partner'
},
{
id: 2,
userId: 2004,
author: '暗影刺客 (省一李白)',
avatar: 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=150',
tag: '国服大神',
tagType: 'cool-tag',
location: '海淀区 · 五道口',
distance: '3.5km',
time: '40分钟前',
content: '今晚王者荣耀荣耀王者冲分车队!目前缺一个听指挥的中单或者软辅妹子,全程语音沟通包赢不保段包赔,想上星的速速滴我!',
topics: ['王者荣耀', '荣耀车队', '连胜冲分'],
images: [
'https://images.unsplash.com/photo-1542751371-adc38448a05e?w=500'
],
actionText: '立即上车',
likes: 76,
liked: true,
comments: 15,
views: 680,
category: 'game'
},
{
id: 3,
userId: 2006,
author: '苏苏学姐',
avatar: 'https://images.unsplash.com/photo-1517841905240-472988babdf9?w=150',
tag: '金牌麦霸',
tagType: 'gold-tag',
location: '朝阳区 · 工体商业街',
distance: '1.2km',
time: '1小时前',
content: '工体纯K量贩欢唱局!甜美情歌、粤语老歌、摇滚气氛拉满。现场备有精美果盘与特饮,今晚欢唱不嗨不散,还有专属歌声试听哦!',
topics: ['KTV欢唱', '量贩陪唱', '同城聚会'],
images: [
'https://images.unsplash.com/photo-1516450360452-9312f5e86fc7?w=500'
],
actionText: '报名同去',
likes: 58,
liked: false,
comments: 11,
views: 520,
category: 'partner'
}
]));
const posts = ref([]);
const filteredPosts = computed(() => {
if (currentTab.value === 'all') return posts.value;
@@ -761,19 +698,7 @@ const loadPostCommentsList = async (post) => {
loadingComments.value = true;
try {
const list = await getPostComments(post.id);
if (list && list.length > 0) {
commentsList.value = list;
} else {
commentsList.value = [
{
id: `cmt_seed_${post.id}`,
author: post.author || '小甜橙',
avatar: post.avatar || 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=120',
content: '欢迎各位小伙伴在评论区留言约伴!一起开黑/探店~',
createdAt: '刚刚'
}
];
}
commentsList.value = Array.isArray(list) ? list : [];
} catch (_) {
commentsList.value = [];
} finally {
@@ -786,10 +711,8 @@ const openAuthorProfile = (target) => {
const authorName = target.author || target.nickname || '同城达人';
let targetId = target.expertId || target.companionId || target.userId;
if (!targetId) {
if (authorName === '小甜橙') targetId = 2005;
else if (authorName.includes('暗影刺客')) targetId = 2004;
else if (authorName === '苏苏学姐') targetId = 2006;
else targetId = target.id || 101;
uni.showToast({ title: '该用户信息不完整', icon: 'none' });
return;
}
const authorSnapshot = {
id: targetId,
@@ -799,8 +722,8 @@ const openAuthorProfile = (target) => {
rankTag: target.tag || '同城认证达人',
levelTag: '实名认证',
game: target.category === 'game' ? '车队开黑' : (target.category === 'highlight' ? '战绩高光' : '同城搭子'),
city: target.location || '北京市 · 朝阳/海淀',
bio: target.content || '热爱同城探店与组局开黑,欢迎一起约伴同行!',
city: target.location || '',
bio: target.content || '',
photos: Array.isArray(target.images) && target.images.length > 0 ? target.images : [target.avatar || DEFAULT_USER_AVATAR]
};
uni.setStorageSync('ACTIVE_AUTHOR_PROFILE', authorSnapshot);
@@ -866,7 +789,7 @@ const sendComment = async () => {
? currentUserProfile.value
: await syncCurrentUserProfile();
const uid = Number(profile.id || uni.getStorageSync('userId')) || 1001;
const authorName = profile.nickname || '同城局长';
const authorName = profile.nickname || '同城用户';
const authorAvatar = profile.avatar || DEFAULT_USER_AVATAR;
try {
@@ -1010,7 +933,7 @@ const handleJoinParty = (post) => {
? currentUserProfile.value
: await syncCurrentUserProfile();
const uid = Number(profile.id || uni.getStorageSync('userId')) || 1001;
const applicantName = profile.nickname || '同城局长';
const applicantName = profile.nickname || '同城用户';
const applicantAvatar = profile.avatar || DEFAULT_USER_AVATAR;
try {
await applyPostParty(post.id, {
@@ -1063,9 +986,9 @@ const publishCategories = [
const newPostForm = ref({
category: 'partner',
content: '',
selectedTopics: ['三里屯探店'],
selectedTopics: [],
images: [],
location: '朝阳区 · 三里屯太古里'
location: ''
});
const contentPlaceholder = computed(() => {
@@ -1173,9 +1096,9 @@ const submitPublishPost = async () => {
const profile = currentUserProfile.value.nickname
? currentUserProfile.value
: await syncCurrentUserProfile();
const uid = Number(profile.id || uni.getStorageSync('userId')) || 1001;
const authorName = profile.nickname || '同城局长';
const authorAvatar = profile.avatar || DEFAULT_USER_AVATAR;
const uid = normalizeUserId();
const authorName = profile.nickname || '同城用户';
const authorAvatar = profile.avatar || '';
let finalImages = [];
try {
@@ -1183,14 +1106,12 @@ const submitPublishPost = async () => {
finalImages = await Promise.all(
newPostForm.value.images.map(img => uploadImage(img))
);
} else {
finalImages = ['https://images.unsplash.com/photo-1517248135467-4c7edcad34c4?w=500'];
}
} catch (uploadErr) {
console.warn('[Community] 图片上传异常,保留原地址:', uploadErr);
finalImages = newPostForm.value.images.length > 0
? newPostForm.value.images
: ['https://images.unsplash.com/photo-1517248135467-4c7edcad34c4?w=500'];
console.warn('[Community] 图片上传失败:', uploadErr);
uni.hideLoading();
uni.showToast({ title: '图片上传失败,请重试后再发布', icon: 'none' });
return;
}
const postPayload = {
@@ -1209,15 +1130,18 @@ const submitPublishPost = async () => {
try {
const res = await createPost(postPayload);
if (!res || !res.id) {
throw new Error('发布失败:服务端未返回动态编号');
}
const createdPost = {
id: res ? res.id : Date.now(),
id: res.id,
userId: uid,
author: (res && res.author) || postPayload.author,
avatar: (res && res.avatar) || postPayload.avatar,
tag: currentMeta.text,
tagType: currentMeta.type,
location: postPayload.location,
distance: '100m内',
distance: '',
time: '刚刚',
content: content,
topics: postPayload.topics,
@@ -1706,6 +1630,29 @@ const submitPublishPost = async () => {
flex-direction: column;
gap: 24rpx;
.posts-empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 10rpx;
padding: 80rpx 24rpx;
border-radius: 24rpx;
border: 1rpx dashed rgba(255, 255, 255, 0.12);
background: rgba(255, 255, 255, 0.03);
.posts-empty-title {
font-size: 28rpx;
font-weight: 600;
color: #E2E8F0;
}
.posts-empty-desc {
font-size: 24rpx;
color: #94A3B8;
}
}
.post-card {
background: #151D30;
border-radius: 24rpx;