From 0693e4dbd75a8c23a7e6dd34aa9a9ecee0a3a7b3 Mon Sep 17 00:00:00 2001 From: bhq@iemsoft.cn <bhq@iemsoft.cn> Date: Tue, 06 Nov 2018 10:34:53 +0800 Subject: [PATCH] 修改登录问题 --- formManagement/src/app/app.component.ts | 76 +++++++++++++++++++------------------- 1 files changed, 38 insertions(+), 38 deletions(-) diff --git a/formManagement/src/app/app.component.ts b/formManagement/src/app/app.component.ts index 25aebb5..2868953 100644 --- a/formManagement/src/app/app.component.ts +++ b/formManagement/src/app/app.component.ts @@ -186,43 +186,51 @@ this.storage.store('token', { "accessToken": token }); this.user.setAccessToken(token); this.showFlg = false; + this.isShowTitle = true; window.parent.location.href = urlHref.replace("?loginKey=main", ""); $(window.parent.document.getElementsByClassName('wrapper')).hide(); - // window.parent.location.reload(); + window.parent.location.reload(); this.router.navigate(['main']); + } else { let loginFlag = (urlHash != "" && urlHash != "#/"); - if (this.storage.get('token') && loginFlag) { - //自定义表单 - this.isShowTitle = true; - this.showFlg = false; - this.getCompanys(); - // this.user.setAccessToken(this.storage.get('token').accessToken); - if (this.storage.get('tenantID') != undefined && this.storage.get('tenantID') != '') { - this.user.setTenantID(this.storage.get('tenantID').tenantID); - } - if (this.storage.get('userName') != undefined && this.storage.get('userName') != '') { - this.user.setUsername(this.storage.get('userName').userName); - } - this.menuName = this.storage.get('lastMenuName'); - this.name = this.storage.get('lastMenuName'); - } else { - this.storage.clear('userName'); - this.storage.clear('tenantID'); - this.storage.clear('token'); - this.storage.clear('lastMenuName'); + if (this._cookieService.get('token') && loginFlag) { + //自定义表单 + this.isShowTitle = true; + this.showFlg = false; + this.getCompanys(); + // this.user.setAccessToken(this.storage.get('token').accessToken); + if (this.storage.get('tenantID') != undefined && this.storage.get('tenantID') != '') { + this.user.setTenantID(this.storage.get('tenantID').tenantID); + } + if (this._cookieService.get('userName') != undefined && this._cookieService.get('userName') != '') { + this.user.setUsername(this._cookieService.get('userName')); + this.userName = this._cookieService.get('userName'); - this.storage.clear('isShowTitle'); - this.storage.clear('showFlg'); - window.location.hash = ''; - } + } + + + + this.menuName = this.storage.get('lastMenuName'); + this.name = this.storage.get('lastMenuName'); + } + // else { + // this.storage.clear('userName'); + // this.storage.clear('tenantID'); + // this.storage.clear('token'); + // this.storage.clear('lastMenuName'); + + // this.storage.clear('isShowTitle'); + // this.storage.clear('showFlg'); + // window.location.hash = ''; + // } } - // history.pushState(null, null, document.URL); - // window.addEventListener('popstate', function () { - // history.pushState(null, null, document.URL); - // }); + history.pushState(null, null, document.URL); + window.addEventListener('popstate', function () { + history.pushState(null, null, document.URL); + }); @@ -366,11 +374,7 @@ (response) => { if (response.rspCode == "000000") { sessionStorage.setItem("userInfo", JSON.stringify(response.data)); - if(response.data.realName != undefined && response.data.realName != null) { - this.userName = response.data.realName; - } else { - this.userName = response.data.userName; - } + this.userName = response.data.userName; this.user.setUsername(this.userName); this.storage.store('userName', { 'userName': this.userName }) @@ -379,11 +383,7 @@ ); } if(userInfo!=undefined ){ - if (userInfo.realName != undefined && userInfo.realName != null) { - this.userName = userInfo.realName; - } else { - this.userName = userInfo.userName; - } + this.userName = userInfo.userName; this.user.setUsername(this.userName); } this.storage.store('userName', { 'userName': this.userName }) -- Gitblit v1.8.0