doum
2026-04-25 b7d451c91ec40bee70f23b1e2cf6a8797643faef
app/store/index.js
@@ -3,30 +3,40 @@
Vue.use(Vuex)
const userInfo = uni.getStorageSync('userInfo');
const token = uni.getStorageSync('token');
const store = new Vuex.Store({
   
   state: {
      userInfo: userInfo || null     // 用户信息
      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.clearStorageSync()
      }
   },
   
   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 })
      }
      // 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 })
      // }
   }
   
})