kitchendDevice/store/actions.js

46 lines
1018 B
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) {
commit('changeUserInfo', {})
return
2023-09-08 15:17:21 +08:00
}
2025-11-08 16:50:26 +08:00
commit('changeUserInfo', res.data)
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
}