|
|
@@ -32,7 +32,7 @@
|
|
|
|
|
|
</div>
|
|
|
<div class="personal-head-right">
|
|
|
- <div @click="dialogVisible = true" class="personal-head-right-li">
|
|
|
+ <div @click="changeSHow" class="personal-head-right-li">
|
|
|
<img src="/src/assets/imgs/my/bianji@2x.png" alt="">
|
|
|
<div class="">{{ $t('personalCenter.editProfile') }}</div>
|
|
|
</div>
|
|
|
@@ -206,7 +206,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- <el-dialog v-model="dialogVisible" :title="$t('personalCenter.editProfile')" width="784">
|
|
|
+ <el-dialog v-model="dialogVisible" :title="$t('personalCenter.editProfile')" width="784" :destroy-on-close="true">
|
|
|
<el-form ref="userFormRef" :model="userInfo" label-width="auto" label-position="top" :rules="rules">
|
|
|
<el-row :gutter="16">
|
|
|
<el-col :span="12">
|
|
|
@@ -409,7 +409,7 @@
|
|
|
</el-form>
|
|
|
<template #footer>
|
|
|
<div class="dialog-footer flex-center">
|
|
|
- <el-button @click="dialogVisible = false">{{ $t('common.cancel') }}</el-button>
|
|
|
+ <el-button @click="userInfo = {},dialogVisible = false">{{ $t('common.cancel') }}</el-button>
|
|
|
<el-button class="gradient" type="primary" @click="handleConfirm(userFormRef)">
|
|
|
{{ $t('common.confirm') }}
|
|
|
</el-button>
|
|
|
@@ -658,7 +658,8 @@ const emailCountdown = ref(0)
|
|
|
|
|
|
// 正则表达式
|
|
|
const PHONE_REGEX = /^1[3-9]\d{9}$/;
|
|
|
-const EMAIL_REGEX = /^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+$/;
|
|
|
+// 优化后的邮箱正则(兼顾准确性和实用性)
|
|
|
+const EMAIL_REGEX = /^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$/;
|
|
|
const isPasswordPhone = computed(() => {
|
|
|
return PHONE_REGEX.test(passwordForm.account);
|
|
|
});
|
|
|
@@ -684,17 +685,17 @@ const sendSmsCode = async () => {
|
|
|
}
|
|
|
|
|
|
// 验证手机号格式
|
|
|
- if (!PHONE_REGEX.test(account) && !EMAIL_REGEX.test(account)) {
|
|
|
+ if ((!PHONE_REGEX.test(account) && appStore?.userInfo?.email) || (!EMAIL_REGEX.test(account) && appStore?.userInfo?.userPhone)) {
|
|
|
DGTMessage.warning(appStore?.userInfo?.userPhone ? t('common.pleaseInputRightEmail') : t('common.pleaseInputRightPhoneNumber'))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
let res = null;
|
|
|
- if (PHONE_REGEX.test(account)) {
|
|
|
+ if (PHONE_REGEX.test(account) && appStore?.userInfo?.email) {
|
|
|
res = await getSmsCode({
|
|
|
phone: account
|
|
|
})
|
|
|
- } else if (EMAIL_REGEX.test(account)) {
|
|
|
+ } else if (EMAIL_REGEX.test(account) && appStore?.userInfo?.userPhone) {
|
|
|
res = await getEmailCode({
|
|
|
email: account
|
|
|
})
|
|
|
@@ -766,7 +767,7 @@ const handleConfirm = async (formEl) => {
|
|
|
if (!appStore.userInfo.userPhone || !appStore.userInfo.email) {
|
|
|
userInfo.value.bindType = appStore.userInfo.userPhone ? 'email' : 'phone'
|
|
|
}
|
|
|
- let obj = !appStore.userInfo.userPhone || !appStore.userInfo.email ? { email: userInfo.value.email, bindType: userInfo.value.bindType, userPhone: userInfo.value.userPhone, verifyCode: userInfo.value.verifyCode } : {}
|
|
|
+ let obj = !appStore.userInfo.userPhone && userInfo.value.userPhone || !appStore.userInfo.email && userInfo.value.email ? { email: userInfo.value.email, bindType: userInfo.value.bindType, userPhone: userInfo.value.userPhone, verifyCode: userInfo.value.verifyCode } : {}
|
|
|
let res = await updateUserInfo({
|
|
|
nickName: userInfo.value.nickName,
|
|
|
userAvatar: coverImage.value.map(item => item.url).join(';'),
|
|
|
@@ -803,6 +804,8 @@ const getInfo = async () => {
|
|
|
}
|
|
|
if (res?.user?.skillTags) {
|
|
|
dynamicTags.value = res.user.skillTags.split(',')
|
|
|
+ } else {
|
|
|
+ dynamicTags.value = []
|
|
|
}
|
|
|
userInfo.value = res.user;
|
|
|
navList.value.forEach(item => {
|
|
|
@@ -846,6 +849,11 @@ const getCount = async () => {
|
|
|
collectCount.value = res?.data?.collectCount;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+const changeSHow = () => {
|
|
|
+ getInfo()
|
|
|
+ dialogVisible.value = true;
|
|
|
+}
|
|
|
onMounted(() => {
|
|
|
getInfo()
|
|
|
getCount()
|