Skip to content

Commit

Permalink
1.2版
Browse files Browse the repository at this point in the history
  • Loading branch information
ChinaGamer committed Jan 4, 2022
1 parent ef8ba22 commit 49bc4f8
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 20 deletions.
113 changes: 113 additions & 0 deletions lib/common/get.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,119 @@ Future<String> 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<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];
}
}
} 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 (_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++;
});
}

print(_schedule["19"]["2"]);
await _next();
await writeSchedule(jsonEncode(_schedule));
}
print("getSchedule End");
Expand Down
16 changes: 8 additions & 8 deletions lib/common/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
});

Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Global {
static Uri getUpdateUrl =
Uri.http(updateApiUrl, "/repos/nano71/GlutAssistantN/releases/latest");
static List<String> getScheduleUrl = [jwUrl, "/academic/student/currcourse/currcourse.jsdo"];
static List<String> getScheduleNextUrl = [jwUrl, "/academic/manager/coursearrange/showTimetable.do"];
static List<String> codeCheckUrl = [jwUrl, "/academic/checkCaptcha.do"];
static double schedulePageTouchMovesMinValue = 70.0;
static double schedulePageGridHeight = 60.0;
Expand Down
18 changes: 15 additions & 3 deletions lib/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ List tomorrowSchedule = [];
List queryScore = [];
List careerList = [];
List careerList2 = [];
List<String> careerInfo = ["","","","","","","","","",""];
List<int> careerCount = [0,0,0,0];
int careerNumber= 0;
List<String> careerInfo = ["", "", "", "", "", "", "", "", "", ""];
List<int> careerCount = [0, 0, 0, 0];
int careerNumber = 0;
int careerJobNumber = 0;
int examAllNumber = 0;
List<List<String>> examList = [];
Expand Down Expand Up @@ -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");
}

32 changes: 24 additions & 8 deletions lib/pages/schedule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -261,20 +261,16 @@ List<Widget> _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 {
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 49bc4f8

Please sign in to comment.