Procházet zdrojové kódy

新增 登录验证设置邮箱

wzg před 1 rokem
rodič
revize
494d85b0ae
1 změnil soubory, kde provedl 88 přidání a 4 odebrání
  1. 88 4
      src/views/index/Login.vue

+ 88 - 4
src/views/index/Login.vue

@@ -79,7 +79,38 @@
         </div>
       </div>
     </div>
-
+    <el-dialog
+      v-model="changeModelVisible"
+      title="设置邮箱"
+      width="500px"
+      @close="reset()"
+    >
+      <el-form
+        ref="ruleFormRef"
+        :model="ruleForm2"
+        :rules="rules2"
+        label-width="120px"
+      >
+        <el-form-item label="当前邮箱">未设置邮箱</el-form-item>
+        <el-form-item label="新邮箱" prop="email">
+          <el-input
+            style="width: 300px"
+            v-model="ruleForm2.email"
+            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>
     <div @click="goBeian" class="copyright">
       Copyright © 2022 汇很多(江苏)科技有限公司 苏ICP备2022023253号-1 号
     </div>
@@ -87,7 +118,7 @@
 </template>
 <script setup>
 import { ref, reactive, toRefs, computed } from "vue";
-import { ElNotification } from "element-plus";
+import { ElNotification, ElMessage } from "element-plus";
 import store from "../../store";
 import router from "../../router";
 
@@ -107,7 +138,7 @@ const rules = ref({
   ],
   password: [
     { required: true, message: "请输入密码", trigger: "blur" },
-    { min: 6, max: 20, message: "请正确输入手机号", trigger: "blur" },
+    { min: 6, max: 20, message: "密码长度为6-20", trigger: "blur" },
   ],
 });
 function check() {
@@ -133,6 +164,16 @@ function login() {
           rolePermission,
           email,
         } = res.data.result;
+        localStorage.setItem("loginAccountId", loginAccountId);
+        if (!email) {
+          ElNotification.warning({
+            title: "提示",
+            duration: 2000,
+            message: "请先设置邮箱",
+          });
+          changeModelVisible.value = true;
+          return;
+        }
         if (!rolePermission.length) {
           ElNotification.error({
             title: "失败",
@@ -154,7 +195,6 @@ function login() {
         localStorage.setItem("contactName", contactName);
         localStorage.setItem("userType", 1);
         localStorage.setItem("email", email);
-        localStorage.setItem("loginAccountId", loginAccountId);
         rolePermission = rolePermission || [];
         let arr = [...new Set([...rolePermission])];
         localStorage.setItem("rolePermission", arr);
@@ -183,6 +223,50 @@ function login() {
 function goBeian() {
   window.open("https://beian.miit.gov.cn/");
 }
+
+let changeModelVisible = ref(false);
+const email = localStorage.email;
+const ruleFormRef = ref(null);
+const ruleForm2 = ref({
+  email: "",
+});
+const rules2 = {
+  email: [
+    { required: true, message: "请输入邮箱地址", trigger: "blur" },
+    {
+      type: "email",
+      message: "请输入正确的邮箱地址",
+      trigger: ["blur", "change"],
+    },
+  ],
+};
+function submitForm() {
+  ruleFormRef.value.validate(async (valid) => {
+    if (valid) {
+      let { data } = await api.changeSubAccountEmail({
+        email: ruleForm2.value.email,
+      });
+      if (data.status === 0) {
+        ElNotification({
+          title: "提示",
+          message: "重置成功,请重新登录!",
+          type: "success",
+        });
+        changeModelVisible.value = false;
+      } else {
+        ElMessage({
+          title: "提示",
+          message: data.msg,
+          type: "warning",
+        });
+      }
+    }
+  });
+}
+
+function reset() {
+  ruleForm2.value = {};
+}
 </script>
 <style scoped>
 .container {