Ver Fonte

新增 登录验证设置邮箱

wzg há 1 ano atrás
pai
commit
4b3840386d
1 ficheiros alterados com 86 adições e 3 exclusões
  1. 86 3
      src/views/index/Login.vue

+ 86 - 3
src/views/index/Login.vue

@@ -85,7 +85,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>
@@ -93,7 +124,7 @@
 </template>
 <script setup>
 import { ref, reactive, toRefs, computed, onMounted } from "vue";
-import { ElNotification } from "element-plus";
+import { ElNotification, ElMessage } from "element-plus";
 import store from "../../store";
 import router from "../../router";
 
@@ -222,6 +253,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: "失败",
@@ -243,7 +284,6 @@ function login() {
         localStorage.setItem("contactName", contactName);
         localStorage.setItem("userType", 1);
         localStorage.setItem("email", email);
-        localStorage.setItem("loginAccountId", loginAccountId);
         localStorage.setItem(
           "logoUrl",
           cargoOwners.value[currentCompanyLevelTwo.value]?.logoUrl || ""
@@ -297,6 +337,49 @@ function getLevel2domain() {
   }
   console.log(currentCompanyLevelTwo.value);
 }
+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 = {};
+}
 
 onMounted(() => {
   getLevel2domain();