import { createStore } from 'vuex' const store = createStore({ state: { userInfo:uni.getStorageSync("SY_USER")||null, farm: JSON.parse(uni.getStorageSync("farm")||"{}"), house: JSON.parse(uni.getStorageSync("house")||"{}"), }, mutations: { saveUserInfo(state, info) { state.userInfo = info uni.setStorageSync("SY_USER", info) }, setFarm(state, data){ state.farm = data; uni.setStorageSync('farm', JSON.stringify(data)); }, setHouse(state, data){ state.house = data; uni.setStorageSync('house', JSON.stringify(data)); } }, actions: { saveUserInfo({commit}, info) { commit('saveUserInfo', info); }, setFarm({commit}, info){ commit('setFarm', info) }, setHouse({commit}, info){ commit('setHouse', info) } } }) export default store