- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡 - 药品百科: 搜索 + 分类筛选 + 20种药品静态数据 - 惠教中心: 4条药品使用指南课程 - 我的: 家庭成员信息管理 - 自定义TabBar + navigation-bar组件 - SVG药品分类插图
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
class UrlParamsHandler {
|
|
private params: Record<string, string> = {};
|
|
|
|
constructor(options?: Record<string, string>) {
|
|
this.initParams(options);
|
|
}
|
|
|
|
private initParams(options?: Record<string, string>) {
|
|
const sp = options || {};
|
|
let hasValue = false;
|
|
|
|
for (const key in sp) {
|
|
hasValue = true;
|
|
if (sp[key] !== undefined) {
|
|
this.params[key] = sp[key] as string;
|
|
}
|
|
}
|
|
|
|
if (hasValue) {
|
|
const seeId = wx.getStorageSync("seeId");
|
|
const code = wx.getStorageSync("code");
|
|
if (this.params["seeId"]) {
|
|
wx.removeStorageSync("code");
|
|
if (this.params["seeId"] != seeId) {
|
|
wx.removeStorageSync("ended");
|
|
wx.removeStorageSync("currentTime");
|
|
wx.removeStorageSync("interruptedTime");
|
|
}
|
|
} else {
|
|
wx.removeStorageSync("state");
|
|
wx.removeStorageSync("seeId");
|
|
if (this.params["code"] != code) {
|
|
wx.removeStorageSync("ended");
|
|
wx.removeStorageSync("currentTime");
|
|
wx.removeStorageSync("interruptedTime");
|
|
}
|
|
}
|
|
|
|
for (const key in this.params) {
|
|
wx.setStorageSync(key, this.params[key]);
|
|
}
|
|
}
|
|
}
|
|
|
|
public getLocalParams(): Record<string, string> {
|
|
return this.params;
|
|
}
|
|
}
|
|
|
|
export default UrlParamsHandler;
|