refactor(用户资料): 重构个人资料设置流程和头像处理

将自动跳转个人资料页的逻辑移除,改为在个人中心显示设置按钮
优化头像处理逻辑,移除默认头像并添加空值检查
调整用户信息展示样式,添加个人资料设置按钮
实现防连点机制保护敏感操作
This commit is contained in:
dzq 2025-12-05 10:20:54 +08:00
parent a1e4a46656
commit d212815281
3 changed files with 67 additions and 27 deletions

View File

@ -101,16 +101,6 @@ onLoad(async (query) => {
console.error('用户登录处理失败:', error);
}
//
// ab98UserId profileDone
if (wxUserDTO.value && !wxUserDTO.value.ab98UserId && wxUserDTO.value.profileDone !== true) {
console.log('用户需要完善资料,跳转到个人资料设置页面');
uni.navigateTo({
url: '/pages/profile/index'
});
return; //
}
//
if (showShopList.value) {
try {

View File

@ -30,27 +30,50 @@ const name = computed(() => {
return userName.value || qyName.value || '未知用户'
})
const userAvatar = computed(() => face_img.value ? toHttpsUrl(face_img.value) :
const userAvatar = computed(() => face_img.value ? toHttpsUrl(face_img.value) :
wxUserDTO.value?.avatar ? toHttpsUrl(wxUserDTO.value.avatar) : '/static/favicon.ico')
const showProfileSetupButton = computed(() => {
return wxUserDTO.value && !wxUserDTO.value.ab98UserId && wxUserDTO.value.profileDone !== true
})
//
const dynamicCodeActionSheet = ref<boolean>(false)
const dynamicCodeData = ref<DynamicCodeResponse | null>(null)
const toast = useToast()
// wx
const wxParamsActionSheet = ref<boolean>(false)
const ab98BalanceInYuan = computed(() => {
if (ab98User.value && ab98User.value.ab98Balance !== undefined) {
return (ab98User.value.ab98Balance / 100).toFixed(2)
}
return '0.00'
})
const wxParamsActionSheet = ref<boolean>(false);
//
const clickTimestamps = ref<number[]>([]);
// wx
const handleShowWxParams = () => {
wxParamsActionSheet.value = true
const now = Date.now();
const timestamps = clickTimestamps.value;
// 3
const threeSecondsAgo = now - 3000;
const validTimestamps = timestamps.filter(timestamp => timestamp >= threeSecondsAgo);
//
if (validTimestamps.length > 0) {
const lastTimestamp = validTimestamps[validTimestamps.length - 1];
const interval = now - lastTimestamp;
if (interval < 100) {
// 100
return;
}
}
//
validTimestamps.push(now);
clickTimestamps.value = validTimestamps;
// 5
if (clickTimestamps.value.length >= 5) {
wxParamsActionSheet.value = true; //
clickTimestamps.value = []; //
}
}
//
@ -78,7 +101,7 @@ const navigateToPage = (pagePath: string, options: { type?: 'navigateTo' | 'swit
}
onMounted(() => {
wxStore.refreshBalance()
wxStore.refreshBalance();
});
onShow(async () => {
@ -117,13 +140,23 @@ const handleGenerateDynamicCode = async () => {
<view class="avatar-wrapper">
<image
class="avatar"
:src="wxUserDTO?.ab98FaceImg || wxUserDTO?.avatar || '/static/favicon.ico'"
:src="toHttpsUrl(wxUserDTO?.ab98FaceImg || wxUserDTO?.avatar || '')"
mode="aspectFill"
@click="handleShowWxParams"
/>
</view>
<view class="user-details">
<view class="user-name">{{ wxUserDTO?.ab98Name || wxUserDTO?.nickName }}</view>
<view v-if="showProfileSetupButton" class="profile-setup-button">
<wd-button
size="small"
type="primary"
plain
@click="navigateToPage('/pages/profile/index')"
>
设置个人资料
</wd-button>
</view>
</view>
</view>
@ -321,6 +354,17 @@ const handleGenerateDynamicCode = async () => {
font-weight: 600;
color: #1a1a1a;
letter-spacing: 0.5px;
margin-bottom: 8px;
}
.profile-setup-button {
margin-top: 8px;
:deep(.wd-button) {
--wot-button-small-height: 28px;
--wot-button-small-padding: 0 12px;
--wot-button-small-font-size: 12px;
}
}
}
}

View File

@ -29,7 +29,7 @@ const nickName = ref('')
//
onMounted(() => {
// 使使
/* // 优先使用微信用户信息其次使用企业用户信
if (wxUserDTO.value) {
avatarUrl.value = wxUserDTO.value.avatar || ''
nickName.value = wxUserDTO.value.nickName || ''
@ -47,8 +47,8 @@ onMounted(() => {
//
if (!avatarUrl.value) {
avatarUrl.value = '/static/favicon.ico'
}
avatarUrl.value = ''
} */
})
//
@ -198,7 +198,12 @@ const handleSubmit = async () => {
}
// 使
const finalAvatarPath = tempAvatarPath.value || avatarUrl.value
const finalAvatarPath = tempAvatarPath.value || avatarUrl.value;
if (!finalAvatarPath) {
toast.show('请选择头像')
return
}
loading.value = true
try {
@ -391,6 +396,7 @@ const handleSubmit = async () => {
font-size: 16px;
color: #1a1a1a;
margin-bottom: 12px;
box-sizing: border-box;
&:focus {
border-color: #409EFF;