import model from "../toolJs/model.js" import tools from '@/toolJs/tools.js' // Action 包含异步操作(请求API方法)、回调函数提交mutaions更改state数据状态,使之可以异步 export default { //配置接口 getHomeConfig({ commit, dispatch }) { return model.getHomeConfig({}).then(res => { res.data.language_arr = [{ "name": "中文", "val": "zh", "key": "zh" }, { "name": "English", "val": "en", "key": "en" }, { "name": "日本語(Japanese)", "val": "jp", "key": "ja" }, { "name": "Français(French)", "val": "fra", "key": "fr" }, { "name": "Deutsch(German)", "val": "de", "key": "de" }, { "name": "한국어(Korean)", "val": "kor", "key": "ko" }, { "name": "Русский(Russian)", "val": "ru", "key": "ru" }, { "name": "Português(Portuguese)", "val": "pt", "key": "pt" }, { "name": "Español(Spanish)", "val": "spa", "key": "es" }, { "name": "Arabic(العربية)", "val": "ara", "key": "ar" }] commit('changeConfigInfo', res.data) return res.data }) }, // 账户信息 getAccountNumber({ commit }) { return model.getAccountNumber({}).then(res => { console.log("账户信息", res.data) if (res.code != 0) { tools.msg(res.msg) return } commit('changeAccountNumber', res.data) }); }, // 成员列表 getFamilyList({ commit }, account) { return model.getUserList(account).then(res => { if (res.code != 0) { tools.msg(res.msg) return } commit('changeFamilay', res.data.user_list) }); }, // 用户信息 getUserInfo({ commit }, account) { return model.getUserInfo(account).then(res => { console.log("用户信息", res.data) if (res.code != 0) { tools.msg(res.msg) return } uni.setStorageSync('userid', res.data.aud_id) uni.setStorageSync('gender', res.data.gender) commit('changeUser', res.data) }); }, // 首页身体数据 getResult({ commit }, account) { return model.getResultHome(account).then((res) => { console.log("报告", res) if (res.code == 0) { commit('changeMeasureResult', res.data) } else { commit('changeMeasureResult', null) } }) }, // 获取用户卡片 getCardAllList({ commit }, account) { return model.getCardAllList(account).then(res => { commit('changeCardList', res.data) }) }, //趋势 GetBodyTrendList({ commit }, account) { return model.getTrendList(account).then((res) => { console.log("趋势", res) commit('changeTrend', res.data) }) }, getPublicRecord({ commit }, account) { let that = this return model.getPublicRecord(account).then(res => { if (res.code == 0) { commit('changePublicRecord', res.data) } }) }, // 跳绳数据 getSkipResult({ //报告 commit }, account) { return model.getSkipDataResult(account).then((res) => { console.log("跳绳报告", res) if (res.code == 0) { commit('changeMeasureSkip', res.data) } else { commit('changeMeasureSkip', null) } }) }, // 肺活量 getLungResult({ //报告 commit }, account) { return model.getLungDataResult(account).then((res) => { if (res.code == 0) { commit('changeLungLevel', res.data.list) commit('changeMeasureLung', res.data) } else { commit('changeMeasureLung', null) } }) }, // 计食器信息 getCountFoodInfo({ commit }, account) { return model.getCountFoodInfo(account).then(res => { if (res.code == 0) { commit('changeCountFoodInfo', res.data) } return res.data }); }, }