| | |
| | | </el-input> |
| | | <i id="iconfont" class="iconfont icon-biyanjing" @click="clickeye()"></i> |
| | | </el-form-item> |
| | | <!-- <el-form-item prop="code"> |
| | | <el-form-item prop="code"> |
| | | <el-input type="text" v-model="formLogin.code" placeholder="验证码"> |
| | | <template slot="append"> |
| | | <img class="login-code" :src="captcha" @click="getCaptchaData" /> |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> --> |
| | | </el-form-item> |
| | | <el-button size="default" @click="submit" type="primary" class="button-login"> 登录 </el-button> |
| | | </el-form> |
| | | </el-card> |
| | |
| | | <script> |
| | | // import { mapActions } from "vuex" |
| | | // import "@/assets/font/iconfont" |
| | | import { getCaptcha, login } from "@/api/login/login.js" |
| | | |
| | | export default { |
| | | name: "LoginView", |
| | |
| | | clearInterval(this.timeInterval) |
| | | }, |
| | | methods: { |
| | | getCaptchaData() {}, |
| | | getCaptchaData() { |
| | | getCaptcha().then((res) => { |
| | | console.log(res) |
| | | if (res.code == 200) { |
| | | this.captchaId = res.data.captchaId |
| | | this.captcha = res.data.picPath |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * @description 提交表单 |
| | |
| | | this.$refs.loginForm.validate((valid) => { |
| | | if (valid) { |
| | | // 登录 |
| | | // 注意 这里的演示没有传验证码 |
| | | // 具体需要传递的数据请自行修改代码 |
| | | // this.login({ |
| | | // username: this.formLogin.username, |
| | | // password: this.formLogin.password, |
| | | // captcha: this.formLogin.code |
| | | // }).then((rsp) => { |
| | | // // 重定向对象不存在则返回顶层路径 |
| | | // if (rsp != "") { |
| | | // // this.$message.warning(rsp); |
| | | // this.error = "填入信息错误,请检查!" |
| | | // let _this = this |
| | | // setTimeout(function () { |
| | | // _this.error = "" |
| | | // }, 3000) |
| | | // return |
| | | // } |
| | | this.$router.replace(this.$route.query.redirect || "/").catch((err) => { |
| | | console.log(err) |
| | | login({ |
| | | username: this.formLogin.username, |
| | | password: this.formLogin.password, |
| | | captcha: this.formLogin.code, |
| | | captchaId: this.captchaId |
| | | }) |
| | | // }) |
| | | .then((res) => { |
| | | console.log("成功" + res) |
| | | this.$router.replace(this.$route.query.redirect || "/").catch((err) => { |
| | | console.log(err) |
| | | }) |
| | | }) |
| | | .catch((err) => { |
| | | console.log(err) |
| | | }) |
| | | } else { |
| | | // 登录表单校验失败 |
| | | // this.$message.error("表单校验失败,请检查"); |