ReedawFoodApp/store/actions.js

156 lines
3.1 KiB
JavaScript
Raw Normal View History

2025-05-30 11:14:38 +08:00
import model from "../toolJs/model.js"
import tools from '@/toolJs/tools.js'
// Action 包含异步操作请求API方法、回调函数提交mutaions更改state数据状态使之可以异步
export default {
2026-03-23 09:50:49 +08:00
//配置接口
getHomeConfig({
commit,
dispatch
}) {
return model.getHomeConfig({}).then(res => {
commit('changeConfigInfo', res.data)
return res.data
})
},
2025-05-30 11:14:38 +08:00
// 账户信息
getAccountNumber({
commit
}) {
return model.getAccountNumber({}).then(res => {
console.log("账户信息", res.data)
if (res.code != 0) {
tools.msg(res.msg)
return
}
commit('changeAccountNumber', res.data)
});
},
2026-03-23 09:50:49 +08:00
// 成员列表
getFamilyList({
2025-05-30 11:14:38 +08:00
commit
},
account) {
2026-03-23 09:50:49 +08:00
return model.getUserList(account).then(res => {
2025-05-30 11:14:38 +08:00
if (res.code != 0) {
tools.msg(res.msg)
return
}
2026-03-23 09:50:49 +08:00
commit('changeFamilay', res.data.user_list)
2025-05-30 11:14:38 +08:00
});
},
2026-03-23 09:50:49 +08:00
// 用户信息
getUserInfo({
2025-05-30 11:14:38 +08:00
commit
},
account) {
2026-03-23 09:50:49 +08:00
return model.getUserInfo(account).then(res => {
console.log("用户信息", res.data)
2025-05-30 11:14:38 +08:00
if (res.code != 0) {
tools.msg(res.msg)
2026-04-11 11:37:58 +08:00
commit('changeUser', {
id: "",
head_pic: null,
nickname: "",
birthday: "",
gender: 0,
sex: 0,
age: 0,
weight: "",
address: "",
measure_model: 0,
card_order: [],
food_count: {},
card_data_list: [],
target_current: {},
vitalcapacity_data: []
})
2025-05-30 11:14:38 +08:00
return
}
2026-03-30 10:02:10 +08:00
uni.setStorageSync('userid', res.data.aud_id)
2026-03-23 09:50:49 +08:00
uni.setStorageSync('gender', res.data.gender)
commit('changeUser', res.data)
2025-05-30 11:14:38 +08:00
});
},
2026-03-23 09:50:49 +08:00
// 首页身体数据
getResult({
2025-05-30 11:14:38 +08:00
commit
}, account) {
2026-03-23 09:50:49 +08:00
return model.getResultHome(account).then((res) => {
2025-05-30 11:14:38 +08:00
console.log("报告", res)
if (res.code == 0) {
commit('changeMeasureResult', res.data)
} else {
2026-04-11 11:37:58 +08:00
commit('changeMeasureResult', {
card_list: [],
top_list: []
})
2025-05-30 11:14:38 +08:00
}
})
},
2026-03-23 09:50:49 +08:00
// 获取用户卡片
getCardAllList({
2026-04-11 11:37:58 +08:00
commit
}) {
return model.getCardAllList({}).then(res => {
2026-03-23 09:50:49 +08:00
commit('changeCardList', res.data)
})
},
2026-03-30 10:02:10 +08:00
//趋势
GetBodyTrendList({
commit
}, account) {
return model.getTrendList(account).then((res) => {
console.log("趋势", res)
commit('changeTrend', res.data)
})
},
2026-03-27 10:04:26 +08:00
getPublicRecord({
commit
2026-04-11 11:37:58 +08:00
}) {
2026-03-27 10:04:26 +08:00
let that = this
2026-04-11 11:37:58 +08:00
return model.getPublicRecord({}).then(res => {
2026-03-27 10:04:26 +08:00
if (res.code == 0) {
commit('changePublicRecord', res.data)
}
})
},
2025-05-30 11:14:38 +08:00
// 跳绳数据
getSkipResult({ //报告
commit
}, account) {
2026-03-23 09:50:49 +08:00
return model.getSkipDataResult(account).then((res) => {
2025-05-30 11:14:38 +08:00
console.log("跳绳报告", res)
if (res.code == 0) {
commit('changeMeasureSkip', res.data)
} else {
commit('changeMeasureSkip', null)
}
})
},
// 肺活量
getLungResult({ //报告
commit
}, account) {
2026-03-23 09:50:49 +08:00
return model.getLungDataResult(account).then((res) => {
2025-05-30 11:14:38 +08:00
if (res.code == 0) {
commit('changeLungLevel', res.data.list)
commit('changeMeasureLung', res.data)
} else {
commit('changeMeasureLung', null)
}
})
},
2026-03-23 09:50:49 +08:00
// 计食器信息
getCountFoodInfo({
2025-05-30 11:14:38 +08:00
commit
}, account) {
2026-03-23 09:50:49 +08:00
return model.getCountFoodInfo(account).then(res => {
if (res.code == 0) {
commit('changeCountFoodInfo', res.data)
2025-05-30 11:14:38 +08:00
}
2026-03-23 09:50:49 +08:00
return res.data
});
2025-05-30 11:14:38 +08:00
},
}