Commit 9a84c01b authored by Damon's avatar Damon

fix: 【ID1001501】【小程序-题库】:通过小程序右上角菜单的【重新进入小程序】,ID就变成平台的了

parent f0be7d85
...@@ -4,20 +4,15 @@ export default { ...@@ -4,20 +4,15 @@ export default {
globalData: { globalData: {
// 开发环境 // 开发环境
uniEnv: process.uniEnv, uniEnv: process.uniEnv,
questionList: [], questionList: []
orgId: -1
}, },
onLaunch: function(options) { onLaunch: function(options) {
this.globalData.id = options?.query?.orgId || -1
// 版本更新 // 版本更新
this.updateApp() this.updateApp()
}, },
onShow: function() { onShow: function(options) {
const orgId = this.globalData.id console.log("options", options)
if (orgId !== this.orgId) { this.updateOrgId(options)
this.logout()
}
this.$u.vuex('orgId', orgId)
}, },
onHide: function() { onHide: function() {
console.log('App Hide') console.log('App Hide')
...@@ -81,10 +76,30 @@ export default { ...@@ -81,10 +76,30 @@ export default {
}) })
} }
}, },
// 更新机构ID
updateOrgId(options) {
const orgId = options?.query?.orgId || -1
// 需要更新机构ID的场景,详细可参考 https://developers.weixin.qq.com/miniprogram/dev/reference/scene-list.html
const scene = [1005, 1006, 1011, 1012, 1013, 1026, 1035, 1047, 1048, 1049, 1053, 1058, 1067, 1091, 1145, 1135, 1183]
if (!this.orgId) {
this.$u.vuex('orgId', orgId)
} else {
if (scene.includes(options.scene)) {
if (orgId !== this.orgId) this.logout()
this.$u.vuex('orgId', orgId)
}
}
},
logout() { logout() {
this.$u.vuex('vuex_token', '') this.$u.vuex('vuex_token', '')
this.$u.vuex('orgId', '')
this.$u.vuex('openId', '') this.$u.vuex('openId', '')
this.$u.vuex('userInfo', {}) this.$u.vuex('userInfo', {})
this.$u.vuex('questionList', {})
this.$u.vuex('lastIndex', {})
this.$u.vuex('answerCount', {})
} }
}, },
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment