12-23-上传master
This commit is contained in:
48
src/pages/ProfileBasic/model.ts
Normal file
48
src/pages/ProfileBasic/model.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import { Effect, Reducer } from 'umi';
|
||||
|
||||
import { BasicGood } from './data.d';
|
||||
import { queryBasicProfile } from './service';
|
||||
|
||||
export interface StateType {
|
||||
basicGoods: BasicGood[];
|
||||
}
|
||||
|
||||
export interface ModelType {
|
||||
namespace: string;
|
||||
state: StateType;
|
||||
effects: {
|
||||
fetchBasic: Effect;
|
||||
};
|
||||
reducers: {
|
||||
show: Reducer<StateType>;
|
||||
};
|
||||
}
|
||||
|
||||
const Model: ModelType = {
|
||||
namespace: 'profileBasic',
|
||||
|
||||
state: {
|
||||
basicGoods: [],
|
||||
},
|
||||
|
||||
effects: {
|
||||
*fetchBasic(_, { call, put }) {
|
||||
const response = yield call(queryBasicProfile);
|
||||
yield put({
|
||||
type: 'show',
|
||||
payload: response,
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
reducers: {
|
||||
show(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
...payload,
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default Model;
|
Reference in New Issue
Block a user