| | |
| | | <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> |
| | |
| | | <img :src="codeUrl" @click="getCode" class="login-code-img"/> |
| | | </div> |
| | | </el-form-item> |
| | | <el-radio-group v-model="loginForm.role" class="mb5"> |
| | | <el-radio :label="0" size="large">监管部门</el-radio> |
| | | <el-radio :label="1" size="large">机构管理员</el-radio> |
| | | </el-radio-group> |
| | | <div style="display: flex;justify-content: space-between;align-items: center;margin-bottom: 25px"> |
| | | <!-- <el-checkbox v-model="loginForm.rememberMe">记住密码</el-checkbox>--> |
| | | <el-button |
| | | :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: "" |
| | | uuid: "", |
| | | role: 0 |
| | | }); |
| | | |
| | | 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 redirect = ref(undefined); |
| | | |
| | | onMounted(()=>{ |
| | | |
| | | Cookies.remove("userState"); |
| | | }) |
| | | |
| | | 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, |
| | | identity: loginForm.value.role |
| | | } |
| | | 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) { |
| | | const userState = JSON.parse(Cookies.get('userState')) |
| | | console.log("userState",userState) |
| | | //机构用户 |
| | | //未审核状态不显示菜单 |
| | | if(userState !==2 ){ |
| | | sidebarRouters.value = menu.noMenu |
| | | Cookies.set('routers',JSON.stringify(sidebarRouters.value)) |
| | | }else { |
| | | 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; |
| | | // 重新获取验证码 |