yichael 4 лет назад
Родитель
Сommit
e2a0fbe9ef
3 измененных файлов с 58 добавлено и 81 удалено
  1. 5 46
      components/login/loginByPWD.vue
  2. 3 0
      components/topMenu.vue
  3. 50 35
      pages/home.vue

+ 5 - 46
components/login/loginByPWD.vue

@@ -68,9 +68,6 @@
 				this.isShowTip = 0;
 				this.isShowTip = 0;
 			},
 			},
 			onLogin() {
 			onLogin() {
-				// this.$emit("onLogin");
-				// return;
-				// console.log("账号密码", this.account, this.password);
 				let url = this.$Api + "/user/loginin";
 				let url = this.$Api + "/user/loginin";
 				uni.request({
 				uni.request({
 					header: {
 					header: {
@@ -79,15 +76,15 @@
 					url: url,
 					url: url,
 					method: 'POST',
 					method: 'POST',
 					data: {
 					data: {
-						// "IlabAccount": "student01",
-						// "Password": "student01"
-						// "IlabAccount": "13790516503",
-						// "Password": "qwerty123..."
 						"IlabAccount": this.account,
 						"IlabAccount": this.account,
 						"Password": this.password
 						"Password": this.password
 					},
 					},
 					dataType: 'json',
 					dataType: 'json',
 					success: (res) => {
 					success: (res) => {
+						
+						localStorage.setItem("account", this.account);
+						localStorage.setItem("password", this.password);
+						
 						let data = res.data;
 						let data = res.data;
 						//登录成功
 						//登录成功
 						if (data.Code == 100) {
 						if (data.Code == 100) {
@@ -102,12 +99,6 @@
 							mydata_userInfo.role = data.Type;
 							mydata_userInfo.role = data.Type;
 							
 							
 							// let url = this.$Api + "/user/setusertype";
 							// let url = this.$Api + "/user/setusertype";
-							// console.log('url=',url)
-							// let aData = {
-							// 	"UserID" : data.UserID,                //虚拟仿真用户ID
-							// 	"Type":"老师"
-							// }
-							// console.log('data=',aData)
 							// uni.request({
 							// uni.request({
 							// 	header: {
 							// 	header: {
 							// 		'Content-Type': 'application/json;charset=UTF-8'
 							// 		'Content-Type': 'application/json;charset=UTF-8'
@@ -116,7 +107,7 @@
 							// 	method: 'POST',
 							// 	method: 'POST',
 							// 	data: {
 							// 	data: {
 							// 		"UserID" : data.UserID,                //虚拟仿真用户ID
 							// 		"UserID" : data.UserID,                //虚拟仿真用户ID
-							// 		"Type":"老师"
+							// 		"Type":"学生"
 							// 	},
 							// 	},
 							// 	dataType: 'json',
 							// 	dataType: 'json',
 							// 	success: (res) => {
 							// 	success: (res) => {
@@ -149,41 +140,9 @@
 					}
 					}
 				});
 				});
 			},
 			},
-			// onLogin: function(type) {
-			// 	this.$emit("onLogin", "onLogin")
-			// },
 			onForget() {
 			onForget() {
 				// this.$emit("onForget", "onForget")
 				// this.$emit("onForget", "onForget")
 			}
 			}
-			// test() {
-			// 	this.$emit("pChangeType","哈哈哈")
-			// 	let url = "http://121.4.59.141:1986/hello";
-			// 	uni.request({
-			// 		header: {
-			// 			// 'Content-Type': 'application/x-www-form-urlencoded'
-			// 			// 'Content-Type': 'application/json',
-			// 			'Content-Type': 'application/json'
-			// 		},
-			// 		url: url,
-			// 		method: 'POST',
-			// 		data: {
-			// 			// "IlabAccount": "teststudent01",
-			// 			// "Password": "qgsTest002"
-			// 			"name": "13790516503",
-			// 			"message": "qwerty123..."
-			// 			// "IlabAccount": this.account,
-			// 			// "Password": this.password
-			// 		},
-			// 		dataType: 'json',
-			// 		success: (res) => {
-			// 			// var result = JSON.parse(res);
-			// 			console.log("success+**+*", res)
-			// 		},
-			// 		fail: (res) => {
-			// 			console.log("fail+**+*", res)
-			// 		}
-			// 	});
-			// }
 		}
 		}
 	}
 	}
 </script>
 </script>

+ 3 - 0
components/topMenu.vue

@@ -378,6 +378,9 @@
 			onClick_exit(){
 			onClick_exit(){
 				this.switchLoginState(false);
 				this.switchLoginState(false);
 				this.$emit("onClick_exit");
 				this.$emit("onClick_exit");
+			
+				localStorage.removeItem("account");
+				localStorage.removeItem("password");
 			}
 			}
 		}
 		}
 	}
 	}

+ 50 - 35
pages/home.vue

@@ -81,7 +81,6 @@
 			TopMenu,
 			TopMenu,
 			Login,
 			Login,
 			SYJJ,
 			SYJJ,
-			// XXLC,
 			XQDL,
 			XQDL,
 			KSXX,
 			KSXX,
 			QXZB,
 			QXZB,
@@ -136,13 +135,59 @@
 					false, //21实景勘察
 					false, //21实景勘察
 					false, //22学习资料下载
 					false, //22学习资料下载
 				],
 				],
-				// bShowLogin: true, //登录
-				// bShowSYJJ: false, //实验简介一级页面
-				// bShowXXLC: false, //学习流程一级页面
-				// bShowSL: false, //开始学习一级页面
 				checkedIndex_SYJJ: 0, //实验简介选中标题索引值
 				checkedIndex_SYJJ: 0, //实验简介选中标题索引值
 			}
 			}
 		},
 		},
+		onLoad(){
+			let account = localStorage.getItem("account");
+			let password = localStorage.getItem("password");
+	
+			if(account!=null && password!=null)
+			{
+				let url = this.$Api + "/user/loginin";
+				uni.request({
+					header: {
+						'Content-Type': 'application/json;charset=UTF-8'
+					},
+					url: url,
+					method: 'POST',
+					data: {
+						"IlabAccount": account,
+						"Password": password
+					},
+					dataType: 'json',
+					success: (res) => {
+						let data = res.data;
+						//登录成功
+						if (data.Code == 100) {
+							// console.log("登陆成功");
+							if (data.Image != '') {
+								mydata_userInfo.avatarSrc = data.Image;
+							}
+							console.log("登陆成功data=",data);
+							mydata_userInfo.Name = data.Name;
+							mydata_userInfo.UserID = data.UserID;
+							mydata_userInfo.Position = data.Position;
+							mydata_userInfo.role = data.Type;
+							
+							if (mydata_userInfo.role == '老师') {
+								userController.updateStudentList(null,null);
+							} else {
+								userController.updateScore();
+							}
+							userController.updateUserInfo();
+							MyRequest.SetUserType(mydata_userInfo.role,null,null);
+							
+							getApp().globalData.bLogin = true;
+							this.onLogin();
+						}
+					},
+					fail: (res) => {
+						console.log("fail+**+*", res)
+					}
+				});
+			}
+		},
 		methods: {
 		methods: {
 			onTopSYClick(index) {
 			onTopSYClick(index) {
 				if(!getApp().globalData.bLogin) {
 				if(!getApp().globalData.bLogin) {
@@ -173,26 +218,6 @@
 				// console.log("登陆成功home");
 				// console.log("登陆成功home");
 				this.$refs.TopMenu.switchLoginState(true);
 				this.$refs.TopMenu.switchLoginState(true);
 				this.showPage(4);
 				this.showPage(4);
-
-				// uni.chooseImage({
-				// 	success: (chooseImageRes) => {
-				// 		const tempFilePaths = chooseImageRes.tempFilePaths;
-				// 		uni.uploadFile({
-				// 			url: 'http://39.105.166.141:8085/project/createprojectnew', //仅为示例,非真实的接口地址
-				// 			filePath: tempFilePaths[0],
-				// 			name: 'file',
-				// 			formData: {
-				// 				'CreateUserID': 'lyy22', // 创建用户 id
-				// 				'ProjectName': 'test22', // 项目名称
-				// 				'Describe': 'aaa22', // 项目描述
-				// 				'Type': 'bbbbb22', // 科幻 现实 历史 主旋律 纪录片
-				// 			},
-				// 			success: (uploadFileRes) => {
-				// 				console.log('upload ok=', uploadFileRes.data);
-				// 			}
-				// 		});
-				// 	}
-				// });
 			},
 			},
 			showPage(index) {
 			showPage(index) {
 				this.curShowPage = index;
 				this.curShowPage = index;
@@ -218,14 +243,12 @@
 					this.showPage(5)
 					this.showPage(5)
 					this.$refs.TopMenu.switchMiddleState(topMenuS.QXZB, index);
 					this.$refs.TopMenu.switchMiddleState(topMenuS.QXZB, index);
 					this.$refs.QXZB.onTopQXZBClick(index);
 					this.$refs.QXZB.onTopQXZBClick(index);
-					// this.$refs.TopMenu.checkedIndexQXZB = index;
 				}
 				}
 				//学习与实验
 				//学习与实验
 				else if (type == "XXYSY") {
 				else if (type == "XXYSY") {
 					this.showPage(6)
 					this.showPage(6)
 					this.$refs.TopMenu.switchMiddleState(topMenuS.XXYSY, index);
 					this.$refs.TopMenu.switchMiddleState(topMenuS.XXYSY, index);
 					this.$refs.XXYSY.onTopXXYSYClick(index);
 					this.$refs.XXYSY.onTopXXYSYClick(index);
-					// this.$refs.TopMenu.checkedIndexXXYSY = index;
 				} else {
 				} else {
 					console.log("2级点击---", lineIndex, type, index);
 					console.log("2级点击---", lineIndex, type, index);
 				}
 				}
@@ -246,9 +269,6 @@
 				let topMiddleState = '';
 				let topMiddleState = '';
 				switch (indexArr[0]) {
 				switch (indexArr[0]) {
 					case 0: //首页
 					case 0: //首页
-						// targetPage = 4;
-						// topMiddleState = topMenuS.SY;
-						// this.$refs.SY.initData();
 						if (indexArr[1] == 0) {
 						if (indexArr[1] == 0) {
 							targetPage = 9;
 							targetPage = 9;
 							topMiddleState = topMenuS.home1;
 							topMiddleState = topMenuS.home1;
@@ -274,7 +294,6 @@
 						topMiddleState = topMenuS.SYJJ;
 						topMiddleState = topMenuS.SYJJ;
 						this.$refs.SYJJ2.showPage(indexArr[1]);
 						this.$refs.SYJJ2.showPage(indexArr[1]);
 						this.$refs.TopMenu.switchState_syjj(indexArr[1]);
 						this.$refs.TopMenu.switchState_syjj(indexArr[1]);
-						// this.$forceUpdate();
 						break;
 						break;
 					case 2: //学习流程
 					case 2: //学习流程
 						switch (indexArr[1]) {
 						switch (indexArr[1]) {
@@ -295,7 +314,6 @@
 								topMiddleState = topMenuS.XXZLXZ;
 								topMiddleState = topMenuS.XXZLXZ;
 								break;
 								break;
 							default:
 							default:
-
 						}
 						}
 						break;
 						break;
 					case 3: //开始学习
 					case 3: //开始学习
@@ -370,7 +388,6 @@
 			onClick_KSRZ() {
 			onClick_KSRZ() {
 				this.showPage(7);
 				this.showPage(7);
 				this.$refs.TopMenu.switchMiddleState(topMenuS.YLRZ, -1);
 				this.$refs.TopMenu.switchMiddleState(topMenuS.YLRZ, -1);
-				// this.$refs.TopMenu.switchRightState(2);
 			},
 			},
 			//开始学习-实景勘察-开始勘察按钮
 			//开始学习-实景勘察-开始勘察按钮
 			onClick_KSKC() {
 			onClick_KSKC() {
@@ -387,7 +404,6 @@
 				else if (type == 5 || type == 6 || type == 7 || type == 8) {
 				else if (type == 5 || type == 6 || type == 7 || type == 8) {
 					this.showPage(2);
 					this.showPage(2);
 				}
 				}
-				//
 				else {
 				else {
 					switch (type) {
 					switch (type) {
 						case 1: //前序准备-返回上一层:返回到开始学习-前序准备的展开页 type-1
 						case 1: //前序准备-返回上一层:返回到开始学习-前序准备的展开页 type-1
@@ -497,7 +513,6 @@
 				}
 				}
 				this.showPage(targetPage);
 				this.showPage(targetPage);
 				this.$refs.TopMenu.switchMiddleState(topMiddleState, index);
 				this.$refs.TopMenu.switchMiddleState(topMiddleState, index);
-				
 				this.$forceUpdate();
 				this.$forceUpdate();
 			},
 			},
 			//项目管理平台
 			//项目管理平台