需求:第一个请求的结果,需要作为第二个请求的请求参数
model 里面数据必须retrue返回,给页面使用
![](https://img.haomeiwen.com/i6619704/ebeb180200919551.png)
执行第一个方法
componentDidMount() {
this.getChildAbilityDetail();
}
第一个请求方法
//获取能力详情
getChildAbilityDetail() {
const currentId = localStorage.getItem('currentId');
let { abilityId = '' } = this.props.location.state;
const age = localStorage.getItem('age');
this.props
.dispatch({
type: 'childAnalysis/getChildAbilityDetail',
payload: { childId: currentId, age: age, testType: 1, kgid: 0, abilityId: abilityId },
})
.then(data => {
this.getTaskTestStatus(data);
});
}
第二个请求方法
//获取能力详情
//请求-获取状态
getTaskTestStatus(childAbilityDetail) {
const { dispatch } = this.props;
const childId = localStorage.getItem('currentId');
const {
task: { taskid = '' },
} = childAbilityDetail;
dispatch({
type: 'childAnalysis/getTaskTestStatus',
payload: { childId: childId, taskIdList: taskid },
});
}
model里面方法,return data:
//能力详情页
*getChildAbilityDetail({ payload }, { call, put }) {
const {
data: { data, code },
} = yield call(getChildAbilityDetail, payload);
if (code === 0) {
yield put({
type: 'updateListResult',
payload: {
childAbilityDetail: data,
},
});
return data;
}
},
网友评论