import {
	createApp
} from 'vue'
import {
	createStore
} from 'vuex'

const store = createStore({
	state: {
		avatar: '', //存储的头像
		nickName: '', //存储的昵称
		weChatNum: '', //存储微信号
		messageCount: 0, //存储系统消息条数
		userType: 1, //存储登录人身份 1:用户 2:招聘者
		invitationCode: '', //存储用户的邀请码
		companyId: '', //企业id
		isVip: false, //用户是否是会员
		isUserVip: false, //企业是否是会员
		phone: '', //用户手机号
		zhiRate: '', //分成比例（一级）
	},
	mutations: {
		SET_DATA(state) {
			state.avatar = '' //存储的头像
			state.nickName = '' //存储的昵称
			state.weChatNum = '' //存储微信号
			state.messageCount = 0 //存储系统消息条数
			state.userType = 1 //存储登录人身份 1:用户 2:招聘者
			state.invitationCode = '' //存储用户的邀请码
			state.companyId = '' //企业id
			state.isVip = false //用户是否是会员
			state.isUserVip = false //企业是否是会员
			state.phone = '' //用户手机号
			state.zhiRate = '' //分成比例（一级）
			localStorage.setItem('postPushId', '')
		},
		SET_AVATAR(state, payload) {
			state.avatar = payload
		},
		SET_NICK_NAME(state, payload) {
			state.nickName = payload
		},
		SET_WE_CHAT_NUM(state, payload) {
			state.weChatNum = payload
		},
		SET_MESSAGE_COUNT(state, payload) {
			state.messageCount = payload
		},
		SET_USER_TYPE(state, payload) {
			state.userType = payload
		},
		SET_INVITATION_CODE(state, payload) {
			state.invitationCode = payload
		},
		SET_COMPANY_ID(state, payload) {
			state.companyId = payload
		},
		SET_IS_VIP(state, payload) {
			state.isVip = payload
		},
		SET_IS_COMPANY_VIP(state, payload) {
			state.isUserVip = payload
		},
		SET_PHONE(state, payload) {
			state.phone = payload
		},
		SET_ZHI_RATE(state, payload) {
			state.zhiRate = payload
		},




	},
	actions: {
		async SET_DATA({
			commit
		}) {
			commit('SET_DATA'); // 手动触发状态重置的mutation  
		},
		async SET_AVATAR({
			commit
		}, payload) {
			commit('SET_AVATAR', payload)
		},
		async SET_NICK_NAME({
			commit
		}, payload) {
			commit('SET_NICK_NAME', payload)
		},
		async SET_WE_CHAT_NUM({
			commit
		}, payload) {
			commit('SET_WE_CHAT_NUM', payload)
		},
		async SET_MESSAGE_COUNT({
			commit
		}, payload) {
			commit('SET_MESSAGE_COUNT', payload)
		},
		async SET_USER_TYPE({
			commit
		}, payload) {
			commit('SET_USER_TYPE', payload)
		},
		async SET_INVITATION_CODE({
			commit
		}, payload) {
			commit('SET_INVITATION_CODE', payload)
		},
		async SET_COMPANY_ID({
			commit
		}, payload) {
			commit('SET_COMPANY_ID', payload)
		},
		async SET_IS_VIP({
			commit
		}, payload) {
			commit('SET_IS_VIP', payload)
		},
		async SET_IS_COMPANY_VIP({
			commit
		}, payload) {
			commit('SET_IS_COMPANY_VIP', payload)
		},
		async SET_PHONE({
			commit
		}, payload) {
			commit('SET_PHONE', payload)
		},
		async SET_ZHI_RATE({
			commit
		}, payload) {
			commit('SET_ZHI_RATE', payload)
		},

	}
})

export default store