Browse Source

oa系统对接令牌验证相关的修改

shengxuefei 4 năm trước cách đây
mục cha
commit
a131065eda

+ 17 - 2
uni-app-front/common/axiosHelper.js

@@ -28,7 +28,7 @@ const service = axios.create({
 service.interceptors.request.use(
 	config => {
 		// do something before request is sent
-		console.info("axioshelper request");
+		//console.info("axioshelper request");
 		//console.info(mget.getters);
 		//console.info(store);
 		if (store.state.isLogin) {
@@ -37,7 +37,7 @@ service.interceptors.request.use(
 			// please modify it according to the actual situation
 			config.headers['X-Token'] = store.state.token.tokenStr;
 		}
-		console.info('axioshelper request',config);
+		console.info('axioshelper request config',config);
 		return config;
 	},
 	error => {
@@ -73,6 +73,21 @@ service.interceptors.response.use(
 			});
 			return;
 		}
+		if(res.isSuccess==false&&(res.code==201||res.code==202||res.code==205)){
+			uni.showModal({
+				title: '警告',
+				content: res.errMsg,
+				showCancel: false,
+				success:function(ret){
+					if(ret.confirm){
+						uni.navigateTo({
+							url:'/pages/login/login'
+						});
+					}
+				}
+			});
+			return;
+		}
 		//console.info(res);
 		return res;
 		

+ 15 - 16
uni-app-front/common/util.js

@@ -160,26 +160,25 @@ function setStateFromStorage(_this,storageState){
 	}
 }
 /* 设置状态值 */
-function setState(_this,storageState){
-	if(storageState){
-		//设置状态中的各种值
-		_this.$store.commit('setIsLogin', storageState.isLogin);
-		_this.$store.commit('setToken', storageState.token);
-		_this.$store.commit('setAvatar', storageState.avatar);
-		_this.$store.commit('setName', storageState.name);
-		_this.$store.commit('setIntroduction', storageState.introduction);
-		_this.$store.commit('setRoles', storageState.roles);
-		_this.$store.commit('setUser', storageState.user);
-		_this.$store.commit('setStationName', storageState.stationName);
-		_this.$store.commit('setStationCode', storageState.stationCode);
-		_this.$store.commit('setDepartmentName', storageState.departmentName);
-		_this.$store.commit('setDepartmentCode', storageState.departmentCode);
-		_this.$store.commit('setProjectCode', storageState.projectCode);
-	}	
+function setState(_this,storageState){ 
+	//设置状态中的各种值
+	_this.$store.commit('setIsLogin', storageState.isLogin);
+	_this.$store.commit('setToken', storageState.tnToken);
+	_this.$store.commit('setAvatar', storageState.avatar);
+	_this.$store.commit('setName', storageState.name);
+	_this.$store.commit('setIntroduction', storageState.introduction);
+	_this.$store.commit('setRoles', storageState.roles);
+	_this.$store.commit('setUser', storageState.user);
+	_this.$store.commit('setStationName', storageState.stationName);
+	_this.$store.commit('setStationCode', storageState.stationCode);
+	_this.$store.commit('setDepartmentName', storageState.departmentName);
+	_this.$store.commit('setDepartmentCode', storageState.departmentCode);
+	_this.$store.commit('setProjectCode', storageState.projectCode); 
 }
 /* 获取状态值 */
 function getState(_this,key){
 	let storageState=uni.getStorageSync("storage_state");
+	console.info('storageState',storageState);
 	if(key==='isLogin'){
 		if(!_this.$store.state.isLogin){
 			if(storageState){

+ 1 - 0
uni-app-front/pages/SelectProject/SelectProject.vue

@@ -49,6 +49,7 @@
 					data:this.$store.state,
 					success:function(){
 						console.info("setProjectCode选择项目后状态缓存成功");
+						console.info('storage_state',uni.getStorageSync('storage_state'));
 					},
 					fail: () => {
 						console.error("setProjectCode选择项目后状态缓存失败");

+ 1 - 0
uni-app-front/pages/login/login.vue

@@ -120,6 +120,7 @@
 								data:this.$store.state,
 								success:function(){
 									console.info("setStorage状态缓存成功");
+									console.info('storage_state',uni.getStorageSync('storage_state'));
 								},
 								fail: () => {
 									console.error("setStorage状态缓存失败");

+ 12 - 11
uni-app-front/pages/loginoa/loginoa.vue

@@ -42,17 +42,17 @@
 							
 							//设置状态中的各种值
 							this.$store.commit('setIsLogin',true);
-							this.$store.commit('setToken',res.token);
-							this.$store.commit('setAvatar',res.avatar);
-							this.$store.commit('setName',res.name);
-							this.$store.commit('setIntroduction',res.introduction);
-							this.$store.commit('setRoles',res.roles);
-							this.$store.commit('setUser',res.user);
-							this.$store.commit('setStationName',res.stationName);
-							this.$store.commit('setStationCode',res.stationCode);
-							this.$store.commit('setDepartmentName',res.departmentName);
-							this.$store.commit('setDepartmentCode',res.departmentCode);
-							if(res.projectCode){
+							this.$store.commit('setToken',res.tnToken);
+							this.$store.commit('setAvatar',res.data.avatar);
+							this.$store.commit('setName',res.data.name);
+							this.$store.commit('setIntroduction',res.data.introduction);
+							this.$store.commit('setRoles',res.data.roles);
+							this.$store.commit('setUser',res.data.user);
+							this.$store.commit('setStationName',res.data.stationName);
+							this.$store.commit('setStationCode',res.data.stationCode);
+							this.$store.commit('setDepartmentName',res.data.departmentName);
+							this.$store.commit('setDepartmentCode',res.data.departmentCode);
+							if(res.data.projectCode){
 								this.$store.commit('setProjectCode',res.projectCode);
 							}							
 			                console.info("登录页面state:",this.$store.state);
@@ -62,6 +62,7 @@
 								data:this.$store.state,
 								success:function(){
 									console.info("setStorage状态缓存成功");
+									console.info('storage_state',uni.getStorageSync('storage_state'));
 								},
 								fail: () => {
 									console.error("setStorage状态缓存失败");