Compare commits

..

No commits in common. "bb962cb8cfaf50d0d5d254b4bb9d2eadda628fd2" and "1917828eab4c9ed03c9412321f4ad6bc00fbedb5" have entirely different histories.

5 changed files with 54 additions and 128 deletions

View File

@ -32,6 +32,11 @@ interface ILoginOutput {
*/
actualName: string;
/**
*
*/
isSubscribeWxAccount: boolean;
/**
* session
*/

View File

@ -1,46 +1,12 @@
import { Data } from "../core/Data";
import { Storage } from "../core/Storage";
import { Login, ILoginOutput } from "../api/Login";
/**
*
*/
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: {
type: LoginStatus
}
idCardLast6: {
type: string
};
/**
*
*
* 使
*/
lastLoginTime: {
type: number
}
eduService: {
type: string
};
/**
*
*
*
*/
isUserInfoChange: {
actualName: {
type: string
};
/**
*
*/
isSubscribeWxAccount: {
type: boolean
}
};
/**
* session
*/
eduSession: {
type: string
};
}
/**
*
*/
class StudentInfo extends Data<IStudentInfoData & ILoginApiData> {
/**
*
*/
private eduStorage = new Storage<IStudentInfoStorageData>("StudentInfo", {
idCardLast6: "",
eduService: "",
actualName: "",
eduSession: "",
studentId: "",
password: "",
loginStatus: LoginStatus.none,
lastLoginTime: 0,
isUserInfoChange: false
});
class StudentInfo extends Data<IStudentInfoData> {
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;
}

View File

@ -1,5 +1,5 @@
import { IAnyData } from "../core/Api";
import { Emitter } from "../core/Emitter";
import { IAnyData } from "core/Api";
import { Emitter } from "core/Emitter";
import { Modular, Manager } from "../core/Module";
/**

View File

@ -1,8 +1,7 @@
{
"description": "项目配置文件详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"description": "项目配置文件",
"packOptions": {
"ignore": [],
"include": []
"ignore": []
},
"miniprogramRoot": "miniprogram/",
"compileType": "miniprogram",
@ -47,16 +46,13 @@
"useCompilerPlugins": [
"typescript",
"sass"
],
"useStaticServer": true
]
},
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"appid": "wx7d809f5e8955843d",
"condition": {},
"srcMiniprogramRoot": "miniprogram/",
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
"scripts": {
"beforeCompile": ""
},
"condition": {}
}

View File

@ -1,5 +1,14 @@
{
"condition": {
"plugin": {
"list": []
},
"game": {
"list": []
},
"gamePlugin": {
"list": []
},
"miniprogram": {
"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"
}
}