// var MyRequest = {
// 	request_test: function() {
// 		console.log("i am request");
// 	}
// };
MyRequest = {
	request_test: function() {
		console.log("i am request");
	},
	uniRquest: function(myurl, mydata, suc100, fail) {
		// console.log("请求url", mydata_api + myurl);
		uni.request({
			header: {
				'Content-Type': 'application/json;charset=UTF-8'
			},
			url: mydata_api + myurl,
			method: 'POST',
			data: mydata,
			dataType: 'json',
			success: (res) => {
				//100成功
				if (res.data.Code == 100) {
					if (suc100) {
						suc100(res);
					}
				}
				//200失败
				else {
					console.log('suc200', res);
				}
			},
			fail: (res) => {
				if (fail) {
					fail();
				}
			}
		});
	},
	SetupScore(scores, suc, fail) {
		let data = {
			"UserID": mydata_userInfo.UserID,
			"Scores": scores
		};
		this.uniRquest('/score/setupscore', data, suc, fail);
	},
	GetScore(suc, fail) {
		let data = {
			"UserID": mydata_userInfo.UserID
		};
		this.uniRquest('/score/getscore', data, suc, fail);
	},
	GetUserInfo(suc, fail) {
		let data = {
			"UserID": mydata_userInfo.UserID
		};
		this.uniRquest('/user/getuserinfo', data, suc, fail);
	},
	GetStudentList(suc, fail) {
		let data = {
			"UserID": mydata_userInfo.UserID
		};
		// console.log("请求学生列表，自己ID",data);
		this.uniRquest('/user/getallstudent', data, suc, fail);
	},
	AddUsers(users, suc, fail) {
		let data = {
			"UserID": mydata_userInfo.UserID,
			"Users": users
		};
		// console.log("添加用户", data);
		this.uniRquest('/user/addusers', data, suc, fail);
	},
	SetUserType(type, suc, fail) {
		let data = {
			"UserID": mydata_userInfo.UserID,
			"Type": type
		};
		// console.log("设置身份", data);
		this.uniRquest('/user/setusertype', data, suc, fail);
	},
	CreateProjectNew(data, suc, fail) {
		this.uniRquest('/project/createprojectnew', data, suc, fail);
	},
	GetProjects(data, suc, fail) {
		this.uniRquest('/project/getprojects', data, suc, fail);
	},
	SetupScore(data, suc, fail) {
		let data2={
			"UserID":mydata_userInfo.UserID,
			"Scores":data
		}
		this.uniRquest('/score/setupscore', data2, suc, fail);
	}
}
