diff --git a/pages/form/index.ts b/pages/form/index.ts index 01bad27..db3a2c3 100644 --- a/pages/form/index.ts +++ b/pages/form/index.ts @@ -12,7 +12,8 @@ Page({ isCamera: false, netWorkErrorDialog: false, historicalList: [], - isJoin: false + isJoin: false, + code: '' }, onShow() { const that = this; @@ -55,6 +56,9 @@ Page({ }) }, onLoad(option) { + if (!this.data.code) { + this.getCode() + } if (option.scene) { const scene = decodeURIComponent(option.scene) const room = scene.split('r=')[1]; @@ -103,6 +107,24 @@ Page({ } }) }, + getCode(callBack?) { + wx.login({ + success: (res) => { + const { code } = res + GetOpenId(code).then(res => { + if (res.code === 200) { + this.setData({ + code: res.data, + }) + callBack?.(true) + } + }) + }, + fail: () => { + callBack?.(false) + } + }) + }, closeDialog() { wx.setStorage({ key: "isConnected", @@ -194,33 +216,28 @@ Page({ }) return } - const that = this; - GetCheckoutRoomNum(this.data.meetingForm.roomNum).then(res => { + GetCheckoutRoomNum(this.data.meetingForm.roomNum).then(async res => { if (res.code === 200) { if (res.data) { - wx.login({ - success: (res) => { - const { code } = res - GetOpenId(code).then(res => { - if (res.code === 200) { - navigateToMeeting(res.data) - } else { - that.setData({ - isJoin: false - }) - } - }).catch(() => { - that.setData({ + if (this.data.code) { + navigateToMeeting(this.data.code) + } else { + this.getCode((bool) => { + if (bool) { + navigateToMeeting(this.data.code) + } else { + Message.error({ + context: this, + offset: [90, 32], + duration: 3000, + content: '登录失败,请重试。', + }); + this.setData({ isJoin: false }) - }) - }, - fail: () => { - that.setData({ - isJoin: false - }) - } - }) + } + }) + } } else { this.setData({ isJoin: false diff --git a/pages/meeting/index.ts b/pages/meeting/index.ts index 7303e19..3bb0de6 100644 --- a/pages/meeting/index.ts +++ b/pages/meeting/index.ts @@ -252,6 +252,9 @@ Page({ wx.onNetworkStatusChange(this.listener) }, onShow() { + wx.setKeepScreenOn({ + keepScreenOn: true, + }); this.setData({ isCurrePage: false })