feat: security hardening, wechat pay v3 platform cert integration, companion certification revocation, and audit closed-loop

这个提交包含在:
xcbyy
2026-10-16 17:38:17 +08:00
父节点 3bf38db8b6
当前提交 78117bb4e1
共有 58 个文件被更改,包括 12971 次插入 和 952 次删除

查看文件

@@ -152,6 +152,7 @@
<view class="list-row btn-active" @click="openNotice">
<image class="row-svg" :src="ICONS.bell" mode="aspectFit" />
<text class="row-label">平台消息与通知</text>
<text class="row-sub-tag">{{ noticeSubscribe ? '提醒开启' : '已静音' }}</text>
<image class="row-arrow-svg" :src="ICONS.chevronRight" mode="aspectFit" />
</view>
<view class="list-row btn-active" @click="openMyReportsModal">
@@ -223,27 +224,33 @@
</view>
</view>
<!-- 昵称输入 (支持微信官方 type="nickname" 快速轻触填入) -->
<!-- 昵称输入 (支持微信官方 type="nickname" 规范,采用 type="text" 避免游客模式 reviewNickname:fail 渲染层报错与失焦清空) -->
<view class="edit-field">
<text class="field-label">用户昵称</text>
<input
class="field-input"
type="nickname"
type="text"
v-model="editForm.nickname"
@input="onNicknameInput"
maxlength="15"
placeholder="请输入新昵称或轻触填入微信昵称"
placeholder="请输入您的新昵称"
placeholder-class="field-placeholder"
/>
</view>
<!-- 联系方式 -->
<view class="edit-field">
<text class="field-label">联系电话 / 微信号</text>
<view class="field-label-row">
<text class="field-label">联系电话 / 微信号</text>
<text class="field-tip-text">支持11位手机号或微信号</text>
</view>
<input
class="field-input"
type="text"
v-model="editForm.phone"
@input="onPhoneInput"
maxlength="20"
placeholder="请输入联系方式(用于组局联络)"
placeholder="请输入11位手机号或微信号"
placeholder-class="field-placeholder"
/>
</view>
@@ -327,52 +334,6 @@
</view>
</view>
<!-- 我的举报与维权进度反馈弹窗 -->
<view class="profile-edit-modal-mask" v-if="showReportsModal" @click="showReportsModal = false">
<view class="profile-edit-modal withdraw-records-modal-box" @click.stop>
<view class="modal-header">
<text class="modal-title">我的举报与维权进度</text>
<view class="btn-close btn-active" @click="showReportsModal = false">
<image class="close-svg" :src="ICONS.close" mode="aspectFit" />
</view>
</view>
<scroll-view scroll-y class="records-modal-scroll" v-if="myReportsList.length > 0">
<view v-for="rpt in myReportsList" :key="rpt.id" class="wd-card-row">
<view class="wd-row-top">
<text class="wd-no">对象:{{ rpt.targetName || rpt.targetId }} · {{ rpt.reason }}</text>
<text
class="wd-badge"
:class="{
pending: rpt.status === '待处理',
success: rpt.status === '已核实处罚',
rejected: rpt.status === '已驳回'
}"
>
{{ rpt.status || '待处理' }}
</text>
</view>
<view class="wd-row-center" v-if="rpt.description">
<text class="wd-ch">举报说明:{{ rpt.description }}</text>
</view>
<view class="wd-row-bot">
<text class="wd-time">{{ rpt.createdAt }}</text>
<text class="wd-reason" v-if="rpt.handleNote || rpt.handleResult">
平台反馈:{{ rpt.handleNote || rpt.handleResult }}
</text>
<text class="wd-time" v-else>平台安全专员正在核实处理中</text>
</view>
</view>
</scroll-view>
<view class="empty-records-box" v-else>
<image class="empty-icon-svg" :src="ICONS.shield" mode="aspectFit" />
<text class="empty-txt">暂无举报与维权记录</text>
</view>
</view>
</view>
<!-- 底部自定义导航栏 (动态自适应发单人4项 / 接单人3项) -->
<AppTabBar current="user" />
@@ -393,13 +354,13 @@ import { getNavBarInfo } from '@/common/nav.js';
import { getUserProfile, rechargeBalance, withdrawCommission, getUserFinanceRecords, updateUserProfile, uploadImage, getRechargeTiers, getPlatformConfigs, applyExpertCert, getUserWithdrawals, getFavorites, removeFavorite, getDistributionTeam, getDistributionRecords, getMyReports, bindInviteCode } from '@/common/api.js';
const DEFAULT_GUEST_AVATAR = 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=200';
const isLoggedIn = ref(true);
const initialUserId = typeof uni !== 'undefined' ? (uni.getStorageSync('userId') || null) : null;
const isLoggedIn = ref(Boolean(initialUserId));
const showLoginModal = ref(false);
// 我的收藏与我的举报反馈
const favoriteList = ref([]);
const loadingFavorites = ref(false);
const showReportsModal = ref(false);
const myReportsList = ref([]);
const loadMyReports = async () => {
@@ -412,10 +373,11 @@ const loadMyReports = async () => {
} catch (_) {}
};
const openMyReportsModal = async () => {
const openMyReportsModal = () => {
if (!ensureLoggedIn()) return;
await loadMyReports();
showReportsModal.value = true;
uni.navigateTo({
url: '/pages/user/reports'
});
};
// 系统与隐私设置
@@ -466,17 +428,17 @@ const DEMO_ACCOUNTS = [
];
const user = ref({
id: 1001,
nickname: '电竞玩家',
avatar: 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=200',
gender: 'male',
id: initialUserId || '',
nickname: initialUserId ? '用户' : '点击登录 / 注册',
avatar: DEFAULT_GUEST_AVATAR,
gender: '保密',
role: 'PLAYER',
balance: '0.00',
commission: '0.00',
orderCount: 0,
invitedCount: 0,
phone: '138****8888',
signature: '同城常驻朝阳 · 寻找靠谱搭子'
phone: '',
signature: initialUserId ? '同城常驻 · 寻找靠谱搭子' : ''
});
const currentRole = ref(getCurrentRole());
const currentThemeKey = ref(getCurrentThemeKey());
@@ -518,9 +480,8 @@ const loadPlatformConfigs = async () => {
};
const navStyle = computed(() => {
return {
'--safe-header-gap': `${navInfo.value.totalHeaderHeight}px`
};
const gap = (navInfo.value && navInfo.value.totalHeaderHeight) || 88;
return `--safe-header-gap: ${gap}px; padding-top: ${gap}px;`;
});
const onThemeChanged = (key) => {
@@ -555,6 +516,8 @@ const handleLogout = () => {
if (res.confirm) {
uni.removeStorageSync('userInfo');
uni.removeStorageSync('userId');
uni.removeStorageSync('PW_USER_INFO');
uni.removeStorageSync('userToken');
uni.setStorageSync('user_has_logged_out', '1');
isLoggedIn.value = false;
user.value = {
@@ -579,8 +542,9 @@ const handleLogout = () => {
};
const loadUserProfile = async (targetId) => {
const hasLoggedOut = uni.getStorageSync('user_has_logged_out');
if (hasLoggedOut && !targetId) {
const storedUid = targetId || (typeof uni !== 'undefined' ? uni.getStorageSync('userId') : null);
const hasLoggedOut = typeof uni !== 'undefined' ? uni.getStorageSync('user_has_logged_out') : null;
if ((hasLoggedOut || !storedUid) && !targetId) {
isLoggedIn.value = false;
user.value = {
id: '',
@@ -591,13 +555,14 @@ const loadUserProfile = async (targetId) => {
commission: '0.00',
orderCount: 0,
invitedCount: 0,
phone: ''
phone: '',
signature: ''
};
return;
}
isLoggedIn.value = true;
let uid = targetId || uni.getStorageSync('userId') || 1001;
let uid = storedUid;
if (uid == 101) {
uid = 2006;
uni.setStorageSync('userId', 2006);
@@ -620,10 +585,13 @@ const loadUserProfile = async (targetId) => {
} else if (profile.isExpert || (profile.role && profile.role.includes('大神'))) {
setExpertCertStatus(CERT_STATUS.APPROVED);
}
uni.setStorageSync('PW_USER_INFO', {
const syncedProfile = {
...(uni.getStorageSync('PW_USER_INFO') || {}),
...(uni.getStorageSync('userInfo') || {}),
...user.value
});
};
uni.setStorageSync('PW_USER_INFO', syncedProfile);
uni.setStorageSync('userInfo', syncedProfile);
// 若通过小程序太阳码海报进入带有待绑定的推荐人标识且当前尚未绑定上级,首次登录自动建立父子关联
const pendingInviter = uni.getStorageSync('PENDING_INVITER_CODE');
if (pendingInviter && !profile.inviterId) {
@@ -670,6 +638,7 @@ onShow(() => {
loadUserProfile();
loadPlatformConfigs();
privacyHidePhone.value = uni.getStorageSync('privacy_hide_phone') === '1';
noticeSubscribe.value = uni.getStorageSync('notice_subscribe') !== '0';
if (isLoggedIn.value) {
loadFavorites();
loadMyReports();
@@ -735,6 +704,11 @@ const toggleRole = () => {
icon: 'success',
duration: 1200
});
setTimeout(() => {
uni.reLaunch({
url: '/pages/expert/hall'
});
}, 500);
} else {
uni.showToast({
title: '已切回【发单人端】',
@@ -762,8 +736,9 @@ const editForm = ref({
const editProfile = () => {
if (!ensureLoggedIn()) return;
const initialNick = (user.value.nickname && user.value.nickname !== '点击登录 / 注册') ? user.value.nickname : '';
editForm.value = {
nickname: user.value.nickname || '',
nickname: initialNick,
avatar: user.value.avatar || PRESET_AVATARS[0],
phone: user.value.phone || '',
gender: user.value.gender || '保密',
@@ -772,6 +747,47 @@ const editProfile = () => {
showEditModal.value = true;
};
const onNicknameInput = (e) => {
if (e && e.detail && typeof e.detail.value === 'string') {
editForm.value.nickname = e.detail.value;
}
};
const onPhoneInput = (e) => {
if (e && e.detail && typeof e.detail.value === 'string') {
editForm.value.phone = e.detail.value.replace(/[\s、,,。;;!!??]/g, '');
}
};
const validateContact = (val) => {
if (!val) return { valid: true };
const str = String(val).trim();
// 1. 中国大陆11位手机号 (以1开头的11位纯数字,第二位为3-9)
const isMobile = /^1[3-9]\d{9}$/.test(str);
if (isMobile) return { valid: true, type: 'phone' };
// 2. 微信标准微信号 (6-20位,以字母开头,仅包含字母、数字、下划线、减号)
const isWechat = /^[a-zA-Z][-_a-zA-Z0-9]{5,19}$/.test(str);
if (isWechat) return { valid: true, type: 'wechat' };
// 3. 历史未修改的脱敏展示掩码 (形如 138****8888)
const isMaskedMobile = /^1[3-9]\d\*{4}\d{4}$/.test(str);
if (isMaskedMobile) return { valid: true, type: 'masked' };
// 如果包含中文标点符号(如顿号、逗号)
if (/[\u3001\u3002\uff0c\uff1b\uff1f\uff01\s]/.test(str)) {
return { valid: false, message: '联系方式中不能包含标点符号或空格' };
}
// 如果是纯数字但不是11位
if (/^\d+$/.test(str) && str.length !== 11) {
return { valid: false, message: '手机号码必须为11位纯数字' };
}
return { valid: false, message: '请输入有效的11位手机号或微信号' };
};
// 点击头像或名称行:已登录时直接打开个人资料设置弹窗,未登录时引导登录
const handleAvatarOrNameClick = () => {
if (isLoggedIn.value) {
@@ -821,10 +837,27 @@ const chooseCustomAvatar = () => {
};
const saveProfile = async () => {
if (!editForm.value.nickname || !editForm.value.nickname.trim()) {
const finalNickname = editForm.value.nickname ? editForm.value.nickname.trim() : '';
if (!finalNickname) {
uni.showToast({ title: '昵称不能为空', icon: 'none' });
return;
}
editForm.value.nickname = finalNickname;
const finalPhone = editForm.value.phone ? editForm.value.phone.trim() : '';
if (finalPhone) {
const contactCheck = validateContact(finalPhone);
if (!contactCheck.valid) {
uni.showToast({
title: contactCheck.message || '请输入有效的11位手机号或微信号',
icon: 'none',
duration: 2000
});
return;
}
}
editForm.value.phone = finalPhone;
const currentAvatar = editForm.value.avatar || '';
if (
currentAvatar.startsWith('http://tmp/') ||
@@ -838,9 +871,9 @@ const saveProfile = async () => {
uni.showLoading({ title: '正在保存资料...' });
try {
const updated = await updateUserProfile(user.value.id || 1001, {
nickname: editForm.value.nickname.trim(),
nickname: finalNickname,
avatar: editForm.value.avatar,
phone: editForm.value.phone,
phone: finalPhone,
gender: editForm.value.gender || '保密',
signature: editForm.value.signature ? editForm.value.signature.trim() : ''
});
@@ -851,12 +884,19 @@ const saveProfile = async () => {
...updated
};
} else {
user.value.nickname = editForm.value.nickname.trim();
user.value.nickname = finalNickname;
user.value.avatar = editForm.value.avatar;
user.value.phone = editForm.value.phone;
user.value.phone = finalPhone;
user.value.gender = editForm.value.gender || '保密';
user.value.signature = editForm.value.signature ? editForm.value.signature.trim() : '';
}
const syncedProfile = {
...(uni.getStorageSync('PW_USER_INFO') || {}),
...(uni.getStorageSync('userInfo') || {}),
...user.value
};
uni.setStorageSync('PW_USER_INFO', syncedProfile);
uni.setStorageSync('userInfo', syncedProfile);
showEditModal.value = false;
uni.showToast({
title: '个人信息修改成功',
@@ -887,54 +927,10 @@ const viewWalletLog = () => {
});
};
const handleRecharge = async () => {
const handleRecharge = () => {
if (!ensureLoggedIn()) return;
let tiers = [];
try {
const list = await getRechargeTiers();
if (Array.isArray(list) && list.length > 0) {
tiers = list;
}
} catch (_) {}
if (tiers.length === 0) {
tiers = [
{ amount: 50, bonusAmount: 0, tag: '基础充值' },
{ amount: 100, bonusAmount: 5, tag: '热门畅享' },
{ amount: 200, bonusAmount: 15, tag: '超值加赠' },
{ amount: 500, bonusAmount: 50, tag: '尊享特惠' }
];
}
const itemList = tiers.map((t) => {
const bonus = Number(t.bonusAmount) > 0 ? ` (赠¥${Number(t.bonusAmount)})` : '';
const tag = t.tag ? ` [${t.tag}]` : '';
return `充值 ¥${Number(t.amount)}${bonus}${tag}`;
});
uni.showActionSheet({
itemList,
success: async (res) => {
const selected = tiers[res.tapIndex] || tiers[0];
const amount = Number(selected.amount);
try {
const result = await rechargeBalance(1001, amount);
if (result && result.balance) {
user.value.balance = result.balance;
}
const bonusMsg = Number(selected.bonusAmount) > 0 ? `,加赠 ¥${Number(selected.bonusAmount)} 已同步入账` : '';
uni.showToast({
title: `充值 ¥${amount} 成功${bonusMsg}!`,
icon: 'success',
duration: 2000
});
} catch (err) {
uni.showToast({
title: '充值失败,请稍后重试',
icon: 'none'
});
}
}
uni.navigateTo({
url: '/pages/user/recharge'
});
};
@@ -1021,6 +1017,7 @@ const updateCacheSize = () => {
// 2. 系统与隐私设置(跳转独立设置页面)
const openSettingsModal = () => {
if (!ensureLoggedIn()) return;
uni.navigateTo({
url: '/pages/user/settings'
});
@@ -1816,6 +1813,22 @@ const navTo = (url) => {
.edit-field {
margin-bottom: 24rpx;
.field-label-row {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10rpx;
.field-label {
margin-bottom: 0;
}
.field-tip-text {
font-size: 20rpx;
color: #64748B;
}
}
.field-label {
font-size: 24rpx;
color: #94A3B8;
@@ -2022,6 +2035,15 @@ const navTo = (url) => {
}
.edit-field {
.field-label-row {
.field-label {
color: #78716C;
}
.field-tip-text {
color: #A8A29E;
}
}
.field-label {
color: #78716C;
}