cultivationApp/store/index.js

37 lines
830 B
JavaScript
Raw Normal View History

2023-11-27 18:23:17 +08:00
import {
createStore
} from 'vuex'
const store = createStore({
state: {
userInfo:uni.getStorageSync("SY_USER")||null,
2024-01-26 17:29:25 +08:00
farm: JSON.parse(uni.getStorageSync("farm")||"{}"),
house: JSON.parse(uni.getStorageSync("house")||"{}"),
2023-11-27 18:23:17 +08:00
},
mutations: {
saveUserInfo(state, info) {
state.userInfo = info
uni.setStorageSync("SY_USER", info)
2024-01-26 17:29:25 +08:00
},
setFarm(state, data){
state.farm = data;
uni.setStorageSync('farm', JSON.stringify(data));
},
setHouse(state, data){
state.house = data;
uni.setStorageSync('house', JSON.stringify(data));
}
2023-11-27 18:23:17 +08:00
},
actions: {
saveUserInfo({commit}, info) {
2024-01-26 17:29:25 +08:00
commit('saveUserInfo', info);
},
setFarm({commit}, info){
commit('setFarm', info)
},
setHouse({commit}, info){
commit('setHouse', info)
}
2023-11-27 18:23:17 +08:00
}
})
export default store