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); }); } } } }