kitchendDevice/store/index.js

97 lines
1.8 KiB
JavaScript

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: {
age: "1",
aud_id: "",
email: "",
gender: "",
head_pic: "",
height: 0,
is_use_set_kcal: "",
nickname: "",
set_kcal: "",
tel: "",
token: "",
weight: 0,
birthday: "",
food_count: {
date: "",
list: [],
nutrients_four: [],
remaining_kcal: ""
}
},
// 配置
configInfo: {
banner_data: [],
search_guess: {
cookbook: [],
food_data: []
},
meal_list: [],
search_history: {
cookbook: [],
food: []
},
cookbook_label: [],
activity_level: [],
default_count_foot: {},
business_cooperation: {}
},
// 计食器
countFoodInfo: {
date: "",
details: {},
list: [],
remaining_kcal: "",
nutrients_four: [],
trace_elements_all_day: []
},
bleValue: {
deviceId: "",
serviceId: "",
notify: "",
write: "",
unit: "g",
type: 1,
unitList: json.unitArray,
isSendVal: false,
oldCountWeight: 0,
countWeight: 100,
bleTipsText: "",
isConnectStatus: 0,
},
isBluetoothTyle: false,
},
// mutations: Store中更改state数据状态的唯一方法(必须是同步函数)
mutations: {
/* 用户信息 */
changeUserInfo(state, newData) {
state.user = newData
},
//蓝牙状态
changeBluetooth(state, newData) {
state.isBluetoothTyle = newData
},
// 蓝牙信息
changeBluetoothValue(state, newData) {
Object.assign(state.bleValue, newData)
},
changeConfig(state, newData) {
state.configInfo = newData
},
// 计食器
changeCountFoodInfo(state, newData) {
state.countFoodInfo = newData
},
},
// 模块化vuex
modules: {},
actions
})