From 64b432916af9c9218ab3f3eca614e26c542142ae Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 07 十一月 2023 15:47:13 +0800
Subject: [PATCH] bug

---
 minipro_standard/store/index.js |  168 +++++++++++++++++++++++++++++++++----------------------
 1 files changed, 100 insertions(+), 68 deletions(-)

diff --git a/minipro_standard/store/index.js b/minipro_standard/store/index.js
index 0b3342b..c3e919e 100644
--- a/minipro_standard/store/index.js
+++ b/minipro_standard/store/index.js
@@ -1,44 +1,50 @@
-import Vue from 'vue'
+import Vue from 'vue'
 import Vuex from 'vuex'
-import { pageCount, getTreeList } from '@/util/api/index.js'
-
-Vue.use(Vuex) // vue鐨勬彃浠舵満鍒�
-
-const navHeight = uni.getStorageSync('navHeight');
-const statusbarHeight = uni.getStorageSync('statusbarHeight');
-const menuButtonWidth = uni.getStorageSync('menuButtonWidth');
-const token = uni.getStorageSync('token');
-const userInfo = uni.getStorageSync('userInfo');
+import {
+	pageCount,
+	getTreeList,
+	getUserInfo
+} from '@/util/api/index.js'
+
+Vue.use(Vuex) // vue鐨勬彃浠舵満鍒�
+
+const navHeight = uni.getStorageSync('navHeight');
+const statusbarHeight = uni.getStorageSync('statusbarHeight');
+const menuButtonWidth = uni.getStorageSync('menuButtonWidth');
+const token = uni.getStorageSync('token');
+const userInfo = uni.getStorageSync('userInfo');
 const Menu = uni.getStorageSync('MenuList');
-
-
-// Vuex.Store 鏋勯�犲櫒閫夐」
-const store = new Vuex.Store({
-	// 涓轰簡涓嶅拰椤甸潰鎴栫粍浠剁殑data涓殑閫犳垚娣锋穯锛宻tate涓殑鍙橀噺鍓嶉潰寤鸿鍔犱笂$绗﹀彿
-	state: {
-		// 鐢ㄦ埛淇℃伅
+const session = uni.getStorageSync('session');
+
+
+// Vuex.Store 鏋勯�犲櫒閫夐」
+const store = new Vuex.Store({
+	// 涓轰簡涓嶅拰椤甸潰鎴栫粍浠剁殑data涓殑閫犳垚娣锋穯锛宻tate涓殑鍙橀噺鍓嶉潰寤鸿鍔犱笂$绗﹀彿
+	state: {
+		// 鐢ㄦ埛淇℃伅
 		userInfo: userInfo || null,
-		token: token || null,
-		menuButtonWidth: menuButtonWidth || '0',
-		statusbarHeight: statusbarHeight || '0',
-		navHeight: navHeight || '0',
-		// 鑿滃崟鏉冮檺
-		Menu: Menu ? Menu : [],
+		token: token || null,
+		menuButtonWidth: menuButtonWidth || '0',
+		statusbarHeight: statusbarHeight || '0',
+		navHeight: navHeight || '0',
+		session: session ? session : '',
+		// 鑿滃崟鏉冮檺
+		Menu: Menu ? JSON.parse(Menu) : [],
 		// 寰呭姙鏁伴噺
 		upcomingNum: {
 			d: 0,
 			y: 0
-		},
-	},
-	mutations: {
-		setHeight(state, val) {
-			state.navHeight = val.navHeight
-			state.statusbarHeight = val.statusbarHeight
-			state.menuButtonWidth = val.menuButtonWidth
-			uni.setStorageSync('navHeight', val.navHeight);
-			uni.setStorageSync('statusbarHeight', val.statusbarHeight);
-			uni.setStorageSync('menuButtonWidth', val.menuButtonWidth);
-		},
+		},
+	},
+	mutations: {
+		setHeight(state, val) {
+			state.navHeight = val.navHeight
+			state.statusbarHeight = val.statusbarHeight
+			state.menuButtonWidth = val.menuButtonWidth
+			uni.setStorageSync('navHeight', val.navHeight);
+			uni.setStorageSync('statusbarHeight', val.statusbarHeight);
+			uni.setStorageSync('menuButtonWidth', val.menuButtonWidth);
+		},
 		SETTOKEN(state, val) {
 			state.token = val
 			uni.setStorageSync('token', val);
@@ -50,42 +56,68 @@
 		SETNUM(state, val) {
 			state.upcomingNum.d = val.d
 			state.upcomingNum.y = val.y
-		},
-		SETMENU (state, data) {
-			state.Menu = data
-			uni.setStorageSync('MenuList', JSON.stringify(data));
-		}
-	},
-	actions: {
-		// 鍚戝悗绔幏鍙栬彍鍗曟爮鏉冮檺
-		async getMenuList (content, type) {
-			let res = await getTreeList({ type: type })
-			if (res.code === 200) {
-				content.commit('SETMENU', res.data)
-			}
-		},
-		// 鑾峰彇鐘舵�侀珮搴�
-		getHeight(context) {
-			let res = uni.getMenuButtonBoundingClientRect()
-			let status = uni.getSystemInfoSync()
-			let menuButtonWidth = res.width
-			let height = res.height
-			let statusbarHeight = status.statusBarHeight
-			let navHeight = res.height + (res.top - statusbarHeight) * 2;
-			context.commit('setHeight', {
-				statusbarHeight,
-				navHeight,
-				height,
-				menuButtonWidth
-			})
 		},
-		async getUpcomingNum() {
+		SETMENU(state, data) {
+			state.Menu = data
+			uni.setStorageSync('MenuList', JSON.stringify(data));
+		},
+		SETSESSION(state, data) {
+			state.session = data;
+			uni.setStorageSync('session', data);
+		},
+		clearCache(state) {
+			state.userInfo = ''
+			state.token = ''
+			state.session = ''
+			state.Menu = []
+			state.upcomingNum.d = 0
+			state.upcomingNum.y = 0
+			uni.clearStorageSync()
+		}
+	},
+	actions: {
+		// 鍚戝悗绔幏鍙栬彍鍗曟爮鏉冮檺
+		async getMenuList(content, type) {
+			let res = await getTreeList({
+				type: type
+			})
+			if (res.code === 200) {
+				content.commit('SETMENU', res.data)
+			}
+		},
+		// 鑾峰彇鐘舵�侀珮搴�
+		getHeight(context) {
+			let res = uni.getMenuButtonBoundingClientRect()
+			let status = uni.getSystemInfoSync()
+			let menuButtonWidth = res.width
+			let height = res.height
+			let statusbarHeight = status.statusBarHeight
+			let navHeight = res.height + (res.top - statusbarHeight) * 2;
+			context.commit('setHeight', {
+				statusbarHeight,
+				navHeight,
+				height,
+				menuButtonWidth
+			})
+		},
+		async getUpcomingNum(context) {
 			let res = await pageCount({})
 			if (res.code === 200) {
-				content.commit('SETNUM', { d: res.data.startNum, y: res.data.endNum })
+				context.commit('SETNUM', {
+					d: res.data.startNum,
+					y: res.data.endNum
+				})
+			}
+		},
+		// 鍚戝悗绔幏鍙栦釜浜轰俊鎭�
+		async getUserInfos(content) {
+			let res = await getUserInfo()
+			if (res.code === 200) {
+				content.commit('SETUSERINFO', res.data)
+				return true;
 			}
 		}
-	}
-})
-
-export default store
+	}
+})
+
+export default store
\ No newline at end of file

--
Gitblit v1.9.3