adultDeviceApp/store/index.js

155 lines
3.6 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: {
headimg: null,
name: "",
nickname: "",
targetweight: 0, //目标体重
firstweight: 0, //初始体重
weight: 0,
birthday: "",
height: 0,
age: "0",
sex: 0,
familyid: 0,
mage: "",
firstresulttime: ""
},
MeasureResult: {},
isedit: false,
isDrawe: false,
isConnected: false,
isBluetoothTyle: false,
configBox: {},
familayList: [],
historyList: [],
Banner: [],
Trend: {},
TrendPk: {},
isTarget: false,
isFirst: false,
isRecord: false,
isLogin: false,
isLogout: true,
appTheme: '',
devHomePram: {}
},
// mutations: Store中更改state数据状态的唯一方法(必须是同步函数)
mutations: {
toggleColor(state, color) { //你可以传入一个颜色参数(需要上面公共css中含有,如果不传入默认为粉色)
state.appTheme = color
},
/* 用户信息 */
changeUser(state, newData) {
if (newData.familyid) {
uni.setStorageSync('familyid', newData.familyid);
}
if (newData.birthday) {
uni.setStorageSync('birthday', newData.birthday);
}
if (newData.height) {
uni.setStorageSync('height', newData.height);
}
if (newData.sex) {
uni.setStorageSync('sex', newData.sex);
}
Object.assign(state.user, newData)
},
//登录弹框
changeUserLogin(state, newData) {
state.isLogin = newData
},
//历史记录
changehistoryList(state, newData) {
state.historyList = newData
},
// 获取称重数据
changeMeasureResult(state, newData) {
state.MeasureResult = 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
},
// 左侧菜单弹框
changeDrawe(state, newData) {
state.isDrawe = newData
},
//获取家庭成员
changeFamilay(state, newData) {
state.familayList = newData
},
//蓝牙状态
changeBluetooth(state, newData) {
state.isBluetoothTyle = newData
},
// 蓝牙连接状态
changeConnected(state, newData) {
state.isConnected = newData
},
//趋势
changeTrend(state, newData) {
state.Trend = newData
},
//对比
changeTrendPk(state, newData) {
state.TrendPk = newData
},
// banner
changeBanner(state, newData) {
state.Banner = newData
},
//配置详情
changeConfig(state, newData) {
state.configBox = newData
},
// 退出登录
changeLogout(state, newData) {
if (newData == false) {
state.user = {
headimg: null,
nickname: "",
name: "",
targetweight: 0, //目标体重
firstweight: 0, //初始体重
weight: 0,
birthday: "",
height: 0,
age: 0,
sex: 0,
familyid: 0,
firstresulttime: ""
}
state.Trend = null
state.historyList = null
state.devTypeList = null
}
state.isLogout = newData
},
changeDevType(state, newData) {
state.devHomePram = newData
}
},
// 模块化vuex
modules: {},
actions
})