You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.2 KiB
65 lines
1.2 KiB
import { queryProvince, queryCity } from '../services/geographic';
|
|
|
|
export default {
|
|
namespace: 'geographic',
|
|
|
|
state: {
|
|
province: [],
|
|
city: [],
|
|
isLoading: false,
|
|
},
|
|
|
|
effects: {
|
|
*fetchProvince(_, { call, put }) {
|
|
yield put({
|
|
type: 'changeLoading',
|
|
payload: true,
|
|
});
|
|
const response = yield call(queryProvince);
|
|
yield put({
|
|
type: 'setProvince',
|
|
payload: response,
|
|
});
|
|
yield put({
|
|
type: 'changeLoading',
|
|
payload: false,
|
|
});
|
|
},
|
|
*fetchCity({ payload }, { call, put }) {
|
|
yield put({
|
|
type: 'changeLoading',
|
|
payload: true,
|
|
});
|
|
const response = yield call(queryCity, payload);
|
|
yield put({
|
|
type: 'setCity',
|
|
payload: response,
|
|
});
|
|
yield put({
|
|
type: 'changeLoading',
|
|
payload: false,
|
|
});
|
|
},
|
|
},
|
|
|
|
reducers: {
|
|
setProvince(state, action) {
|
|
return {
|
|
...state,
|
|
province: action.payload,
|
|
};
|
|
},
|
|
setCity(state, action) {
|
|
return {
|
|
...state,
|
|
city: action.payload,
|
|
};
|
|
},
|
|
changeLoading(state, action) {
|
|
return {
|
|
...state,
|
|
isLoading: action.payload,
|
|
};
|
|
},
|
|
},
|
|
};
|
|
|