import {
	code,
	dologin,
	sendSms,
	register,
	getBindUserDeviceId,
	getDayInfo,
} from '@/common/api.js';

let state = {
		user: {},
		apiToken: '',
		serverTime:0,
	},
	getters = {
		getUserInfo(state){
			return state.userInfo
		},
		getApiToken(state){
			return state.apiToken
		},
		getServerTime(state){
			return state.serverTime
		},
	},
	mutations = {
		setUserInfo(state,data) {
			state.userInfo = data
		},
		setApiToken(state,data){
			state.apiToken = data
		},
		logOut(state,data) {
			state.apiToken = ''
		}
	},
	actions = {
		async code({commit}, data) {
			const res = await code(data)
			return res
		},
		async dologin({commit}, data) {
			const res = await dologin(data)
			return res
		},
		async sendSms({commit}, data) {
			const res = await sendSms(data)
			return res
		},
		async register({commit}, data) {
			const res = await register(data)
			return res
		},
		async getBindUserDeviceId({commit}, data) {
			const res = await getBindUserDeviceId(data)
			return res
		},
		async getDayInfo({commit}, data) {
			const res = await getDayInfo(data)
			return res
		}
	}
export default {
	namespaced: true,
	state,
	getters,
	mutations,
	actions
}
