11wqe1 4 тижнів тому
батько
коміт
e9886e9e0c
1 змінених файлів з 44 додано та 29 видалено
  1. 44 29
      src/views/login/loginPage.vue

+ 44 - 29
src/views/login/loginPage.vue

@@ -982,39 +982,54 @@ export default {
 						type: "warning",
 					}
 				);
-
-				// let userjson = await getUser({ userid: this.stuInfoCode.userid });
+				this.loading = true;
 
 				console.log("this.stuInfoCode", this.stuInfoCode);
-				// window.localStorage["identity"] = 0;
-
-				// window.topU.U.UF.Cookie.set("cocoroboLoginType=2");
-				// window.topU
-				// 	? (window.topU.US.userInfo = userjson)
-				// 	: (window.parent.US.userInfo = userjson);
-				window.topU.postMessage(
-					{
-						tools: "inviteLogin",
-						userid: this.stuInfoCode.userid,
-						courseId: "",
-					},
-					"*"
-				);
+				// let loginData=JSON.stringify({openid: this.stuInfoCode.userid,edu: true})
 
-				this.$message.success("登录成功");
-
-				this.$router.push({ path: this.redirect || "/", query: { courseId: this.courseId } });
-				sessionStorage.setItem("lytype", "courseDetail");
+				let params = {
+					geetest_challenge: "",
+					geetest_validate: "",
+					geetest_seccode: "",
+					openid: this.stuInfoCode.userid,
+					edu: true
+				};
+				axios.defaults.withCredentials = true;
+				axios
+					.post("https://beta.api.cocorobo.cn/api/user", qs.stringify(params))
+					.then(async (res) => {
+							console.log("res", res);
+							this.loading = false;
 
-				console.log('ok');
-				
-				this.addOp3(
-					"1",
-					"",
-					{ type: this.prefixL + "stuCode_login" },
-					"success",
-					this.stuInfoCode.userid
-				);
+							let _data = res.data[0][0];
+							let userjson = await getUser({ userid: _data.userid });
+
+							console.log("userjson", userjson);
+							if (_data.active === 1) {
+								window.localStorage["identity"] = JSON.stringify(_data.identity);
+								
+								window.topU.U.UF.Cookie.set("cocoroboLoginType=2");
+								window.topU
+									? (window.topU.US.userInfo = _data)
+									: (window.parent.US.userInfo = _data);
+								await this.login();
+								this.$message.success("登录成功");
+								
+								this.$router.push({ path: this.redirect || "/", query: { courseId: this.courseId } });
+								this.addOp3(
+									"1",
+									"",
+									{ type: this.prefixL + "stuCode_login" },
+									"success",
+									this.stuInfoCode.userid
+								);
+							} else {
+								this.$message.error("登录失败");
+							}
+					})
+					.catch((err) => {
+						console.error(err);
+					});
 			} catch (error) {
 				console.error("登录过程中出错:", error);
 			}