116 lines
2.1 KiB
JavaScript
116 lines
2.1 KiB
JavaScript
import Vue from 'vue'
|
|
import Vuex from 'vuex'
|
|
import actions from './actions.js'
|
|
Vue.use(Vuex)
|
|
export default new Vuex.Store({
|
|
// state: 存储基本数据
|
|
state: {
|
|
user: {
|
|
age: "1",
|
|
aud_id: "",
|
|
email: "",
|
|
gender: "",
|
|
head_pic: "",
|
|
height: 0,
|
|
isEditInfo: false,
|
|
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: [],
|
|
language_arr: [],
|
|
default_count_foot: {
|
|
list: [],
|
|
},
|
|
source_quote: {
|
|
food_details: []
|
|
},
|
|
business_cooperation: {}
|
|
},
|
|
// 计食器
|
|
countFoodInfo: {
|
|
date: "",
|
|
details: {},
|
|
list: [],
|
|
remaining_kcal: "",
|
|
nutrients_four: [],
|
|
trace_elements_all_day: []
|
|
},
|
|
phoneInfo: {
|
|
info: {},
|
|
versionUrl: null,
|
|
platform: ""
|
|
},
|
|
bleValue: {
|
|
deviceId: "",
|
|
serviceId: "",
|
|
notify: "",
|
|
write: "",
|
|
unit: "g",
|
|
type: 1,
|
|
oldCountWeight: 0,
|
|
countWeight: 100,
|
|
bleTipsText: "",
|
|
isConnectStatus: 0,
|
|
},
|
|
isBluetoothTyle: false,
|
|
setLocale: "zh"
|
|
},
|
|
// mutations: Store中更改state数据状态的唯一方法(必须是同步函数)
|
|
mutations: {
|
|
// 版本信息
|
|
changePhoneInfo(state, newData) {
|
|
Object.assign(state.phoneInfo, newData)
|
|
},
|
|
/* 用户信息 */
|
|
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
|
|
},
|
|
// 设置语言
|
|
changeLocale(state, newData) {
|
|
console.log("changeLocale", newData)
|
|
state.setLocale = newData
|
|
},
|
|
// 计食器
|
|
changeCountFoodInfo(state, newData) {
|
|
state.countFoodInfo = newData
|
|
},
|
|
},
|
|
// 模块化vuex
|
|
modules: {},
|
|
actions
|
|
}) |