46 lines
1018 B
JavaScript
46 lines
1018 B
JavaScript
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) {
|
||
commit('changeUserInfo', {})
|
||
return
|
||
}
|
||
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
|
||
});
|
||
},
|
||
} |