intelligentGroup/store/actions.js

129 lines
2.3 KiB
JavaScript
Raw Permalink Normal View History

2023-09-08 14:52:40 +08:00
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 => {})
},
2023-09-15 14:26:04 +08:00
// 导航栏列表
getNavbarlist({
commit
}) {
return model.getNavbarlist({}).then(res => {
if (res.code != 0) false
commit('changeNavbarlist', res.data)
}).catch(e => {})
},
2023-09-08 14:52:40 +08:00
// 用户信息
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
})
},
}