class UrlParamsHandler { private params: Record = {}; constructor(options?: Record) { this.initParams(options); } private initParams(options?: Record) { 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 { return this.params; } } export default UrlParamsHandler;