登录
This commit is contained in:
@ -522,6 +522,12 @@ function reset() {
|
||||
const emit = defineEmits(['submit']);
|
||||
</script>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'PuzzleVerification',
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.vue-puzzle-vcode {
|
||||
position: fixed;
|
||||
|
||||
@ -121,7 +121,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import PuzzleVerification from './components/PuzzleVerification.vue';
|
||||
import { fetchLoginCaptCha, fetchAuthorizationsCaptcha } from '@/api/all/login';
|
||||
import { fetchLoginCaptCha, fetchAuthorizationsCaptcha, fetchProfileInfo } from '@/api/all/login';
|
||||
import { ref, reactive, onUnmounted, computed } from 'vue';
|
||||
import { useUserStore } from '@/stores';
|
||||
import { handleUserLogin } from '@/utils/user';
|
||||
@ -137,10 +137,10 @@ const visible = ref(false);
|
||||
const hasGetCode = ref(false);
|
||||
const submitting = ref(false);
|
||||
const hasCheck = ref(false);
|
||||
const mobileNumber = ref('13616544933');
|
||||
const mobileNumber = ref('');
|
||||
const selectedAccount = ref(0);
|
||||
|
||||
const accounts = ref([{ name: '灵机用户291094' }, { name: '灵机用户291094' }]);
|
||||
const accounts = ref([]);
|
||||
|
||||
const loginForm = reactive({
|
||||
mobile: '',
|
||||
@ -213,6 +213,7 @@ const clearError = (field: string) => {
|
||||
|
||||
const handleOk = () => {
|
||||
visible.value = false;
|
||||
handleUserLogin();
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
@ -254,6 +255,27 @@ const handleVerificationSubmit = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 获取用户信息
|
||||
const getProfileInfo = async () => {
|
||||
const { code, data } = await fetchProfileInfo();
|
||||
if (code === 200) {
|
||||
userStore.setUserInfo(data);
|
||||
let enterprises = data['enterprises'];
|
||||
mobileNumber.value = data['mobile'];
|
||||
accounts.value = enterprises;
|
||||
if (enterprises.length > 0) {
|
||||
if (enterprises.length == 1) {
|
||||
let enterprise = enterprises[0];
|
||||
userStore.setCompanyInfo(enterprise);
|
||||
handleUserLogin();
|
||||
} else {
|
||||
// 多个企业时候需要弹窗让用户选择企业
|
||||
visible.value = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 提交表单
|
||||
const handleSubmit = async () => {
|
||||
if (disabledSubmitBtn.value) return;
|
||||
@ -268,15 +290,13 @@ const handleSubmit = async () => {
|
||||
}
|
||||
|
||||
submitting.value = true;
|
||||
|
||||
const { code, data } = await fetchAuthorizationsCaptcha(loginForm);
|
||||
|
||||
if (code === 200) {
|
||||
// 处理登录成功逻辑
|
||||
AMessage.success(isLogin.value ? '登录成功' : '注册成功');
|
||||
userStore.setToken(data.access_token);
|
||||
|
||||
handleUserLogin();
|
||||
getProfileInfo();
|
||||
}
|
||||
} catch (error) {
|
||||
// 错误信息会显示在输入框下方
|
||||
|
||||
Reference in New Issue
Block a user