From b07889e22f823fac80a66b503671e170668f4ee6 Mon Sep 17 00:00:00 2001
From: 陶杰 <1378534974@qq.com>
Date: 星期二, 10 十二月 2024 10:10:25 +0800
Subject: [PATCH] 1.供应商子账号

---
 store/index.js |   82 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 82 insertions(+), 0 deletions(-)

diff --git a/store/index.js b/store/index.js
index 7ebfdfd..16b907a 100644
--- a/store/index.js
+++ b/store/index.js
@@ -19,6 +19,7 @@
 		leftWinActive: '/pages/component/view/view',
 		activeOpen: '',
 		menu: [],
+		appMenu: [],
 		univerifyErrorMsg: '',
 		currentInfo: {}, //个人用户信息
 		cache_address: {},
@@ -61,7 +62,9 @@
 			state.hasLogin = false
 			state.openid = null
 			state.currentInfo = {}
+			state.appMenu=[]
 			storage.removeItem('token')
+			storage.removeItem('appMenu');
 			message.showToast('退出登录成功')
 
 		},
@@ -196,6 +199,7 @@
 		}) {
 			//把权限获取到
 			// console.log('getCurrentInfo,getCurrentInfo')
+			
 			const currentInfo = await http.request('get', '/api/current/user', {})
 			if (currentInfo && currentInfo.code == 0) {
 				// state.cMenu = cMenu
@@ -212,6 +216,80 @@
 				//这种情况就是要跳转到登录页面
 			}
 		},
+
+		getSwitchSubAccount: async function({commit,state},payload) {
+			//把权限获取到
+			// console.log('getCurrentInfo,getCurrentInfo')
+
+			const currentInfo = await http.request('get', '/api/supplierSub/getSwitchById', {
+				params: {
+					id:payload.id
+				}
+			})
+			if (currentInfo && currentInfo.code == 0) {
+			
+				state.currentInfo = currentInfo.data || {}
+				state.type = currentInfo.data.type || ''
+				state.spacecode = currentInfo.data.spacecode || ''
+				
+				commit("updateLogin", true)
+			} else {
+				commit("updateLogin", false)
+				//这种情况就是要跳转到登录页面
+			}
+
+			return currentInfo;
+		},
+		
+
+		getAppMenu: async function({
+			commit,
+			state
+		}) {
+			//把权限获取到
+			const menu = await http.request('get', '/api/app/menu/permission/menu', {}) 
+			storage.setItem('appMenu', []);
+			if (menu && menu.code == 0) {
+				const appMenu = menu.data || []
+				storage.setItem('appMenu', appMenu);
+			
+				// commit("updateLogin", true)
+			} else {
+				// commit("updateLogin", false)
+				//这种情况就是要跳转到登录页面
+			}
+		},
+
+		getAppMenuSupplier: async function({
+			commit,
+			state
+		}) {
+			//把权限获取到
+			const menu = await http.request('get', '/api/app/menu/supplier/permission/menu', {}) 
+			storage.setItem('appMenu', []);
+			if (menu && menu.code == 0) {
+				const appMenu = menu.data || []
+				storage.setItem('appMenu', appMenu);
+			} else {
+				
+			}
+		},
+		getAppMenuPartner: async function({
+			commit,
+			state
+		}) {
+			//把权限获取到
+			const menu = await http.request('get', '/api/app/menu/partner/permission/menu', {}) 
+			storage.setItem('appMenu', []);
+			if (menu && menu.code == 0) {
+				const appMenu = menu.data || []
+				storage.setItem('appMenu', appMenu);
+			} else {
+			
+			}
+		},
+
+
 		loginwx: async function({
 			dispatch,
 			commit,
@@ -302,6 +380,8 @@
 					storage.setItem('token', resp.data.access_token)
 					commit("updateLogin", true)
 					await dispatch('getCurrentInfo')
+					// 获取所有权限菜单
+					await dispatch('getAppMenuPartner')
 					uni.reLaunch({
 						url: '/pages/home/supplier-home'
 					})
@@ -367,6 +447,8 @@
 					storage.setItem('token', resp.data.access_token)
 					commit("updateLogin", true)
 					await dispatch('getCurrentInfo')
+					// 获取所有供应商权限菜单
+					await dispatch('getAppMenuSupplier')
 
 					console.log('login,reLaunch')
 					// #ifdef APP

--
Gitblit v1.9.3