修复登录失败的提示
This commit is contained in:
@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -59,4 +60,14 @@ public class LoginController {
|
|||||||
}
|
}
|
||||||
return "login";
|
return "login";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/beforeLogin")
|
||||||
|
@ResponseBody
|
||||||
|
public boolean beforeLogin(TbUser tbUser)throws Exception{
|
||||||
|
System.out.println(tbUser.toString());
|
||||||
|
//加密用户密码
|
||||||
|
tbUser.setColpassword(new BigInteger(CodingUtil.encryptSHA(tbUser.getColpassword().getBytes())).toString(32));
|
||||||
|
TbUser user = userService.doLoginService(tbUser.getColname(),tbUser.getColpassword());
|
||||||
|
return user!=null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ var Main = {
|
|||||||
submitForm(formName, url) {
|
submitForm(formName, url) {
|
||||||
this.$refs[formName].validate((valid) => {
|
this.$refs[formName].validate((valid) => {
|
||||||
var that = this;
|
var that = this;
|
||||||
if (valid) {//此处暂时去除校验
|
if (valid) {
|
||||||
axios({
|
axios({
|
||||||
url: getRootPath_web()+'/' + url,
|
url: getRootPath_web()+'/' + url,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@@ -302,6 +302,54 @@ var Main = {
|
|||||||
handleClick(tab, event) {
|
handleClick(tab, event) {
|
||||||
console.log(tab, event);
|
console.log(tab, event);
|
||||||
},
|
},
|
||||||
|
clickToSubmit(formName) {
|
||||||
|
this.$refs[formName].validate((valid) => {
|
||||||
|
var that = this;
|
||||||
|
if (valid) {
|
||||||
|
axios({
|
||||||
|
url: getRootPath_web()+'/beforeLogin',
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
colname :outSideThis.ruleForm1.colname.value,
|
||||||
|
colpassword:outSideThis.ruleForm1.colpassword.value
|
||||||
|
},
|
||||||
|
transformRequest: [function (data) {
|
||||||
|
// Do whatever you want to transform the data
|
||||||
|
let ret = '';
|
||||||
|
for (let it in data) {
|
||||||
|
ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}],
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
|
}
|
||||||
|
}).then(function (response) {
|
||||||
|
console.log(response.data);
|
||||||
|
if (response.data===true){
|
||||||
|
//that.$refs[formName].submit;
|
||||||
|
//return true;
|
||||||
|
document.getElementById('ruleForm1').submit();
|
||||||
|
}else if (response.data===false){
|
||||||
|
that.openNotiError("失败", response.data.message);
|
||||||
|
}else {
|
||||||
|
that.openNotiError("错误", response.data.message);
|
||||||
|
}
|
||||||
|
}).catch(function (error) {
|
||||||
|
console.log(error);
|
||||||
|
that.openNotiError("错误", "服务器错误!");
|
||||||
|
});
|
||||||
|
//console.log(this.$refs.content.value)
|
||||||
|
//this.openNotiSuccess("成功", "修改成功!")
|
||||||
|
//this.$options.methods.openNotiSuccess.bind(this)();
|
||||||
|
//alert('submit!');
|
||||||
|
} else {
|
||||||
|
console.log('error submit!!');
|
||||||
|
that.openNotiError("错误", "表单填写错误!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
showMsg(msg) {
|
showMsg(msg) {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: msg,
|
message: msg,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
:rules="rules1" ref="ruleForm1" label-width="100px"
|
:rules="rules1" ref="ruleForm1" label-width="100px"
|
||||||
class="demo-ruleForm"
|
class="demo-ruleForm"
|
||||||
action="/cms/login/dologin"
|
action="/cms/login/dologin"
|
||||||
method="POST" name="login">
|
method="POST" name="ruleForm1" id="ruleForm1">
|
||||||
<el-form-item label="用户名"
|
<el-form-item label="用户名"
|
||||||
prop="colname">
|
prop="colname">
|
||||||
<el-input
|
<el-input
|
||||||
@@ -39,9 +39,9 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary"
|
<el-button type="primary"
|
||||||
native-type="submit">提交
|
@click="clickToSubmit('ruleForm1')">提交
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button @click="resetForm('ruleForm2')">重置</el-button>
|
<el-button @click="resetForm('ruleForm1')">重置</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|||||||
Reference in New Issue
Block a user