kitchendDevice/store/index.js

92 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-09-08 15:17:21 +08:00
import Vue from 'vue'
import Vuex from 'vuex'
import actions from './actions.js'
Vue.use(Vuex)
export default new Vuex.Store({
// state: 存储基本数据
state: {
user: {
2025-11-08 16:50:26 +08:00
age: "1",
2025-03-25 10:17:30 +08:00
aud_id: "",
email: "",
gender: "",
head_pic: "",
2025-11-08 16:50:26 +08:00
height: 0,
2025-03-25 10:17:30 +08:00
is_use_set_kcal: "",
nickname: "",
set_kcal: "",
tel: "",
token: "",
2025-11-08 16:50:26 +08:00
weight: 0,
2025-11-25 14:21:22 +08:00
birthday: "",
food_count: {
date: "",
list: [],
nutrients_four: [],
remaining_kcal: ""
}
2025-11-08 16:50:26 +08:00
},
// 配置
configInfo: {
banner_data: [],
search_guess: {
cookbook: [],
food_data: []
},
2025-11-25 14:21:22 +08:00
meal_list: [],
2025-11-08 16:50:26 +08:00
search_history: {
cookbook: [],
food: []
},
2025-11-27 15:04:25 +08:00
activity_level: [],
2025-11-25 14:21:22 +08:00
default_count_foot: {},
2025-11-08 16:50:26 +08:00
business_cooperation: {}
},
// 计食器
countFoodInfo: {
date: "",
2025-11-25 14:21:22 +08:00
details: {},
2025-11-08 16:50:26 +08:00
list: [],
remaining_kcal: "",
2025-11-25 14:21:22 +08:00
nutrients_four: [],
trace_elements_all_day: []
},
bleValue: {
deviceId: "",
serviceId: "",
notify: "",
write: "",
2025-11-26 17:32:18 +08:00
unit: "g",
oldCountWeight: 0,
2025-11-25 14:21:22 +08:00
countWeight: 100,
2025-11-26 17:32:18 +08:00
bleTipsText: "",
isConnectStatus: null,
2023-09-08 15:17:21 +08:00
},
isBluetoothTyle: false,
},
// mutations: Store中更改state数据状态的唯一方法(必须是同步函数)
mutations: {
/* 用户信息 */
2025-03-25 10:17:30 +08:00
changeUserInfo(state, newData) {
2023-09-08 15:17:21 +08:00
state.user = newData
},
//蓝牙状态
changeBluetooth(state, newData) {
state.isBluetoothTyle = newData
},
2025-11-25 14:21:22 +08:00
// 蓝牙信息
changeBluetoothValue(state, newData) {
Object.assign(state.bleValue, newData)
2023-09-08 15:17:21 +08:00
},
2025-11-08 16:50:26 +08:00
changeConfig(state, newData) {
state.configInfo = newData
2025-03-25 10:17:30 +08:00
},
2025-11-08 16:50:26 +08:00
// 计食器
changeCountFoodInfo(state, newData) {
state.countFoodInfo = newData
2023-09-08 15:17:21 +08:00
},
},
// 模块化vuex
modules: {},
actions
2025-03-25 10:17:30 +08:00
})