소스 검색

鉴权调整

wgl 4 년 전
부모
커밋
777d40ffa2

+ 13 - 0
src/apis/user.js

@@ -54,6 +54,19 @@ export function getAllFunList(token) {
 	})
 }
 
+//获取所有鉴权功能列表,包括常用功能
+export function getAuthFunList(token) {
+	var token = token || (getToken() ? getToken() : '');
+	return request({
+		url: '/mobile/icon/findIconRouteByPerson',
+		data: Qs.stringify({}),
+		method: 'post',
+		headers: {
+			'Authorization': token,
+		},
+	})
+}
+
 //保存常用功能
 export function saveFun(ids) {
 	return request({

+ 14 - 14
src/components/Common.vue

@@ -114,12 +114,12 @@
 			//获取用户详情
 			getUserInfoByOpenId() {
 				this.isLoading = true;
-				
+
 				var type = type || '';
 				API_WeiXin.getDataByOpenId(this.openId).then(response => {
-					
+
 					this.isLoading = false;
-					
+
 					//console.log(response)
 
 					var token = response ? response.token : '';
@@ -140,7 +140,7 @@
 
 					//获取所有功能列表
 					if (token) {
-						this.getAllFunList();
+						this.getAuthFunList();
 					} else {
 						this.asynCallBack();
 					}
@@ -149,16 +149,16 @@
 					mui.toast(error);
 				})
 			},
-			//获取所有功能列表
-			getAllFunList() {
+			//获取所有功能监权列表
+			getAuthFunList() {
 				this.isLoading = true;
-				API_User.getAllFunList().then(response => {
-					
+				API_User.getAuthFunList().then(response => {
+
 					this.isLoading = false;
-					
-					if (response && response.allIcon) {
-						var allIcon = response.allIcon;
-						this.set_fun_list(allIcon);
+
+					if (response && response.allIconRoute) {
+						var allIconRoute = response.allIconRoute;
+						this.set_auth_fun_list(allIconRoute);
 
 						this.asynCallBack();
 					} else {
@@ -194,7 +194,7 @@
 				set_person_popedom: types.SET_PERSON_POPEDOM,
 				set_menu_list: types.SET_MENI_LIST,
 				set_person_temp: types.SET_PERSON_TEMP,
-				set_fun_list: types.SET_FUN_LIST,
+				set_auth_fun_list: types.SET_AUTH_FUN_LIST,
 				set_app_version: types.SET_APP_VERSION,
 				set_common_menu_list: types.SET_COMMON_MENU_LIST,
 			})
@@ -214,7 +214,7 @@
 				menu_list: 'menu_list',
 				common_menu_list: 'common_menu_list',
 				person_temp: 'person_temp',
-				fun_list: 'fun_list',
+				auth_fun_list: 'auth_fun_list',
 				app_version: 'app_version'
 			})
 		}

+ 10 - 17
src/projects/business/main.js

@@ -70,19 +70,12 @@ Viewer.setDefaults({
 });
 
 //获取纯权限路由数组,由函数每次获取
-function getFunList() {
+function getAuthFunList() {
 	let funList = [];
-	let fun_list = store.state.fun_list;
+	let fun_list = store.state.auth_fun_list;
 	if (fun_list && fun_list.length > 0) {
 		fun_list.forEach(function(item) {
-			item.list.forEach(function(iten) {
-				funList.push(iten.iconRoute);
-				if (iten.iconSubRouteList) {
-					iten.iconSubRouteList.forEach(function(iteb) {
-						funList.push(iteb)
-					})
-				}
-			})
+			funList.push(item)
 		})
 	}
 	return funList;
@@ -91,11 +84,11 @@ function getFunList() {
 
 const checkAuth = (to, from, next) => {
 	if (to.meta != null && to.meta.requireAuth) {
-		if (store.state.person_data || store.state.fun_list) {
+		if (store.state.person_data || store.state.auth_fun_list) {
 
 			if ((to.meta.form != null && to.meta.form) || (to.meta.mode != null && to.meta.mode)) {
 
-				let funList = getFunList();
+				let funList = getAuthFunList();
 				//验证
 				if (funList.indexOf(to.name) > -1) {
 					next();
@@ -138,15 +131,15 @@ const checkFun = (to, from, next) => {
 	//如果funlist不存在,在更新版本号清空后,先重新请求再判断
 	var token = to.query.token;
 	if (token) {
-		if (store.state.fun_list) {
+		if (store.state.auth_fun_list) {
 			checkAuth(to, from, next);
 		} else {
 			//这里token一定要存在,从微信模板消息带过来的
-			API_User.getAllFunList(token).then(response => {
+			API_User.getAuthFunList(token).then(response => {
 
-				if (response && response.allIcon) {
-					var allIcon = response.allIcon;
-					store.commit('SET_FUN_LIST', allIcon);
+				if (response && response.allIconRoute) {
+					var allIconRoute = response.allIconRoute;
+					store.commit('SET_AUTH_FUN_LIST', allIconRoute);
 
 					checkAuth(to, from, next);
 				} else {

+ 19 - 2
src/projects/business/views/Master/AllFun.vue

@@ -42,6 +42,7 @@
 </template>
 
 <script>
+	import * as API_User from '$project/apis/user'
 	import Common from '$project/components/Common.vue'
 	import Loading from '$project/components/Loading.vue'
 	import TopHeader from '$project/components/TopHeader.vue'
@@ -63,6 +64,8 @@
 				isLoading: false,
 
 				pageTitle: '全部服务',
+
+				fun_list: [],
 			}
 		},
 		created() {},
@@ -77,11 +80,26 @@
 					}
 				}
 			},
+			//获取所有功能列表
+			getAllFunList() {
+				this.isLoading = true;
+				API_User.getAllFunList().then(response => {
+
+					this.isLoading = false;
+
+					this.fun_list = response.allIcon;
+
+				}).catch(error => {
+					mui.toast(error);
+				})
+			},
 			asynCallBack() {
 
 			},
 		},
-		mounted() {},
+		mounted() {
+			this.getAllFunList();
+		},
 		destroyed() {
 
 		},
@@ -91,7 +109,6 @@
 				token: 'token',
 				person_data: 'person_data',
 				person_popedom: 'person_popedom',
-				fun_list: 'fun_list',
 				menu_list: 'menu_list'
 			})
 		}

+ 0 - 1
src/projects/business/views/Master/Property/Complaint/List.vue

@@ -235,7 +235,6 @@
 				token: 'token',
 				person_data: 'person_data',
 				person_popedom: 'person_popedom',
-				fun_list: 'fun_list'
 			})
 		}
 	}

+ 0 - 1
src/projects/business/views/Master/Property/Complaint/VerifyList.vue

@@ -184,7 +184,6 @@
 				token: 'token',
 				person_data: 'person_data',
 				person_popedom: 'person_popedom',
-				fun_list: 'fun_list'
 			})
 		}
 	}

+ 0 - 1
src/projects/business/views/Master/Property/Repair/List.vue

@@ -235,7 +235,6 @@
 				token: 'token',
 				person_data: 'person_data',
 				person_popedom: 'person_popedom',
-				fun_list: 'fun_list'
 			})
 		}
 	}

+ 0 - 1
src/projects/business/views/Master/Property/Repair/VerifyList.vue

@@ -182,7 +182,6 @@
 				token: 'token',
 				person_data: 'person_data',
 				person_popedom: 'person_popedom',
-				fun_list: 'fun_list'
 			})
 		}
 	}

+ 13 - 20
src/projects/pension/main.js

@@ -47,19 +47,12 @@ Vue.use(VueDirectiveImagePreviewer, {
 })
 
 //获取纯权限路由数组,由函数每次获取
-function getFunList() {
+function getAuthFunList() {
 	let funList = [];
-	let fun_list = store.state.fun_list;
+	let fun_list = store.state.auth_fun_list;
 	if (fun_list && fun_list.length > 0) {
 		fun_list.forEach(function(item) {
-			item.list.forEach(function(iten) {
-				funList.push(iten.iconRoute);
-				if (iten.iconSubRouteList) {
-					iten.iconSubRouteList.forEach(function(iteb) {
-						funList.push(iteb)
-					})
-				}
-			})
+			funList.push(item)
 		})
 	}
 	return funList;
@@ -68,11 +61,11 @@ function getFunList() {
 
 const checkAuth = (to, from, next) => {
 	if (to.meta != null && to.meta.requireAuth) {
-		if (store.state.person_data || store.state.fun_list) {
+		if (store.state.person_data || store.state.auth_fun_list) {
 
 			if ((to.meta.form != null && to.meta.form) || (to.meta.mode != null && to.meta.mode)) {
 
-				let funList = getFunList();
+				let funList = getAuthFunList();
 				//验证
 				if (funList.indexOf(to.name) > -1) {
 					next();
@@ -116,21 +109,21 @@ const checkFun = (to, from, next) => {
 	//如果funlist不存在,在更新版本号清空后,先重新请求再判断
 	var token = to.query.token;
 	if (token) {
-		if (store.state.fun_list) {
+		if (store.state.auth_fun_list) {
 			checkAuth(to, from, next);
 		} else {
 			//这里token一定要存在,从微信模板消息带过来的
-			API_User.getAllFunList(token).then(response => {
-
-				if (response && response.allIcon) {
-					var allIcon = response.allIcon;
-					store.commit('SET_FUN_LIST', allIcon);
-
+			API_User.getAuthFunList(token).then(response => {
+			
+				if (response && response.allIconRoute) {
+					var allIconRoute = response.allIconRoute;
+					store.commit('SET_AUTH_FUN_LIST', allIconRoute);
+			
 					checkAuth(to, from, next);
 				} else {
 					mui.toast('链接已失效,请登录小鹏管家查看');
 				}
-
+			
 			}).catch(error => {
 				mui.toast(error);
 			})

+ 19 - 2
src/projects/pension/views/Master/AllFun.vue

@@ -42,6 +42,7 @@
 </template>
 
 <script>
+	import * as API_User from '$project/apis/user'
 	import Common from '$project/components/Common.vue'
 	import Loading from '$project/components/Loading.vue'
 	import TopHeader from '$project/components/TopHeader.vue'
@@ -63,6 +64,8 @@
 				isLoading: false,
 
 				pageTitle: '全部服务',
+
+				fun_list: [],
 			}
 		},
 		created() {},
@@ -77,11 +80,26 @@
 					}
 				}
 			},
+			//获取所有功能列表
+			getAllFunList() {
+				this.isLoading = true;
+				API_User.getAllFunList().then(response => {
+
+					this.isLoading = false;
+
+					this.fun_list = response.allIcon;
+
+				}).catch(error => {
+					mui.toast(error);
+				})
+			},
 			asynCallBack() {
 
 			},
 		},
-		mounted() {},
+		mounted() {
+			this.getAllFunList();
+		},
 		destroyed() {
 
 		},
@@ -91,7 +109,6 @@
 				token: 'token',
 				person_data: 'person_data',
 				person_popedom: 'person_popedom',
-				fun_list: 'fun_list',
 				menu_list: 'menu_list'
 			})
 		}

+ 2 - 0
src/store/getters.js

@@ -14,6 +14,8 @@ export const person_temp = state => state.person_temp
 
 export const fun_list = state => state.fun_list
 
+export const auth_fun_list = state => state.auth_fun_list
+
 export const register_form_data = state => state.register_form_data
 
 export const app_version = state => state.app_version

+ 1 - 0
src/store/mutation-types.js

@@ -7,6 +7,7 @@ export const SET_ADD_PERSON_DATA = 'SET_ADD_PERSON_DATA'
 export const SET_MENI_LIST = 'SET_MENI_LIST'
 export const SET_PERSON_TEMP = 'SET_PERSON_TEMP'
 export const SET_FUN_LIST = 'SET_FUN_LIST'
+export const SET_AUTH_FUN_LIST = 'SET_AUTH_FUN_LIST'
 export const SET_REGISTER_FORM_DATA = 'SET_REGISTER_FORM_DATA'
 export const SET_APP_VERSION = 'SET_APP_VERSION'
 export const SET_COMMON_MENU_LIST = 'SET_COMMON_MENU_LIST'

+ 6 - 0
src/store/mutations.js

@@ -8,6 +8,7 @@ import {
 	setCommonMenuList,
 	setPersonTemp,
 	setFunList,
+	setAuthFunList,
 	setRegisterFormData,
 	setAppVersion,
 	setPersionHomeModel,
@@ -71,6 +72,11 @@ const mutations = {
 		setFunList(storage_prefix, data)
 		state.fun_list = data
 	},
+	
+	[types.SET_AUTH_FUN_LIST](state, data) {
+		setAuthFunList(storage_prefix, data)
+		state.auth_fun_list = data
+	},
 
 	[types.SET_REGISTER_FORM_DATA](state, data) {
 		setRegisterFormData(storage_prefix, data)

+ 2 - 0
src/store/state.js

@@ -7,6 +7,7 @@ import {
 	getCommonMenuList,
 	getPersonTemp,
 	getFunList,
+	getAuthFunList,
 	getRegisterFormData,
 	getAppVersion,
 	getPersionHomeModel,
@@ -32,6 +33,7 @@ const state = {
 	common_menu_list: getCommonMenuList(storage_prefix),
 	person_temp: getPersonTemp(storage_prefix),
 	fun_list: getFunList(storage_prefix),
+	auth_fun_list: getAuthFunList(storage_prefix),
 	register_form_data: getRegisterFormData(storage_prefix),
 	app_version: getAppVersion(storage_prefix),
 	persion_home_model: getPersionHomeModel(storage_prefix),

+ 4 - 0
src/utils/storage.js

@@ -82,6 +82,10 @@ export const setFunList = (channel, data) => set(channel + '_fun_list', data)
 
 export const getFunList = (channel) => get(channel + '_fun_list')
 
+export const setAuthFunList = (channel, data) => set(channel + '_auth_fun_list', data)
+
+export const getAuthFunList = (channel) => get(channel + '_auth_fun_list')
+
 export const setRegisterFormData = (channel, data) => set(channel + '_register_form_data', data)
 
 export const getRegisterFormData = (channel) => get(channel + '_register_form_data')