120 lines
2.1 KiB
JavaScript
120 lines
2.1 KiB
JavaScript
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 => {})
|
||
},
|
||
|
||
// 用户信息
|
||
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
|
||
})
|
||
},
|
||
|
||
} |