| | |
| | | <template> |
| | | <div class="login-panel"> |
| | | <div class="login-img"> |
| | | <img src="src/assets/images/loginImg.png"> |
| | | <img :src="loginImgPng"> |
| | | </div> |
| | | <el-form ref="loginRef" :model="loginForm" :rules="loginRules" class="login-form"> |
| | | <h3 class="title">登录系统</h3> |
| | |
| | | auto-complete="off" |
| | | placeholder="密码" |
| | | @keyup.enter="handleLogin" |
| | | show-password |
| | | > |
| | | <template #prefix><svg-icon icon-class="password" class="el-input__icon input-icon" /></template> |
| | | </el-input> |
| | |
| | | :loading="loading" |
| | | size="large" |
| | | type="primary" |
| | | style="width:50%;" |
| | | style="width:63%;" |
| | | @click.prevent="handleLogin" |
| | | > |
| | | <span v-if="!loading">登 录</span> |
| | |
| | | import { encrypt, decrypt } from "@/utils/jsencrypt"; |
| | | import useUserStore from '@/store/modules/user' |
| | | import { Register } from "@/layout/components"; |
| | | import { Base64 } from 'js-base64' |
| | | import menu from "@/layout/components/Sidebar/menu"; |
| | | import loginImgPng from "@/assets/images/loginImg.png" |
| | | |
| | | const userStore = useUserStore() |
| | | const route = useRoute(); |
| | |
| | | const { proxy } = getCurrentInstance(); |
| | | |
| | | const loginForm = ref({ |
| | | username: "admin", |
| | | password: "admin@123", |
| | | username: "", |
| | | password: "", |
| | | code: "", |
| | | uuid: "" |
| | | }); |
| | |
| | | const loginRules = { |
| | | username: [{ required: true, trigger: "blur", message: "请输入您的账号" }], |
| | | password: [{ required: true, trigger: "blur", message: "请输入您的密码" }], |
| | | code: [{ required: true, trigger: "change", message: "请输入验证码" }] |
| | | code: [{ required: true, trigger: "blur", message: "请输入验证码" }] |
| | | }; |
| | | |
| | | const codeUrl = ref(""); |
| | |
| | | }) |
| | | |
| | | const openRegist = ()=>{ |
| | | regRef.value.dialogVisible = true |
| | | regRef.value.openDialog('add', {}); |
| | | } |
| | | |
| | | watch(route, (newRoute) => { |
| | | redirect.value = newRoute.query && newRoute.query.redirect; |
| | | }, { immediate: true }); |
| | | |
| | | |
| | | const sidebarRouters = ref([]) |
| | | function handleLogin() { |
| | | proxy.$refs.loginRef.validate(valid => { |
| | | if (valid) { |
| | |
| | | // Cookies.remove("rememberMe"); |
| | | // } |
| | | // 调用action的登录方法 |
| | | userStore.login(loginForm.value).then(() => { |
| | | const query = route.query; |
| | | const otherQueryParams = Object.keys(query).reduce((acc, cur) => { |
| | | if (cur !== "redirect") { |
| | | acc[cur] = query[cur]; |
| | | // loginForm.value.password = Base64.encode(loginForm.value.password) |
| | | const param = { |
| | | username: loginForm.value.username, |
| | | password: Base64.encode(loginForm.value.password), |
| | | code: loginForm.value.code, |
| | | uuid: loginForm.value.uuid |
| | | } |
| | | userStore.login(param).then(() => { |
| | | // const query = route.query; |
| | | // const otherQueryParams = Object.keys(query).reduce((acc, cur) => { |
| | | // if (cur !== "redirect") { |
| | | // acc[cur] = query[cur]; |
| | | // } |
| | | // return acc; |
| | | // }, {}); |
| | | const userInfo = JSON.parse(Cookies.get('userInfo')) |
| | | if(userInfo.identity === 0 ) { |
| | | sidebarRouters.value = menu.adminMenu |
| | | Cookies.set('routers',JSON.stringify(sidebarRouters.value)) |
| | | }else if(userInfo.identity === 1) { |
| | | sidebarRouters.value = menu.agencyMenu |
| | | Cookies.set('routers',JSON.stringify(sidebarRouters.value)) |
| | | } |
| | | return acc; |
| | | }, {}); |
| | | router.push({ path: redirect.value || "/", query: otherQueryParams }); |
| | | let path = "" |
| | | if(sidebarRouters.value[0].children && sidebarRouters.value[0].children.length > 0){ |
| | | path = sidebarRouters.value[0].path + '/'+ sidebarRouters.value[0].children[0].path |
| | | }else { |
| | | path = sidebarRouters.value[0].path |
| | | } |
| | | |
| | | router.push({ |
| | | path: path |
| | | }) |
| | | // router.push({ path: redirect.value || "/", query: otherQueryParams }); |
| | | }).catch(() => { |
| | | loading.value = false; |
| | | // 重新获取验证码 |