|
@@ -144,10 +144,16 @@ func doLogin(user: String, password: String, action: @escaping (_: Int) -> Void)
|
|
|
|
|
|
struct DecodableType: Decodable { let url: String }
|
|
struct DecodableType: Decodable { let url: String }
|
|
|
|
|
|
-func getUserInfo(userInfo: inout UserInfo) {
|
|
|
|
- userInfo.name = "向量"
|
|
|
|
|
|
+func getUserInfo(action: @escaping (_: UserInfo) -> Void) {
|
|
FetchHandler().fetchAny(url: "bxn-portal/portal/osforstudent/index") { res in
|
|
FetchHandler().fetchAny(url: "bxn-portal/portal/osforstudent/index") { res in
|
|
- print(res)
|
|
|
|
|
|
+ var userInfo: UserInfo = .init(name: "", o: "")
|
|
|
|
+ if let name = res.firstMatch(of: /userFullName" value="(.*?)"/) {
|
|
|
|
+ userInfo.name = "\(name.1)"
|
|
|
|
+ }
|
|
|
|
+ if let name = res.firstMatch(of: /userId" value="(.*?)"/) {
|
|
|
|
+ userInfo.o = "\(name.1)"
|
|
|
|
+ }
|
|
|
|
+ action(userInfo)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -192,7 +198,9 @@ struct loginView: View {
|
|
btnText = "登录失败"
|
|
btnText = "登录失败"
|
|
btnColor = .red
|
|
btnColor = .red
|
|
} else {
|
|
} else {
|
|
- getUserInfo(userInfo: &userInfo)
|
|
|
|
|
|
+ getUserInfo { res in
|
|
|
|
+ userInfo = res
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}) {
|
|
}) {
|
|
@@ -227,9 +235,9 @@ struct accountView: View {
|
|
Text(userInfo.name)
|
|
Text(userInfo.name)
|
|
}
|
|
}
|
|
HStack {
|
|
HStack {
|
|
- Text("所属班级")
|
|
|
|
|
|
+ Text("内部 ID")
|
|
Spacer()
|
|
Spacer()
|
|
- Text(userInfo.name)
|
|
|
|
|
|
+ Text(userInfo.o)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Section {
|
|
Section {
|