import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

export default new Vuex.Store({
	state:{
		userInfo:{},
		token:"",
		plantBaseInfoId:"",
	},
	getters:{
		userInfo: state=>state.userInfo,
		token: state=>state.token,
	},
	mutations:{
		setUserInfo(state, val){
			state.userInfo={
				...val.userInfo,
				companyName:val.departs[0].departName
			}
			state.token=val.token
		},
		outLogin(state){
			state.userInfo={}
			state.token=''
			uni.reLaunch({
				url:"/pages/home/login",
			})
		},
		setHeadImg(state,val){
			state.userInfo.avatar=val
		},
		setBaseId(state, val){//基地id
			state.plantBaseInfoId = val
		},
	},
	actions:{
		
	}
})