kitchendDevice/store/actions.js

120 lines
2.2 KiB
JavaScript
Raw 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 {
//sessionId
getsessionId({
commit
}) {
return uni.login({
success(res) {
if (res.code) {
if (res.errMsg = "login:ok") {
model.onlogin({
code: res.code
}).then(ress => {
uni.setStorageSync('sessionid', ress.data.sessionid)
return ress
})
}
}
}
})
},
// 用户信息
getPetInfo({
commit
},
account) {
return model.getPetInfo(account).then(res => {
if (res.code != 0) false
uni.setStorageSync('petid', res.data.id);
commit('changePetInfo', res.data)
commit('changeInfoConf', res.data.conf)
});
},
// 获取历史记录
gethistoryList({
commit
}, account) {
return model.getList(account).then((res) => {
if (res.data && res.data.items) {
commit('changehistoryList', res.data.items)
} else {
commit('changehistoryList', null)
}
return res
})
},
// 宠物列表
getPetList({
commit
}) {
return model.getPetList({
pagenum: 20,
pagesize: 1
}).then((res) => {
if (res.data) {
commit("changePetList", res.data)
} else {
commit("changePetList", null)
}
return res
})
},
//养护提醒
getAlertList({
commit
}, account) {
return model.getAlertList(account).then(res => {
if (res.data && res.data.rows) {
commit('changeAlertList', res.data.rows)
} else {
commit('changeAlertList', null)
}
return res
})
},
//通知提醒
getNoticelist({
commit
}) {
return model.getnoticelist({}).then(res => {
if (res.data) {
commit('changeNoticelist', res.data)
} else {
commit('changeNoticelist', null)
}
return res
})
},
// 配置详情
getConfig({
commit
}) {
return model.getConfig({
appid: config.appid
}).then((res) => {
if (res.code == 0) {
commit("changeConfig", res.data)
}
})
},
// 枚举
getnumdata({
commit
}) {
return model.getnumdata({
appid: config.appid
}).then((res) => {
if (res.code == 0) {
commit("changenumdata", res.data)
}
})
},
}