import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) const userInfo = uni.getStorageSync('userInfo'); const token = uni.getStorageSync('token'); const store = new Vuex.Store({ state: { userInfo: userInfo || null, token: token || null // token }, mutations: { setUserInfo(state, val) { state.userInfo = val uni.setStorageSync('userInfo', val); }, setToken(state, val) { state.token = val uni.setStorageSync('token', val); }, clearAll(state) { state.userInfo = null state.token = null uni.removeStorageSync('userInfo'); uni.removeStorageSync('token'); } }, 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;