产品库增加企微端登录,登录修复

This commit is contained in:
aixianling
2022-06-13 19:47:49 +08:00
parent dcf0271990
commit ff0414cb79
2 changed files with 40 additions and 11 deletions

View File

@@ -46,7 +46,7 @@ export default {
}
},
methods: {
...mapActions(['getToken','getAccount']),
...mapActions(['getToken', 'getAccount', 'getCode']),
...mapMutations(['login', 'logout']),
handleLogin() {
this.$refs.loginForm.validate(v => {
@@ -61,7 +61,7 @@ export default {
}
this.getToken({...this.form, module, corpId}).then(token => {
this.login(token)
if( module != 'AppCountryAlbum'){
if (module != 'AppCountryAlbum') {
this.getAccount({module})
}
this.target ? uni.reLaunch({url: this.target}) : uni.navigateBack({})
@@ -74,7 +74,35 @@ export default {
}
},
onShow() {
this.handleLogout()
if (/wxwork/.test(navigator.userAgent)) {
//在企微端
if (this.$route.query.code) {
let {name: module, libPath} = this.currentApp,
corpId = 'ww596787bb70f08288'
if (/\/project\/police\//.test(libPath)) {
module = 'hnjc'
} else if (/\/project\/beta\//.test(libPath)) {
corpId = 'ww2a667717a70164f1'
module = 'wangge'
}
let {code} = this.$route.query
this.getToken({code}).then(token => {
this.login(token)
if (module != 'AppCountryAlbum') {
this.getAccount({module})
}
this.target ? uni.reLaunch({url: this.target}) : uni.navigateBack({})
}).catch(err => {
this.err = err
})
} else {
this.getCode().catch(err => {
this.err = err
})
}
} else {
this.handleLogout()
}
},
mounted() {
this.$refs.loginForm.setRules(this.rules)