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

查看文件

@@ -491,20 +491,13 @@ const handleChooseLocation = () => {
},
fail: (err) => {
console.warn('[ActivityCreate] 地图选点取消或未授权:', err);
// 若未授权或在H5/开发环境,平滑引导点选推荐公开商圈
if (recommendPublicZones.value.length > 0) {
selectZone(recommendPublicZones.value[0]);
uni.showToast({ title: '已填入推荐商圈', icon: 'none' });
}
uni.showToast({ title: '未选择地点,可手动填写', icon: 'none' });
}
});
// #endif
// #ifndef MP-WEIXIN || APP-PLUS
if (recommendPublicZones.value.length > 0) {
selectZone(recommendPublicZones.value[0]);
uni.showToast({ title: '已为您填入示范商圈', icon: 'none' });
}
uni.showToast({ title: '当前环境不支持地图选点,请手动填写', icon: 'none' });
// #endif
};
@@ -659,7 +652,7 @@ const handleSubmit = async () => {
location: trimmedLocation,
latitude: form.value.latitude,
longitude: form.value.longitude,
creatorNickname: cachedUser.nickname || '同城局长',
creatorNickname: cachedUser.nickname || '同城用户',
creatorAvatar: cachedUser.avatar || 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=150&h=150&fit=crop',
};

查看文件

@@ -52,7 +52,7 @@
</text>
</view>
<text class="dp-status-text">
当前单人出价 ¥{{ activity.perPersonFee || 500 }}/人 · 招募{{ activity.maxParticipants }}人 · 已报名{{ joinedCount }}人
当前单人出价 ¥{{ activity.perPersonFee || 0 }}/人 · 招募{{ activity.maxParticipants }}人 · 已报名{{ joinedCount }}人
</text>
</view>
<view class="dp-btn-group">
@@ -76,9 +76,9 @@
<view class="creator-info btn-active" @click="openHostProfile">
<view class="creator-name-row">
<text class="creator-name">{{ activity.creatorNickname }}</text>
<text class="host-badge">同城局长</text>
<text class="host-badge">发起人</text>
</view>
<text class="creator-sub">同城组局召集人 · 履约守约率 100%</text>
<text class="creator-sub">同城组局召集人</text>
</view>
<button class="btn-chat btn-active" @click.stop="chatWithHost">私聊</button>
</view>
@@ -418,7 +418,8 @@ import {
adjustActivityPrice,
verifyActivityCheckin,
cancelActivity,
leaveActivity
leaveActivity,
normalizeUserId
} from '@/common/api.js';
import { ICONS } from '@/common/icons.js';
import { getCurrentThemeKey, applyThemeToNativeUI } from '@/common/theme.js';
@@ -489,18 +490,18 @@ const stopPropagation = (e) => {
const activity = ref({
id: '',
title: '同城生活组局',
game: '同城陪伴',
title: '',
game: '',
payType: 'AA',
totalFee: 0,
perPersonFee: 0,
maxParticipants: 4,
currentParticipants: 1,
startTime: '根据预约安排',
location: '同城公开商业场所',
creatorId: 1001,
creatorNickname: '局长',
creatorAvatar: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=100',
maxParticipants: 0,
currentParticipants: 0,
startTime: '',
location: '',
creatorId: 0,
creatorNickname: '',
creatorAvatar: '',
participants: [],
priceAdjustHistory: []
});
@@ -510,9 +511,12 @@ const loadLiveDetail = async (id) => {
const detail = await getActivityDetail(id);
if (detail) {
activity.value = detail;
} else {
uni.showToast({ title: '组局不存在或已下架', icon: 'none' });
}
} catch (err) {
console.warn('[ActivityDetail] 获取详情失败:', err);
uni.showToast({ title: err.message || '组局加载失败', icon: 'none' });
}
};
@@ -559,14 +563,14 @@ const setQuickPrice = (val) => {
};
const joinedCount = computed(() => {
if (activity.value && activity.value.participants) {
if (activity.value && Array.isArray(activity.value.participants)) {
return activity.value.participants.length;
}
return 2;
return 0;
});
const currentPerPerson = computed(() => {
return Number(activity.value.perPersonFee) || 500;
return Number(activity.value.perPersonFee) || 0;
});
const appendQuickOptions = computed(() => {
@@ -631,7 +635,8 @@ const confirmAdjustPrice = async () => {
uni.hideLoading();
} catch (err) {
uni.hideLoading();
console.warn('[ActivityDetail] 远程调价异常,执行本地同步:', err.message);
uni.showToast({ title: err.message || '调价失败,请稍后重试', icon: 'none' });
return;
}
activity.value.perPersonFee = newP;
@@ -686,44 +691,45 @@ const copyLocation = () => {
const openHostProfile = () => {
const hostId = activity.value.creatorId || 1001;
const hostName = activity.value.creatorNickname || '同城局长';
const hostName = activity.value.creatorNickname || '同城用户';
const hostAvatar = activity.value.creatorAvatar || 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=150';
const hostSnapshot = {
id: hostId,
userId: hostId,
nickname: hostName,
avatar: hostAvatar,
rankTag: '同城局长 · 守约率100%',
levelTag: '实名认证',
game: activity.value.game || '同城陪伴',
city: activity.value.location || '北京市 · 朝阳商圈',
bio: `【${activity.value.title || '同城生活组局'}】发起人,历史组局履约守约率 100%,热情好客,欢迎同城搭子一起加入!`,
photos: [hostAvatar]
rankTag: '发起人',
levelTag: '',
game: activity.value.game || '',
city: activity.value.location || '',
bio: activity.value.title ? `【${activity.value.title}】发起人` : '',
photos: hostAvatar ? [hostAvatar] : []
};
uni.setStorageSync('ACTIVE_AUTHOR_PROFILE', hostSnapshot);
uni.navigateTo({
url: `/pages/expert/detail?id=${encodeURIComponent(String(hostId))}&name=${encodeURIComponent(hostName)}&avatar=${encodeURIComponent(hostAvatar)}&tag=${encodeURIComponent('同城局长 · 守约100%')}&city=${encodeURIComponent(hostSnapshot.city)}`
url: `/pages/expert/detail?id=${encodeURIComponent(String(hostId))}&name=${encodeURIComponent(hostName)}&avatar=${encodeURIComponent(hostAvatar)}&tag=${encodeURIComponent('发起人')}&city=${encodeURIComponent(hostSnapshot.city)}`
});
};
const chatWithHost = () => {
uni.showActionSheet({
itemList: [
'复制组局联络专属口令',
'查看局长主页及守约信誉'
'复制组局信息',
'查看发起人主页'
],
success: (res) => {
if (res.tapIndex === 0) {
const hidePhone = uni.getStorageSync('privacy_hide_phone') === '1';
const rawPhone = activity.value.contactPhone || '13888886666';
const displayContact = hidePhone
? rawPhone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2') + '(隐私保护已脱敏)'
: rawPhone;
const tokenText = `【同城组局联络口令】${activity.value.title || '同城组局'} | 时间:${activity.value.startTime || '今天 19:30'} | 地点:${activity.value.location || '公开商圈'} | 联络方式:${displayContact} | 专属核验口令:#JU-${activity.value.id || '101'}-PW`;
const parts = [
`【组局】${activity.value.title || ''}`,
`时间:${activity.value.startTime || '待定'}`,
`地点:${activity.value.location || '待定'}`
];
const contact = String(activity.value.contactPhone || '').trim();
if (contact) parts.push(`联络方式:${contact}`);
uni.setClipboardData({
data: tokenText,
data: parts.join(' | '),
success: () => {
uni.showToast({ title: '专属组局口令已复制', icon: 'success' });
uni.showToast({ title: '组局信息已复制', icon: 'success' });
}
});
} else if (res.tapIndex === 1) {
@@ -737,9 +743,9 @@ const goToMyTicket = (code) => {
if (!ensureLoginOrRedirect(`/pages/activity/detail?id=${currentActId.value}`)) {
return;
}
const c = code || (activity.value.participants && activity.value.participants[0] ? activity.value.participants[0].verifyCode : '8392');
const c = code || ((activity.value.participants || []).find(p => Number(p.userId) === Number(currentUserId.value)) || {}).verifyCode || '';
uni.navigateTo({
url: `/pages/activity/my-ticket?id=${activity.value.id}&code=${c}`
url: `/pages/activity/my-ticket?id=${activity.value.id}${c ? `&code=${encodeURIComponent(c)}` : ''}`
});
};
@@ -851,19 +857,17 @@ const handleJoin = () => {
// 报名前请求一次性订阅授权(组局报名通知)
requestSubscribeFor('activity');
uni.showLoading({ title: '正在报名生成核销码...' });
let code = '8392';
let code = '';
try {
const fee = activity.value.payType === 'AA' ? activity.value.aaFee : 0;
const activeUid = currentUserId.value || Number(uni.getStorageSync('userId'));
const activeUid = normalizeUserId();
const joinRes = await joinActivity(activity.value.id, {
userId: activeUid,
payAmount: fee,
});
if (joinRes && joinRes.verifyCode) {
code = joinRes.verifyCode;
}
code = joinRes && joinRes.verifyCode ? joinRes.verifyCode : '';
uni.hideLoading();
uni.showToast({ title: '报名成功!已生成4位核销码', icon: 'success' });
uni.showToast({ title: '报名成功', icon: 'success' });
setTimeout(() => {
goToMyTicket(code);
}, 1000);

查看文件

@@ -176,12 +176,12 @@ import { ref, computed, onMounted, onUnmounted } from 'vue';
import { onShow, onLoad } from '@dcloudio/uni-app';
import AppTabBar from '@/components/CustomTabBar.vue';
import SkeletonScreen from '@/components/SkeletonScreen.vue';
import { getActivities, getNavCategories } from '@/common/api.js';
import { getActivities, getNavCategories, normalizeUserId } from '@/common/api.js';
import { ICONS } from '@/common/icons.js';
import { getCurrentThemeKey, applyThemeToNativeUI } from '@/common/theme.js';
import { getNavBarInfo } from '@/common/nav.js';
const CURRENT_USER_ID = 1001;
const CURRENT_USER_ID = normalizeUserId();
const isLoading = ref(true);
const activities = ref([]);
@@ -335,7 +335,7 @@ const filteredActivities = computed(() => {
// 2. 支付模式或发单人筛选
let matchTab = true;
if (currentTab.value === 'MINE') {
matchTab = Number(a.creatorId) === CURRENT_USER_ID || a.creatorNickname === '同城局长';
matchTab = Number(a.creatorId) === Number(CURRENT_USER_ID);
} else if (currentTab.value !== 'ALL') {
matchTab = a.payType === currentTab.value;
}

查看文件

@@ -1,6 +1,6 @@
<template>
<view class="ticket-container" :class="['theme-' + currentThemeKey]">
<view class="ticket-card">
<view class="ticket-card" v-if="hasTicket">
<!-- 票据头部 -->
<view class="ticket-header">
<view class="game-badge">{{ ticketData.game }}</view>
@@ -107,22 +107,25 @@
</view>
<!-- 门票操作按钮 -->
<view class="action-wrap">
<view class="action-wrap" v-if="hasTicket">
<button class="btn-cancel-ticket btn-active" v-if="!isCheckedIn" @click="handleCancelTicket">
申请退票退款 (释放席位)
</button>
<button class="btn-verify-demo btn-active" @click="toggleCheckIn">
{{ isCheckedIn ? '重置为待核销状态' : '局长现场核销此门票' }}
</button>
<button class="btn-back btn-active" @click="goBack">返回活动详情</button>
</view>
<view class="ticket-empty" v-else>
<text class="ticket-empty-title">暂无可用门票</text>
<text class="ticket-empty-desc">报名组局后,专属入场核销码会出现在这里</text>
<button class="btn-back btn-active" @click="goBack">去逛同城组局</button>
</view>
</view>
</template>
<script setup>
import { ref, computed, onMounted, onUnmounted } from 'vue';
import { onLoad, onShow } from '@dcloudio/uni-app';
import { getActivityDetail, verifyActivityCheckin, getMyActivities, leaveActivity } from '@/common/api.js';
import { getActivityDetail, getMyActivities, leaveActivity, normalizeUserId } from '@/common/api.js';
import { encodeCode128B } from '@/common/barcode.js';
import { generateQRCodeMatrix } from '@/common/qrcode.js';
import { getCurrentThemeKey } from '@/common/theme.js';
@@ -132,28 +135,24 @@ const currentThemeKey = ref(getCurrentThemeKey());
const activeCodeType = ref('BARCODE');
const ticketData = ref({
id: '',
title: '同城组局现场门票',
game: '同城陪伴',
startTime: '根据预约到场',
location: '同城商业街区',
creatorNickname: '组局房主'
title: '',
game: '',
startTime: '',
location: '',
creatorNickname: ''
});
const verifyCode = ref('8392');
const verifyCode = ref('');
const isCheckedIn = ref(false);
const currentTime = ref('');
const hasTicket = ref(true);
const hasTicket = ref(false);
const currentUserId = computed(() => {
try {
return Number(uni.getStorageSync('userId')) || 1001;
} catch (_) {
return 1001;
}
});
const currentUserId = computed(() => normalizeUserId());
const ticketSn = computed(() => {
const actId = ticketData.value && ticketData.value.id ? ticketData.value.id : '101';
return `TICKET-${actId}-${verifyCode.value}`;
const actId = ticketData.value && ticketData.value.id ? ticketData.value.id : '';
const code = String(verifyCode.value || '');
if (!actId || !code) return '';
return `TICKET-${actId}-${code}`;
});
const barcodeSegments = computed(() => {
@@ -184,9 +183,8 @@ const updateTime = () => {
let savedQuery = null;
const loadTicketData = async (query = savedQuery) => {
if (query && query.code) {
verifyCode.value = String(query.code);
}
hasTicket.value = false;
verifyCode.value = query && query.code ? String(query.code) : '';
// 1. 若有指定活动ID,直接拉取该活动详情
if (query && query.id) {
@@ -194,15 +192,13 @@ const loadTicketData = async (query = savedQuery) => {
const detail = await getActivityDetail(query.id);
if (detail) {
ticketData.value = detail;
if (detail.participants && detail.participants.length > 0) {
const found = detail.participants.find(p => p.verifyCode === verifyCode.value);
if (found) {
isCheckedIn.value = Boolean(found.checkedIn);
} else if (!query.code) {
verifyCode.value = detail.participants[0].verifyCode;
isCheckedIn.value = Boolean(detail.participants[0].checkedIn);
}
const uid = Number(currentUserId.value);
const mine = (detail.participants || []).find(p => Number(p.userId) === uid);
if (mine) {
if (mine.verifyCode) verifyCode.value = String(mine.verifyCode);
isCheckedIn.value = Boolean(mine.checkedIn);
}
hasTicket.value = Boolean(detail.id && verifyCode.value);
return;
}
} catch (err) {
@@ -212,43 +208,27 @@ const loadTicketData = async (query = savedQuery) => {
// 2. 若无传参,真实拉取当前用户的已报名组局列表
try {
const uid = currentUserId.value;
const uid = Number(currentUserId.value);
const myActs = await getMyActivities(uid);
const joinedList = myActs.joined || [];
if (joinedList.length > 0) {
let targetAct = joinedList.find(act => {
const myP = (act.participants || []).find(p => Number(p.userId) === uid || p.nickname === '同城局长' || p.verifyCode);
return myP && !myP.checkedIn;
}) || joinedList[0];
const joinedList = (myActs && myActs.joined) || [];
const withTicket = joinedList.filter((act) => {
const mine = (act.participants || []).find(p => Number(p.userId) === uid && p.verifyCode);
return Boolean(mine);
});
if (withTicket.length > 0) {
const targetAct = withTicket.find((act) => {
const mine = (act.participants || []).find(p => Number(p.userId) === uid);
return mine && !mine.checkedIn;
}) || withTicket[0];
const mine = (targetAct.participants || []).find(p => Number(p.userId) === uid) || {};
ticketData.value = targetAct;
if (targetAct.participants && targetAct.participants.length > 0) {
const myP = targetAct.participants.find(p => Number(p.userId) === uid || p.verifyCode);
if (myP && myP.verifyCode) {
verifyCode.value = String(myP.verifyCode);
isCheckedIn.value = Boolean(myP.checkedIn);
} else {
verifyCode.value = String(targetAct.participants[0].verifyCode || '8392');
isCheckedIn.value = Boolean(targetAct.participants[0].checkedIn);
}
}
return;
verifyCode.value = String(mine.verifyCode || '');
isCheckedIn.value = Boolean(mine.checkedIn);
hasTicket.value = Boolean(targetAct.id && verifyCode.value);
}
} catch (err) {
console.warn('[MyTicket] 获取用户报名门票异常:', err);
}
// 3. 兜底拉取线上第一个活动
try {
const defaultDetail = await getActivityDetail('act_101');
if (defaultDetail) {
ticketData.value = defaultDetail;
if (defaultDetail.participants && defaultDetail.participants.length > 0) {
verifyCode.value = String(defaultDetail.participants[0].verifyCode || '8392');
isCheckedIn.value = Boolean(defaultDetail.participants[0].checkedIn);
}
}
} catch (_) {}
};
onLoad(async (query) => {
@@ -270,38 +250,6 @@ onUnmounted(() => {
if (timer) clearInterval(timer);
});
const toggleCheckIn = async () => {
if (!isCheckedIn.value) {
try {
uni.showLoading({ title: '正在核销签到...' });
await verifyActivityCheckin(ticketData.value.id, verifyCode.value, currentUserId.value);
uni.hideLoading();
isCheckedIn.value = true;
uni.showToast({
title: '4位核销码核销成功,已完成现场签到!',
icon: 'success',
duration: 2000
});
} catch (err) {
uni.hideLoading();
// 若线上返回已核销或网络异常,同步状态
isCheckedIn.value = true;
uni.showToast({
title: err.message || '核销完成',
icon: 'none',
duration: 2000
});
}
} else {
isCheckedIn.value = false;
uni.showToast({
title: '状态已重置为待核销',
icon: 'none',
duration: 1500
});
}
};
const handleCancelTicket = () => {
uni.showModal({
title: '申请退票并退款?',
@@ -313,7 +261,12 @@ const handleCancelTicket = () => {
if (res.confirm) {
try {
uni.showLoading({ title: '正在办理退票...' });
const actId = ticketData.value && ticketData.value.id ? ticketData.value.id : 'act_101';
const actId = ticketData.value && ticketData.value.id;
if (!actId) {
uni.hideLoading();
uni.showToast({ title: '门票信息缺失,无法退票', icon: 'none' });
return;
}
await leaveActivity(actId, currentUserId.value);
uni.hideLoading();
uni.showToast({ title: '退票成功,款项已退回钱包', icon: 'success' });
@@ -624,6 +577,34 @@ const goBack = () => {
}
}
.ticket-empty {
margin-top: 80rpx;
display: flex;
flex-direction: column;
align-items: center;
gap: 12rpx;
padding: 60rpx 32rpx;
border-radius: 24rpx;
background: var(--bg-surface, #151D30);
border: 1rpx dashed rgba(148, 163, 184, 0.35);
.ticket-empty-title {
font-size: 30rpx;
font-weight: 600;
color: var(--text-primary, #F8FAFC);
}
.ticket-empty-desc {
font-size: 24rpx;
color: var(--text-muted, #94A3B8);
text-align: center;
}
.btn-back {
margin-top: 20rpx;
}
}
.action-wrap {
margin-top: 48rpx;
display: flex;