From ae746a471cdaf4c9a53411014889ebd34b8dd9b7 Mon Sep 17 00:00:00 2001 From: aixianling Date: Mon, 25 Jul 2022 14:21:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BC=81=E5=BE=AE=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E5=BA=93=E8=87=AA=E5=8A=A8=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/login.vue | 64 ++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/src/pages/login.vue b/src/pages/login.vue index cb39a8b9..2a3bd8ef 100644 --- a/src/pages/login.vue +++ b/src/pages/login.vue @@ -51,54 +51,46 @@ export default { handleLogin() { this.$refs.loginForm.validate(v => { if (v) { - let {name: module, libPath} = this.currentApp, - corpId = 'ww596787bb70f08288' - if (/\/project\/police\//.test(libPath)) { - module = 'hnjc' - } else if (/\/project\/saas\//.test(libPath)) { - module = 'online' - } else if (/\/project\/xincheng\//.test(libPath)) { - module = 'xaxc' - } else if (/\/project\/beta\//.test(libPath)) { - corpId = 'ww2a667717a70164f1' - module = 'wangge' - } - this.setModule(module) - this.getToken({...this.form, module, corpId}).then(() => { - if (module != 'AppCountryAlbum') { - this.getAccount({module}) - } - this.target ? uni.reLaunch({url: this.target}) : uni.navigateBack({}) - }).catch(() => 0) + this.handleSignIn({...this.form, module, corpId}) } }) }, handleLogout() { this.$http.delete("/auth/token/logout").finally(() => this.logout()) + }, + handleSignIn(params) { + this.getSystem().then(({module, corpId}) => this.getToken({...params, module, corpId}).then(() => { + if (module != 'AppCountryAlbum') { + this.getAccount({module}) + } + this.target ? uni.reLaunch({url: this.target}) : uni.navigateBack({}) + }).catch(() => 0)) + }, + getSystem() { + let {name: module, libPath} = this.currentApp, + corpId = 'ww596787bb70f08288' + if (/\/project\/police\//.test(libPath)) { + module = 'hnjc' + } else if (/\/project\/saas\//.test(libPath)) { + module = 'online' + } else if (/\/project\/xincheng\//.test(libPath)) { + module = 'xaxc' + } else if (/\/project\/beta\//.test(libPath)) { + corpId = 'ww2a667717a70164f1' + module = 'wangge' + } + this.setModule(module) + return {corpId, module} } }, onShow() { 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(() => { - if (module != 'AppCountryAlbum') { - this.getAccount({module}) - } - this.target ? uni.reLaunch({url: this.target}) : uni.navigateBack({}) - }).catch(err => { - this.err = err - }) + const {code} = this.$route.query + this.handleSignIn({code}) } else { + this.getSystem() this.getCode().catch(err => { this.err = err })