import Vue from 'vue'
import Vuex from 'vuex'
// const userInfo = uni.getStorageSync('userInfo')
// const userInfoJson = JSON.parse(userInfo)



Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        // 屏幕信息
        systemInfo: {},
        // 胶囊信息
        bounding: {},
        // 用户信息
        // userInfo: JSON.parse(uni.getStorageSync('userInfo')) || {}
        userInfo:  uni.getStorageSync('userInfo') || {}
    },
    mutations: {
        set_systemInfo (state, data) {
            state.systemInfo = data
            uni.setStorageSync('systemInfo', state.systemInfo)
        },
        set_bounding(state, data) {
            state.bounding = data
            uni.setStorageSync('bounding', state.bounding)
        },
        set_userInfo(state, data) {
            state.userInfo = data
            uni.setStorageSync('userInfo', state.userInfo)
        }
    }
})

export default store