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