wujingjing
2025-01-10 cb8d6096461752e321dda968d39999f3c2f81183
src/layout/component/login/Login.vue
@@ -59,7 +59,8 @@
import { computed, reactive, ref } from 'vue';
import { PostLogin, loginMessageUser, loginVerifyMessage } from '/@/api/ai/user';
import { isLoginStatus, isShowLogin, userInfo } from '/@/stores/chatRoom';
import { LoginInfo } from '/@/utils/storage';
import { Local, LoginInfo } from '/@/utils/storage';
import { userInfoKey } from '/@/utils/request';
const handleClose = () => {
   isShowLogin.value = false;
@@ -102,11 +103,12 @@
});
//登录
const onSubmit = async () => {
   let res;
   if (state.activeLoginName === 'accountUser') {
      //账户密码登录
      const isValid = await loginFormRef.value.validate().catch(() => {});
      if (!isValid) return;
      const res = await PostLogin({
      res = await PostLogin({
         user: state.loginForm.account,
         pass: state.loginForm.pwd,
         client: LOGIN_CLIENT,
@@ -114,13 +116,22 @@
      if (!res.json_ok) {
         return ElMessage.error(res.json_msg);
      }
      userInfo.set(res);
      Local.set(userInfoKey, {
         id: res.id,
         realName: res.real_name,
         department: res.part,
         sex: res.sex,
         note: res.note,
         userName: res.name,
         phoneNumber: res.phone,
         email: res.email,
      } as any);
      LoginInfo.set(res.hswatersession, state.loginForm.account);
   } else if (state.activeLoginName === 'phoneUser') {
      //手机登录
      const isValid = await formPhoneRef.value.validate().catch(() => {});
      if (!isValid) return;
      const res = await loginMessageUser({
      res = await loginMessageUser({
         phone: state.loginPhoneForm.phoneUser,
         code: state.loginPhoneForm.verifyCode,
         client: LOGIN_CLIENT,
@@ -128,9 +139,19 @@
      if (!res.json_ok) {
         return ElMessage.error(res.json_msg);
      }
      Local.set(userInfoKey, {
         id: res.id,
         realName: res.real_name,
         department: res.part,
         sex: res.sex,
         note: res.note,
         userName: res.name,
         phoneNumber: res.phone,
         email: res.email,
      } as any);
      LoginInfo.set(res.hswatersession, state.loginPhoneForm.phoneUser);
      userInfo.set(res);
   }
   Local.set('isNewUser', !res?.web_login);
   isShowLogin.value = false;
   isLoginStatus.value = true;
   window.location.reload();