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 | 120 +++++++++++++++++++++++++++++++++++++----------------------
1 files changed, 75 insertions(+), 45 deletions(-)
diff --git a/minipro_standard/store/index.js b/minipro_standard/store/index.js
index c5561c5..cb25fd3 100644
--- a/minipro_standard/store/index.js
+++ b/minipro_standard/store/index.js
@@ -1,6 +1,10 @@
import Vue from 'vue'
-import Vuex from 'vuex'
-import { pageCount, getTreeList } from '@/util/api/index.js'
+import Vuex from 'vuex'
+import {
+ pageCount,
+ getTreeList,
+ getUserInfo
+} from '@/util/api/index.js'
Vue.use(Vuex) // vue鐨勬彃浠舵満鍒�
@@ -10,7 +14,7 @@
const token = uni.getStorageSync('token');
const userInfo = uni.getStorageSync('userInfo');
const Menu = uni.getStorageSync('MenuList');
-const session = uni.getStorageSync('session');
+const session = uni.getStorageSync('session');
// Vuex.Store 鏋勯�犲櫒閫夐」
@@ -18,18 +22,18 @@
// 涓轰簡涓嶅拰椤甸潰鎴栫粍浠剁殑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 ? Menu : [],
- // 寰呭姙鏁伴噺
- upcomingNum: {
- d: 0,
- y: 0
+ Menu: Menu ? JSON.parse(Menu) : [],
+ // 寰呭姙鏁伴噺
+ upcomingNum: {
+ d: 0,
+ y: 0
},
},
mutations: {
@@ -41,57 +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);
- },
- SETNUM(state, val) {
- state.upcomingNum.d = val.d
- state.upcomingNum.y = val.y
+ SETTOKEN(state, val) {
+ state.token = val
+ uni.setStorageSync('token', val);
},
- SETMENU (state, data) {
+ 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) {
+ 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) {
+ async getMenuList(content, type) {
+ let res = await getTreeList({
+ type: type
+ })
+ if (res && 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() {
+ 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
+
+ },
+ async getUpcomingNum(context) {
let res = await pageCount({})
- if (res.code === 200) {
- content.commit('SETNUM', { d: res.data.startNum, y: res.data.endNum })
- }
- }
+
+ 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