import Vue from 'vue'
import Vuex from 'vuex'
import actions from './actions.js'
Vue.use(Vuex)
export default new Vuex.Store({
	// state: 存储基本数据
	state: {
		user: {
			id: "",
			headimg: null,
			nickname: "",
			birthday: "",
			gender: 0,
			sex: 0,
			card_data_list: [],
			target_current: {}
		},
		MeasureSkip: null,
		MeasureResult: null,
		MeasureLung: null,
		familayList: [],
		historyList: [],
		cardList: {
			user: [],
			all: []
		},
		Trend: [],
		isDrawe: false, //左侧弹框
		isedit: false, //信息弹框
		isTarget: false, //目标体重
		isFirst: false, //初始体重
		isRecord: false, //手动记录
		isSlider: false, //分数占比

	},
	// mutations:  Store中更改state数据状态的唯一方法(必须是同步函数)
	mutations: {
		/* 用户信息 */
		changeUser(state, newData) {
			uni.setStorageSync('userid', newData.id)
			Object.assign(state.user, newData)
		},
		// 卡片列表
		changeCardList(state, newData) {
			state.cardList = newData
		},
		//历史记录
		changehistoryList(state, newData) {
			state.historyList = newData
		},
		// 获取称重数据
		changeMeasureResult(state, newData) {
			state.MeasureResult = newData
		},
		// 跳绳数据
		changeMeasureSkip(state, newData) {
			state.MeasureSkip = newData
		},
		// 肺活量
		changeMeasureLung(state, newData) {
			state.MeasureLung = newData
		},

		// 信息弹框
		changeEdit(state, newData) {
			state.isedit = newData
		},
		// 目标体重
		changeTarget(state, newData) {
			state.isTarget = newData
		},
		// 初始体重
		changeFirst(state, newData) {
			state.isFirst = newData
		},
		// 手动记录
		changeRecord(state, newData) {
			state.isRecord = newData
		},
		// 分数占比
		changeSlider(state, newData) {
			state.isSlider = newData
		},
		// 左侧菜单弹框
		changeDrawe(state, newData) {
			state.isDrawe = newData
		},
		//获取家庭成员
		changeFamilay(state, newData) {
			state.familayList = newData
		},
		//趋势
		changeTrend(state, newData) {
			state.Trend = newData
		}
	},
	// 模块化vuex
	modules: {},
	actions
})