kitchendDevice/store/actions.js

53 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import model from "../tools/model.js"
import tools from '@/tools/tools.js'
import config from '@/config.js'
// Action 包含异步操作请求API方法、回调函数提交mutaions更改state数据状态使之可以异步
export default {
//配置接口
getHomeConfig({
commit,
dispatch
}) {
return model.getHomeConfig({}).then(res => {
commit('changeConfig', res.data)
dispatch("getUserInfo")
return res.data
})
},
// 用户信息
getUserInfo({
commit,
dispatch
}) {
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 == "") {
commit('changeUserInfo', {
isEditInfo: true,
aud_id: ""
})
} else {
commit('changeUserInfo', res.data)
}
dispatch("getCountFoodInfo", {
aud_id: res.data.aud_id,
time: tools.getDate("start")
})
return res.data
});
},
// 计食器信息
getCountFoodInfo({
commit
}, account) {
return model.getCountFoodInfo(account).then(res => {
if (res.code == 0) {
commit('changeCountFoodInfo', res.data)
}
return res.data
});
},
}