examTeamApp/store/actions.js

102 lines
2.2 KiB
JavaScript
Raw Normal View History

2024-05-02 15:59:36 +08:00
import model from "../tools/model.js"
import tools from '@/tools/tools.js'
// Action 包含异步操作请求API方法、回调函数提交mutaions更改state数据状态使之可以异步
export default {
// 用户信息
getUserInfo({
commit
},
account) {
return model.getUserInfo(account).then(res => {
2024-05-29 16:35:45 +08:00
console.log("用户信息", res.data)
if (res.code != 0) {
that.$tools.msg(res.msg)
return
}
2024-05-02 15:59:36 +08:00
commit('changeUser', res.data)
2024-05-29 16:35:45 +08:00
});
},
// 成员列表
getFamilyList({
commit
},
account) {
return model.getUserList(account).then(res => {
if (res.code != 0) {
that.$tools.msg(res.msg)
2024-05-02 15:59:36 +08:00
return
}
2024-05-29 16:35:45 +08:00
commit('changeFamilay', res.data)
2024-05-02 15:59:36 +08:00
});
2024-05-29 16:35:45 +08:00
},
// 获取所有卡片
getCardList({
commit
},
account) {
return model.getCardAllList(account).then(res => {
console.log("卡片列表", res.data)
commit('changeCardList', res.data)
})
},
// 身体数据
getResult({ //报告
commit
}, account) {
return model.getResult(account).then((res) => {
console.log("报告", res)
if (res.code == 0) {
commit('changeMeasureResult', res.data)
} else {
commit('changeMeasureResult', null)
}
})
},
// 跳绳数据
getSkipResult({ //报告
commit
}, account) {
return model.getSkipResult(account).then((res) => {
console.log("跳绳报告", res)
if (res.code == 0) {
commit('changeMeasureSkip', res.data)
} else {
commit('changeMeasureSkip', null)
}
})
},
// 肺活量
getLungResult({ //报告
commit
}, account) {
return model.getLungResult(account).then((res) => {
console.log("肺活量报告", res)
if (res.code == 0) {
commit('changeMeasureLung', res.data)
} else {
commit('changeMeasureLung', null)
}
})
},
GetBodyTrendList({ //趋势
commit
}, account) {
return model.getTrendList(account).then((res) => {
console.log("趋势", res)
commit('changeTrend', res.data)
})
},
gethistoryList({ // 获取历史记录
commit
}, account) {
return model.getHistoryList(account).then((res) => {
if (res.data && res.data.items) {
commit('changehistoryList', res.data.items)
} else {
commit('changehistoryList', null)
}
})
2024-05-02 15:59:36 +08:00
}
}