| | |
| | | <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> |
| | |
| | | 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) => { |
| | |
| | | // Cookies.remove("rememberMe"); |
| | | // } |
| | | // 调用action的登录方法 |
| | | loginForm.value.password = Base64.encode(loginForm.value.password) |
| | | 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; |
| | | }, {}); |
| | | const userInfo = JSON.parse(Cookies.get('userInfo')) |
| | | if(userInfo.identity === 0) { |
| | | sidebarRouters.value = menu.adminMenu |
| | | Cookies.set('routers',JSON.stringify(sidebarRouters.value)) |
| | | } |
| | | console.log("sidebarRouters.value",sidebarRouters.value) |
| | | router.push({ |
| | | path: sidebarRouters.value[0].path |
| | | }) |
| | | 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; |