Compare commits
No commits in common. "bb962cb8cfaf50d0d5d254b4bb9d2eadda628fd2" and "1917828eab4c9ed03c9412321f4ad6bc00fbedb5" have entirely different histories.
bb962cb8cf
...
1917828eab
@ -32,6 +32,11 @@ interface ILoginOutput {
|
|||||||
*/
|
*/
|
||||||
actualName: string;
|
actualName: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户是否关注了公共号
|
||||||
|
*/
|
||||||
|
isSubscribeWxAccount: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 教务处的 session
|
* 教务处的 session
|
||||||
*/
|
*/
|
||||||
|
@ -1,46 +1,12 @@
|
|||||||
import { Data } from "../core/Data";
|
import { Data } from "../core/Data";
|
||||||
import { Storage } from "../core/Storage";
|
|
||||||
import { Login, ILoginOutput } from "../api/Login";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录状态
|
* 登录状态
|
||||||
*/
|
*/
|
||||||
enum LoginStatus {
|
enum LoginStatus {
|
||||||
|
|
||||||
/**
|
|
||||||
* 已认证
|
|
||||||
*/
|
|
||||||
verified = 1,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 失效的认证
|
|
||||||
* 通常为用户名密码错误
|
|
||||||
*/
|
|
||||||
invalid = 2,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 没有登录信息
|
|
||||||
*/
|
|
||||||
none = 3
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* API 返回数据
|
|
||||||
*/
|
|
||||||
type ILoginApiData = {
|
|
||||||
[P in keyof ILoginOutput]: {
|
|
||||||
type: ILoginOutput[P];
|
|
||||||
getAsync: () => Promise<ILoginOutput[P]>;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Storage 缓存数据类型
|
|
||||||
*/
|
|
||||||
type IStudentInfoStorageData = ILoginOutput & {
|
|
||||||
[P in keyof IStudentInfoData]: IStudentInfoData[P]["type"];
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 学生信息数据结构
|
* 学生信息数据结构
|
||||||
*/
|
*/
|
||||||
@ -61,94 +27,49 @@ type IStudentInfoData = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录状态
|
* 身份证后六位
|
||||||
|
* 用于尝试水卡登录
|
||||||
*/
|
*/
|
||||||
loginStatus: {
|
idCardLast6: {
|
||||||
type: LoginStatus
|
type: string
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上次登录时间
|
* 使用的教务处链接
|
||||||
* 时间戳
|
|
||||||
*/
|
*/
|
||||||
lastLoginTime: {
|
eduService: {
|
||||||
type: number
|
type: string
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 距离上次登录后
|
* 用户的真实姓名
|
||||||
* 学号和密码是否发生过改变
|
|
||||||
*/
|
*/
|
||||||
isUserInfoChange: {
|
actualName: {
|
||||||
|
type: string
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户是否关注了公共号
|
||||||
|
*/
|
||||||
|
isSubscribeWxAccount: {
|
||||||
type: boolean
|
type: boolean
|
||||||
}
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 教务处的 session
|
||||||
|
*/
|
||||||
|
eduSession: {
|
||||||
|
type: string
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 学生信息
|
* 学生信息
|
||||||
*/
|
*/
|
||||||
class StudentInfo extends Data<IStudentInfoData & ILoginApiData> {
|
class StudentInfo extends Data<IStudentInfoData> {
|
||||||
|
|
||||||
/**
|
|
||||||
* 学生信息缓存
|
|
||||||
*/
|
|
||||||
private eduStorage = new Storage<IStudentInfoStorageData>("StudentInfo", {
|
|
||||||
idCardLast6: "",
|
|
||||||
eduService: "",
|
|
||||||
actualName: "",
|
|
||||||
eduSession: "",
|
|
||||||
studentId: "",
|
|
||||||
password: "",
|
|
||||||
loginStatus: LoginStatus.none,
|
|
||||||
lastLoginTime: 0,
|
|
||||||
isUserInfoChange: false
|
|
||||||
});
|
|
||||||
|
|
||||||
public override onLoad() {
|
public override onLoad() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户登录
|
|
||||||
*/
|
|
||||||
private async login(): Promise<boolean> {
|
|
||||||
|
|
||||||
// 获取账号密码
|
|
||||||
const stuId = this.eduStorage.get("studentId");
|
|
||||||
const pwd = this.eduStorage.get("password");
|
|
||||||
|
|
||||||
if (!stuId || !pwd) return false;
|
|
||||||
|
|
||||||
// 发送请求
|
|
||||||
const data = await new Login().param({
|
|
||||||
studentId: stuId,
|
|
||||||
password: pwd
|
|
||||||
}).request().wait();
|
|
||||||
|
|
||||||
// 请求成功
|
|
||||||
let res = data.data;
|
|
||||||
if (res) {
|
|
||||||
|
|
||||||
// 保存数据
|
|
||||||
this.eduStorage.set("actualName", res.actualName);
|
|
||||||
this.eduStorage.set("eduService", res.eduService);
|
|
||||||
this.eduStorage.set("eduSession", res.eduSession);
|
|
||||||
this.eduStorage.set("idCardLast6", res.idCardLast6);
|
|
||||||
|
|
||||||
// 记录时间
|
|
||||||
this.eduStorage.set("lastLoginTime", new Date().getTime());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取状态
|
|
||||||
*/
|
|
||||||
private async getStatus() {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { StudentInfo };
|
|
||||||
export default StudentInfo;
|
|
@ -1,5 +1,5 @@
|
|||||||
import { IAnyData } from "../core/Api";
|
import { IAnyData } from "core/Api";
|
||||||
import { Emitter } from "../core/Emitter";
|
import { Emitter } from "core/Emitter";
|
||||||
import { Modular, Manager } from "../core/Module";
|
import { Modular, Manager } from "../core/Module";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
{
|
{
|
||||||
"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
"description": "项目配置文件",
|
||||||
"packOptions": {
|
"packOptions": {
|
||||||
"ignore": [],
|
"ignore": []
|
||||||
"include": []
|
|
||||||
},
|
},
|
||||||
"miniprogramRoot": "miniprogram/",
|
"miniprogramRoot": "miniprogram/",
|
||||||
"compileType": "miniprogram",
|
"compileType": "miniprogram",
|
||||||
@ -47,16 +46,13 @@
|
|||||||
"useCompilerPlugins": [
|
"useCompilerPlugins": [
|
||||||
"typescript",
|
"typescript",
|
||||||
"sass"
|
"sass"
|
||||||
],
|
]
|
||||||
"useStaticServer": true
|
|
||||||
},
|
},
|
||||||
"simulatorType": "wechat",
|
"simulatorType": "wechat",
|
||||||
"simulatorPluginLibVersion": {},
|
"simulatorPluginLibVersion": {},
|
||||||
"appid": "wx7d809f5e8955843d",
|
"appid": "wx7d809f5e8955843d",
|
||||||
"condition": {},
|
"scripts": {
|
||||||
"srcMiniprogramRoot": "miniprogram/",
|
"beforeCompile": ""
|
||||||
"editorSetting": {
|
},
|
||||||
"tabIndent": "insertSpaces",
|
"condition": {}
|
||||||
"tabSize": 2
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,5 +1,14 @@
|
|||||||
{
|
{
|
||||||
"condition": {
|
"condition": {
|
||||||
|
"plugin": {
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"game": {
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"gamePlugin": {
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
"miniprogram": {
|
"miniprogram": {
|
||||||
"list": [
|
"list": [
|
||||||
{
|
{
|
||||||
@ -10,10 +19,5 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"projectname": "mini-dlpu-v3",
|
|
||||||
"setting": {
|
|
||||||
"compileHotReLoad": true
|
|
||||||
},
|
|
||||||
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html"
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user