Skip to content

Commit

Permalink
获取考试&&版本更新
Browse files Browse the repository at this point in the history
  • Loading branch information
nano71 committed Nov 14, 2021
1 parent a364b39 commit aaca070
Show file tree
Hide file tree
Showing 16 changed files with 491 additions and 53 deletions.
86 changes: 85 additions & 1 deletion lib/common/get.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Future<List> getScore() async {
var response =
await post(Global.getScoreUrl, body: postData, headers: {"cookie": mapCookieToString()})
.timeout(const Duration(milliseconds: 6000));
if(response.headers["location"] == "/academic/common/security/login.jsp"){
if (response.headers["location"] == "/academic/common/security/login.jsp") {
return ["登录过期"];
}
dom.Document document = parse(response.body);
Expand All @@ -216,3 +216,87 @@ Future<List> getScore() async {
print("getScore End");
return list;
}

Future<String> getExam() async {
print("getExam");
try {
var response = await post(Global.getExamUrl, headers: {"cookie": mapCookieToString()})
.timeout(const Duration(milliseconds: 6000));
dom.Document document = parse(gbk.decode(response.bodyBytes));
if (document.querySelector("title")!.text.contains("提示信息")) {
return "fail";
} else {
document = parse(response.body);
examList = [];
var _row = document.querySelectorAll(".datalist> tbody > tr");
for (int i = 1; i < _row.length; i++) {
List<String> _list = [];
String time = _row[i].querySelectorAll("td")[2].text;
List timeList = time.split("-");
_list.add(_row[i].querySelectorAll("td")[1].text);
_list.add(time);
_list.add(_row[i]
.querySelectorAll("td")[3]
.text
.replaceAll("空港校区", "")
.replaceAll("教", "")
.trim()
.substring(1)
.trim());
_list.add(_row[i].querySelectorAll("td")[4].text);

DateTime startDate = DateTime.now();
DateTime endDate = DateTime(int.parse(timeList[0]), int.parse(timeList[1]),
int.parse(timeList[2].toString().substring(0, 2)));
int days = endDate.difference(startDate).inDays;
if (days < 0) {
examListC.add(true);
examListA++;
} else {
examListB++;
examListC.add(false);
}

examList.add(_list);
}
print("getExam End");
return "success";
}
} on TimeoutException catch (e) {
print("getExam Error");
return "超时" + e.toString();
} on SocketException catch (e) {
print("getExam Error");
return "网络连接失败" + e.toString();
}
}

Future getCareer() async {
print("getCareer");
_next(url) async {
var response = await get(Uri.http(Global.jwUrl, url), headers: {"cookie": mapCookieToString()})
.timeout(const Duration(milliseconds: 6000));
dom.Document document = parse(gbk.decode(response.bodyBytes));
print(document.querySelectorAll("tr").length);
}

var response = await get(Global.getCareerUrl, headers: {"cookie": mapCookieToString()})
.timeout(const Duration(milliseconds: 6000));
dom.Document document = parse(gbk.decode(response.bodyBytes));
if (gbk.decode(response.bodyBytes).contains("用户名不能为空!")) {

} else {
String url = document
.querySelectorAll("a")[3]
.parent!
.innerHtml
.trim()
.replaceAll(
'" target="_blank"><img src="/academic/styles/images/calendar_timeline.png" title="修读顺序:按照课组及学年学期的顺序,用二维表方式显示教学计划课',
"")
.replaceAll('<a href="', "");
print(url);
await _next(url);
print("getCareer End");
}
}
2 changes: 2 additions & 0 deletions lib/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ class Global {
static Uri loginUrl = Uri.http(jwUrl, "/academic/j_acegi_security_check");
static Uri loginUrl2 = Uri.http(jwUrl, "/academic/index_new.jsp");
static Uri getWeekUrl = Uri.http(jwUrl, "/academic/listLeft.do");
static Uri getExamUrl = Uri.http(jwUrl, "/academic/manager/examstu/studentQueryAllExam.do");
static Uri getNameUrl = Uri.http(jwUrl, "/academic/student/studentinfo/studentInfoModifyIndex.do",
{"frombase": "0", "wantTag": "0"});
static Uri getScoreUrl = Uri.http(jwUrl, "/academic/manager/score/studentOwnScore.do");
static Uri getCareerUrl = Uri.http(jwUrl, "/academic/manager/studyschedule/studentSelfSchedule.jsdo");
static List<String> getScheduleUrl = [jwUrl, "/academic/student/currcourse/currcourse.jsdo"];
static List<String> codeCheckUrl = [jwUrl, "/academic/checkCaptcha.do"];
static double schedulePageTouchMovesMinValue = 70.0;
Expand Down
15 changes: 13 additions & 2 deletions lib/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ReTodayListState {

ReTodayListState(this.index);
}

double gpa = 0.0;
double avg = 0.0;
double weight = 0.0;
Expand All @@ -50,6 +51,10 @@ Map writeData = {
List todaySchedule = [];
List tomorrowSchedule = [];
List queryScore = [];
List<List<String>> examList = [];
List<bool> examListC = [];
int examListA = 0;
int examListB = 0;
String todayScheduleTitle = "";
String tomorrowScheduleTitle = "";
final List startTimeList = [
Expand Down Expand Up @@ -119,6 +124,12 @@ String courseLongText2ShortName(String value) {
}

String levelToNumber(String value) {
return value.replaceAll("优", "95").replaceAll("良", "85").replaceAll("中", "65").replaceAll(
"及格", "65").replaceAll("合格", "65").replaceAll("不及格", "40").replaceAll("不合格", "40");
return value
.replaceAll("优", "95")
.replaceAll("良", "85")
.replaceAll("中", "65")
.replaceAll("及格", "65")
.replaceAll("合格", "65")
.replaceAll("不及格", "40")
.replaceAll("不合格", "40");
}
3 changes: 1 addition & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import 'package:glutassistantn/pages/init.dart';
import 'config.dart';

main() {
SystemUiOverlayStyle systemUiOverlayStyle =
const SystemUiOverlayStyle(statusBarColor: Colors.white);
SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(statusBarColor: Colors.transparent);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
print("startApp...");
runApp(const MyApp());
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/career.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class _CareerPageState extends State<CareerPage> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"页面开发中...",
"敬请期待...",
style: TextStyle(fontSize: 18, color: readColor()),
),
],
Expand Down
27 changes: 22 additions & 5 deletions lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter/widgets.dart';
import 'package:glutassistantn/common/get.dart';
import 'package:glutassistantn/common/init.dart';
import 'package:glutassistantn/pages/query.dart';
import 'package:glutassistantn/pages/queryexam.dart';
import 'package:glutassistantn/widget/bars.dart';
import 'package:glutassistantn/widget/cards.dart';
import 'package:glutassistantn/widget/icons.dart';
Expand Down Expand Up @@ -38,8 +39,7 @@ class HomePageState extends State<HomePage> with TickerProviderStateMixin {
late Animation _animationForHomeCards1;
late Animation _animationForHomeCards2;
late Animation _animationForHomeCards3;
ColorTween homeCardsColorTween =
ColorTween(begin: readColorBegin(), end: readColorEnd());
ColorTween homeCardsColorTween = ColorTween(begin: readColorBegin(), end: readColorEnd());
int _goTopInitCount = 0;
bool _bk = true;
Timer? _time;
Expand Down Expand Up @@ -269,7 +269,12 @@ class HomePageState extends State<HomePage> with TickerProviderStateMixin {
},
onTapUp: (d) {
Future.delayed(const Duration(milliseconds: 100), () {
_goTop();
if (writeData["username"] == "") {
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => const LoginPage()));
} else {
_goTop();
}
_animationControllerForHomeCards1.reverse();
});
},
Expand Down Expand Up @@ -310,8 +315,13 @@ class HomePageState extends State<HomePage> with TickerProviderStateMixin {
},
onTapUp: (d) {
Future.delayed(const Duration(milliseconds: 100), () {
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => const QueryPage()));
if (writeData["username"] == "") {
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => const LoginPage()));
} else {
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => const QueryPage()));
}
_animationControllerForHomeCards2.reverse();
});
},
Expand All @@ -334,6 +344,13 @@ class HomePageState extends State<HomePage> with TickerProviderStateMixin {
},
onTapUp: (d) {
Future.delayed(const Duration(milliseconds: 100), () {
if (writeData["username"] == "") {
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => const LoginPage()));
} else {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => const QueryExamPage()));
}
_animationControllerForHomeCards3.reverse();
});
},
Expand Down
50 changes: 37 additions & 13 deletions lib/pages/mine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:glutassistantn/pages/career.dart';
import 'package:glutassistantn/pages/setting.dart';
import 'package:glutassistantn/pages/update.dart';
import 'package:glutassistantn/widget/bars.dart';
import 'package:glutassistantn/widget/icons.dart';
import 'package:url_launcher/url_launcher.dart';

import '../config.dart';
import '../data.dart';
Expand Down Expand Up @@ -53,35 +55,33 @@ class MinePageState extends State<MinePage> {
InkWell(
onTap: () {
Navigator.of(context).push(
// 在FormPage()里传入参数
MaterialPageRoute(builder: (context) => const CareerPage()));
},
child: mineItem(Icons.workspaces_outline,
const EdgeInsets.fromLTRB(16, 14, 0, 14), "课程生涯", readColor()),
),
// InkWell(
// onTap: () {
// Navigator.of(context).push(
// // 在FormPage()里传入参数
// MaterialPageRoute(builder: (context) => const QueryPage()));
// },
// child: mineItem(
// Icons.list_alt_rounded, const EdgeInsets.fromLTRB(16, 14, 0, 14), "成绩查询"),
// ),
topLine,
InkWell(
onTap: () {
// launch("https://github.com/ChinaGamer/GlutAssistantN/releases/latest");

Navigator.of(context).push(
// 在FormPage()里传入参数
MaterialPageRoute(builder: (context) => const InfoPage()));
MaterialPageRoute(builder: (context) => const UpdatePage()));
},
child: mineItem(Icons.system_update_alt,
const EdgeInsets.fromLTRB(16, 14, 0, 14), "版本更新", readColor()),
),
InkWell(
onTap: () {
Navigator.of(context)
.push(MaterialPageRoute(builder: (context) => const InfoPage()));
},
child: mineItem(Icons.info_outline, const EdgeInsets.fromLTRB(16, 14, 0, 14),
"说明", readColor()),
),
InkWell(
onTap: () {
Navigator.of(context).push(
// 在FormPage()里传入参数
MaterialPageRoute(builder: (context) => const SettingPage(title: "设置2")));
},
child: mineItem(Icons.settings_outlined,
Expand Down Expand Up @@ -129,6 +129,30 @@ Widget mineItem(IconData icon, EdgeInsets padding, String title, Color color) {
);
}

Widget mineItem3(IconData icon, EdgeInsets padding, String title, Color color) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Icon(icon, color: color),
Container(
padding: padding,
child: Text(
title,
style: const TextStyle(fontSize: 16),
),
)
],
),
Icon(
Icons.link,
color: Colors.black45,
),
],
);
}

Widget mineItem2(IconData icon, EdgeInsets padding, String title) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
Expand Down
34 changes: 22 additions & 12 deletions lib/pages/query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ class _QueryPageState extends State<QueryPage> {
if (list[i][2].toString().contains("慕") && list[i][3] == "") {
no++;
} else {
_q += (int.parse(levelToNumber(list[i][4])) * double.parse(list[i][5]));
_xf += double.parse(levelToNumber(list[i][5]));
sum += int.parse(levelToNumber(list[i][4]));
if (list[i].length > 5) {
_q += (int.parse(levelToNumber(list[i]![4])) * double.parse(list[i]![5]));
_xf += double.parse(levelToNumber(list[i][5]));
}
if (list[i].length > 4) {
sum += int.parse(levelToNumber(list[i][4]));
}
}
}
_avg = double.parse((sum / (list.length - no)).toStringAsFixed(1));
Expand Down Expand Up @@ -114,14 +118,20 @@ class _QueryPageState extends State<QueryPage> {
physics: const AlwaysScrollableScrollPhysics(parent: BouncingScrollPhysics()),
slivers: [
publicTopBar(
"成绩查询",
InkWell(
child: const Icon(Icons.close_outlined, size: 24),
onTap: () {
Navigator.of(context).pop();
},
),
),
"成绩查询",
InkWell(
child: const Icon(
Icons.close_outlined,
size: 24,
color: Colors.white,
),
onTap: () {
Navigator.of(context).pop();
},
),
readColor(),
Colors.white,
0),
SliverToBoxAdapter(
child: Container(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
Expand Down Expand Up @@ -226,7 +236,7 @@ class _QueryPageState extends State<QueryPage> {
),
),
),
QueryScore()
ScoreList()
],
),
),
Expand Down
Loading

0 comments on commit aaca070

Please sign in to comment.