import model from "../tools/model.js" import tools from '@/tools/tools.js' // Action 包含异步操作(请求API方法)、回调函数提交mutaions更改state数据状态,使之可以异步 export default { // 用户信息 getUserInfo({ commit }, account) { return model.getUserInfo(account).then(res => { commit('changeUser', res.data) if (!res.data.height || !res.data.mage || !res.data.birthday) { uni.redirectTo({ url: `/pageTwo/login/userinfo` }) return } }); }, // 获取称重结果 getResult({ commit }, account) { return model.getResult(account).then((res) => { console.log("报告", res) if (res.code == 0) { commit('changeMeasureResult', res.data) } else { commit('changeMeasureResult', null) } return res.data }) }, // 获取历史记录 gethistoryList({ commit }, account) { return model.getHistoryList(account).then((res) => { if (res.data && res.data.items) { commit('changehistoryList', res.data.items) } else { commit('changehistoryList', null) } return res }) }, //趋势 GetBodyTrendList({ commit }, account) { return model.GetBodyTrendList(account).then((res) => { if (res) { commit('changeTrend', res.cidata) } return res }) }, // 更新家庭成员 getFamilyList({ commit }) { return model.getFamilyList({ pagenum: 20, pagesize: 1 }).then((res) => { commit('changeFamilay', res) return res }) }, // 获取历史记录 gethistoryList({ commit }, account) { return model.getHistoryList(account).then((res) => { if (res.data && res.data.rows) { commit('changehistoryList', res.data.rows) } else { commit('changehistoryList', null) } return res }) }, }