Browse Source

测试axios登录

sunChengjie 1 year ago
parent
commit
805b5b352c
1 changed files with 15 additions and 18 deletions
  1. 15 18
      src/pages/login.vue

+ 15 - 18
src/pages/login.vue

@@ -62,25 +62,22 @@ export default {
 				Toast('请输入登录名');
 				return;
 			}
-			await employee_login({ account: this.name, password: this.password })
+			const res = await employee_login({ account: this.name, password: this.password }, { emulateJSON: true })
 			// this.$http.post(this.$store.state.host + "/appSysUser/employee_login", { account: this.name, password: this.password }, { emulateJSON: true })
-				.then(res => {
-					//发送成功
-					if (res.body.result == 'success') {
-						//localStorage
-						localStorage.setItem("userId", res.body.userId);
-						localStorage.setItem("roomId", res.body.roomId);
-						localStorage.setItem("accountType", res.body.accountType);
-						localStorage.setItem("name", this.name);
-						localStorage.setItem("password", this.password);
-						this.$router.push({ path: '/' });
-					} else {
-						Toast('登录失败!');
-					}
-				}, res => {
-					//发送失败
-					Toast("发送失败!")
-				})
+			console.log(res, 'qweqwe')
+			//发送成功
+			if (res.body.result == 'success') {
+				//localStorage
+				localStorage.setItem("userId", res.body.userId);
+				localStorage.setItem("roomId", res.body.roomId);
+				localStorage.setItem("accountType", res.body.accountType);
+				localStorage.setItem("name", this.name);
+				localStorage.setItem("password", this.password);
+				this.$router.push({ path: '/' });
+			} else {
+				Toast('登录失败!');
+			}
+			Toast("发送失败!")
 		}
 	}
 }