intelligentGroup/store/actions.js

129 lines
2.3 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'
// 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
})
}
}
}
})
},
// 首页信息
getHomeContent({
commit
},
account) {
return model.getHomeContent(account).then(res => {
if (res.code != 0) false
commit('changeHomeContent', res.data)
}).catch(e => {})
},
// 导航栏列表
getNavbarlist({
commit
}) {
return model.getNavbarlist({}).then(res => {
if (res.code != 0) false
commit('changeNavbarlist', res.data)
}).catch(e => {})
},
// 用户信息
getUserInfo({
commit
}) {
return model.getuserinfo({}).then(res => {
if (res.code != 0) false
commit('changeUserInfo', res.data)
uni.setStorageSync('UserInfo', res.data)
});
},
// 资讯列表
getInfoList({
commit
},
account) {
return model.getinfolist(account).then(res => {
if (res.code != 0) false
commit('changeInfoList', res.data)
});
},
// 获取历史记录
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
})
},
}