2023-11-27 18:23:17 +08:00
|
|
|
import {
|
|
|
|
createStore
|
|
|
|
} from 'vuex'
|
|
|
|
const store = createStore({
|
2023-12-25 00:26:32 +08:00
|
|
|
state: {
|
|
|
|
userInfo: uni.getStorageSync("SY_USER") || null,
|
|
|
|
tabbrIndex: 0
|
|
|
|
|
2023-11-27 18:23:17 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
mutations: {
|
|
|
|
saveUserInfo(state, info) {
|
|
|
|
state.userInfo = info
|
2023-12-25 00:26:32 +08:00
|
|
|
uni.setStorageSync("SY_USER", info)
|
|
|
|
},
|
|
|
|
changeTabbar(state, index) {
|
|
|
|
state.tabbrIndex = index
|
2023-11-27 18:23:17 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
actions: {
|
2023-12-25 00:26:32 +08:00
|
|
|
saveUserInfo({
|
|
|
|
commit
|
|
|
|
}, info) {
|
|
|
|
|
2023-11-27 18:23:17 +08:00
|
|
|
commit('saveUserInfo', info)
|
2023-12-25 00:26:32 +08:00
|
|
|
|
|
|
|
},
|
|
|
|
changeTabbar({
|
|
|
|
commit
|
|
|
|
}, info) {
|
|
|
|
commit('changeTabbar', info)
|
|
|
|
|
2023-11-27 18:23:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
export default store
|