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 实测通过
这个提交包含在:
@@ -23,7 +23,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 多角色体验账号矩阵 (局长/买家/金牌大神) -->
|
||||
<view class="demo-accounts-card">
|
||||
<view class="demo-accounts-card" v-if="demoAccounts.length > 0">
|
||||
<view class="demo-card-head">
|
||||
<text class="demo-title">多角色体验账号直登</text>
|
||||
<text class="demo-sub">评审与体验专用 · 一键切换角色</text>
|
||||
@@ -31,12 +31,12 @@
|
||||
|
||||
<view class="demo-list">
|
||||
<view
|
||||
v-for="acc in DEMO_ACCOUNTS"
|
||||
:key="acc.id"
|
||||
v-for="acc in demoAccounts"
|
||||
:key="acc.userId"
|
||||
class="demo-item btn-active"
|
||||
@click="loginWithDemo(acc)"
|
||||
>
|
||||
<image class="demo-avatar" :src="acc.avatar" mode="aspectFill" />
|
||||
<image class="demo-avatar" :src="acc.avatar || DEFAULT_AVATAR" mode="aspectFill" />
|
||||
<view class="demo-info">
|
||||
<view class="demo-name-row">
|
||||
<text class="demo-name">{{ acc.nickname }}</text>
|
||||
@@ -69,7 +69,7 @@ import { ref, onMounted } from 'vue';
|
||||
import { onLoad, onShow } from '@dcloudio/uni-app';
|
||||
import { ICONS } from '@/common/icons.js';
|
||||
import { getCurrentThemeKey, applyThemeToNativeUI } from '@/common/theme.js';
|
||||
import { getPlatformConfigs, loginWithWechatPhone } from '@/common/api.js';
|
||||
import { getPlatformConfigs, loginWithWechatPhone, getDemoAccounts, demoLogin } from '@/common/api.js';
|
||||
|
||||
const APP_LOGO = 'https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=200';
|
||||
const DEFAULT_AVATAR = 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=200';
|
||||
@@ -107,32 +107,18 @@ const loadProtocolConfig = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const DEMO_ACCOUNTS = [
|
||||
{
|
||||
id: 1001,
|
||||
nickname: '晨曦微光局长',
|
||||
roleTag: 'host',
|
||||
roleDesc: '房主/局长',
|
||||
desc: '余额充足 · 发起项目制/AA组局',
|
||||
avatar: 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=200'
|
||||
},
|
||||
{
|
||||
id: 2001,
|
||||
nickname: '快乐小买家',
|
||||
roleTag: 'buyer',
|
||||
roleDesc: '普通买家',
|
||||
desc: '搭子报名 · 预约陪伴 · 核销码签到',
|
||||
avatar: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=200'
|
||||
},
|
||||
{
|
||||
id: 2006,
|
||||
nickname: '苏苏学姐',
|
||||
roleTag: 'expert',
|
||||
roleDesc: '金牌陪伴师',
|
||||
desc: '工作台接单 · 雷达抢单 · 现场核销',
|
||||
avatar: 'https://images.unsplash.com/photo-1524504388940-b1c1722653e1?w=200'
|
||||
const demoAccounts = ref([]);
|
||||
const loadingDemoAccounts = ref(false);
|
||||
|
||||
const loadDemoAccounts = async () => {
|
||||
if (loadingDemoAccounts.value) return;
|
||||
loadingDemoAccounts.value = true;
|
||||
try {
|
||||
demoAccounts.value = await getDemoAccounts();
|
||||
} finally {
|
||||
loadingDemoAccounts.value = false;
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
onLoad((options) => {
|
||||
if (options && options.redirect) {
|
||||
@@ -148,6 +134,7 @@ onMounted(() => {
|
||||
currentThemeKey.value = getCurrentThemeKey();
|
||||
applyThemeToNativeUI(currentThemeKey.value);
|
||||
loadProtocolConfig();
|
||||
loadDemoAccounts();
|
||||
});
|
||||
|
||||
onShow(() => {
|
||||
@@ -281,7 +268,7 @@ const handleGetPhoneNumber = async (e) => {
|
||||
confirmColor: '#10B981',
|
||||
success: (mRes) => {
|
||||
if (mRes.confirm) {
|
||||
completeLogin(1001);
|
||||
loginFirstDemoAccount();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -289,10 +276,7 @@ const handleGetPhoneNumber = async (e) => {
|
||||
}
|
||||
}
|
||||
|
||||
completeLogin(1001, {
|
||||
nickname: '微信用户',
|
||||
avatar: DEFAULT_AVATAR
|
||||
});
|
||||
loginFirstDemoAccount();
|
||||
} else {
|
||||
console.warn('[WeChat Login] 未授权手机号或环境受限:', e?.detail?.errMsg);
|
||||
uni.showModal({
|
||||
@@ -303,7 +287,7 @@ const handleGetPhoneNumber = async (e) => {
|
||||
confirmColor: '#10B981',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
completeLogin(1001);
|
||||
loginFirstDemoAccount();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -311,7 +295,7 @@ const handleGetPhoneNumber = async (e) => {
|
||||
// #endif
|
||||
|
||||
// #ifndef MP-WEIXIN
|
||||
completeLogin(1001);
|
||||
loginFirstDemoAccount();
|
||||
// #endif
|
||||
};
|
||||
|
||||
@@ -321,19 +305,34 @@ const handleFallbackLogin = () => {
|
||||
uni.showToast({ title: '请先阅读并勾选服务协议', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
completeLogin(1001);
|
||||
loginFirstDemoAccount();
|
||||
// #endif
|
||||
};
|
||||
|
||||
const loginWithDemo = (acc) => {
|
||||
const loginWithDemo = async (acc) => {
|
||||
if (!agreedProtocol.value) {
|
||||
uni.showToast({ title: '请先阅读并勾选服务协议', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
completeLogin(acc.id, {
|
||||
nickname: acc.nickname,
|
||||
avatar: acc.avatar
|
||||
});
|
||||
uni.showLoading({ title: '正在登录...' });
|
||||
try {
|
||||
const res = await demoLogin(acc.userId);
|
||||
uni.hideLoading();
|
||||
completeLogin(res.userId, res.user || {}, res.userToken || '');
|
||||
} catch (e) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({ title: (e && e.message) || '体验登录失败', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
const loginFirstDemoAccount = async () => {
|
||||
if (!demoAccounts.value.length) await loadDemoAccounts();
|
||||
const first = demoAccounts.value[0];
|
||||
if (!first) {
|
||||
uni.showToast({ title: '体验账号未配置,请联系管理员', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
await loginWithDemo(first);
|
||||
};
|
||||
|
||||
const openUserAgreement = () => {
|
||||
|
||||
在新工单中引用
屏蔽一个用户