import Vue from 'vue' import Vuex from 'vuex' import actions from './actions.js' import json from '@/content.json' Vue.use(Vuex) export default new Vuex.Store({ // state: 存储基本数据 state: { user: { aud_id: "", head_pic: null, nickname: "", birthday: "", gender: 0, sex: 0, age: 0, stage: "", height: "", weight: "", address: "", head_data: 0, food_count: {}, card_order: [], card_data_list: [], target_current: {}, vitalcapacity_data: [] }, // 配置接口 configInfo: { activity_level: [], area_list: [], banner: [], meal_list: [], language_arr: [], literature: { index: [], bmi_evaluation: [], height_prediction: [], warning: [] }, identity_list: [], grade_list: [], cookbook_label: [], default_count_foot: [], business_cooperation_url: [], }, // 蓝牙 bleValue: { deviceId: "", serviceId: "", isFood: false, foodWeight: 100, foodUnit: "g", foodNotify: "", foodWrite: "", foodunitList: json.unitArray, foodType: 1, //食物称 1实时,2锁定 状态类型 bleTipsText: "搜索中", //蓝牙提示语 isConnectStatus: 0, //蓝牙连接状态 0搜索中,1失败,2成功 }, // 计食器 countFoodInfo: { date: "", details: {}, list: [], remaining_kcal: "", nutrients_four: [], trace_elements_all_day: [] }, // 用户接口 accountNumber: { create_time: "", head_pic: "", last_update_time: "", my_email: "", my_tel: "", nickname: "", }, MeasureResult: { body_type_name: "", body_type_unit: "", body_type_value: "", bottom_list: [], cplist: { moodlist: [], nutritionlist: [], sleeplist: [], sportlist: [] }, literature: [], record_time: "", score_name: "", score_unit: "", score_value: "", target_current: { target_weight: 0, initial_weight: "", cumulative_weight: "", cumulative_day: "" }, top_list: [] }, phoneInfo: { info: {}, versionUrl: null, platform: "" }, MeasureSkip: null, MeasureLung: null, familayList: [], PublicRecord: [], LungLevel: [], //肺活量标准 CardList: { chosen_fixed: [], chosen_yes: [], chosen_no: [] }, homeCardIndex: 0, isDrawe: false, //左侧弹框 isTarget: false, //目标体重 isFirst: false, //初始体重 isRecord: false, //手动记录 isPublicRecord: false, //公共手动记录弹框 isBluetoothTyle: false, isConnected: false, setLocale: "zh", trendInfo: { weightList: [], target_weight: "", calculate_val: "", initial_weight: "", calculate_time: "", } }, mutations: { // 版本信息 changePhoneInfo(state, newData) { Object.assign(state.phoneInfo, newData) }, // 账户信息 changeAccountNumber(state, newData) { Object.assign(state.accountNumber, newData) }, /* 用户信息 */ changeUser(state, newData) { Object.assign(state.user, newData) }, // 首页卡片当前项 changehomeCard(state, newData) { state.homeCardIndex = newData }, //获取家庭成员 changeFamilay(state, newData) { if (newData.length == 0) { uni.setStorageSync('userid', "") uni.setStorageSync('gender', 0) state.user = { id: "", head_pic: null, nickname: "", birthday: "", gender: 0, sex: 0, age: 0, weight: "", address: "", measure_model: 0, card_order: [], food_count: {}, card_data_list: [], target_current: {}, vitalcapacity_data: [] } } state.familayList = newData }, // 卡片列表 changeCardList(state, newData) { state.CardList = newData }, // 左侧菜单弹框 changeDrawe(state, newData) { state.isDrawe = newData }, // 获取称重数据 changeMeasureResult(state, newData) { Object.assign(state.MeasureResult, newData) }, //趋势 changeTrend(state, newData) { state.trendInfo = newData }, // 菜谱 changeMenuList(state, newData) { state.menuList = newData }, // 跳绳数据 changeMeasureSkip(state, newData) { state.MeasureSkip = newData }, // 肺活量标准 changeLungLevel(state, newData) { state.lungLevel = newData }, // 肺活量 changeMeasureLung(state, newData) { state.MeasureLung = newData }, // 目标体重 changeTarget(state, newData) { state.isTarget = newData }, // 初始体重 changeFirst(state, newData) { state.isFirst = newData }, // 手动记录 changeRecord(state, newData) { state.isRecord = newData }, // 公共手动记录内容 changePublicRecord(state, newData) { state.PublicRecord = newData }, // 公共手动弹框 changeTsPublicRecord(state, newData) { state.isPublicRecord = newData }, // 设置语言 changeLocale(state, newData) { state.setLocale = newData }, // 计时 changeConfigInfo(state, newData) { state.configInfo = newData }, // 计食器 changeCountFoodInfo(state, newData) { state.countFoodInfo = newData }, // 蓝牙信息 changeBluetoothValue(state, newData) { Object.assign(state.bleValue, newData) }, //蓝牙状态 changeBluetooth(state, newData) { state.isBluetoothTyle = newData }, // changeConnected(state, newData) { state.isConnected = newData }, }, // 模块化vuex modules: {}, actions })