| | |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import {toRefs, reactive, defineComponent, computed, ref} from 'vue'; |
| | | import {toRefs, reactive, defineComponent, computed, ref, onMounted} from 'vue'; |
| | | import { useRoute, useRouter } from 'vue-router'; |
| | | import { ElMessage } from 'element-plus'; |
| | | import { useI18n } from 'vue-i18n'; |
| | |
| | | import { NextLoading } from '/@/utils/loading'; |
| | | import { useLoginApi } from '/@/api/login'; |
| | | import { useUserInfo } from '/@/stores/userInfo'; |
| | | import { ElMessage } from 'element-plus' |
| | | import type { FormInstance, FormRules } from 'element-plus' |
| | | import {workApplyApi} from "/@/api/specialWorkSystem/workApply"; |
| | | import {verifyPhone,verifyIdCard} from "/@/utils/toolsValidate" |
| | | import { Base64 } from 'js-base64' |
| | | export default defineComponent({ |
| | | name: 'accountLogin', |
| | | setup() { |
| | |
| | | const router = useRouter(); |
| | | const state = reactive({ |
| | | isShowPassword: false, |
| | | saveCode: false, |
| | | ruleForm: { |
| | | username: '', |
| | | password: '' |
| | |
| | | }); |
| | | const identifyRef = ref<FormInstance>() |
| | | const codeRef = ref<FormInstance>() |
| | | |
| | | // 页面载入时执行方法 |
| | | onMounted(() => { |
| | | hasUserCodeOrPassword() |
| | | // getAllDepartment(); |
| | | }); |
| | | |
| | | const hasUserCodeOrPassword =()=> { |
| | | if (localStorage.getItem('userCode') && localStorage.getItem('userPassword')) { |
| | | state.ruleForm.username = localStorage.getItem('userCode') |
| | | state.ruleForm.password = Base64.decode(localStorage.getItem('userPassword'))//解密 |
| | | state.saveCode = true |
| | | } |
| | | } |
| | | const checkCode = (rule: any, value: any, callback: any) => { |
| | | if (value == '') { |
| | | return callback(new Error('该内容不能为空')) |
| | |
| | | // Session.set('token', res.data.data.accessToken); |
| | | // Session.set('projectId', ''); |
| | | // Session.set('uid', res.data.data.uid); |
| | | if (state.saveCode) { |
| | | localStorage.setItem('userCode', state.ruleForm.username) |
| | | localStorage.setItem('userPassword', Base64.encode(state.ruleForm.password),) |
| | | } else { |
| | | localStorage.removeItem('userCode') |
| | | localStorage.removeItem('userPassword') |
| | | } |
| | | await signInSuccess(); |
| | | } else { |
| | | state.loading.signIn = false; |