| ¶Ô±ÈÐÂÎļþ |
| | |
| | | import Vue from 'vue' |
| | | import Vuex from 'vuex' |
| | | |
| | | Vue.use(Vuex) |
| | | const userInfo = uni.getStorageSync('userInfo'); |
| | | |
| | | const store = new Vuex.Store({ |
| | | |
| | | state: { |
| | | userInfo: userInfo || null // ç¨æ·ä¿¡æ¯ |
| | | }, |
| | | mutations: { |
| | | // è®¾ç½®ç¨æ·ä¿¡æ¯ |
| | | setUserInfo(state, val) { |
| | | state.userInfo = val |
| | | uni.setStorageSync('userInfo', val); |
| | | } |
| | | }, |
| | | |
| | | actions: { |
| | | // è·åç¶æé«åº¦ |
| | | getHeight(context) { |
| | | let res = uni.getMenuButtonBoundingClientRect() |
| | | let status = uni.getSystemInfoSync() |
| | | var height = res.height |
| | | let statusbarHeight = status.statusBarHeight |
| | | let navHeight = res.height + (res.top - statusbarHeight) * 2; |
| | | context.commit('setHeight', { statusbarHeight, navHeight, height }) |
| | | } |
| | | } |
| | | |
| | | }) |
| | | |
| | | export default store; |