| | |
| | | import { ref, reactive, onMounted } from 'vue' |
| | | import type { FormInstance, FormRules } from 'element-plus' |
| | | import { getCaptcha, login } from '@/api' |
| | | import { setToken } from '@/common/utils/index' |
| | | import { setToken, getToken } from '@/common/utils/index' |
| | | import { ElMessage } from 'element-plus' |
| | | import { useRouter } from 'vue-router' |
| | | |
| | |
| | | const captchaId = ref('') |
| | | |
| | | const getCaptchaData = () => { |
| | | getCaptcha().then((rsp) => { |
| | | if (rsp.code == 200) { |
| | | captcha.value = rsp.data.picPath |
| | | captchaId.value = rsp.data.captchaId |
| | | } |
| | | getCaptcha().then((rsp: any) => { |
| | | captcha.value = rsp?.data?.picPath |
| | | captchaId.value = rsp?.data?.captchaId |
| | | }) |
| | | } |
| | | onMounted(() => { |
| | |
| | | password: ruleForm.pass, |
| | | captcha: ruleForm.code, |
| | | captchaId: captchaId.value |
| | | }).then((rsp) => { |
| | | if (rsp.code == 200) { |
| | | console.log(rsp) |
| | | setToken(rsp.token) |
| | | ElMessage({ |
| | | message: '登录成功!', |
| | | type: 'success' |
| | | }) |
| | | ruleForm.accountNumber = '' |
| | | ruleForm.pass = '' |
| | | ruleForm.code = '' |
| | | router.push('/') |
| | | } |
| | | }).then((rsp: any) => { |
| | | console.log(rsp) |
| | | setToken(rsp?.data?.token) |
| | | ElMessage({ |
| | | message: '登录成功!', |
| | | type: 'success' |
| | | }) |
| | | ruleForm.accountNumber = '' |
| | | ruleForm.pass = '' |
| | | ruleForm.code = '' |
| | | router.push('/') |
| | | }) |
| | | } else { |
| | | console.log('error submit!') |