kitchendDevice/store/actions.js

53 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-09-08 15:17:21 +08:00
import model from "../tools/model.js"
import tools from '@/tools/tools.js'
import config from '@/config.js'
// Action 包含异步操作请求API方法、回调函数提交mutaions更改state数据状态使之可以异步
export default {
2025-11-08 16:50:26 +08:00
//配置接口
getHomeConfig({
commit,
dispatch
2023-09-08 15:17:21 +08:00
}) {
2025-11-08 16:50:26 +08:00
return model.getHomeConfig({}).then(res => {
commit('changeConfig', res.data)
dispatch("getUserInfo")
return res.data
2023-09-08 15:17:21 +08:00
})
},
// 用户信息
2025-11-08 16:50:26 +08:00
getUserInfo({
commit,
dispatch
2023-09-08 15:17:21 +08:00
}) {
2025-11-08 16:50:26 +08:00
return model.getHomeUserInfo({}).then(res => {
if (res.code != 0) {
tools.msg(res.msg)
return
}
if (res.data.weight == 0 || res.data.weight == null || res.data.weight == "") {
2025-11-26 17:32:18 +08:00
commit('changeUserInfo', {
isEditInfo: true,
2025-11-26 17:32:18 +08:00
aud_id: ""
})
} else {
commit('changeUserInfo', res.data)
2023-09-08 15:17:21 +08:00
}
2025-11-08 16:50:26 +08:00
dispatch("getCountFoodInfo", {
aud_id: res.data.aud_id,
time: tools.getDate("start")
})
return res.data
});
2023-09-08 15:17:21 +08:00
},
2025-11-08 16:50:26 +08:00
// 计食器信息
getCountFoodInfo({
2023-09-08 15:17:21 +08:00
commit
}, account) {
2025-11-08 16:50:26 +08:00
return model.getCountFoodInfo(account).then(res => {
2023-09-08 15:17:21 +08:00
if (res.code == 0) {
2025-11-08 16:50:26 +08:00
commit('changeCountFoodInfo', res.data)
2023-09-08 15:17:21 +08:00
}
2025-11-08 16:50:26 +08:00
return res.data
});
2023-09-08 15:17:21 +08:00
},
2025-11-08 16:50:26 +08:00
}