|
|
@@ -2,79 +2,76 @@
|
|
|
<el-drawer v-model="visible" :title="$t('personal.name')" size="40%">
|
|
|
<el-tabs style="height: 200px" class="demo-tabs">
|
|
|
<el-tab-pane label="基本信息" v-loading="loading">
|
|
|
- <template #label>
|
|
|
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
|
|
- <path stroke-linecap="round" stroke-linejoin="round" d="M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
|
|
|
- </svg>
|
|
|
- 基本信息
|
|
|
- </template>
|
|
|
+ <template #label>
|
|
|
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
|
|
+ <path
|
|
|
+ stroke-linecap="round"
|
|
|
+ stroke-linejoin="round"
|
|
|
+ d="M17.982 18.725A7.488 7.488 0 0 0 12 15.75a7.488 7.488 0 0 0-5.982 2.975m11.963 0a9 9 0 1 0-11.963 0m11.963 0A8.966 8.966 0 0 1 12 21a8.966 8.966 0 0 1-5.982-2.275M15 9.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"
|
|
|
+ />
|
|
|
+ </svg>
|
|
|
+ 基本信息
|
|
|
+ </template>
|
|
|
<el-form :model="formData" :rules="ruleForm" label-width="100px" class="mt30" ref="formdataRef">
|
|
|
<el-row :gutter="20">
|
|
|
- <el-col :span="24" class="mb20">
|
|
|
- <el-form-item prop="avatar">
|
|
|
- <ImageUpload v-model:imageUrl="formData.avatar" borderRadius="50%">
|
|
|
- <template #empty>
|
|
|
- <el-icon><Avatar /></el-icon>
|
|
|
- <span>请上传头像</span>
|
|
|
- </template>
|
|
|
- </ImageUpload>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="24" class="mb20">
|
|
|
- <el-form-item label="用户名" prop="username">
|
|
|
- <el-input v-model="formData.username" clearable disabled></el-input>
|
|
|
+ <el-col :span="24" class="mb20" v-if="formData?.appId">
|
|
|
+ <el-form-item label="商户号">
|
|
|
+ <el-input v-model="formData.appId" readonly></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="24" class="mb20">
|
|
|
- <el-form-item label="手机" prop="phone">
|
|
|
- <el-input v-model="formData.phone" placeholder="请输入手机" clearable></el-input>
|
|
|
+ <el-col :span="24" class="mb20" v-if="formData?.nickname">
|
|
|
+ <el-form-item label="昵称" prop="nickname">
|
|
|
+ <el-input v-model="formData.nickname" placeholder="请输入昵称" clearable readonly></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
-
|
|
|
- <el-col :span="24" class="mb20">
|
|
|
- <el-form-item label="邮箱" prop="email">
|
|
|
- <el-input v-model="formData.email" placeholder="请输入邮箱" clearable></el-input>
|
|
|
+ <el-col :span="24" class="mb20" v-if="formData?.name">
|
|
|
+ <el-form-item label="姓名" prop="name">
|
|
|
+ <el-input v-model="formData.name" placeholder="请输入姓名" clearable readonly></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="24" class="mb20">
|
|
|
- <el-form-item label="昵称" prop="nickname">
|
|
|
- <el-input v-model="formData.nickname" placeholder="请输入昵称" clearable></el-input>
|
|
|
+ <el-col :span="24" class="mb20" v-if="formData?.phone">
|
|
|
+ <el-form-item label="手机" prop="phone">
|
|
|
+ <el-input v-model="formData.phone" placeholder="请输入手机" clearable readonly></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="24" class="mb20">
|
|
|
- <el-form-item label="姓名" prop="name">
|
|
|
- <el-input v-model="formData.name" placeholder="请输入姓名" clearable></el-input>
|
|
|
+ <el-col :span="24" class="mb20" v-if="formData?.email">
|
|
|
+ <el-form-item label="邮箱" prop="email">
|
|
|
+ <el-input v-model="formData.email" placeholder="请输入邮箱" clearable readonly></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="24" class="mb20">
|
|
|
+ <!-- <el-col :span="24" class="mb20">
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" @click="handleSaveUser"> 更新个人信息 </el-button>
|
|
|
</el-form-item>
|
|
|
- </el-col>
|
|
|
+ </el-col> -->
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
</el-tab-pane>
|
|
|
<el-tab-pane label="安全信息">
|
|
|
- <template #label>
|
|
|
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
|
|
- <path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75m-3-7.036A11.959 11.959 0 0 1 3.598 6 11.99 11.99 0 0 0 3 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285Z" />
|
|
|
- </svg>
|
|
|
- 安全信息
|
|
|
- </template>
|
|
|
+ <template #label>
|
|
|
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
|
|
+ <path
|
|
|
+ stroke-linecap="round"
|
|
|
+ stroke-linejoin="round"
|
|
|
+ d="M9 12.75 11.25 15 15 9.75m-3-7.036A11.959 11.959 0 0 1 3.598 6 11.99 11.99 0 0 0 3 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285Z"
|
|
|
+ />
|
|
|
+ </svg>
|
|
|
+ 安全信息
|
|
|
+ </template>
|
|
|
<el-form :model="passwordFormData" :rules="passwordRuleForm" label-width="100px" class="mt30" ref="passwordFormdataRef">
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="24" class="mb20">
|
|
|
<el-form-item label="原密码" prop="password">
|
|
|
- <el-input v-model="passwordFormData.password" :type="showPassword ? 'text' : 'password'" placeholder="请输入密码" clearable type="password">
|
|
|
- <template #suffix>
|
|
|
- <i
|
|
|
- class="iconfont el-input__icon login-content-password"
|
|
|
- :class="showPassword ? 'icon-yincangmima' : 'icon-xianshimima'"
|
|
|
- @click="showPassword = !showPassword"
|
|
|
- >
|
|
|
- </i>
|
|
|
- </template>
|
|
|
- </el-input>
|
|
|
+ <el-input v-model="passwordFormData.password" :type="showPassword ? 'text' : 'password'" placeholder="请输入密码" clearable>
|
|
|
+ <template #suffix>
|
|
|
+ <i
|
|
|
+ class="iconfont el-input__icon login-content-password"
|
|
|
+ :class="showPassword ? 'icon-yincangmima' : 'icon-xianshimima'"
|
|
|
+ @click="showPassword = !showPassword"
|
|
|
+ >
|
|
|
+ </i>
|
|
|
+ </template>
|
|
|
+ </el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="mb20">
|
|
|
@@ -102,49 +99,23 @@
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
</el-tab-pane>
|
|
|
- <el-tab-pane label="第三方账号">
|
|
|
- <template #label>
|
|
|
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-4">
|
|
|
- <path stroke-linecap="round" stroke-linejoin="round" d="M7.864 4.243A7.5 7.5 0 0 1 19.5 10.5c0 2.92-.556 5.709-1.568 8.268M5.742 6.364A7.465 7.465 0 0 0 4.5 10.5a7.464 7.464 0 0 1-1.15 3.993m1.989 3.559A11.209 11.209 0 0 0 8.25 10.5a3.75 3.75 0 1 1 7.5 0c0 .527-.021 1.049-.064 1.565M12 10.5a14.94 14.94 0 0 1-3.6 9.75m6.633-4.596a18.666 18.666 0 0 1-2.485 5.33" />
|
|
|
- </svg>
|
|
|
-
|
|
|
- 社交登录
|
|
|
- </template>
|
|
|
- <el-table :data="socialList" class="mt10">
|
|
|
- <el-table-column type="index" label="序号" width="80"></el-table-column>
|
|
|
- <el-table-column prop="name" label="平台"></el-table-column>
|
|
|
- <el-table-column label="状态">
|
|
|
- <template #default="scope">
|
|
|
- <el-tag v-if="scope.row.openId"> 已绑定 </el-tag>
|
|
|
- <el-tag v-else> 未绑定 </el-tag>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column prop="action" label="操作">
|
|
|
- <template #default="scope">
|
|
|
- <el-button @click="unbinding(scope.row.type)" text type="primary" v-if="scope.row.openId"> 解绑 </el-button>
|
|
|
- <el-button @click="handleClick(scope.row.type)" text type="primary" v-else> 绑定 </el-button>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
- </el-tab-pane>
|
|
|
</el-tabs>
|
|
|
</el-drawer>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts" name="personal">
|
|
|
-import {useUserInfo} from '/@/stores/userInfo';
|
|
|
-import {editInfo, getObj, password, unbindingUser} from '/@/api/admin/user';
|
|
|
-import {useMessage} from '/@/hooks/message';
|
|
|
-import {rule, validateNull} from '/@/utils/validate';
|
|
|
+import { useUserInfo } from '/@/stores/userInfo';
|
|
|
+import { editInfo, password, unbindingUser } from '/@/api/admin/user';
|
|
|
+import { useMessage } from '/@/hooks/message';
|
|
|
+import { rule, validateNull } from '/@/utils/validate';
|
|
|
import other from '/@/utils/other';
|
|
|
-import {Session} from '/@/utils/storage';
|
|
|
-import {useI18n} from 'vue-i18n';
|
|
|
-import {getLoginAppList} from "/@/api/admin/social";
|
|
|
+import { Session } from '/@/utils/storage';
|
|
|
+import { useI18n } from 'vue-i18n';
|
|
|
+import { getLoginAppList } from '/@/api/admin/social';
|
|
|
import { SocialLoginEnum } from '/@/api/login';
|
|
|
|
|
|
const { t } = useI18n();
|
|
|
|
|
|
-const ImageUpload = defineAsyncComponent(() => import('/@/components/Upload/Image.vue'));
|
|
|
const StrengthMeter = defineAsyncComponent(() => import('/@/components/StrengthMeter/index.vue'));
|
|
|
|
|
|
const visible = ref(false);
|
|
|
@@ -153,13 +124,14 @@ const visible = ref(false);
|
|
|
const formData = ref({
|
|
|
userId: '',
|
|
|
username: '',
|
|
|
+ appId: '',
|
|
|
name: '',
|
|
|
email: '',
|
|
|
avatar: '',
|
|
|
nickname: '',
|
|
|
wxDingUserid: '',
|
|
|
wxCpUserid: '',
|
|
|
- phone: ('' as string) || undefined,
|
|
|
+ phone: '',
|
|
|
});
|
|
|
|
|
|
const showPassword = ref(false);
|
|
|
@@ -173,13 +145,10 @@ const formdataRef = ref();
|
|
|
const passwordFormdataRef = ref();
|
|
|
|
|
|
const ruleForm = reactive({
|
|
|
- phone: [
|
|
|
- { required: true, message: '手机号不能为空', trigger: 'blur' },
|
|
|
- { validator: rule.validatePhone, trigger: 'blur' },
|
|
|
- ],
|
|
|
- nickname: [{ validator: rule.overLength, trigger: 'blur' },{ required: true, message: '昵称不能为空', trigger: 'blur' }],
|
|
|
- email: [{ validator: rule.overLength, trigger: 'blur' },{ required: true, message: '邮箱不能为空', trigger: 'blur' }],
|
|
|
- name: [{ validator: rule.overLength, trigger: 'blur' },{ required: true, message: '姓名不能为空', trigger: 'blur' }],
|
|
|
+ phone: [{ validator: rule.validatePhone, trigger: 'blur' }],
|
|
|
+ nickname: [{ validator: rule.overLength, trigger: 'blur' }],
|
|
|
+ email: [{ validator: rule.overLength, trigger: 'blur' }],
|
|
|
+ name: [{ validator: rule.overLength, trigger: 'blur' }],
|
|
|
});
|
|
|
const validatorPassword2 = (rule: any, value: any, callback: any) => {
|
|
|
if (value !== passwordFormData.newpassword1) {
|
|
|
@@ -252,7 +221,7 @@ const handleSaveUser = () => {
|
|
|
}
|
|
|
|
|
|
if (formData.value.phone && formData.value.phone.includes('*')) {
|
|
|
- formData.value.phone = undefined;
|
|
|
+ formData.value.phone = '';
|
|
|
}
|
|
|
|
|
|
editInfo(formData.value)
|
|
|
@@ -318,31 +287,35 @@ const unbinding = (type: SocialLoginEnum) => {
|
|
|
useMessage().error(err.msg);
|
|
|
})
|
|
|
.finally(() => {
|
|
|
- initUserInfo(formData.value.userId);
|
|
|
+ // 重新获取用户信息
|
|
|
+ useUserInfo()
|
|
|
+ .setUserInfos()
|
|
|
+ .then(() => {
|
|
|
+ const data = useUserInfo().userInfos;
|
|
|
+ initUserInfo(data.user);
|
|
|
+ });
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const open = () => {
|
|
|
visible.value = true;
|
|
|
const data = useUserInfo().userInfos;
|
|
|
- initUserInfo(data.user.userId);
|
|
|
- // Object.assign(formData, data.user);
|
|
|
+ initUserInfo(data.user);
|
|
|
};
|
|
|
|
|
|
const loading = ref(false);
|
|
|
-const initUserInfo = (userId: any) => {
|
|
|
+const initUserInfo = (userData: any) => {
|
|
|
loading.value = true;
|
|
|
- getObj(userId)
|
|
|
- .then((res) => {
|
|
|
- formData.value = res.data;
|
|
|
- initSocialList();
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- useMessage().error(err.msg);
|
|
|
- })
|
|
|
- .finally(() => {
|
|
|
- loading.value = false;
|
|
|
- });
|
|
|
+ // 过滤掉 null 和 undefined 值
|
|
|
+ const filteredData: any = {};
|
|
|
+ Object.keys(userData).forEach((key) => {
|
|
|
+ if (userData[key] !== null && userData[key] !== undefined) {
|
|
|
+ filteredData[key] = userData[key];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ formData.value = filteredData;
|
|
|
+ initSocialList();
|
|
|
+ loading.value = false;
|
|
|
};
|
|
|
|
|
|
// 暴露变量
|