feat: security hardening, wechat pay v3 platform cert integration, companion certification revocation, and audit closed-loop
这个提交包含在:
@@ -14,6 +14,9 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 顶部导航栏占位(避免内容被固定导航栏遮挡) -->
|
||||
<view class="nav-bar-placeholder"></view>
|
||||
|
||||
<!-- 顶部统计与在线过滤筛选栏 -->
|
||||
<view class="filter-header-bar" v-if="!isLoading && allFavorites.length > 0">
|
||||
<view class="header-stat-wrap">
|
||||
@@ -130,10 +133,11 @@ const allFavorites = ref([]);
|
||||
const filterOnlyOnline = ref(false);
|
||||
|
||||
const navStyle = computed(() => {
|
||||
const info = navInfo.value || {};
|
||||
return {
|
||||
'--safe-header-gap': `${navInfo.value.totalHeaderHeight}px`,
|
||||
'--capsule-right-space': `${navInfo.value.capsuleRightSpace}px`,
|
||||
'--capsule-height': `${navInfo.value.capsuleHeight}px`
|
||||
'--safe-header-gap': `${info.totalHeaderHeight || 88}px`,
|
||||
'--capsule-right-space': `${info.capsuleRightSpace || 0}px`,
|
||||
'--capsule-height': `${info.capsuleHeight || 32}px`
|
||||
};
|
||||
});
|
||||
|
||||
@@ -241,6 +245,7 @@ onShow(() => {
|
||||
height: var(--safe-header-gap);
|
||||
background: rgba(10, 15, 29, 0.9);
|
||||
backdrop-filter: blur(12px);
|
||||
-webkit-backdrop-filter: blur(12px);
|
||||
z-index: 1000;
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
|
||||
|
||||
@@ -271,8 +276,11 @@ onShow(() => {
|
||||
}
|
||||
|
||||
.nav-title-wrap {
|
||||
flex: 1;
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
text-align: center;
|
||||
pointer-events: none;
|
||||
|
||||
.nav-title {
|
||||
font-size: 32rpx;
|
||||
@@ -288,14 +296,22 @@ onShow(() => {
|
||||
}
|
||||
}
|
||||
|
||||
// 顶部固定导航栏高度占位,确保后续所有内容严格规避遮挡
|
||||
.nav-bar-placeholder {
|
||||
height: var(--safe-header-gap);
|
||||
width: 100%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
// 顶部统计与过滤栏
|
||||
.filter-header-bar {
|
||||
margin-top: calc(var(--safe-header-gap) + 16rpx);
|
||||
margin-top: 16rpx;
|
||||
padding: 0 32rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16rpx;
|
||||
flex-shrink: 0;
|
||||
|
||||
.header-stat-wrap {
|
||||
.stat-count-txt {
|
||||
@@ -346,7 +362,7 @@ onShow(() => {
|
||||
|
||||
// 骨架屏
|
||||
.favorites-loading {
|
||||
margin-top: calc(var(--safe-header-gap) + 24rpx);
|
||||
margin-top: 24rpx;
|
||||
padding: 0 32rpx;
|
||||
|
||||
.skeleton-card {
|
||||
@@ -581,7 +597,7 @@ onShow(() => {
|
||||
|
||||
// 空状态卡片
|
||||
.empty-state-card {
|
||||
margin-top: 120rpx;
|
||||
margin-top: 80rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
1407
pwuniapp/pages/user/recharge.vue
普通文件
1407
pwuniapp/pages/user/recharge.vue
普通文件
文件差异内容过多而无法显示
加载差异
1190
pwuniapp/pages/user/reports.vue
普通文件
1190
pwuniapp/pages/user/reports.vue
普通文件
文件差异内容过多而无法显示
加载差异
@@ -186,15 +186,40 @@ import { onShow } from '@dcloudio/uni-app';
|
||||
import { ICONS } from '@/common/icons.js';
|
||||
import { getCurrentThemeKey, applyThemeToNativeUI } from '@/common/theme.js';
|
||||
import { getNavBarInfo } from '@/common/nav.js';
|
||||
import { getUserSettings, updateUserSettings } from '@/common/api.js';
|
||||
|
||||
const currentThemeKey = ref(getCurrentThemeKey());
|
||||
const navInfo = ref(getNavBarInfo());
|
||||
|
||||
// 本地设置状态
|
||||
const ESSENTIAL_STORAGE_KEYS = [
|
||||
'peiwan_token',
|
||||
'peiwan_current_role',
|
||||
'app_theme_key',
|
||||
'privacy_hide_phone',
|
||||
'notice_subscribe',
|
||||
'userId',
|
||||
'userInfo',
|
||||
'user_has_logged_out',
|
||||
'expert_cert_status',
|
||||
'privacy_agreed',
|
||||
'cache_cleaned_snapshot_kb'
|
||||
];
|
||||
|
||||
const checkIsLoggedIn = () => {
|
||||
const hasLoggedOut = uni.getStorageSync('user_has_logged_out') === '1';
|
||||
if (hasLoggedOut) return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
const currentUserId = computed(() => {
|
||||
return Number(uni.getStorageSync('userId') || 1001);
|
||||
});
|
||||
|
||||
// 本地与云端同步设置状态
|
||||
const privacyHidePhone = ref(uni.getStorageSync('privacy_hide_phone') === '1');
|
||||
const noticeSubscribe = ref(uni.getStorageSync('notice_subscribe') !== '0');
|
||||
const cacheSizeText = ref('1.25 MB');
|
||||
const isLoggedIn = ref(!!uni.getStorageSync('peiwan_token'));
|
||||
const cacheSizeText = ref('0 KB');
|
||||
const isLoggedIn = ref(checkIsLoggedIn());
|
||||
|
||||
// 顶部自定义导航栏适配
|
||||
const navStyle = computed(() => {
|
||||
@@ -210,80 +235,149 @@ const switchActiveColor = computed(() => {
|
||||
return currentThemeKey.value === 'warm' ? '#EA580C' : '#6366F1';
|
||||
});
|
||||
|
||||
// 计算本地缓存大小
|
||||
// 真实计算可清理的本地临时缓存大小
|
||||
const updateCacheSize = () => {
|
||||
try {
|
||||
const info = uni.getStorageInfoSync();
|
||||
const kb = info.currentSize || 0;
|
||||
if (kb > 1024) {
|
||||
cacheSizeText.value = `${(kb / 1024).toFixed(2)} MB`;
|
||||
const allKeys = Array.isArray(info.keys) ? info.keys : [];
|
||||
const tempKeys = allKeys.filter(k => !ESSENTIAL_STORAGE_KEYS.includes(k));
|
||||
const snapshotRaw = uni.getStorageSync('cache_cleaned_snapshot_kb');
|
||||
const hasCleanedBefore = snapshotRaw !== '' && snapshotRaw !== null && snapshotRaw !== undefined;
|
||||
|
||||
let tempBytes = 0;
|
||||
tempKeys.forEach((k) => {
|
||||
try {
|
||||
const val = uni.getStorageSync(k);
|
||||
const serialized = typeof val === 'string' ? val : JSON.stringify(val || '');
|
||||
tempBytes += (k.length + serialized.length) * 2;
|
||||
} catch (_) {}
|
||||
});
|
||||
|
||||
const currentKb = Number(info.currentSize || 0);
|
||||
if (tempBytes > 0) {
|
||||
const kb = Math.max(1, Math.ceil(tempBytes / 1024));
|
||||
cacheSizeText.value = kb > 1024 ? `${(kb / 1024).toFixed(2)} MB` : `${kb} KB`;
|
||||
} else if (!hasCleanedBefore && currentKb > 0) {
|
||||
cacheSizeText.value = currentKb > 1024 ? `${(currentKb / 1024).toFixed(2)} MB` : `${currentKb} KB`;
|
||||
} else {
|
||||
cacheSizeText.value = `${kb} KB`;
|
||||
const diffKb = Math.max(0, currentKb - Number(snapshotRaw || 0));
|
||||
cacheSizeText.value = diffKb > 1024 ? `${(diffKb / 1024).toFixed(2)} MB` : `${diffKb} KB`;
|
||||
}
|
||||
} catch (_) {
|
||||
cacheSizeText.value = '1.25 MB';
|
||||
cacheSizeText.value = '0 KB';
|
||||
}
|
||||
};
|
||||
|
||||
// 切换手机号脱敏隐藏
|
||||
const onToggleHidePhone = (e) => {
|
||||
const val = e.detail.value;
|
||||
// 同步远端用户的隐私与通知偏好
|
||||
const syncSettingsFromServer = async () => {
|
||||
if (!isLoggedIn.value) return;
|
||||
try {
|
||||
const res = await getUserSettings(currentUserId.value);
|
||||
if (res && typeof res === 'object') {
|
||||
if (typeof res.privacyHidePhone === 'boolean') {
|
||||
privacyHidePhone.value = res.privacyHidePhone;
|
||||
}
|
||||
if (typeof res.noticeSubscribe === 'boolean') {
|
||||
noticeSubscribe.value = res.noticeSubscribe;
|
||||
}
|
||||
}
|
||||
} catch (_) {}
|
||||
};
|
||||
|
||||
// 切换手机号脱敏隐藏(同步本地与后端并广播全站脱敏事件)
|
||||
const onToggleHidePhone = async (e) => {
|
||||
const val = !!e.detail.value;
|
||||
privacyHidePhone.value = val;
|
||||
uni.setStorageSync('privacy_hide_phone', val ? '1' : '0');
|
||||
uni.$emit('privacy-settings-change', { privacyHidePhone: val });
|
||||
await updateUserSettings(currentUserId.value, {
|
||||
privacyHidePhone: val,
|
||||
noticeSubscribe: noticeSubscribe.value
|
||||
});
|
||||
uni.showToast({
|
||||
title: val ? '已开启手机号隐藏' : '已关闭手机号隐藏',
|
||||
title: val ? '已开启手机号脱敏保护' : '已关闭手机号脱敏保护',
|
||||
icon: 'none'
|
||||
});
|
||||
};
|
||||
|
||||
// 切换通知订阅
|
||||
const onToggleNotice = (e) => {
|
||||
const val = e.detail.value;
|
||||
// 切换通知订阅(微信小程序端支持唤起订阅授权,并同步服务端)
|
||||
const onToggleNotice = async (e) => {
|
||||
const val = !!e.detail.value;
|
||||
noticeSubscribe.value = val;
|
||||
uni.setStorageSync('notice_subscribe', val ? '1' : '0');
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
if (val && typeof uni.requestSubscribeMessage === 'function') {
|
||||
try {
|
||||
uni.requestSubscribeMessage({
|
||||
tmplIds: ['ORDER_STATUS_NOTICE_TMPL', 'ACTIVITY_TEAM_NOTICE_TMPL'],
|
||||
complete: () => {}
|
||||
});
|
||||
} catch (_) {}
|
||||
}
|
||||
// #endif
|
||||
|
||||
uni.$emit('notice-subscribe-change', val);
|
||||
await updateUserSettings(currentUserId.value, {
|
||||
privacyHidePhone: privacyHidePhone.value,
|
||||
noticeSubscribe: val
|
||||
});
|
||||
uni.showToast({
|
||||
title: val ? '已开启服务提醒' : '已关闭服务提醒',
|
||||
title: val ? '已开启订单与组局动态提醒' : '已关闭订单与组局动态提醒',
|
||||
icon: 'none'
|
||||
});
|
||||
};
|
||||
|
||||
// 一键清理本地缓存
|
||||
// 一键清理本地缓存(精准清理非核心临时键值与本地保存的临时文件)
|
||||
const clearLocalCache = () => {
|
||||
uni.showModal({
|
||||
title: '清除缓存',
|
||||
content: '清理将释放临时数据,保留登录账号与必要配置。确定继续?',
|
||||
content: '清理将释放临时图片与历史交互缓存,保留当前登录账号与隐私配置。确定继续?',
|
||||
confirmText: '确定清理',
|
||||
cancelText: '取消',
|
||||
confirmColor: '#EF4444',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
const token = uni.getStorageSync('peiwan_token');
|
||||
const userRole = uni.getStorageSync('peiwan_current_role');
|
||||
const themeKey = uni.getStorageSync('app_theme_key');
|
||||
const hidePhone = uni.getStorageSync('privacy_hide_phone');
|
||||
const noticeSub = uni.getStorageSync('notice_subscribe');
|
||||
const userId = uni.getStorageSync('userId');
|
||||
const userInfo = uni.getStorageSync('userInfo');
|
||||
const info = uni.getStorageInfoSync();
|
||||
const allKeys = Array.isArray(info.keys) ? info.keys : [];
|
||||
let removedCount = 0;
|
||||
allKeys.forEach((k) => {
|
||||
if (!ESSENTIAL_STORAGE_KEYS.includes(k)) {
|
||||
uni.removeStorageSync(k);
|
||||
removedCount++;
|
||||
}
|
||||
});
|
||||
|
||||
uni.clearStorageSync();
|
||||
// #ifdef MP-WEIXIN
|
||||
if (typeof uni.getSavedFileList === 'function') {
|
||||
uni.getSavedFileList({
|
||||
success: (fileRes) => {
|
||||
if (fileRes && Array.isArray(fileRes.fileList)) {
|
||||
fileRes.fileList.forEach((f) => {
|
||||
uni.removeSavedFile({ filePath: f.filePath, fail: () => {} });
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: () => {}
|
||||
});
|
||||
}
|
||||
// #endif
|
||||
|
||||
if (token) uni.setStorageSync('peiwan_token', token);
|
||||
if (userRole) uni.setStorageSync('peiwan_current_role', userRole);
|
||||
if (themeKey) uni.setStorageSync('app_theme_key', themeKey);
|
||||
if (hidePhone) uni.setStorageSync('privacy_hide_phone', hidePhone);
|
||||
if (noticeSub) uni.setStorageSync('notice_subscribe', noticeSub);
|
||||
if (userId) uni.setStorageSync('userId', userId);
|
||||
if (userInfo) uni.setStorageSync('userInfo', userInfo);
|
||||
const afterInfo = uni.getStorageInfoSync();
|
||||
uni.setStorageSync('cache_cleaned_snapshot_kb', Number(afterInfo.currentSize || 0));
|
||||
const finalInfo = uni.getStorageInfoSync();
|
||||
uni.setStorageSync('cache_cleaned_snapshot_kb', Number(finalInfo.currentSize || 0));
|
||||
|
||||
cacheSizeText.value = '0 KB';
|
||||
uni.showToast({
|
||||
title: '缓存清理完毕',
|
||||
title: removedCount > 0 ? `已清理 ${removedCount} 项临时缓存` : '缓存清理完毕 (0 KB)',
|
||||
icon: 'none'
|
||||
});
|
||||
} catch (_) {
|
||||
cacheSizeText.value = '0 KB';
|
||||
uni.showToast({
|
||||
title: '清理成功',
|
||||
title: '缓存清理完毕',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
@@ -306,11 +400,11 @@ const handleSwitchAccount = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// 退出登录
|
||||
// 退出登录(与个人中心退出逻辑完全同步)
|
||||
const handleLogout = () => {
|
||||
uni.showModal({
|
||||
title: '退出登录',
|
||||
content: '确定退出当前账号登录吗?',
|
||||
content: '退出登录后将清除本地会话,切换为未登录游客态。确定退出吗?',
|
||||
confirmText: '确认退出',
|
||||
cancelText: '取消',
|
||||
confirmColor: '#EF4444',
|
||||
@@ -319,9 +413,12 @@ const handleLogout = () => {
|
||||
uni.removeStorageSync('peiwan_token');
|
||||
uni.removeStorageSync('peiwan_current_role');
|
||||
uni.removeStorageSync('userInfo');
|
||||
uni.removeStorageSync('userId');
|
||||
uni.removeStorageSync('userToken');
|
||||
uni.setStorageSync('user_has_logged_out', '1');
|
||||
isLoggedIn.value = false;
|
||||
uni.showToast({
|
||||
title: '已退出登录',
|
||||
title: '已退出当前登录',
|
||||
icon: 'none'
|
||||
});
|
||||
setTimeout(() => {
|
||||
@@ -352,8 +449,9 @@ onShow(() => {
|
||||
navInfo.value = getNavBarInfo();
|
||||
privacyHidePhone.value = uni.getStorageSync('privacy_hide_phone') === '1';
|
||||
noticeSubscribe.value = uni.getStorageSync('notice_subscribe') !== '0';
|
||||
isLoggedIn.value = !!uni.getStorageSync('peiwan_token');
|
||||
isLoggedIn.value = checkIsLoggedIn();
|
||||
updateCacheSize();
|
||||
syncSettingsFromServer();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
在新工单中引用
屏蔽一个用户