first commit
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
<template>
|
||||
<view>
|
||||
<u-navbar
|
||||
:safeAreaInsetTop="true"
|
||||
:placeholder="true"
|
||||
:title="userName"
|
||||
:fixed="true"
|
||||
:autoBack="false"
|
||||
leftIconColor="#C39A4B"
|
||||
bgColor="#C39A4B"
|
||||
titleStyle="max-width:none;width:auto;font-weight:bold;color:#ffffff;"
|
||||
>
|
||||
<view @tap="logout"
|
||||
style="margin-top:2px;margin-right:3px;"
|
||||
slot="right"
|
||||
>
|
||||
<image src="../../static/images/ico_exit.png" style="width:24px;height:24px;"></image>
|
||||
</view>
|
||||
</u-navbar>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {logout} from '../../api/commonApi.js';
|
||||
const ADFS_LOGOUT_URL = 'https://adfs.mgm.mo/adfs/ls/?wa=wsignout1.0&wtrealm=mgm_mobilecrm_app&wreply=https://hostcrmapp.mgm.mo/sso_callback/logout';
|
||||
export default {
|
||||
name:"mgmHeader",
|
||||
data() {
|
||||
return {
|
||||
userName:'',
|
||||
siteData:null,
|
||||
userData:null
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.siteData = uni.getStorageSync("siteData");
|
||||
this.userData = uni.getStorageSync("userData");
|
||||
this.userName = this.userData.userName + ", " + this.userData.userId;
|
||||
this.isLogin();
|
||||
},
|
||||
methods:{
|
||||
updateUserData() {
|
||||
this.userData = uni.getStorageSync("userData");
|
||||
if (this.userData) {
|
||||
this.userName = this.userData.userName + ", " + this.userData.userId;
|
||||
} else {
|
||||
this.userName = '';
|
||||
}
|
||||
},
|
||||
async logout(){
|
||||
uni.showLoading({
|
||||
title: this.$t("common.loading")
|
||||
});
|
||||
try{
|
||||
let params = {};
|
||||
const res = await logout(params);
|
||||
if(res.success == true){
|
||||
if(res.data !== null){
|
||||
uni.setTabBarItem({
|
||||
index:0,
|
||||
visible:false
|
||||
});
|
||||
uni.setTabBarItem({
|
||||
index:1,
|
||||
visible:false
|
||||
});
|
||||
uni.setTabBarItem({
|
||||
index:2,
|
||||
visible:false
|
||||
});
|
||||
if(this.siteData.mockSSO==false&&!this.siteData.internalTag){
|
||||
//this.logoutWithADFSApp()
|
||||
uni.redirectTo({
|
||||
url:'/pages/azureLogout/azureLogout'
|
||||
});
|
||||
}else{
|
||||
uni.removeStorageSync("userData");
|
||||
uni.removeStorageSync("token");
|
||||
uni.removeStorageSync("idToken");
|
||||
this.navTo('/pages/login/login',2,false);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(this.siteData.mockSSO==false&&!this.siteData.internalTag){
|
||||
//this.logoutWithADFSApp()
|
||||
uni.redirectTo({
|
||||
url:'/pages/azureLogout/azureLogout'
|
||||
});
|
||||
}else{
|
||||
uni.removeStorageSync("userData");
|
||||
uni.removeStorageSync("token");
|
||||
uni.removeStorageSync("idToken");
|
||||
this.navTo('/pages/login/login',2,false);
|
||||
}
|
||||
}
|
||||
}catch(e){
|
||||
console.error(e);
|
||||
uni.$u.toast(e.errMsg,5000);
|
||||
var request = e.config!=undefined?JSON.stringify(e.config):"";
|
||||
var response = e.data!=undefined?JSON.stringify(e.data):"";
|
||||
await this.writeLog(this.userData.userId,"logout","","[APP][header.vue][logout][Catch Exception]"+e.errMsg,request,response,1,false);
|
||||
}finally{
|
||||
uni.hideLoading();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user