Skip to content

Commit

Permalink
修复登录问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ChinaGamer committed Jan 5, 2022
1 parent 49bc4f8 commit 9a50885
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 99 deletions.
180 changes: 92 additions & 88 deletions lib/common/get.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ Future<String> getSchedule() async {
}
}
_next() async {
print("获取课表变更(调课/停课/补课)");
String _id = document
.querySelector(".button[value='个人课表']")!
.attributes["onclick"]!
Expand All @@ -160,101 +161,105 @@ Future<String> getSchedule() async {
var response2 = await get(_url, headers: {"cookie": mapCookieToString()})
.timeout(Duration(seconds: Global.timeOutSec));
document = parse(gbk.decode(response2.bodyBytes));
dom.Element table = document.querySelectorAll(".infolist_hr")[2];
List<dom.Element> trs = table.querySelectorAll(".infolist_hr_common");
int _index = 0;
String _name = "";
String _teacher = "";
trs.forEach((element) {
List<dom.Element> tds = element.querySelectorAll("td");
int _length = tds.length;
print(_length);
if (_length == 17) {
//周
String _delWeek = tds[8].innerHtml.trim();
String _addWeek = tds[13].innerHtml.trim();
//课节
List<String> _delTime = tds[10]
.innerHtml
.trim()
.replaceAll("第", "")
.replaceAll("节", "")
.replaceAll("周", "")
.replaceAll("双", "")
.split('-');
List<String> _addTime = tds[15]
.innerHtml
.trim()
.replaceAll("第", "")
.replaceAll("节", "")
.replaceAll("周", "")
.replaceAll("双", "")
.split('-');
//星期
String _delWeekDay = weekDay2Number(tds[9].innerHtml.trim());
String _addWeekDay = weekDay2Number(tds[14].innerHtml.trim());
//教室
String _addRoom = tds[16].innerHtml.trim();
//老师
String _addTeacher = tds[4].innerHtml.trim();
_teacher = _addTeacher;
//课
String _addName = tds[2].innerHtml.trim();
_name = _addName;
if (_delWeek != "&nbsp;") {
for (int i = int.parse(_delTime[0]); i <= int.parse(_delTime[1]); i++) {
_schedule[_delWeek][_delWeekDay][i.toString()] = ["null", "null", "null"];
List<dom.Element> tables = document.querySelectorAll(".infolist_hr");
if (tables.length >= 3) {
dom.Element table = tables[2];
List<dom.Element> trs = table.querySelectorAll(".infolist_hr_common");
int _index = 0;
String _name = "";
String _teacher = "";
trs.forEach((element) {
List<dom.Element> tds = element.querySelectorAll("td");
int _length = tds.length;
print(_length);
if (_length == 17) {
//周
String _delWeek = tds[8].innerHtml.trim();
String _addWeek = tds[13].innerHtml.trim();
//课节
List<String> _delTime = tds[10]
.innerHtml
.trim()
.replaceAll("第", "")
.replaceAll("节", "")
.replaceAll("周", "")
.replaceAll("双", "")
.split('-');
List<String> _addTime = tds[15]
.innerHtml
.trim()
.replaceAll("第", "")
.replaceAll("节", "")
.replaceAll("周", "")
.replaceAll("双", "")
.split('-');
//星期
String _delWeekDay = weekDay2Number(tds[9].innerHtml.trim());
String _addWeekDay = weekDay2Number(tds[14].innerHtml.trim());
//教室
String _addRoom = tds[16].innerHtml.trim();
//老师
String _addTeacher = tds[4].innerHtml.trim();
_teacher = _addTeacher;
//课
String _addName = tds[2].innerHtml.trim();
_name = _addName;
if (_delWeek != "&nbsp;") {
for (int i = int.parse(_delTime[0]); i <= int.parse(_delTime[1]); i++) {
_schedule[_delWeek][_delWeekDay][i.toString()] = ["null", "null", "null"];
}
}
}
if (_addWeek != "&nbsp;") {
for (int i = int.parse(_addTime[0]); i <= int.parse(_addTime[1]); i++) {
_schedule[_addWeek][_addWeekDay][i.toString()] = [_addName, _addTeacher, _addRoom];
if (_addWeek != "&nbsp;") {
for (int i = int.parse(_addTime[0]); i <= int.parse(_addTime[1]); i++) {
_schedule[_addWeek][_addWeekDay]
[i.toString()] = [_addName, _addTeacher, _addRoom];
}
}
}
} else if (_length == 10) {
//周
String _delWeek = tds[1].innerHtml.trim();
String _addWeek = tds[6].innerHtml.trim();
//课节
List<String> _delTime = tds[3]
.innerHtml
.trim()
.replaceAll("第", "")
.replaceAll("节", "")
.replaceAll("周", "")
.replaceAll("双", "")
.split('-');
List<String> _addTime = tds[8]
.innerHtml
.trim()
.replaceAll("第", "")
.replaceAll("节", "")
.replaceAll("周", "")
.replaceAll("双", "")
.split('-');
//星期
String _delWeekDay = weekDay2Number(tds[2].innerHtml.trim());
String _addWeekDay = weekDay2Number(tds[7].innerHtml.trim());
//教室
String _addRoom = tds[9].innerHtml.trim();
} else if (_length == 10) {
//周
String _delWeek = tds[1].innerHtml.trim();
String _addWeek = tds[6].innerHtml.trim();
//课节
List<String> _delTime = tds[3]
.innerHtml
.trim()
.replaceAll("第", "")
.replaceAll("节", "")
.replaceAll("周", "")
.replaceAll("双", "")
.split('-');
List<String> _addTime = tds[8]
.innerHtml
.trim()
.replaceAll("第", "")
.replaceAll("节", "")
.replaceAll("周", "")
.replaceAll("双", "")
.split('-');
//星期
String _delWeekDay = weekDay2Number(tds[2].innerHtml.trim());
String _addWeekDay = weekDay2Number(tds[7].innerHtml.trim());
//教室
String _addRoom = tds[9].innerHtml.trim();

if (_delWeek != "&nbsp;") {
for (int i = int.parse(_delTime[0]); i <= int.parse(_delTime[1]); i++) {
_schedule[_delWeek][_delWeekDay][i.toString()] = ["null", "null", "null"];
if (_delWeek != "&nbsp;") {
for (int i = int.parse(_delTime[0]); i <= int.parse(_delTime[1]); i++) {
_schedule[_delWeek][_delWeekDay][i.toString()] = ["null", "null", "null"];
}
}
}
if (_addWeek != "&nbsp;") {
for (int i = int.parse(_addTime[0]); i <= int.parse(_addTime[1]); i++) {
_schedule[_addWeek][_addWeekDay][i.toString()] = [_name, _teacher, _addRoom];
print(_schedule[_addWeek][_addWeekDay][i.toString()]);
if (_addWeek != "&nbsp;") {
for (int i = int.parse(_addTime[0]); i <= int.parse(_addTime[1]); i++) {
_schedule[_addWeek][_addWeekDay][i.toString()] = [_name, _teacher, _addRoom];
print(_schedule[_addWeek][_addWeekDay][i.toString()]);
}
}
}
}
_index++;
});
_index++;
});
}
}

print(_schedule["19"]["2"]);
print(writeData);
await _next();
await writeSchedule(jsonEncode(_schedule));
}
Expand Down Expand Up @@ -452,7 +457,6 @@ Future getCareer() async {
start = i + 1;
}
if (i == list.length - 1) {
print("结尾了");
newList.add(list.sublist(start, i + 1));
}
}
Expand Down
40 changes: 29 additions & 11 deletions lib/pages/career.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class _CareerPageBodyState extends State<CareerPageBody> {
GlobalKey<TextProgressDynamicStateForCareer> textKey = GlobalKey();
final int _week = int.parse(writeData["week"]);
int year = 0;
int year2 = 0;
int allYear = 0;

@override
void initState() {
Expand Down Expand Up @@ -112,24 +112,42 @@ class _CareerPageBodyState extends State<CareerPageBody> {

double _weekProgressDouble() {
if (careerInfo[2] != "" && careerInfo[3] != "") {
//年级
year = int.parse(careerInfo[2].replaceAll("级", "").trim());
year2 = int.parse(
// 全部学年
allYear = int.parse(
careerInfo[3].substring(careerInfo[3].toString().indexOf("年") - 1).replaceAll("年", ""));
setState(() {});
}
double semesterPercentage = year2 == 3 ? 1 / 6 : 1 / 8;
//完整的一个学期占比
double semesterPercentage = allYear == 3 ? 1 / 6 : 1 / 8;

//本学期
double weekPercentage = (_week * 5 / 100) - 0.05 + (DateTime.now().weekday / 7 * 5 / 100);
int year3 = year + year2 - DateTime.now().year;
next() {

//剩余学年 :: 2019 + 3年 - 2022

int year3 = year + allYear - DateTime.now().year;
print(DateTime.now().month);
if (DateTime.now().month < 3) {
year3++;
}

//本学期在全部学期占比
double proportionOfSemesterInAllSemesters = weekPercentage * semesterPercentage;

//year2 = 3 , year3 = 0
_next() {
if (writeData["semester"] == "秋")
return 1 - year3 / year2 + weekPercentage * semesterPercentage;
return (allYear * 2 - year3 * 2) * semesterPercentage + proportionOfSemesterInAllSemesters;
else
return 1 - year3 / year2 + semesterPercentage + weekPercentage * semesterPercentage;
return (allYear * 2 - year3 * 2 + 1) * semesterPercentage +
proportionOfSemesterInAllSemesters;
}

if (_week > 20 && DateTime.now().year == year + year2) return 1.00;
if (_week > 20 && DateTime.now().year == year + allYear) return 1.00;
if (careerInfo[2] == "" && careerInfo[3] == "") return 0.0;
return next();
return _next();
}

@override
Expand Down Expand Up @@ -389,7 +407,7 @@ class _CareerPageBodyState extends State<CareerPageBody> {
SliverList(
delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
return CareerListProcess(index);
}, childCount: year2),
}, childCount: allYear),
),
],
),
Expand Down Expand Up @@ -531,7 +549,7 @@ careerDialog(context, index, type, year) {
return NoRippleOverScroll(
child: SimpleDialog(
title: Row(
mainAxisAlignment:MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down

0 comments on commit 9a50885

Please sign in to comment.