Browse Source

退出登录调接口清除token

hbchen 1 year ago
parent
commit
5d2c16abe4
4 changed files with 105 additions and 87 deletions
  1. 4 2
      src/api/api.js
  2. 5 2
      src/api/modules/oldApi.js
  3. 19 8
      src/views/Home.vue
  4. 77 75
      src/views/transferPage.vue

+ 4 - 2
src/api/api.js

@@ -201,7 +201,8 @@ const {
   weekReportValidAudio,
   weekReportValidAudio,
   getUserUuid,
   getUserUuid,
   getBusinessCode,
   getBusinessCode,
-  recordActiveLogin
+  recordActiveLogin,
+  userLogOut
 
 
 } = oldApis;
 } = oldApis;
 
 
@@ -278,6 +279,7 @@ export {
   weekReportValidAudio,
   weekReportValidAudio,
   getUserUuid,
   getUserUuid,
   getBusinessCode,
   getBusinessCode,
-  recordActiveLogin
+  recordActiveLogin,
+  userLogOut
 };
 };
 
 

+ 5 - 2
src/api/modules/oldApi.js

@@ -37,7 +37,9 @@ import http from "@/api/http.js"
  const banneradd = params => { return http.post('/banner/add',params); };  //新增banner
  const banneradd = params => { return http.post('/banner/add',params); };  //新增banner
  const banneredit = params => { return http.post('/banner/edit',params); };  //编辑banner
  const banneredit = params => { return http.post('/banner/edit',params); };  //编辑banner
  const bannerdelete = params => { return http.post('/banner/delete',params); };  //删除banner
  const bannerdelete = params => { return http.post('/banner/delete',params); };  //删除banner
- const getUserUuid=()=>{return http.get('/sysuser/uuid',{})}//获取用户uuid
+ const getUserUuid=()=>{return http.get('/sysuser/uuid',{})};//获取用户uuid
+ const userLogOut = params => { return http.post('/sysuser/logout',params); };  //系统用户退出登录,用于后端清空Token
+
 
 
 /* ppt */
 /* ppt */
 const pptlist = params => { 
 const pptlist = params => { 
@@ -399,5 +401,6 @@ export {
 	getBusinessCode,
 	getBusinessCode,
 	getPublicSettingsApi,
 	getPublicSettingsApi,
 	recordActiveLogin,
 	recordActiveLogin,
-	getRealPublicSettings
+	getRealPublicSettings,
+	userLogOut
 }
 }

+ 19 - 8
src/views/Home.vue

@@ -321,7 +321,8 @@ import {
   customInterence,
   customInterence,
   roadshowInterence,
   roadshowInterence,
   getBusinessCode,
   getBusinessCode,
-  homeInterface
+  homeInterface,
+  userLogOut
 } from "api/api.js";
 } from "api/api.js";
 import { getPublicSettingsApi } from '@/api/modules/oldApi';
 import { getPublicSettingsApi } from '@/api/modules/oldApi';
 import PwdDlg from "@/components/pwdDlg.vue";
 import PwdDlg from "@/components/pwdDlg.vue";
@@ -831,17 +832,21 @@ export default {
     },
     },
     logout() {
     logout() {
       //退出登录
       //退出登录
-      var that = this;
       this.$confirm("确认退出吗?", "提示", {
       this.$confirm("确认退出吗?", "提示", {
         type: "warning",
         type: "warning",
-      })
-        .then(() => {
+      }).then(() => {
           if(this.isTrail){
           if(this.isTrail){
             // 结算活跃计时
             // 结算活跃计时
             loginEndCalc()
             loginEndCalc()
             // 结算登录计时
             // 结算登录计时
             recordActiveLoginFun()
             recordActiveLoginFun()
           }
           }
+
+          userLogOut().then(res=>{})
+          .finally(()=>{
+            this.toLoginVariable()
+          })
+          
           setTimeout(() => {
           setTimeout(() => {
             // 退出登录时可能有一些请求需要发送或者处理
             // 退出登录时可能有一些请求需要发送或者处理
             localStorage.setItem("auth", "");
             localStorage.setItem("auth", "");
@@ -853,11 +858,17 @@ export default {
             localStorage.setItem("ManageType", "");
             localStorage.setItem("ManageType", "");
             localStorage.setItem("RoleIdentity", "");
             localStorage.setItem("RoleIdentity", "");
             localStorage.setItem("loginTime", "");
             localStorage.setItem("loginTime", "");
-
-            that.$router.push("/login");
           }, 10);
           }, 10);
-        })
-        .catch(() => {});
+
+        }).catch(() => {});
+    },
+    toLoginVariable(){
+      let logoutUrl = this.$setting.publicConfigs ? this.$setting.publicConfigs.LogoutUrl||"":""
+      if(logoutUrl){
+        window.location.href=logoutUrl
+      }else{
+        this.$router.push("/login?HZ=1");
+      }
     },
     },
     toDoc(){
     toDoc(){
       //打开更新日志项目
       //打开更新日志项目

+ 77 - 75
src/views/transferPage.vue

@@ -1,100 +1,102 @@
 <template>
 <template>
-    <div></div>
+	<div></div>
 </template>
 </template>
 
 
 <script>
 <script>
 import { departInterence } from '@/api/api.js';
 import { departInterence } from '@/api/api.js';
 export default {
 export default {
-    data() {
-        return {
-            
-        }
-    },
-    created(){
-        this.init()
-        
-    },
-    methods:{
-        async init(){
-            if(Object.keys(this.$route.query).length > 0){
-                const res=await departInterence.useCodeLogin(this.$route.query)
-								// console.log(res);
-								// return 
-                if(res.Ret===200){
-                    localStorage.setItem('auth', res.Data.Authorization)
-										localStorage.setItem('userName', res.Data.RealName)
-										localStorage.setItem('Role', res.Data.RoleTypeCode)
-										localStorage.setItem('RoleIdentity', res.Data.SysRoleTypeCode)
-										localStorage.setItem('RoleType', res.Data.ProductName)
-										localStorage.setItem('ManageType', res.Data.Authority)
-										localStorage.setItem('AdminId', res.Data.AdminId)
-                    localStorage.setItem('AdminName',res.Data.AdminName)
-                    // 如果路由参数有redirect_uri则跳转到redirect_uri,redirect_uri通过encode
-                    if(this.$route.query.redirect_uri){
-                        const path=decodeURIComponent(this.$route.query.redirect_uri)
-                        this.$router.push(path)
-                        return
-                    }
-					let path = "";
-					switch (res.Data.RoleTypeCode) {
-						case "rai_researcher":
-						case "ficc_researcher":
-						case "researcher":
-						path = "/reportlist";
-						break;
-						// case "compliance": //合规
-						// path = "/contractapprovallist";
-						// break;
-						case "special_researcher": //特邀研究员
-						path = "/dataList";
-						break;
-						// case "special_ficc_seller":
-						// path = "/meetingCalendar";
-						// break;
-						default:
-						path = await this.getOtherRolePath("myCalendar");
-					}
-					this.$router.push({ path });
-                    return
-                }else{
-									this.$router.replace('/login?HZ=1')
-								}
-            }
+	data() {
+		return {
+
+		}
+	},
+	created() {
+		this.init()
+
+	},
+	methods: {
+		async init() {
+			if (Object.keys(this.$route.query).length <= 0) {
+				this.$router.replace('/login')
+				return
+			}
+			// debugger;
 
 
-            this.$router.replace('/login?HZ=1')
-        },
-        getOtherRolePath(pathVal){
+			const res = await departInterence.useCodeLogin(this.$route.query)
+			// console.log(res);
+			// debugger;
+			if (res.Ret !== 200) {
+				this.$router.replace('/login?HZ=1')
+				return
+			}
+
+			localStorage.setItem('auth', res.Data.Authorization)
+			localStorage.setItem('userName', res.Data.RealName)
+			localStorage.setItem('Role', res.Data.RoleTypeCode)
+			localStorage.setItem('RoleIdentity', res.Data.SysRoleTypeCode)
+			localStorage.setItem('RoleType', res.Data.ProductName)
+			localStorage.setItem('ManageType', res.Data.Authority)
+			localStorage.setItem('AdminId', res.Data.AdminId)
+			localStorage.setItem('AdminName', res.Data.AdminName)
+			// 如果路由参数有redirect_uri则跳转到redirect_uri,redirect_uri通过encode
+			if (this.$route.query.redirect_uri) {
+				const path = decodeURIComponent(this.$route.query.redirect_uri)
+				this.$router.push(path)
+				return
+			}
+
+			let path = "";
+			switch (res.Data.RoleTypeCode) {
+				case "rai_researcher":
+				case "ficc_researcher":
+				case "researcher":
+					path = "/reportlist";
+					break;
+				// case "compliance": //合规
+				// path = "/contractapprovallist";
+				// break;
+				case "special_researcher": //特邀研究员
+					path = "/dataList";
+					break;
+				// case "special_ficc_seller":
+				// path = "/meetingCalendar";
+				// break;
+				default:
+					path = await this.getOtherRolePath("myCalendar");
+			}
+
+			this.$router.push({ path });
+		},
+		getOtherRolePath(pathVal) {
 			return departInterence.getMenu().then(res => {
 			return departInterence.getMenu().then(res => {
-				let resolvePath=''
-				if(res.Ret === 200) {
-					let menuList = res.Data.List||[];
-					if(!menuList.length){
+				let resolvePath = ''
+				if (res.Ret === 200) {
+					let menuList = res.Data.List || [];
+					if (!menuList.length) {
 						this.$message.error('该账号没有任何菜单权限,请联系管理员')
 						this.$message.error('该账号没有任何菜单权限,请联系管理员')
 						return
 						return
 					}
 					}
 					// 是否已经拿到菜单信息
 					// 是否已经拿到菜单信息
-					sessionStorage.setItem('hasGetMenu','true')
-					sessionStorage.setItem('MenuList',JSON.stringify(menuList));
+					sessionStorage.setItem('hasGetMenu', 'true')
+					sessionStorage.setItem('MenuList', JSON.stringify(menuList));
 					/* 是否有数据报表权限 */
 					/* 是否有数据报表权限 */
-					this.$store.commit('SET_DATA_AUTH',menuList.some(item => item.name === '报表统计'))
+					this.$store.commit('SET_DATA_AUTH', menuList.some(item => item.name === '报表统计'))
 
 
 					for (let i = 0; i < menuList.length; i++) {
 					for (let i = 0; i < menuList.length; i++) {
 						const element = menuList[i];
 						const element = menuList[i];
-						const arr=menuList[i].children||[]
-						if(arr.some(it => it.path == pathVal)){
-							resolvePath='/'+pathVal
+						const arr = menuList[i].children || []
+						if (arr.some(it => it.path == pathVal)) {
+							resolvePath = '/' + pathVal
 							break
 							break
 						}
 						}
 					}
 					}
-					return resolvePath || '/'+menuList[0].children[0].path
+					return resolvePath || '/' + menuList[0].children[0].path
 				}
 				}
-				return '/'+pathVal
+				return '/' + pathVal
 			})
 			})
 		}
 		}
-    }
+	}
 }
 }
 </script>
 </script>
 
 
-<style>
-
-</style>
+<style></style>