|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Vue.use(Vuex) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const openId = uni.getStorageSync('openId'); | 
|---|
|  |  |  | const member = uni.getStorageSync('member'); | 
|---|
|  |  |  | const openId = uni.getStorageSync('openId') | 
|---|
|  |  |  | const member = uni.getStorageSync('member') | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // meeting | 
|---|
|  |  |  | const navHeight = uni.getStorageSync('navHeight') | 
|---|
|  |  |  | const statusbarHeight = uni.getStorageSync('statusbarHeight') | 
|---|
|  |  |  | const height = uni.getStorageSync('height') | 
|---|
|  |  |  | const token = uni.getStorageSync('token') | 
|---|
|  |  |  | const time = uni.getStorageSync('time') | 
|---|
|  |  |  | const userInfo = uni.getStorageSync('userInfo') | 
|---|
|  |  |  | const sessionKey = uni.getStorageSync('sessionKey') | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const store = new Vuex.Store({ | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | state: { | 
|---|
|  |  |  | openId: openId || '', | 
|---|
|  |  |  | member: member || null | 
|---|
|  |  |  | member: member || null, | 
|---|
|  |  |  | statusbarHeight: statusbarHeight || '0', | 
|---|
|  |  |  | navHeight: navHeight || '0', | 
|---|
|  |  |  | token: token || null, | 
|---|
|  |  |  | time: time || null, | 
|---|
|  |  |  | userInfo: userInfo || {}, | 
|---|
|  |  |  | height: height || '0', | 
|---|
|  |  |  | sessionKey: sessionKey || '' | 
|---|
|  |  |  | }, | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mutations: { | 
|---|
|  |  |  | // 设置openId | 
|---|
|  |  |  | setOpenId(state, val) { | 
|---|
|  |  |  | state.openId = val | 
|---|
|  |  |  | uni.setStorageSync('openId', val); | 
|---|
|  |  |  | uni.setStorageSync('openId', val) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 设置用户信息 | 
|---|
|  |  |  | setMember(state, val) { | 
|---|
|  |  |  | state.member = val | 
|---|
|  |  |  | uni.setStorageSync('member', val); | 
|---|
|  |  |  | uni.setStorageSync('member', val) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 设置导航栏高度 | 
|---|
|  |  |  | setHeight(state, val) { | 
|---|
|  |  |  | state.navHeight = val.navHeight | 
|---|
|  |  |  | state.statusbarHeight = val.statusbarHeight | 
|---|
|  |  |  | state.height = val.height | 
|---|
|  |  |  | uni.setStorageSync('navHeight', val.navHeight) | 
|---|
|  |  |  | uni.setStorageSync('statusbarHeight', val.statusbarHeight) | 
|---|
|  |  |  | uni.setStorageSync('height', val.height) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 设置缓存token | 
|---|
|  |  |  | setToken(state, token) { | 
|---|
|  |  |  | state.token = token | 
|---|
|  |  |  | uni.setStorageSync('token', token) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 设置过期时间戳 | 
|---|
|  |  |  | setTimeStamp(state, time) { | 
|---|
|  |  |  | state.time = time | 
|---|
|  |  |  | uni.setStorageSync('time', time) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 设置用户信息 | 
|---|
|  |  |  | setUserInfo(state, obj) { | 
|---|
|  |  |  | state.userInfo = obj | 
|---|
|  |  |  | uni.setStorageSync('userInfo', obj) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 设置SessionKey | 
|---|
|  |  |  | setSessionKey(state, val) { | 
|---|
|  |  |  | state.sessionKey = val | 
|---|
|  |  |  | uni.setStorageSync('sessionKey', val) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | // 清空所有缓存 | 
|---|
|  |  |  | empty(state) { | 
|---|
|  |  |  | state.token = '' | 
|---|
|  |  |  | state.userInfo = '' | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | export default store | 
|---|