From 49bc4f854e43afd06bd9a7ee03a17babd578fa8a Mon Sep 17 00:00:00 2001 From: ChinaGamer <1742968988@.qq.com> Date: Tue, 4 Jan 2022 14:57:10 +0800 Subject: [PATCH] =?UTF-8?q?1.2=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/common/get.dart | 113 ++++++++++++++++++++++++++++++++++++++++ lib/common/init.dart | 16 +++--- lib/config.dart | 1 + lib/data.dart | 18 +++++-- lib/pages/schedule.dart | 32 +++++++++--- pubspec.yaml | 2 +- 6 files changed, 162 insertions(+), 20 deletions(-) diff --git a/lib/common/get.dart b/lib/common/get.dart index 427f467..91893c1 100644 --- a/lib/common/get.dart +++ b/lib/common/get.dart @@ -143,6 +143,119 @@ Future getSchedule() async { } } } + _next() async { + String _id = document + .querySelector(".button[value='个人课表']")! + .attributes["onclick"]! + .substring(61) + .split("&year")[0]; + print(_id); + Uri _url = Uri.http(Global.getScheduleNextUrl[0], Global.getScheduleNextUrl[1], { + "id": _id, + "yearid": ((int.parse(writeData["yearBk"])) - 1980).toString(), + "termid": writeData["semesterBk"] == "秋" ? "3" : "1", + "timetableType": "STUDENT", + "sectionType": "BASE" + }); + 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 trs = table.querySelectorAll(".infolist_hr_common"); + int _index = 0; + String _name = ""; + String _teacher = ""; + trs.forEach((element) { + List 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 _delTime = tds[10] + .innerHtml + .trim() + .replaceAll("第", "") + .replaceAll("节", "") + .replaceAll("周", "") + .replaceAll("双", "") + .split('-'); + List _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 != " ") { + for (int i = int.parse(_delTime[0]); i <= int.parse(_delTime[1]); i++) { + _schedule[_delWeek][_delWeekDay][i.toString()] = ["null", "null", "null"]; + } + } + if (_addWeek != " ") { + 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 _delTime = tds[3] + .innerHtml + .trim() + .replaceAll("第", "") + .replaceAll("节", "") + .replaceAll("周", "") + .replaceAll("双", "") + .split('-'); + List _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 != " ") { + for (int i = int.parse(_delTime[0]); i <= int.parse(_delTime[1]); i++) { + _schedule[_delWeek][_delWeekDay][i.toString()] = ["null", "null", "null"]; + } + } + if (_addWeek != " ") { + 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++; + }); + } + + print(_schedule["19"]["2"]); + await _next(); await writeSchedule(jsonEncode(_schedule)); } print("getSchedule End"); diff --git a/lib/common/init.dart b/lib/common/init.dart index 3125996..084e38f 100644 --- a/lib/common/init.dart +++ b/lib/common/init.dart @@ -25,11 +25,11 @@ initTodaySchedule() async { final String _week = writeData["week"].toString(); Map _schedule = schedule; List toDay = []; - await _schedule[_week][DateTime.now().weekday.toString()].forEach((k, v) => { - if (v[1] != "null") + await _schedule[_week][DateTime.now().weekday.toString()].forEach((key, value) => { + if (value[1] != "null") { - if (v.length < 5) {v.add(k)}, - toDay.add(v) + if (value.length < 5) {value.add(key)}, + toDay.add(value) } }); @@ -59,12 +59,12 @@ initTomorrowSchedule() async { } if (DateTime.now().weekday <= 6) { - await _schedule[_week][_getWeekDay()].forEach((k, v) => { - if (v[1] != "null") {v.add(k), tomorrow.add(v)} + await _schedule[_week][_getWeekDay()].forEach((key, value) => { + if (value[1] != "null") {value.add(key), tomorrow.add(value)} }); } else { - await _schedule[(int.parse(_week) + 1).toString()][_getWeekDay()].forEach((k, v) => { - if (v[1] != "null") {v.add(k), tomorrow.add(v)} + await _schedule[(int.parse(_week) + 1).toString()][_getWeekDay()].forEach((key, value) => { + if (value[1] != "null") {value.add(key), tomorrow.add(value)} }); } if (tomorrow.isNotEmpty) { diff --git a/lib/config.dart b/lib/config.dart index 28cfe1f..c3568d6 100644 --- a/lib/config.dart +++ b/lib/config.dart @@ -30,6 +30,7 @@ class Global { static Uri getUpdateUrl = Uri.http(updateApiUrl, "/repos/nano71/GlutAssistantN/releases/latest"); static List getScheduleUrl = [jwUrl, "/academic/student/currcourse/currcourse.jsdo"]; + static List getScheduleNextUrl = [jwUrl, "/academic/manager/coursearrange/showTimetable.do"]; static List codeCheckUrl = [jwUrl, "/academic/checkCaptcha.do"]; static double schedulePageTouchMovesMinValue = 70.0; static double schedulePageGridHeight = 60.0; diff --git a/lib/data.dart b/lib/data.dart index c7ae3d1..b65629c 100644 --- a/lib/data.dart +++ b/lib/data.dart @@ -76,9 +76,9 @@ List tomorrowSchedule = []; List queryScore = []; List careerList = []; List careerList2 = []; -List careerInfo = ["","","","","","","","","",""]; -List careerCount = [0,0,0,0]; -int careerNumber= 0; +List careerInfo = ["", "", "", "", "", "", "", "", "", ""]; +List careerCount = [0, 0, 0, 0]; +int careerNumber = 0; int careerJobNumber = 0; int examAllNumber = 0; List> examList = []; @@ -163,3 +163,15 @@ String levelToNumber(String value) { .replaceAll("不及格", "40") .replaceAll("不合格", "40"); } + +String weekDay2Number(String value) { + return value + .replaceAll("周一", "1") + .replaceAll("周二", "2") + .replaceAll("周三", "3") + .replaceAll("周四", "4") + .replaceAll("周五", "5") + .replaceAll("周六", "6") + .replaceAll("周日", "7"); +} + diff --git a/lib/pages/schedule.dart b/lib/pages/schedule.dart index 210c998..5111e05 100644 --- a/lib/pages/schedule.dart +++ b/lib/pages/schedule.dart @@ -261,20 +261,16 @@ List _loopWeekDayColGrid(String week, String weekDay) { if (courseName != "null") { if (i == 1) { - // print(courseName + " start${i}"); s = i; } else if (courseName == courseLongText2ShortName(_schedule[(i - 1).toString()][0])) { if (i == 11) { - // print(courseName + " end${i}"); list.add(_grid( courseName, studyArea, randomColors(), Global.schedulePageGridHeight * (i - s + 1))); } else if (courseName != courseLongText2ShortName(_schedule[(i + 1).toString()][0])) { - // print(courseName + " end${i}"); list.add(_grid( courseName, studyArea, randomColors(), Global.schedulePageGridHeight * (i - s + 1))); } } else { - // print(courseName + " start${i}"); s = i; } } else { @@ -288,12 +284,32 @@ Widget _grid(String title, String studyArea, Color color, [double height = 60.0] TextStyle style = const TextStyle(fontSize: 12, color: Colors.white); return Container( height: height, - color: color, - padding: const EdgeInsets.only(left: 6, right: 6), + decoration: BoxDecoration( + color: color, + border: Border( + top: BorderSide( + width: 1, //宽度 + color: Colors.white, //边框颜色 + ), + right: BorderSide( + width: 1, //宽度 + color: Colors.white, //边框颜色 + ), + bottom: BorderSide( + width: 1, //宽度 + color: Colors.white, //边框颜色 + ), + left: BorderSide( + width: 1, //宽度 + color: Colors.white, //边框颜色 + )), + borderRadius: const BorderRadius.all(Radius.circular(4.0)), + ), + padding: const EdgeInsets.only(left: 5, right: 5, top: 5, bottom: 5), alignment: Alignment.center, child: Column( - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.max, children: [ Text( title, diff --git a/pubspec.yaml b/pubspec.yaml index 3e1506b..ee88400 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.2.211219+10 +version: 1.2.220104+11 environment: sdk: ">=2.12.0 <3.0.0"