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 次删除

查看文件

@@ -291,45 +291,24 @@ const stopPropagation = (e) => {
const isLoading = ref(true);
const isFav = ref(false);
const buildDefaultServices = (gameTitle = '同城陪伴', basePrice = 68) => [
{
id: 'srv_1',
name: `${gameTitle} · 基础陪伴 (2小时)`,
title: `${gameTitle} · 基础陪伴 (2小时)`,
price: basePrice,
unit: '小时',
desc: '正规公开商圈同城陪伴,AA制或协商消费'
},
{
id: 'srv_2',
name: `${gameTitle} · 半日畅享 (3小时)`,
title: `${gameTitle} · 半日畅享 (3小时)`,
price: Math.round(basePrice * 2.8),
unit: '次',
desc: '深度互动与陪伴交流,赠送专属点歌或语音祝福'
}
];
const expert = ref({
id: '101',
nickname: '同城陪伴师',
avatar: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=300',
gender: 'female',
id: '',
nickname: '',
avatar: '',
gender: '',
levelTag: '',
game: '同城陪伴',
game: '',
rankTag: '',
city: '',
rating: 0,
orderCount: 0,
isOnline: false,
isOnline: false,
bio: '',
voiceDuration: 0,
price: 0,
services: [],
photos: [
'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=400',
'https://images.unsplash.com/photo-1517841905240-472988babdf9?w=400'
],
photos: [],
reviews: []
});
// 是否为真实大神档案(非合成的普通用户资料)
@@ -374,31 +353,32 @@ const toggleFavorite = async () => {
};
const handleReplyReview = (rev) => {
const targetId = Number(expert.value.id || currentExpertTargetId || 101);
const targetId = Number(expert.value.id || currentExpertTargetId || 0);
if (!ensureLoginOrRedirect(`/pages/expert/detail?id=${targetId}`)) {
return;
}
const defaultReplies = [
'感谢老板的支持与五星好评!开黑配合非常默契,期待下次一起上大分!',
'谢谢老板认可!非常准时礼貌的高素质玩家老板,下次继续开黑走起~',
'多谢老板认可!服务过程非常愉快,有空随时来约局呀!'
];
uni.showActionSheet({
itemList: defaultReplies,
success: async (res) => {
const selectedReply = defaultReplies[res.tapIndex] || defaultReplies[0];
uni.showModal({
title: '回复评价',
editable: true,
placeholderText: '请输入回复内容',
confirmText: '提交回复',
success: async (modalRes) => {
const reply = String(modalRes.content || '').trim();
if (!modalRes.confirm) return;
if (!reply) {
uni.showToast({ title: '回复内容不能为空', icon: 'none' });
return;
}
try {
uni.showLoading({ title: '正在提交回复...' });
await replyOrderReview(rev.id, selectedReply);
rev.replyContent = selectedReply;
await replyOrderReview(rev.id, reply);
rev.replyContent = reply;
rev.replyTime = '刚刚';
uni.hideLoading();
uni.showToast({ title: '感谢回复已送达', icon: 'success' });
uni.showToast({ title: '回复已提交', icon: 'success' });
} catch (err) {
uni.hideLoading();
rev.replyContent = selectedReply;
rev.replyTime = '刚刚';
uni.showToast({ title: '感谢回复已送达', icon: 'success' });
uni.showToast({ title: err.message || '回复提交失败', icon: 'none' });
}
}
});
@@ -431,12 +411,12 @@ onLoad(async (query) => {
const snapAvatar = queryAvatar || (matchedSnapshot && matchedSnapshot.avatar) || expert.value.avatar;
const snapTag = queryTag || (matchedSnapshot && matchedSnapshot.rankTag) || expert.value.rankTag;
const snapCity = queryCity || (matchedSnapshot && matchedSnapshot.city) || expert.value.city;
const snapGame = (matchedSnapshot && matchedSnapshot.game) || '同城搭子';
const snapGame = (matchedSnapshot && matchedSnapshot.game) || '';
const snapBio = (matchedSnapshot && matchedSnapshot.bio) || expert.value.bio;
const snapPhotos = (matchedSnapshot && Array.isArray(matchedSnapshot.photos) && matchedSnapshot.photos.length > 0)
? matchedSnapshot.photos
: [snapAvatar];
const snapPrice = snapGame === '车队开黑' ? 88 : 128;
: (snapAvatar ? [snapAvatar] : []);
const snapPrice = Number(expert.value.price) || 0;
expert.value = {
...expert.value,
@@ -445,13 +425,13 @@ onLoad(async (query) => {
avatar: snapAvatar,
coverImage: snapPhotos[0] || snapAvatar,
rankTag: snapTag,
levelTag: '实名认证',
levelTag: '',
game: snapGame,
city: snapCity,
bio: snapBio,
price: snapPrice,
photos: snapPhotos,
services: buildDefaultServices(snapGame, snapPrice)
services: []
};
if (expert.value.services && expert.value.services.length > 0) {
selectedServiceId.value = expert.value.services[0].id;
@@ -553,19 +533,9 @@ const toggleVoice = () => {
const chatOnline = () => {
uni.showActionSheet({
itemList: [
`复制大神游戏开黑专属房号`,
`联系 7x24h 官方在线客服`
],
itemList: [`联系 7x24h 官方在线客服`],
success: (res) => {
if (res.tapIndex === 0) {
uni.setClipboardData({
data: `PW-${expert.value.id}-${Math.floor(1000 + Math.random() * 9000)}`,
success: () => {
uni.showToast({ title: '专属房号已复制', icon: 'success' });
}
});
} else if (res.tapIndex === 1) {
uni.showActionSheet({
itemList: [
'拨打官方服务热线 (400-888-6666)',

查看文件

@@ -9,7 +9,7 @@
<text class="expert-name">{{ expert.nickname }}</text>
<text class="pro-badge" :class="{ offline: !isOnline }">{{ isOnline ? '接单中' : '已打烊' }}</text>
</view>
<text class="rating-sub">评分 {{ expert.rating || '5.0' }} · 接单率 {{ expert.orderRate || '99.2%' }}</text>
<text class="rating-sub">评分 {{ expert.rating || '暂无' }} · 接单率 {{ expert.orderRate || '—' }}</text>
</view>
</view>
@@ -243,14 +243,13 @@ const getInitialExpert = () => {
try {
cached = uni.getStorageSync('PW_USER_INFO') || uni.getStorageSync('userInfo');
} catch (_) {}
let uid = (cached && cached.id) || uni.getStorageSync('userId') || 2006;
if (uid == 101) uid = 2006;
const uid = (cached && cached.id) || Number(uni.getStorageSync('userId')) || 0;
return {
id: uid,
nickname: (cached && cached.nickname) || '接单大神',
avatar: (cached && cached.avatar) || DEFAULT_EXPERT_AVATAR,
rating: (cached && cached.rating) || '5.0',
orderRate: (cached && cached.orderRate) || '99.2%'
nickname: (cached && cached.nickname) || '',
avatar: (cached && cached.avatar) || '',
rating: (cached && cached.rating) || '',
orderRate: (cached && cached.orderRate) || ''
};
};
@@ -272,9 +271,9 @@ const navStyle = computed(() => {
});
const todayStats = ref({
income: '380.00',
orders: 4,
waitingVerify: 1
income: '0.00',
orders: 0,
waitingVerify: 0
});
const onThemeChanged = (newTheme) => {

查看文件

@@ -265,9 +265,6 @@
</view>
</view>
<view class="quick-demo" @click="fillDemoCode">
<text>点击自动填入演示码 [8392] 并触发核销</text>
</view>
</view>
</view>
@@ -497,9 +494,9 @@ import {
const currentThemeKey = ref(getCurrentThemeKey());
const expert = ref({
id: 101,
nickname: '认证大神',
avatar: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=300'
id: 0,
nickname: '',
avatar: ''
});
const isReceivingOrders = ref(uni.getStorageSync('EXPERT_RECEIVING_STATUS') !== '0');
const todayIncome = ref('0.00');
@@ -519,35 +516,7 @@ const rawTrendsData = ref({ daily: [], weekly: [], monthly: [] });
const activeTooltip = ref(null);
const currentTrendsList = computed(() => {
const list = rawTrendsData.value[trendPeriod.value] || [];
if (list.length > 0) return list;
if (trendPeriod.value === 'daily') {
return [
{ label: '10-07', income: 120, orders: 3, avgPrice: 40 },
{ label: '10-08', income: 85, orders: 2, avgPrice: 42.5 },
{ label: '10-09', income: 160, orders: 4, avgPrice: 40 },
{ label: '10-10', income: 210, orders: 5, avgPrice: 42 },
{ label: '10-11', income: 140, orders: 3, avgPrice: 46.7 },
{ label: '10-12', income: 290, orders: 6, avgPrice: 48.3 },
{ label: '10-13', income: 180, orders: 4, avgPrice: 45 }
];
} else if (trendPeriod.value === 'weekly') {
return [
{ label: '3周前', income: 950, orders: 22, avgPrice: 43.2 },
{ label: '2周前', income: 1120, orders: 25, avgPrice: 44.8 },
{ label: '上周', income: 1350, orders: 28, avgPrice: 48.2 },
{ label: '本周', income: 890, orders: 19, avgPrice: 46.8 }
];
} else {
return [
{ label: '5月', income: 3200, orders: 75, avgPrice: 42.7 },
{ label: '6月', income: 3800, orders: 86, avgPrice: 44.2 },
{ label: '7月', income: 4500, orders: 98, avgPrice: 45.9 },
{ label: '8月', income: 4200, orders: 90, avgPrice: 46.7 },
{ label: '9月', income: 5100, orders: 105, avgPrice: 48.6 },
{ label: '10月', income: 2800, orders: 58, avgPrice: 48.3 }
];
}
return rawTrendsData.value[trendPeriod.value] || [];
});
const currentPeriodSummary = computed(() => {
@@ -813,63 +782,22 @@ const showConfirmModal = ref(false);
const verifiedParticipant = ref({
nickname: '电竞萌新小可爱',
avatar: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=150&h=150&fit=crop',
activityTitle: 'AA制五排王者百星车队',
code: '8392',
fee: '25.00'
nickname: '',
avatar: '',
activityTitle: '',
code: '',
fee: '0.00'
});
const poolOrders = ref([
{
id: 'pool_101',
game: '王者荣耀',
price: 35,
desc: 'QQ区/星耀1晋级赛冲王者/需开黑配合/射手或辅助',
countdown: 48
},
{
id: 'pool_102',
game: '和平精英',
price: 45,
desc: '微信区/四排海岛/刚枪上分/kd保4以上',
countdown: 32
},
{
id: 'pool_103',
game: '美食陪吃',
price: 68,
desc: '朝阳大悦城海底捞/周末饭搭子/消费现场AA/需守时礼貌',
countdown: 56
}
]);
const poolOrders = ref([]);
const activeOrders = ref([
{
id: 'ord_active_1',
buyerName: '超能电竞玩家',
buyerAvatar: 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=150&h=150&fit=crop',
serviceTitle: '排位包胜率',
hours: 2,
totalAmount: 70,
statusText: '正在开黑对局履约中'
},
{
id: 'ord_active_2',
buyerName: '北京吃货小张',
buyerAvatar: 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=150&h=150&fit=crop',
serviceTitle: '火锅探店饭搭子',
hours: 2,
totalAmount: 136,
statusText: '已核销4位码入座,服务中'
}
]);
const activeOrders = ref([]);
const toggleReceivingStatus = async () => {
const next = !isReceivingOrders.value;
const newStatusStr = next ? '接单中' : '休息中';
try {
await updateCompanionProfile(expert.value.id || 101, { status: newStatusStr });
await updateCompanionProfile(currentExpertId(), { status: newStatusStr });
} catch (err) {
uni.showToast({
title: (err && err.message) || '接单状态切换失败,请稍后重试',
@@ -905,16 +833,12 @@ const clearCode = () => {
isCodeError.value = false;
};
const fillDemoCode = () => {
inputDigits.value = [8, 3, 9, 2];
verifyInputCode();
};
const loadWorkspaceOrders = async () => {
try {
// 先解析真实大神档案,避免工作台使用演示 id
await loadExpertProfile();
const eid = currentExpertId() || 101;
const eid = currentExpertId();
if (!eid) return;
const stats = await getExpertStats(eid);
if (stats) {
if (stats.income !== undefined) todayIncome.value = stats.income;
@@ -950,7 +874,7 @@ const loadWorkspaceOrders = async () => {
}
try {
const trends = await getExpertRevenueTrends(currentExpertId() || 101);
const trends = await getExpertRevenueTrends(currentExpertId());
if (trends && (trends.daily || trends.weekly || trends.monthly)) {
rawTrendsData.value = trends;
}
@@ -1002,11 +926,11 @@ const verifyInputCode = async () => {
}
verifiedParticipant.value = {
id: info.id,
nickname: info.nickname || '同城搭子',
avatar: info.avatar || 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=150',
activityTitle: info.title || '同城生活组局',
nickname: info.nickname || '同城用户',
avatar: info.avatar || '',
activityTitle: info.title || '',
code: info.code,
fee: info.fee || '50.00',
fee: info.fee !== undefined && info.fee !== null ? String(info.fee) : '0.00',
};
isCodeError.value = false;
showConfirmModal.value = true;
@@ -1025,7 +949,7 @@ const confirmCheckin = async () => {
const codeStr = verifiedParticipant.value.code;
uni.showLoading({ title: '确认核销中...' });
try {
await universalVerifyCheckin(codeStr, 1001);
await universalVerifyCheckin(codeStr, normalizeUserId());
uni.hideLoading();
showConfirmModal.value = false;
const gainedFee = Number(verifiedParticipant.value.fee) || 25;
@@ -1048,7 +972,7 @@ const confirmCheckin = async () => {
const grabOrder = async (order) => {
try {
await claimOrder(order.id, {
expertId: currentExpertId() || 101,
expertId: currentExpertId(),
companionName: '我 (接单大神)',
expertAvatar: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=150'
});
@@ -1077,7 +1001,7 @@ const handleRejectOrder = (order) => {
if (res.confirm) {
try {
await rejectOrder(order.id, {
expertId: expert.value.id || 101,
expertId: currentExpertId(),
reason: '大神当前档期冲突拒单'
});
} catch (err) {
@@ -1102,19 +1026,9 @@ const handleRejectOrder = (order) => {
const chatWithBuyer = () => {
uni.showActionSheet({
itemList: [
'复制开黑联络码',
'联系 7x24h 官方客服'
],
itemList: ['联系 7x24h 官方客服'],
success: (res) => {
if (res.tapIndex === 0) {
uni.setClipboardData({
data: `BUYER-${Math.floor(100000 + Math.random() * 900000)}`,
success: () => {
uni.showToast({ title: '联络码已复制', icon: 'success' });
}
});
} else if (res.tapIndex === 1) {
uni.showActionSheet({
itemList: [
'拨打官方服务热线 (400-888-6666)',
@@ -1151,7 +1065,7 @@ const completeOrder = (id) => {
success: async (res) => {
if (res.confirm) {
try {
await applyCompleteOrder(id, { expertId: expert.value.id || 101 });
await applyCompleteOrder(id, { expertId: currentExpertId() });
} catch (err) {
uni.showToast({
title: (err && err.message) || '提交失败,请稍后重试',