123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401 |
- <template>
- <div class="login">
- <el-form
- ref="loginForm"
- :model="loginForm"
- :rules="loginRules"
- class="login-form"
- >
- <el-row>
- <el-col :span="12" class="comlogo"></el-col>
- <el-col :span="12">
- <div class="grid-content bg-purple-dark title">
- 智能制造平台
- </div></el-col
- >
- </el-row>
- <el-row class="rowww">
- <el-col :span="12" class="text" prop="username">用户名</el-col>
- <el-input
- v-model="loginForm.username"
- type="text"
- auto-complete="off"
- placeholder="账号"
- class="inputt"
- />
- </el-row>
- <el-row class="roww">
- <el-col :span="12" class="text" prop="password">密码</el-col>
- <el-input
- v-model="loginForm.password"
- type="password"
- auto-complete="off"
- placeholder="密码"
- @keyup.enter.native="handleLogin"
- show-password
- class="inputt"
- >
- </el-input>
- </el-row>
- <el-row class="roww">
- <el-row>
- <el-col class="text" prop="code">验证码</el-col>
- </el-row>
- <el-row>
- <el-col :span="18">
- <el-input
- v-model="loginForm.code"
- auto-complete="off"
- placeholder="验证码"
- @keyup.enter.native="handleLogin"
- class="inputt"
- >
- </el-input>
- </el-col>
- <el-col :span="4" :offset="1">
- <div class="login-code">
- <img :src="codeUrl" @click="getCode" class="login-code-img" />
- </div>
- </el-col>
- </el-row>
- </el-row>
- <el-row class="bottomtext">
- <!-- <div class="login-code">
- <img :src="codeUrl" @click="getCode" class="login-code-img" />
- </div> -->
- <el-checkbox v-model="loginForm.rememberMe" class="aaa"
- >在这个设备上记住我</el-checkbox
- >
- </el-row>
- <el-row>
- <el-col
- class="logg"
- :loading="loading"
- @click.native.prevent="handleLogin"
- >登录</el-col
- >
- </el-row>
- </el-form>
- <!-- <el-form
- ref="loginForm"
- :model="loginForm"
- :rules="loginRules"
- class="login-form"
- >
- <img src="../assets/images/comp.png" class="comlogo" />
- <span class="title">智能制造平台</span>
- <el-form-item prop="username">
- <p style="line-height: 12px">用户名</p>
- <el-input
- v-model="loginForm.username"
- type="text"
- auto-complete="off"
- placeholder="账号"
- show-password
- >
-
- </el-input>
- </el-form-item>
- <el-form-item prop="password">
- <p style="line-height: 12px">密码</p>
- <el-input
- v-model="loginForm.password"
- type="password"
- auto-complete="off"
- placeholder="密码"
- @keyup.enter.native="handleLogin"
- show-password
- >
-
- </el-input>
- </el-form-item>
- <el-form-item prop="code" v-if="captchaEnabled">
- <div style="line-height: 12px">验证码</div>
- <el-input
- v-model="loginForm.code"
- auto-complete="off"
- placeholder="验证码"
- style="width: 63%"
- @keyup.enter.native="handleLogin"
- show-password
- >
- </el-input>
- <div class="login-code">
- <img :src="codeUrl" @click="getCode" class="login-code-img" />
- </div>
- </el-form-item>
- <el-checkbox
- v-model="loginForm.rememberMe"
- class="a"
- >在这个设备上记住我</el-checkbox
- >
- <el-form-item >
- <el-button
- :loading="loading"
- size="medium"
- type="primary"
- @click.native.prevent="handleLogin"
- >
- <span v-if="!loading">登 录</span>
- <span v-else>登 录 中...</span>
- </el-button>
- <div style="float: right" v-if="register">
- <router-link class="link-type" :to="'/register'"
- >立即注册</router-link
- >
- </div>
- </el-form-item>
- </el-form>
-
- <div class="el-login-footer">
- <span>Copyright © 2018-2023 zkqy.vip All Rights Reserved.</span>
- </div> -->
- </div>
- </template>
- <script>
- import { getCodeImg } from "@/api/login";
- import { changeDatasource } from "@/api/dataEngine";
- import Cookies from "js-cookie";
- import { encrypt, decrypt } from "@/utils/jsencrypt";
- export default {
- name: "Login",
- data() {
- return {
- 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: true,
- // 验证码开关
- captchaEnabled: true,
- // 注册开关
- register: false,
- redirect: undefined,
- };
- },
- watch: {
- $route: {
- handler: function (route) {
- this.redirect = route.query && route.query.redirect;
- },
- immediate: true,
- },
- },
- created() {
- this.getCode();
- this.getCookie();
- },
- methods: {
- forgetEvent() {},
- 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;
- }
- });
- },
- 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),
- };
- },
- handleLogin() {
- this.$refs.loginForm.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(() => {
- changeDatasource(); //切换数据源
- this.$router.push({ path: this.redirect || "/" }).catch(() => {});
- })
- .catch(() => {
- this.loading = false;
- if (this.captchaEnabled) {
- this.getCode();
- }
- });
- }
- });
- },
- },
- };
- </script>
- <style rel="stylesheet/scss" lang="scss" scoped>
- ::v-deep.el-input--medium .el-input__inner {
- height: 54px;
- line-height: 54px;
- }
- .logg {
- margin-top: 42px;
- margin-left: 196px;
- width: 240px;
- height: 54px;
- line-height: 54px;
- text-align: center;
- opacity: 1;
- border-radius: 27px;
- background: linear-gradient(
- 135deg,
- rgba(79, 138, 255, 1) 0%,
- rgba(75, 94, 255, 1) 100%
- );
- box-shadow: 0px 4px 16px rgba(179, 192, 231, 1);
- color: #fff;
- font-size: 20px;
- font-weight: 500;
- cursor: pointer;
- }
- .aaa {
- width: 248px;
- height: 24px;
- font-size: 16px !important;
- font-weight: 400;
- letter-spacing: 0px;
- line-height: 24px;
- color: rgba(58, 63, 99, 1);
- text-align: left;
- vertical-align: top;
- margin-top: 16px;
- }
- .bottomtext {
- margin-top: -5px !important;
- margin-left: 58px !important;
- }
- .rowww {
- width: 522px;
- height: 80px;
- margin-top: 25px;
- margin-left: 55px;
- }
- .roww {
- width: 522px;
- height: 80px;
- margin-top: 16px;
- margin-left: 55px;
- }
- .ppp {
- width: 522px;
- height: 24px;
- opacity: 1;
- /** 文本1 */
- font-size: 16px;
- font-weight: 400;
- letter-spacing: 0px;
- line-height: 24px;
- color: rgba(58, 63, 99, 1);
- text-align: left;
- vertical-align: top;
- }
- .el-input__inner {
- width: 522px;
- /* height: 54px !important; */
- }
- .inputt {
- /* height: 54px !important; */
- border-radius: 4px;
- background: rgba(255, 255, 255, 1);
- border: 1px solid rgba(218, 224, 242, 1);
- margin-top: 2px;
- }
- .inputt input {
- width: 100%;
- }
- .comlogo {
- margin-left: 28px;
- margin-top: 57px;
- width: 194px;
- height: 64px;
- background: url(../assets/images/mec_logo_login.png);
- /* box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.25); */
- opacity: 1;
- }
- .login {
- display: flex;
- justify-content: center;
- align-items: center;
- height: 100%;
- background-image: url("../assets/images/background.jpg");
- background-size: cover;
- }
- .title {
- width: 212px;
- height: 35px;
- margin-top: 69px;
- margin-left: 17px;
- font-size: 32px;
- font-weight: 400;
- letter-spacing: 0px;
- line-height: 38.4px;
- color: rgba(7, 68, 138, 1);
- text-align: left;
- vertical-align: top;
- float: left;
- }
- .login-form {
- margin-left: 44%;
- margin-top: 48px;
- width: 621px;
- height: 624px;
- opacity: 1;
- border-radius: 39px;
- background: rgba(255, 255, 255, 1);
- float: left;
- }
- .login-code {
- width: 40px;
- height: 54px;
- opacity: 1;
- }
- .el-col-18 {
- width: 66%;
- }
- </style>
|