|
|
@@ -28,7 +28,103 @@
|
|
|
</div>
|
|
|
<div class="right">
|
|
|
<img class="user-icon" src="../assets/user.png" alt="" />
|
|
|
- <div class="user">{{ contactName }}</div>
|
|
|
+ <el-dropdown>
|
|
|
+ <span class="user">
|
|
|
+ {{ contactName }}
|
|
|
+ </span>
|
|
|
+ <template #dropdown>
|
|
|
+ <el-dropdown-menu>
|
|
|
+ <el-dropdown-item
|
|
|
+ @click="(changeModelVisible = true), (modelType = 'password')"
|
|
|
+ >
|
|
|
+ 修改密码
|
|
|
+ </el-dropdown-item>
|
|
|
+ <el-dropdown-item
|
|
|
+ @click="(changeModelVisible = true), (modelType = 'email')"
|
|
|
+ >
|
|
|
+ 修改邮箱
|
|
|
+ </el-dropdown-item>
|
|
|
+ </el-dropdown-menu>
|
|
|
+ </template>
|
|
|
+ </el-dropdown>
|
|
|
+ <el-dialog
|
|
|
+ v-model="changeModelVisible"
|
|
|
+ :title="modelType == 'email' ? '修改邮箱' : '修改密码'"
|
|
|
+ width="500px"
|
|
|
+ @close="reset()"
|
|
|
+ >
|
|
|
+ <el-form
|
|
|
+ ref="ruleFormRef"
|
|
|
+ :model="ruleForm"
|
|
|
+ :rules="rules"
|
|
|
+ label-width="120px"
|
|
|
+ >
|
|
|
+ <el-form-item label="当前邮箱">
|
|
|
+ {{ email }}
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="modelType == 'email'" label="新邮箱" prop="email">
|
|
|
+ <el-input
|
|
|
+ style="width: 300px"
|
|
|
+ v-model="ruleForm.email"
|
|
|
+ placeholder="请输入新邮箱"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ v-if="modelType == 'password'"
|
|
|
+ label="验证码"
|
|
|
+ prop="verificationCode"
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ style="width: 160px"
|
|
|
+ v-model="ruleForm.verificationCode"
|
|
|
+ placeholder="请输入验证码"
|
|
|
+ ></el-input>
|
|
|
+ <el-button
|
|
|
+ style="width: 120px"
|
|
|
+ class="ml20"
|
|
|
+ size="small"
|
|
|
+ type="primary"
|
|
|
+ @click="getCode"
|
|
|
+ :disabled="send"
|
|
|
+ :loading="send"
|
|
|
+ >
|
|
|
+ {{ send ? seconds + "秒后重发" : "获取验证码" }}
|
|
|
+ </el-button>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ v-if="modelType == 'password'"
|
|
|
+ label="新密码"
|
|
|
+ prop="newPassword"
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ style="width: 300px"
|
|
|
+ v-model="ruleForm.newPassword"
|
|
|
+ placeholder="请输入新密码"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ v-if="modelType == 'password'"
|
|
|
+ label="确认新密码"
|
|
|
+ prop="password2"
|
|
|
+ >
|
|
|
+ <el-input
|
|
|
+ style="width: 300px"
|
|
|
+ v-model="ruleForm.password2"
|
|
|
+ placeholder="请确认新密码"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div class="df aic jcc">
|
|
|
+ <el-button
|
|
|
+ class="mr20"
|
|
|
+ type="primary"
|
|
|
+ @click="changeModelVisible = false"
|
|
|
+ >
|
|
|
+ 取消
|
|
|
+ </el-button>
|
|
|
+ <el-button type="primary" @click="submitForm()">确定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
<el-popover placement="bottom" trigger="hover" :width="280">
|
|
|
<div
|
|
|
style="
|
|
|
@@ -75,6 +171,10 @@ import store from "../store";
|
|
|
import router from "../router";
|
|
|
import { onMounted, ref } from "vue";
|
|
|
import { AnonymousLogin, tcb } from "../apis/cloudLogin";
|
|
|
+import { ElMessage, ElNotification } from "element-plus";
|
|
|
+import api from "../apis/fetch";
|
|
|
+import md5 from "md5";
|
|
|
+
|
|
|
const db = tcb.database();
|
|
|
const v = db.collection("huihenduo_versions");
|
|
|
const __ = db.command;
|
|
|
@@ -111,6 +211,112 @@ async function cloudLogin() {
|
|
|
getAbledVersions();
|
|
|
}
|
|
|
|
|
|
+let changeModelVisible = ref(false);
|
|
|
+const email = localStorage.email;
|
|
|
+const ruleFormRef = ref(null);
|
|
|
+const ruleForm = ref({
|
|
|
+ email: "",
|
|
|
+ verificationCode: "",
|
|
|
+ newPassword: "",
|
|
|
+});
|
|
|
+const rules = {
|
|
|
+ email: [
|
|
|
+ { required: true, message: "请输入邮箱地址", trigger: "blur" },
|
|
|
+ {
|
|
|
+ type: "email",
|
|
|
+ message: "请输入正确的邮箱地址",
|
|
|
+ trigger: ["blur", "change"],
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ newPassword: [{ required: true, message: "请输入密码", trigger: "blur" }],
|
|
|
+ password2: [{ required: true, message: "请输入密码", trigger: "blur" }],
|
|
|
+ verificationCode: [
|
|
|
+ { required: true, message: "请输入验证码", trigger: "blur" },
|
|
|
+ ],
|
|
|
+};
|
|
|
+function submitForm() {
|
|
|
+ ruleFormRef.value.validate(async (valid) => {
|
|
|
+ if (valid) {
|
|
|
+ if (modelType.value == "email") {
|
|
|
+ let { data } = await api.changeSubAccountEmail({
|
|
|
+ email: ruleForm.value.email,
|
|
|
+ });
|
|
|
+ if (data.status === 0) {
|
|
|
+ ElNotification({
|
|
|
+ title: "提示",
|
|
|
+ message: "重置成功!",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ changeModelVisible.value = false;
|
|
|
+ } else {
|
|
|
+ ElMessage({
|
|
|
+ title: "提示",
|
|
|
+ message: data.msg,
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else if (modelType.value == "password") {
|
|
|
+ if (ruleForm.value.newPassword !== ruleForm.value.password2) {
|
|
|
+ ElMessage({
|
|
|
+ title: "提示",
|
|
|
+ message: "两次密码不一致",
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let { data } = await api.changePassword({
|
|
|
+ verificationCode: ruleForm.value.verificationCode,
|
|
|
+ newPassword: md5(md5(ruleForm.value.newPassword)),
|
|
|
+ });
|
|
|
+ if (data.status === 0) {
|
|
|
+ ElNotification({
|
|
|
+ title: "提示",
|
|
|
+ message: data.msg,
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ changeModelVisible.value = false;
|
|
|
+
|
|
|
+ quit();
|
|
|
+ } else {
|
|
|
+ ElMessage({
|
|
|
+ title: "提示",
|
|
|
+ message: data.msg,
|
|
|
+ type: "warning",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+function reset() {
|
|
|
+ ruleForm.value = {};
|
|
|
+}
|
|
|
+const modelType = ref("");
|
|
|
+
|
|
|
+const send = ref(false);
|
|
|
+const seconds = ref(10);
|
|
|
+async function getCode() {
|
|
|
+ send.value = true;
|
|
|
+ let { data } = await api.sendEmailVerifyCode({
|
|
|
+ email: localStorage.email,
|
|
|
+ verificationType: 2,
|
|
|
+ });
|
|
|
+ if (data.status === 0) {
|
|
|
+ ElMessage({
|
|
|
+ title: "提示",
|
|
|
+ message: "验证码已发送,请注意查收",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ let timer = setInterval(() => {
|
|
|
+ seconds.value--;
|
|
|
+ if (seconds.value <= 0) {
|
|
|
+ clearInterval(timer);
|
|
|
+ send.value = false;
|
|
|
+ seconds.value = 10;
|
|
|
+ }
|
|
|
+ }, 1000);
|
|
|
+ }
|
|
|
+}
|
|
|
onMounted(() => {
|
|
|
cloudLogin();
|
|
|
// logoUrl.value = localStorage.logoUrl || "../assets/white-logo.png";
|