2019-7-29--登陆验证
程序员文章站
2022-04-27 20:40:13
upitem() { console.log("1 :", 1); let user = this.username; let pwd = this.password; if (user == "" || pwd == "") { this.$toast("账号或密码不能为空!!"); } else... ......
upitem() {
console.log("1 :", 1);
let user = this.username;
let pwd = this.password;
if (user == "" || pwd == "") {
this.$toast("账号或密码不能为空!!");
} else {
let pattuser = /^[a-z]\w{2,14}$/;
let pattpwd = /^\w{2,15}$/;
if (!pattuser.test(user)) {
this.$toast("用户名必须满足字符开头,\n 且长度在2-15为之间!!");
} else {
if (!pattpwd.test(pwd)) {
this.$toast("密码必须为2-15位非特殊字符!");
} else {
var params = new urlsearchparams();
params.append("username", user);
params.append("password", pwd);
this.axios
.post("http://www.doubleb.fun/api/checklogin.php", params)
.then(res => {
if (res.data.status == "200") {
// console.log('res :', res);
this.uid = res.data.uid;
document.cookie =
"userstate=" + res.data.usertoken + "&uid=" + this.uid;
this.$toast("登录成功");
this.show = false;
// settimeout(() => {
// this.addcar();
// }, 50);
} else {
this.$toast("登录失败!! \n 请检查用户名或者密码后重新输入。");
}
console.log(res);
})
.catch(err => {
console.error(err);
});
}
}
}
}
上一篇: main方法击破
下一篇: BP神经网络 c++实现