| | |
| | | <script setup lang="ts"> |
| | | import { ElMessage, type FormInstance } from 'element-plus'; |
| | | import { computed, reactive, ref } from 'vue'; |
| | | import { PostLogin, loginMessageUser, loginVerifyMessage } from '/@/api/ai/user'; |
| | | import { isLoginStatus, isShowLogin, userInfo } from '/@/stores/chatRoom'; |
| | | import { Local, LoginInfo } from '/@/utils/storage'; |
| | | import { userInfoKey } from '/@/utils/request'; |
| | | import { ACCOUNT_EXPIRE_DAY, handleAfterLogin, LOGIN_CLIENT, STORED_ACCOUNT_KEY } from './login'; |
| | | import { loginMessageUser, loginVerifyMessage, PostLogin } from '/@/api/ai/user'; |
| | | import { isShowLogin } from '/@/stores/chatRoom'; |
| | | import { encrypt } from '/@/utils/cypto'; |
| | | import { LocalPlus } from '/@/utils/storage'; |
| | | |
| | | const handleClose = () => { |
| | | isShowLogin.value = false; |
| | |
| | | ], |
| | | verifyCode: [{ required: true, message: '请输入验证码', trigger: 'blur' }], |
| | | }; |
| | | const LOGIN_CLIENT = 'Web端'; |
| | | const loginFormRef = ref<FormInstance>(null); //账户密码登录 |
| | | const formPhoneRef = ref(); //手机号登录 |
| | | const hasSended = computed(() => { |
| | |
| | | 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.loginForm.account); |
| | | } else if (state.activeLoginName === 'phoneUser') { |
| | | //手机登录 |
| | | const isValid = await formPhoneRef.value.validate().catch(() => {}); |
| | |
| | | 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); |
| | | } |
| | | Local.set('isNewUser', !res?.web_login); |
| | | isShowLogin.value = false; |
| | | isLoginStatus.value = true; |
| | | window.location.reload(); |
| | | |
| | | if (state.activeLoginName === 'accountUser') { |
| | | const accountEncryptStr = encrypt({ |
| | | username: state.loginForm.account, |
| | | password: state.loginForm.pwd, |
| | | }); |
| | | LocalPlus.set(STORED_ACCOUNT_KEY, accountEncryptStr, ACCOUNT_EXPIRE_DAY); |
| | | } |
| | | handleAfterLogin(res); |
| | | }; |
| | | const countdown = ref(null); |
| | | |