diff --git a/src/app.ts b/src/app.ts index a1db8c4..edcfc2f 100644 --- a/src/app.ts +++ b/src/app.ts @@ -46,6 +46,24 @@ App({ wx.ajax = licia.curry(request)({ gUrl: this.globalData.url }); + this.initLogin(); + + wx.setInnerAudioOption({ + obeyMuteSwitch: false, + mixWithOther: false, + }); + }, + onShow(options) { + if (options.query.scene) { + this.globalData.scene = parseScene(options.query.scene); + } + if (this.globalData.loginState) { + this.globalData.loginState = ""; + this.initLogin(); + } + // this.startLogin(); + }, + initLogin() { wx.login({ success: (res) => { wx.ajax({ @@ -61,17 +79,6 @@ App({ }); }, }); - - wx.setInnerAudioOption({ - obeyMuteSwitch: false, - mixWithOther: false, - }); - }, - onShow(options) { - if (options.query.scene) { - this.globalData.scene = parseScene(options.query.scene); - } - // this.startLogin(); }, waitLogin(waitLoginState = false) { let time: number; diff --git a/typings/index.d.ts b/typings/index.d.ts index 0c2c220..fe869d9 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -16,6 +16,7 @@ interface IAppOption { newFeedback: string; }; userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback; + initLogin: (callback?: () => void) => void; waitLogin: (waitLoginState?: boolean) => Promise; getMenuInfo: (arg0: WechatMiniprogram.Page.Instance) => void; getUserInfo: (arg0: WechatMiniprogram.Page.Instance, arg1?: (arg0: any) => void) => void;