From ca73a173f008c8d7a9d700bad897ca24fe2d2203 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期一, 16 十月 2023 09:29:57 +0800
Subject: [PATCH] 111

---
 minipro_standard/store/index.js |  111 ++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 88 insertions(+), 23 deletions(-)

diff --git a/minipro_standard/store/index.js b/minipro_standard/store/index.js
index f73661c..cb25fd3 100644
--- a/minipro_standard/store/index.js
+++ b/minipro_standard/store/index.js
@@ -1,5 +1,10 @@
 import Vue from 'vue'
 import Vuex from 'vuex'
+import {
+	pageCount,
+	getTreeList,
+	getUserInfo
+} from '@/util/api/index.js'
 
 Vue.use(Vuex) // vue鐨勬彃浠舵満鍒�
 
@@ -7,7 +12,9 @@
 const statusbarHeight = uni.getStorageSync('statusbarHeight');
 const menuButtonWidth = uni.getStorageSync('menuButtonWidth');
 const token = uni.getStorageSync('token');
-const userInfo = uni.getStorageSync('userInfo');
+const userInfo = uni.getStorageSync('userInfo');
+const Menu = uni.getStorageSync('MenuList');
+const session = uni.getStorageSync('session');
 
 
 // Vuex.Store 鏋勯�犲櫒閫夐」
@@ -15,11 +22,19 @@
 	// 涓轰簡涓嶅拰椤甸潰鎴栫粍浠剁殑data涓殑閫犳垚娣锋穯锛宻tate涓殑鍙橀噺鍓嶉潰寤鸿鍔犱笂$绗﹀彿
 	state: {
 		// 鐢ㄦ埛淇℃伅
-		userInfo: userInfo || null,
+		userInfo: userInfo || null,
 		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) {
@@ -30,33 +45,83 @@
 			uni.setStorageSync('statusbarHeight', val.statusbarHeight);
 			uni.setStorageSync('menuButtonWidth', val.menuButtonWidth);
 		},
-		SETTOKEN(state, val) {
-			state.token = val
-			uni.setStorageSync('token', val);
-		},
-		SETUSERINFO(state, val) {
-			state.userInfo = val
-			uni.setStorageSync('userInfo', val);
+		SETTOKEN(state, val) {
+			state.token = val
+			uni.setStorageSync('token', val);
+		},
+		SETUSERINFO(state, val) {
+			state.userInfo = val
+			uni.setStorageSync('userInfo', val);
+		},
+		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));
+		},
+		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 && res.code === 200) {
+				content.commit('SETMENU', res.data)
+			}
+		},
 		// 鑾峰彇鐘舵�侀珮搴�
 		getHeight(context) {
+			// #ifdef MP-WEIXIN
+			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
+			})
+			// #endif
 			
-			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 && res.code === 200) {
+				context.commit('SETNUM', {
+					d: res.data.startNum,
+					y: res.data.endNum
+				})
+			}
+		},
+		// 鍚戝悗绔幏鍙栦釜浜轰俊鎭�
+		async getUserInfos(content) {
+			let res = await getUserInfo()
+			if (res && 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