|
|
|
|
@ -1,344 +1,349 @@
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { computed, onMounted, reactive, ref } from "vue";
|
|
|
|
|
import { useRoute, useRouter } from "vue-router";
|
|
|
|
|
import { useMessage } from "naive-ui";
|
|
|
|
|
import { computed, onMounted, reactive, ref } from 'vue'
|
|
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
|
|
import { useMessage } from 'naive-ui'
|
|
|
|
|
|
|
|
|
|
// import captcha from './captcha.vue'
|
|
|
|
|
import { PageEnum } from "@/enums/pageEnum";
|
|
|
|
|
import { useUserStore } from "@/store/modules/user";
|
|
|
|
|
import { ResultEnum } from "@/enums/httpEnum";
|
|
|
|
|
import { getCode, smsLogin } from "@/api/login/login";
|
|
|
|
|
import SvgIcon from "@/components/Icon/SvgIcon.vue";
|
|
|
|
|
import { PageEnum } from '@/enums/pageEnum'
|
|
|
|
|
import { useUserStore } from '@/store/modules/user'
|
|
|
|
|
import { ResultEnum } from '@/enums/httpEnum'
|
|
|
|
|
import { getCode, smsLogin } from '@/api/login/login'
|
|
|
|
|
import SvgIcon from '@/components/Icon/SvgIcon.vue'
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits(["close", "forget"]);
|
|
|
|
|
const emit = defineEmits(['close', 'forget'])
|
|
|
|
|
interface FormState {
|
|
|
|
|
enterprisecode?: string;
|
|
|
|
|
username: string;
|
|
|
|
|
password: string;
|
|
|
|
|
enterprisecode?: string
|
|
|
|
|
username: string
|
|
|
|
|
password: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface FormSms {
|
|
|
|
|
agentcode: string;
|
|
|
|
|
phone: string;
|
|
|
|
|
phonecode: string;
|
|
|
|
|
agentcode: string
|
|
|
|
|
phone: string
|
|
|
|
|
phonecode: string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const formRef = ref();
|
|
|
|
|
const formRefSms = ref();
|
|
|
|
|
const message = useMessage();
|
|
|
|
|
const loading = ref(false);
|
|
|
|
|
const autoLogin = ref(false);
|
|
|
|
|
const LOGIN_NAME = PageEnum.BASE_LOGIN_NAME;
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const route = useRoute();
|
|
|
|
|
const show = ref(false);
|
|
|
|
|
const flag = ref(true);
|
|
|
|
|
const loginSuccess = ref(true);
|
|
|
|
|
const loginRejectMessge = ref("");
|
|
|
|
|
|
|
|
|
|
let formInline: FormState = reactive({
|
|
|
|
|
const formRef = ref()
|
|
|
|
|
const formRefSms = ref()
|
|
|
|
|
const message = useMessage()
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
const autoLogin = ref(false)
|
|
|
|
|
const LOGIN_NAME = PageEnum.BASE_LOGIN_NAME
|
|
|
|
|
const userStore = useUserStore()
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
const route = useRoute()
|
|
|
|
|
const show = ref(false)
|
|
|
|
|
const flag = ref(true)
|
|
|
|
|
const loginSuccess = ref(true)
|
|
|
|
|
const loginRejectMessge = ref('')
|
|
|
|
|
|
|
|
|
|
const formInline: FormState = reactive({
|
|
|
|
|
// enterprisecode: "演示公司",
|
|
|
|
|
// username: "yanshi01",
|
|
|
|
|
// password: "123456",
|
|
|
|
|
enterprisecode: "",
|
|
|
|
|
username: "",
|
|
|
|
|
password: "",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let formSms: FormSms = reactive({
|
|
|
|
|
agentcode: "",
|
|
|
|
|
phone: "",
|
|
|
|
|
phonecode: "",
|
|
|
|
|
});
|
|
|
|
|
const tab = ref(0);
|
|
|
|
|
const countTime = ref("获取验证码");
|
|
|
|
|
enterprisecode: '',
|
|
|
|
|
username: '',
|
|
|
|
|
password: '',
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const formSms: FormSms = reactive({
|
|
|
|
|
agentcode: '',
|
|
|
|
|
phone: '',
|
|
|
|
|
phonecode: '',
|
|
|
|
|
})
|
|
|
|
|
const tab = ref(0)
|
|
|
|
|
const countTime = ref('获取验证码')
|
|
|
|
|
const rules = {
|
|
|
|
|
enterprisecode: [
|
|
|
|
|
{ required: true, message: "请输入企业编码", trigger: "blur" },
|
|
|
|
|
{ required: true, message: '请输入企业编码', trigger: 'blur' },
|
|
|
|
|
{
|
|
|
|
|
trigger: ["blur", "input", "change"],
|
|
|
|
|
level: "error",
|
|
|
|
|
trigger: ['blur', 'input', 'change'],
|
|
|
|
|
level: 'error',
|
|
|
|
|
validator(_rule, value) {
|
|
|
|
|
if (loginSuccess.value || !value) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (loginRejectMessge.value.indexOf("企业") > -1) {
|
|
|
|
|
return new Error(loginRejectMessge.value);
|
|
|
|
|
}
|
|
|
|
|
if (loginSuccess.value || !value)
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
if (loginRejectMessge.value.includes('企业'))
|
|
|
|
|
return new Error(loginRejectMessge.value)
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
agentcode: [
|
|
|
|
|
{ required: true, message: "请输入验证码", trigger: "blur" },
|
|
|
|
|
{ required: true, message: '请输入验证码', trigger: 'blur' },
|
|
|
|
|
{
|
|
|
|
|
trigger: ["blur", "input", "change"],
|
|
|
|
|
level: "error",
|
|
|
|
|
trigger: ['blur', 'input', 'change'],
|
|
|
|
|
level: 'error',
|
|
|
|
|
validator(_rule, value) {
|
|
|
|
|
if (loginSuccess.value || !value) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (loginRejectMessge.value.indexOf("验证码") > -1) {
|
|
|
|
|
return new Error(loginRejectMessge.value);
|
|
|
|
|
}
|
|
|
|
|
if (loginSuccess.value || !value)
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
if (loginRejectMessge.value.includes('验证码'))
|
|
|
|
|
return new Error(loginRejectMessge.value)
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
phone: [
|
|
|
|
|
{ required: true, message: "请输入手机号", trigger: "blur" },
|
|
|
|
|
{ required: true, message: '请输入手机号', trigger: 'blur' },
|
|
|
|
|
{
|
|
|
|
|
trigger: ["blur", "input", "change"],
|
|
|
|
|
level: "error",
|
|
|
|
|
trigger: ['blur', 'input', 'change'],
|
|
|
|
|
level: 'error',
|
|
|
|
|
validator(_rule, value) {
|
|
|
|
|
if (loginSuccess.value || !value) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (loginRejectMessge.value.indexOf("手机号") > -1) {
|
|
|
|
|
return new Error(loginRejectMessge.value);
|
|
|
|
|
}
|
|
|
|
|
if (loginSuccess.value || !value)
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
if (loginRejectMessge.value.includes('手机号'))
|
|
|
|
|
return new Error(loginRejectMessge.value)
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
phonecode: [
|
|
|
|
|
{ required: true, message: "请输入验证码", trigger: "blur" },
|
|
|
|
|
{ required: true, message: '请输入验证码', trigger: 'blur' },
|
|
|
|
|
{
|
|
|
|
|
trigger: ["blur", "input", "change"],
|
|
|
|
|
level: "error",
|
|
|
|
|
trigger: ['blur', 'input', 'change'],
|
|
|
|
|
level: 'error',
|
|
|
|
|
validator(_rule, value) {
|
|
|
|
|
if (value.length < 4 && value.length > 0) {
|
|
|
|
|
return new Error("请正确填写4位手机短信验证码");
|
|
|
|
|
}
|
|
|
|
|
if (loginSuccess.value || !value) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (loginRejectMessge.value.indexOf("验证码") > -1) {
|
|
|
|
|
return new Error(loginRejectMessge.value);
|
|
|
|
|
}
|
|
|
|
|
if (value.length < 4 && value.length > 0)
|
|
|
|
|
return new Error('请正确填写4位手机短信验证码')
|
|
|
|
|
|
|
|
|
|
if (loginSuccess.value || !value)
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
if (loginRejectMessge.value.includes('验证码'))
|
|
|
|
|
return new Error(loginRejectMessge.value)
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
username: [
|
|
|
|
|
{ required: true, message: "请输入账号", trigger: "blur" },
|
|
|
|
|
{ required: true, message: '请输入账号', trigger: 'blur' },
|
|
|
|
|
{
|
|
|
|
|
trigger: ["blur", "input", "change"],
|
|
|
|
|
level: "error",
|
|
|
|
|
trigger: ['blur', 'input', 'change'],
|
|
|
|
|
level: 'error',
|
|
|
|
|
validator(_rule, value) {
|
|
|
|
|
if (loginSuccess.value || !value) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (loginRejectMessge.value.indexOf("账号") > -1) {
|
|
|
|
|
return new Error(loginRejectMessge.value);
|
|
|
|
|
}
|
|
|
|
|
if (loginSuccess.value || !value)
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
if (loginRejectMessge.value.includes('账号'))
|
|
|
|
|
return new Error(loginRejectMessge.value)
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
password: [
|
|
|
|
|
{ required: true, message: "请输入密码", trigger: "blur" },
|
|
|
|
|
{ required: true, message: '请输入密码', trigger: 'blur' },
|
|
|
|
|
{
|
|
|
|
|
trigger: ["blur", "input", "change"],
|
|
|
|
|
level: "error",
|
|
|
|
|
trigger: ['blur', 'input', 'change'],
|
|
|
|
|
level: 'error',
|
|
|
|
|
validator(_rule, value) {
|
|
|
|
|
if (loginSuccess.value || !value) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (loginRejectMessge.value.indexOf("密码") > -1) {
|
|
|
|
|
return new Error(loginRejectMessge.value);
|
|
|
|
|
}
|
|
|
|
|
if (loginSuccess.value || !value)
|
|
|
|
|
return true
|
|
|
|
|
|
|
|
|
|
if (loginRejectMessge.value.includes('密码'))
|
|
|
|
|
return new Error(loginRejectMessge.value)
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
captcha: [{ required: true, message: "请输入验证码", trigger: "blur" }],
|
|
|
|
|
};
|
|
|
|
|
captcha: [{ required: true, message: '请输入验证码', trigger: 'blur' }],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleSubmit(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
loginSuccess.value = true;
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
loginSuccess.value = true
|
|
|
|
|
formRef.value.validate(async (errors) => {
|
|
|
|
|
if (!errors) {
|
|
|
|
|
const { username, password, enterprisecode } = formInline;
|
|
|
|
|
message.loading("登录中...");
|
|
|
|
|
loading.value = true;
|
|
|
|
|
const { username, password, enterprisecode } = formInline
|
|
|
|
|
message.loading('登录中...')
|
|
|
|
|
loading.value = true
|
|
|
|
|
const params = {
|
|
|
|
|
username,
|
|
|
|
|
password,
|
|
|
|
|
codetoken: userStore.getCapToken,
|
|
|
|
|
agentcode: enterprisecode,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
const { code, message: msg } = await userStore.login(params);
|
|
|
|
|
loginRejectMessge.value = msg;
|
|
|
|
|
const { code, message: msg } = await userStore.login(params)
|
|
|
|
|
loginRejectMessge.value = msg
|
|
|
|
|
if (code === ResultEnum.SUCCESS) {
|
|
|
|
|
// 是否保存账号
|
|
|
|
|
if (autoLogin.value) {
|
|
|
|
|
localStorage.setItem("LOGIN_FORM_PASS", JSON.stringify(formInline));
|
|
|
|
|
} else {
|
|
|
|
|
localStorage.removeItem("LOGIN_FORM_PASS");
|
|
|
|
|
}
|
|
|
|
|
loginSuccess.value = true;
|
|
|
|
|
const { data: userInfo } = await userStore.getInformation();
|
|
|
|
|
message.destroyAll();
|
|
|
|
|
const toPath = decodeURIComponent((route.query?.redirect || "/") as string);
|
|
|
|
|
if (route.name === LOGIN_NAME)
|
|
|
|
|
if (autoLogin.value)
|
|
|
|
|
localStorage.setItem('LOGIN_FORM_PASS', JSON.stringify(formInline))
|
|
|
|
|
else
|
|
|
|
|
localStorage.removeItem('LOGIN_FORM_PASS')
|
|
|
|
|
|
|
|
|
|
loginSuccess.value = true
|
|
|
|
|
const { data: userInfo } = await userStore.getInformation()
|
|
|
|
|
message.destroyAll()
|
|
|
|
|
const toPath = decodeURIComponent((route.query?.redirect || '/') as string)
|
|
|
|
|
if (route.name === LOGIN_NAME) {
|
|
|
|
|
if (userInfo.frontmenuTList && userInfo.frontmenuTList.length) {
|
|
|
|
|
message.success("登录成功,即将进入系统");
|
|
|
|
|
message.success('登录成功,即将进入系统')
|
|
|
|
|
router.replace(
|
|
|
|
|
userInfo.frontmenuTList ? userInfo.frontmenuTList[0]["resUrl"] : "/"
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
message.error("用户无菜单权限,请联系管理员");
|
|
|
|
|
userInfo.frontmenuTList ? userInfo.frontmenuTList[0].resUrl : '/',
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
else router.replace(toPath);
|
|
|
|
|
} else {
|
|
|
|
|
loginSuccess.value = false;
|
|
|
|
|
message.destroyAll();
|
|
|
|
|
message.info(msg || "登录失败");
|
|
|
|
|
formRef.value.validate();
|
|
|
|
|
else {
|
|
|
|
|
message.error('用户无菜单权限,请联系管理员')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else { router.replace(toPath) }
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
loginSuccess.value = false
|
|
|
|
|
message.destroyAll()
|
|
|
|
|
message.info(msg || '登录失败')
|
|
|
|
|
formRef.value.validate()
|
|
|
|
|
}
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
message.error("请填写完整信息,并且进行验证码校验");
|
|
|
|
|
finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
message.error('请填写完整信息,并且进行验证码校验')
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
let data: any = localStorage.getItem("LOGIN_FORM_SMS");
|
|
|
|
|
let data: any = localStorage.getItem('LOGIN_FORM_SMS')
|
|
|
|
|
if (data) {
|
|
|
|
|
data = JSON.parse(data) as any;
|
|
|
|
|
formSms.agentcode = data.agentcode;
|
|
|
|
|
formSms.phone = data.phone;
|
|
|
|
|
formSms.phonecode = "";
|
|
|
|
|
autoLogin.value = true;
|
|
|
|
|
data = JSON.parse(data) as any
|
|
|
|
|
formSms.agentcode = data.agentcode
|
|
|
|
|
formSms.phone = data.phone
|
|
|
|
|
formSms.phonecode = ''
|
|
|
|
|
autoLogin.value = true
|
|
|
|
|
}
|
|
|
|
|
data = localStorage.getItem("LOGIN_FORM_PASS");
|
|
|
|
|
data = localStorage.getItem('LOGIN_FORM_PASS')
|
|
|
|
|
if (data) {
|
|
|
|
|
data = JSON.parse(data) as any;
|
|
|
|
|
formInline.username = data.username;
|
|
|
|
|
formInline.password = "";
|
|
|
|
|
data = JSON.parse(data) as any
|
|
|
|
|
formInline.username = data.username
|
|
|
|
|
formInline.password = ''
|
|
|
|
|
// formInline.password = data.password;
|
|
|
|
|
formInline.enterprisecode = data.enterprisecode;
|
|
|
|
|
autoLogin.value = true;
|
|
|
|
|
formInline.enterprisecode = data.enterprisecode
|
|
|
|
|
autoLogin.value = true
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function handleSmsSubmit(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
loginSuccess.value = true;
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
loginSuccess.value = true
|
|
|
|
|
formRefSms.value.validate(async (errors) => {
|
|
|
|
|
if (!errors) {
|
|
|
|
|
const { phone, agentcode, phonecode } = formSms;
|
|
|
|
|
message.loading("登录中...");
|
|
|
|
|
loading.value = true;
|
|
|
|
|
const { phone, agentcode, phonecode } = formSms
|
|
|
|
|
message.loading('登录中...')
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const res = await smsLogin({
|
|
|
|
|
phone,
|
|
|
|
|
agentcode,
|
|
|
|
|
phonecode,
|
|
|
|
|
});
|
|
|
|
|
const { code, message: msg } = res;
|
|
|
|
|
loginRejectMessge.value = msg;
|
|
|
|
|
})
|
|
|
|
|
const { code, message: msg } = res
|
|
|
|
|
loginRejectMessge.value = msg
|
|
|
|
|
if (code === ResultEnum.SUCCESS) {
|
|
|
|
|
// 是否保存账号
|
|
|
|
|
if (autoLogin.value) {
|
|
|
|
|
localStorage.setItem("LOGIN_FORM_SMS", JSON.stringify(formSms));
|
|
|
|
|
} else {
|
|
|
|
|
localStorage.removeItem("LOGIN_FORM_SMS");
|
|
|
|
|
}
|
|
|
|
|
loginSuccess.value = true;
|
|
|
|
|
if (autoLogin.value)
|
|
|
|
|
localStorage.setItem('LOGIN_FORM_SMS', JSON.stringify(formSms))
|
|
|
|
|
else
|
|
|
|
|
localStorage.removeItem('LOGIN_FORM_SMS')
|
|
|
|
|
|
|
|
|
|
loginSuccess.value = true
|
|
|
|
|
// const { code, message: msg } = await userStore.login(params)
|
|
|
|
|
await userStore.setStorageToken(res.data);
|
|
|
|
|
const { data: userInfo } = await userStore.getInformation();
|
|
|
|
|
message.destroyAll();
|
|
|
|
|
const toPath = decodeURIComponent((route.query?.redirect || "/") as string);
|
|
|
|
|
await userStore.setStorageToken(res.data)
|
|
|
|
|
const { data: userInfo } = await userStore.getInformation()
|
|
|
|
|
message.destroyAll()
|
|
|
|
|
const toPath = decodeURIComponent((route.query?.redirect || '/') as string)
|
|
|
|
|
if (route.name === LOGIN_NAME) {
|
|
|
|
|
if (userInfo.frontmenuTList && userInfo.frontmenuTList.length) {
|
|
|
|
|
message.success("登录成功,即将进入系统");
|
|
|
|
|
message.success('登录成功,即将进入系统')
|
|
|
|
|
router.replace(
|
|
|
|
|
userInfo.frontmenuTList ? userInfo.frontmenuTList[0]["resUrl"] : "/"
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
message.error("用户无菜单权限,请联系管理员");
|
|
|
|
|
userInfo.frontmenuTList ? userInfo.frontmenuTList[0].resUrl : '/',
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
message.error('用户无菜单权限,请联系管理员')
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
router.replace(toPath);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
message.destroyAll();
|
|
|
|
|
message.info(msg || "登录失败");
|
|
|
|
|
loginSuccess.value = false;
|
|
|
|
|
formRefSms.value.validate();
|
|
|
|
|
else {
|
|
|
|
|
router.replace(toPath)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false;
|
|
|
|
|
else {
|
|
|
|
|
message.destroyAll()
|
|
|
|
|
message.info(msg || '登录失败')
|
|
|
|
|
loginSuccess.value = false
|
|
|
|
|
formRefSms.value.validate()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (e) {
|
|
|
|
|
}
|
|
|
|
|
finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
message.error("请填写完整信息,并且进行验证码校验");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
else {
|
|
|
|
|
message.error('请填写完整信息,并且进行验证码校验')
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function close() {
|
|
|
|
|
loading.value = false;
|
|
|
|
|
emit("close");
|
|
|
|
|
loading.value = false
|
|
|
|
|
emit('close')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function switchTab(type: number) {
|
|
|
|
|
loading.value = false;
|
|
|
|
|
tab.value = type;
|
|
|
|
|
loading.value = false
|
|
|
|
|
tab.value = type
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function computedForm() {
|
|
|
|
|
if (tab.value == 0) {
|
|
|
|
|
return !formInline.enterprisecode || !formInline.username || !formInline.password;
|
|
|
|
|
}
|
|
|
|
|
if (tab.value == 1) {
|
|
|
|
|
return !formSms.agentcode || !formSms.phone || !formSms.phonecode;
|
|
|
|
|
}
|
|
|
|
|
if (tab.value == 0)
|
|
|
|
|
return !formInline.enterprisecode || !formInline.username || !formInline.password
|
|
|
|
|
|
|
|
|
|
if (tab.value == 1)
|
|
|
|
|
return !formSms.agentcode || !formSms.phone || !formSms.phonecode
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function sendCode(value) {
|
|
|
|
|
if (!formSms.phone) return;
|
|
|
|
|
if (!formSms.phone)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if (!flag.value) return;
|
|
|
|
|
flag.value = false;
|
|
|
|
|
if (!flag.value)
|
|
|
|
|
return
|
|
|
|
|
flag.value = false
|
|
|
|
|
|
|
|
|
|
const res = await getCode({
|
|
|
|
|
phone: formSms.phone,
|
|
|
|
|
agentcode: formSms.agentcode,
|
|
|
|
|
});
|
|
|
|
|
if (res.code == "OK") {
|
|
|
|
|
startCount();
|
|
|
|
|
} else {
|
|
|
|
|
message.error(res.message);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (res.code == 'OK')
|
|
|
|
|
startCount()
|
|
|
|
|
else
|
|
|
|
|
message.error(res.message)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function startCount() {
|
|
|
|
|
let time = 60;
|
|
|
|
|
countTime.value = "60s";
|
|
|
|
|
let time = 60
|
|
|
|
|
countTime.value = '60s'
|
|
|
|
|
const timer = setInterval(() => {
|
|
|
|
|
countTime.value = `${--time}s`;
|
|
|
|
|
countTime.value = `${--time}s`
|
|
|
|
|
if (time === 0) {
|
|
|
|
|
clearInterval(timer);
|
|
|
|
|
countTime.value = "重新获取";
|
|
|
|
|
flag.value = true;
|
|
|
|
|
clearInterval(timer)
|
|
|
|
|
countTime.value = '重新获取'
|
|
|
|
|
flag.value = true
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
|
|
|
|
}, 1000)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function forget() {
|
|
|
|
|
loading.value = false;
|
|
|
|
|
emit("forget");
|
|
|
|
|
loading.value = false
|
|
|
|
|
emit('forget')
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="form-login">
|
|
|
|
|
<img class="img-close" src="@/assets/images/login/close.png" alt="" @click="close" />
|
|
|
|
|
<img class="img-close" src="@/assets/images/login/close.png" alt="" @click="close">
|
|
|
|
|
<div class="tab">
|
|
|
|
|
<div
|
|
|
|
|
:class="{ 'tab-item-active': tab === 0 }"
|
|
|
|
|
@ -373,7 +378,7 @@ function forget() {
|
|
|
|
|
maxlength="20"
|
|
|
|
|
>
|
|
|
|
|
<template #prefix>
|
|
|
|
|
<svg-icon size="20" name="enterprise" />
|
|
|
|
|
<SvgIcon size="20" name="enterprise" />
|
|
|
|
|
</template>
|
|
|
|
|
</n-input>
|
|
|
|
|
</n-form-item>
|
|
|
|
|
@ -385,7 +390,7 @@ function forget() {
|
|
|
|
|
maxlength="16"
|
|
|
|
|
>
|
|
|
|
|
<template #prefix>
|
|
|
|
|
<svg-icon size="20" name="account" />
|
|
|
|
|
<SvgIcon size="20" name="account" />
|
|
|
|
|
</template>
|
|
|
|
|
</n-input>
|
|
|
|
|
</n-form-item>
|
|
|
|
|
@ -399,7 +404,7 @@ function forget() {
|
|
|
|
|
maxlength="16"
|
|
|
|
|
>
|
|
|
|
|
<template #prefix>
|
|
|
|
|
<svg-icon size="20" name="password" />
|
|
|
|
|
<SvgIcon size="20" name="password" />
|
|
|
|
|
</template>
|
|
|
|
|
</n-input>
|
|
|
|
|
</n-form-item>
|
|
|
|
|
@ -411,8 +416,8 @@ function forget() {
|
|
|
|
|
size="large"
|
|
|
|
|
:loading="loading"
|
|
|
|
|
block
|
|
|
|
|
@click="handleSubmit"
|
|
|
|
|
:disabled="computedForm()"
|
|
|
|
|
@click="handleSubmit"
|
|
|
|
|
>
|
|
|
|
|
登录
|
|
|
|
|
</n-button>
|
|
|
|
|
@ -446,7 +451,7 @@ function forget() {
|
|
|
|
|
placeholder="请输入企业编码"
|
|
|
|
|
>
|
|
|
|
|
<template #prefix>
|
|
|
|
|
<svg-icon size="20" name="enterprise" />
|
|
|
|
|
<SvgIcon size="20" name="enterprise" />
|
|
|
|
|
</template>
|
|
|
|
|
</n-input>
|
|
|
|
|
</n-form-item>
|
|
|
|
|
@ -463,7 +468,7 @@ function forget() {
|
|
|
|
|
src="@/assets/images/login/phone.png"
|
|
|
|
|
alt=""
|
|
|
|
|
@click="close"
|
|
|
|
|
/>
|
|
|
|
|
>
|
|
|
|
|
</template>
|
|
|
|
|
</n-input>
|
|
|
|
|
</n-form-item>
|
|
|
|
|
@ -481,7 +486,7 @@ function forget() {
|
|
|
|
|
src="@/assets/images/login/auth.png"
|
|
|
|
|
alt=""
|
|
|
|
|
@click="close"
|
|
|
|
|
/>
|
|
|
|
|
>
|
|
|
|
|
</template>
|
|
|
|
|
<template #suffix>
|
|
|
|
|
<div
|
|
|
|
|
@ -505,8 +510,8 @@ function forget() {
|
|
|
|
|
size="large"
|
|
|
|
|
:loading="loading"
|
|
|
|
|
block
|
|
|
|
|
@click="handleSmsSubmit"
|
|
|
|
|
:disabled="computedForm()"
|
|
|
|
|
@click="handleSmsSubmit"
|
|
|
|
|
>
|
|
|
|
|
登录
|
|
|
|
|
</n-button>
|
|
|
|
|
|