| | |
| | | <template> |
| | | <div class="login"> |
| | | <div class="nav"> |
| | | <img alt="" src="../assets/images/bj.png" /> |
| | | <div class="ml-[10px]">射洪市项目管理系统</div> |
| | | </div> |
| | | <div class="conter"> |
| | | <div class="left"> |
| | | <div class="title">射洪市项目管理系统</div> |
| | | <div> |
| | | 运用系统的观点、方法和理论,对项目涉及的全部工作进行有效地管理 |
| | | <div class="login"> |
| | | <div class="nav"> |
| | | <img alt="" src="../assets/images/bj.png" /> |
| | | <div class="ml-[10px]">射洪智慧项目管理系统</div> |
| | | </div> |
| | | <div class="img"></div> |
| | | </div> |
| | | <div class="right"> |
| | | <div class="tab"> |
| | | <div |
| | | :class="{ active: currentTab === 'corporation' }" |
| | | class="login-corporation" |
| | | @click="currentClick('corporation')" |
| | | > |
| | | 法人登录 |
| | | </div> |
| | | <div |
| | | :class="{ active: currentTab === 'supervise' }" |
| | | class="login-supervise" |
| | | @click="superviseClick('supervise')" |
| | | > |
| | | 监管部门登录 |
| | | </div> |
| | | </div> |
| | | <el-form |
| | | ref="loginRef" |
| | | :model="loginForm" |
| | | :rules="loginRules" |
| | | class="login-form" |
| | | > |
| | | <!-- <el-form-item v-if="tenantEnabled" prop="tenantId"> |
| | | <div class="conter"> |
| | | <div class="left"> |
| | | <div class="title">射洪智慧项目管理系统</div> |
| | | <div> |
| | | 运用系统的观点、方法和理论,对项目涉及的全部工作进行有效地管理 |
| | | </div> |
| | | <div class="img"></div> |
| | | </div> |
| | | <div class="right"> |
| | | <div class="tab"> |
| | | <div |
| | | :class="{ active: currentTab === 'corporation' }" |
| | | class="login-corporation" |
| | | @click="currentClick('corporation')" |
| | | > |
| | | 法人登录 |
| | | </div> |
| | | <div |
| | | :class="{ active: currentTab === 'supervise' }" |
| | | class="login-supervise" |
| | | @click="superviseClick('supervise')" |
| | | > |
| | | 监管部门登录 |
| | | </div> |
| | | </div> |
| | | <el-form |
| | | ref="loginRef" |
| | | :model="loginForm" |
| | | :rules="loginRules" |
| | | class="login-form" |
| | | > |
| | | <!-- <el-form-item v-if="tenantEnabled" prop="tenantId"> |
| | | <el-select v-model="loginForm.tenantId" filterable placeholder="请选择/输入公司名称" style="width: 100%"> |
| | | <el-option v-for="item in tenantList" :key="item.tenantId" :label="item.companyName" |
| | | :value="item.tenantId"></el-option> |
| | | <template #prefix><svg-icon icon-class="company" class="el-input__icon input-icon" /></template> |
| | | </el-select> |
| | | </el-form-item> --> |
| | | <el-form-item prop="username"> |
| | | <el-input |
| | | v-model="loginForm.username" |
| | | auto-complete="off" |
| | | maxlength="20" |
| | | placeholder="请输入账号" |
| | | size="large" |
| | | type="text" |
| | | > |
| | | <template #prefix> |
| | | <svg-icon class="el-input__icon input-icon" icon-class="user" /> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item prop="password"> |
| | | <el-input |
| | | v-model="loginForm.password" |
| | | auto-complete="off" |
| | | maxlength="20" |
| | | placeholder="请输入密码" |
| | | size="large" |
| | | type="password" |
| | | @keyup.enter="handleLogin" |
| | | > |
| | | <template #prefix> |
| | | <svg-icon |
| | | class="el-input__icon input-icon" |
| | | icon-class="password" |
| | | /> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item v-if="captchaEnabled" prop="code"> |
| | | <el-input |
| | | v-model="loginForm.code" |
| | | auto-complete="off" |
| | | maxlength="20" |
| | | placeholder="验证码" |
| | | size="large" |
| | | style="width: 167px" |
| | | @keyup.enter="handleLogin" |
| | | > |
| | | <template #prefix> |
| | | <svg-icon |
| | | class="el-input__icon input-icon" |
| | | icon-class="validCode" |
| | | /> |
| | | </template> |
| | | </el-input> |
| | | <div class="login-code"> |
| | | <img :src="codeUrl" class="login-code-img" @click="getCode" /> |
| | | <el-form-item prop="username"> |
| | | <el-input |
| | | v-model="loginForm.username" |
| | | auto-complete="off" |
| | | maxlength="20" |
| | | placeholder="请输入账号" |
| | | size="large" |
| | | type="text" |
| | | > |
| | | <template #prefix> |
| | | <svg-icon |
| | | class="el-input__icon input-icon" |
| | | icon-class="user" |
| | | /> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item prop="password"> |
| | | <el-input |
| | | v-model="loginForm.password" |
| | | auto-complete="off" |
| | | maxlength="20" |
| | | placeholder="请输入密码" |
| | | size="large" |
| | | type="password" |
| | | @keyup.enter="handleLogin" |
| | | > |
| | | <template #prefix> |
| | | <svg-icon |
| | | class="el-input__icon input-icon" |
| | | icon-class="password" |
| | | /> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item v-if="captchaEnabled" prop="code"> |
| | | <el-input |
| | | v-model="loginForm.code" |
| | | auto-complete="off" |
| | | maxlength="20" |
| | | placeholder="验证码" |
| | | size="large" |
| | | style="width: 167px" |
| | | @keyup.enter="handleLogin" |
| | | > |
| | | <template #prefix> |
| | | <svg-icon |
| | | class="el-input__icon input-icon" |
| | | icon-class="validCode" |
| | | /> |
| | | </template> |
| | | </el-input> |
| | | <div class="login-code"> |
| | | <img |
| | | :src="codeUrl" |
| | | class="login-code-img" |
| | | @click="getCode" |
| | | /> |
| | | </div> |
| | | </el-form-item> |
| | | <el-checkbox |
| | | v-model="loginForm.rememberMe" |
| | | style="margin: 0 0 25px 0; color: #2d5eff" |
| | | >记住密码</el-checkbox |
| | | > |
| | | <div></div> |
| | | <el-form-item style="width: 100%"> |
| | | <el-button |
| | | :loading="loading" |
| | | size="large" |
| | | style="width: 100%" |
| | | type="primary" |
| | | @click.prevent="handleLogin" |
| | | > |
| | | <span v-if="!loading">登 录</span> |
| | | <span v-else>登 录 中...</span> |
| | | </el-button> |
| | | <div v-if="register" style="float: right"> |
| | | <router-link :to="'/register'" class="link-type" |
| | | >立即注册</router-link |
| | | > |
| | | </div> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div class="other"> |
| | | <div class="other-title"> |
| | | <span style="color: #b3b8c1">其他登录方式:</span |
| | | ><span style="color: #2d5eff; cursor: pointer"> |
| | | <svg-icon icon-class="phone" />手机验证码登录 |
| | | </span> |
| | | </div> |
| | | <div class="forget">忘记密码?</div> |
| | | </div> |
| | | </div> |
| | | </el-form-item> |
| | | <el-checkbox |
| | | v-model="loginForm.rememberMe" |
| | | style="margin: 0 0 25px 0; color: #2d5eff" |
| | | >记住密码</el-checkbox |
| | | > |
| | | <div></div> |
| | | <el-form-item style="width: 100%"> |
| | | <el-button |
| | | :loading="loading" |
| | | size="large" |
| | | style="width: 100%" |
| | | type="primary" |
| | | @click.prevent="handleLogin" |
| | | > |
| | | <span v-if="!loading">登 录</span> |
| | | <span v-else>登 录 中...</span> |
| | | </el-button> |
| | | <div v-if="register" style="float: right"> |
| | | <router-link :to="'/register'" class="link-type" |
| | | >立即注册</router-link |
| | | > |
| | | </div> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div class="other"> |
| | | <div class="other-title"> |
| | | <span style="color: #b3b8c1">其他登录方式:</span |
| | | ><span style="color: #2d5eff; cursor: pointer"> |
| | | <SvgIcon icon-class="phone" />手机验证码登录 |
| | | </span> |
| | | </div> |
| | | <div class="forget">忘记密码?</div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { getCodeImg } from "@/api/login"; |
| | | import Cookies from "js-cookie"; |
| | | import { encrypt, decrypt } from "@/utils/jsencrypt"; |
| | | import SvgIcon from '@/components/SvgIcon/index.vue'; |
| | | |
| | | export default { |
| | | name: "Login", |
| | | data() { |
| | | return { |
| | | currentTab: "corporation", |
| | | codeUrl: "", |
| | | loginForm: { |
| | | username: "admin", |
| | | password: "admin123", |
| | | rememberMe: false, |
| | | code: "", |
| | | uuid: "", |
| | | }, |
| | | loginRules: { |
| | | username: [ |
| | | { required: true, trigger: "blur", message: "请输入您的账号" }, |
| | | ], |
| | | password: [ |
| | | { required: true, trigger: "blur", message: "请输入您的密码" }, |
| | | ], |
| | | code: [{ required: true, trigger: "change", message: "请输入验证码" }], |
| | | }, |
| | | loading: false, |
| | | // 验证码开关 |
| | | captchaEnabled: true, |
| | | // 注册开关 |
| | | register: false, |
| | | redirect: undefined, |
| | | }; |
| | | }, |
| | | watch: { |
| | | $route: { |
| | | handler: function (route) { |
| | | this.redirect = route.query && route.query.redirect; |
| | | }, |
| | | immediate: true, |
| | | name: "Login", |
| | | data() { |
| | | return { |
| | | currentTab: "corporation", |
| | | codeUrl: "", |
| | | loginForm: { |
| | | username: "", |
| | | password: "", |
| | | rememberMe: false, |
| | | code: "", |
| | | uuid: "", |
| | | }, |
| | | loginRules: { |
| | | username: [ |
| | | { required: true, trigger: "blur", message: "请输入您的账号" }, |
| | | ], |
| | | password: [ |
| | | { required: true, trigger: "blur", message: "请输入您的密码" }, |
| | | ], |
| | | code: [{ required: true, trigger: "change", message: "请输入验证码" }], |
| | | }, |
| | | loading: false, |
| | | // 验证码开关 |
| | | captchaEnabled: true, |
| | | // 注册开关 |
| | | register: false, |
| | | redirect: undefined, |
| | | }; |
| | | }, |
| | | }, |
| | | created() { |
| | | this.getCode(); |
| | | this.getCookie(); |
| | | }, |
| | | methods: { |
| | | getCode() { |
| | | getCodeImg().then((res) => { |
| | | this.captchaEnabled = |
| | | res.captchaEnabled === undefined ? true : res.captchaEnabled; |
| | | if (this.captchaEnabled) { |
| | | this.codeUrl = "data:image/gif;base64," + res.img; |
| | | this.loginForm.uuid = res.uuid; |
| | | } |
| | | }); |
| | | comments: { |
| | | SvgIcon |
| | | }, |
| | | getCookie() { |
| | | const username = Cookies.get("username"); |
| | | const password = Cookies.get("password"); |
| | | const rememberMe = Cookies.get("rememberMe"); |
| | | this.loginForm = { |
| | | username: username === undefined ? this.loginForm.username : username, |
| | | password: |
| | | password === undefined ? this.loginForm.password : decrypt(password), |
| | | rememberMe: rememberMe === undefined ? false : Boolean(rememberMe), |
| | | }; |
| | | watch: { |
| | | $route: { |
| | | handler: function (route) { |
| | | this.redirect = route.query && route.query.redirect; |
| | | }, |
| | | immediate: true, |
| | | }, |
| | | }, |
| | | // 法人登录 |
| | | currentClick(tab) { |
| | | this.currentTab = tab; |
| | | this.loginForm.role = "2"; |
| | | console.log(this.loginForm); |
| | | created() { |
| | | this.getCode(); |
| | | this.getCookie(); |
| | | }, |
| | | // 监管部门登录 |
| | | superviseClick(tab) { |
| | | this.currentTab = tab; |
| | | this.loginForm.role = "1"; |
| | | console.log(this.loginForm); |
| | | }, |
| | | handleLogin() { |
| | | debugger |
| | | this.$refs.loginRef.validate((valid) => { |
| | | if (valid) { |
| | | this.loading = true; |
| | | if (this.loginForm.rememberMe) { |
| | | Cookies.set("username", this.loginForm.username, { expires: 30 }); |
| | | Cookies.set("password", encrypt(this.loginForm.password), { |
| | | expires: 30, |
| | | methods: { |
| | | getCode() { |
| | | getCodeImg().then((res) => { |
| | | this.captchaEnabled = |
| | | res.captchaEnabled === undefined ? true : res.captchaEnabled; |
| | | if (this.captchaEnabled) { |
| | | this.codeUrl = "data:image/gif;base64," + res.img; |
| | | this.loginForm.uuid = res.uuid; |
| | | } |
| | | }); |
| | | Cookies.set("rememberMe", this.loginForm.rememberMe, { |
| | | expires: 30, |
| | | }, |
| | | getCookie() { |
| | | const username = Cookies.get("username"); |
| | | const password = Cookies.get("password"); |
| | | const rememberMe = Cookies.get("rememberMe"); |
| | | this.loginForm = { |
| | | username: username === undefined ? this.loginForm.username : username, |
| | | password: |
| | | password === undefined ? this.loginForm.password : decrypt(password), |
| | | rememberMe: rememberMe === undefined ? false : Boolean(rememberMe), |
| | | }; |
| | | }, |
| | | // 法人登录 |
| | | currentClick(tab) { |
| | | this.currentTab = tab; |
| | | this.loginForm.role = "2"; |
| | | console.log(this.loginForm); |
| | | }, |
| | | // 监管部门登录 |
| | | superviseClick(tab) { |
| | | this.currentTab = tab; |
| | | this.loginForm.role = "1"; |
| | | console.log(this.loginForm); |
| | | }, |
| | | handleLogin() { |
| | | this.$refs.loginRef.validate((valid) => { |
| | | if (valid) { |
| | | this.loading = true; |
| | | if (this.loginForm.rememberMe) { |
| | | Cookies.set("username", this.loginForm.username, { expires: 30 }); |
| | | Cookies.set("password", encrypt(this.loginForm.password), { |
| | | expires: 30, |
| | | }); |
| | | Cookies.set("rememberMe", this.loginForm.rememberMe, { |
| | | expires: 30, |
| | | }); |
| | | } else { |
| | | Cookies.remove("username"); |
| | | Cookies.remove("password"); |
| | | Cookies.remove("rememberMe"); |
| | | } |
| | | this.$store |
| | | .dispatch("Login", this.loginForm) |
| | | .then(() => { |
| | | this.$router.push({ path: this.redirect || "/" }).catch(() => { }); |
| | | }) |
| | | .catch(() => { |
| | | this.loading = false; |
| | | if (this.captchaEnabled) { |
| | | this.getCode(); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } else { |
| | | Cookies.remove("username"); |
| | | Cookies.remove("password"); |
| | | Cookies.remove("rememberMe"); |
| | | } |
| | | this.$store |
| | | .dispatch("Login", this.loginForm) |
| | | .then(() => { |
| | | this.$router.push({ path: this.redirect || "/" }).catch(() => {}); |
| | | }) |
| | | .catch(() => { |
| | | this.loading = false; |
| | | if (this.captchaEnabled) { |
| | | this.getCode(); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | }, |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | .login { |
| | | .nav { |
| | | display: flex; |
| | | align-items: center; |
| | | height: 40px; |
| | | margin-left: 24px; |
| | | background-color: #fff; |
| | | font-family: PangMenZhengDao; |
| | | font-size: 20px; |
| | | font-style: italic; |
| | | color: #1e2538; |
| | | line-height: 40px; |
| | | } |
| | | |
| | | .conter { |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | gap: 100px; |
| | | height: calc(100vh - 50px); |
| | | background-image: url("../assets/images/login-background.png"); |
| | | background-size: cover; |
| | | |
| | | .left { |
| | | width: 500px; |
| | | height: auto; |
| | | |
| | | .title { |
| | | font-size: 34px; |
| | | color: #1f2639; |
| | | line-height: 16px; |
| | | } |
| | | |
| | | .img { |
| | | background-image: url("../assets/images/login.png"); |
| | | background-size: cover; |
| | | height: 295px; |
| | | width: 366px; |
| | | margin: auto; |
| | | margin-top: 20px; |
| | | } |
| | | .nav { |
| | | display: flex; |
| | | align-items: center; |
| | | height: 40px; |
| | | margin-left: 24px; |
| | | background-color: #fff; |
| | | font-family: PangMenZhengDao; |
| | | font-size: 20px; |
| | | font-style: italic; |
| | | color: #1e2538; |
| | | line-height: 40px; |
| | | } |
| | | |
| | | .right { |
| | | border-radius: 6px; |
| | | background: #ffffff; |
| | | width: 500px; |
| | | padding: 0px 25px 5px 25px; |
| | | |
| | | .tab { |
| | | margin: 20px 0; |
| | | .conter { |
| | | display: flex; |
| | | font-size: 24px; |
| | | line-height: 24px; |
| | | justify-content: center; |
| | | align-items: center; |
| | | gap: 100px; |
| | | height: calc(100vh - 50px); |
| | | background-image: url('../assets/images/login-background.png'); |
| | | background-size: cover; |
| | | |
| | | .login-corporation { |
| | | cursor: pointer; |
| | | .left { |
| | | width: 500px; |
| | | height: auto; |
| | | |
| | | .title { |
| | | font-size: 34px; |
| | | color: #1f2639; |
| | | line-height: 16px; |
| | | } |
| | | |
| | | .img { |
| | | background-image: url('../assets/images/login.png'); |
| | | background-size: cover; |
| | | height: 295px; |
| | | width: 366px; |
| | | margin: auto; |
| | | margin-top: 20px; |
| | | } |
| | | } |
| | | |
| | | .login-supervise { |
| | | cursor: pointer; |
| | | } |
| | | .right { |
| | | border-radius: 6px; |
| | | background: #ffffff; |
| | | width: 500px; |
| | | padding: 0px 25px 5px 25px; |
| | | |
| | | .active { |
| | | color: #2d5eff; |
| | | } |
| | | } |
| | | .tab { |
| | | margin: 20px 0; |
| | | display: flex; |
| | | font-size: 24px; |
| | | line-height: 24px; |
| | | gap: 100px; |
| | | |
| | | .other { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | font-size: 14px; |
| | | margin-bottom: 10px; |
| | | .login-corporation { |
| | | cursor: pointer; |
| | | } |
| | | |
| | | .other-title { |
| | | display: flex; |
| | | gap: 10px; |
| | | } |
| | | .login-supervise { |
| | | cursor: pointer; |
| | | } |
| | | |
| | | .forget { |
| | | color: #2d5eff; |
| | | cursor: pointer; |
| | | .active { |
| | | color: #2d5eff; |
| | | } |
| | | } |
| | | |
| | | .other { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | font-size: 14px; |
| | | margin-bottom: 10px; |
| | | |
| | | .other-title { |
| | | display: flex; |
| | | gap: 10px; |
| | | } |
| | | |
| | | .forget { |
| | | color: #2d5eff; |
| | | cursor: pointer; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | .title { |
| | | margin: 0px auto 30px auto; |
| | | text-align: center; |
| | | color: #707070; |
| | | margin: 0px auto 30px auto; |
| | | text-align: center; |
| | | color: #707070; |
| | | } |
| | | |
| | | .login-form { |
| | | .el-input { |
| | | height: 40px; |
| | | .el-input { |
| | | height: 40px; |
| | | |
| | | input { |
| | | height: 40px; |
| | | input { |
| | | height: 40px; |
| | | } |
| | | } |
| | | } |
| | | |
| | | .input-icon { |
| | | height: 39px; |
| | | width: 14px; |
| | | margin-left: 0px; |
| | | } |
| | | .input-icon { |
| | | height: 39px; |
| | | width: 14px; |
| | | margin-left: 0px; |
| | | } |
| | | } |
| | | |
| | | .login-tip { |
| | | font-size: 13px; |
| | | text-align: center; |
| | | color: #bfbfbf; |
| | | font-size: 13px; |
| | | text-align: center; |
| | | color: #bfbfbf; |
| | | } |
| | | |
| | | .login-code { |
| | | width: 33%; |
| | | height: 40px; |
| | | float: right; |
| | | width: 33%; |
| | | height: 40px; |
| | | float: right; |
| | | |
| | | img { |
| | | cursor: pointer; |
| | | vertical-align: middle; |
| | | } |
| | | img { |
| | | cursor: pointer; |
| | | vertical-align: middle; |
| | | } |
| | | } |
| | | |
| | | .login-code-img { |
| | | height: 40px; |
| | | padding-left: 12px; |
| | | height: 40px; |
| | | padding-left: 12px; |
| | | } |
| | | </style> |