import Config from '../../../../utils/config'; import { getScoreList, getFciGroup, getFciDogByGroupId, detail } from '../../services/index'; import { indext20143, indext20142, indext20141, indextsd20143, indextsd20142, indextsd20141, indext20153, indext20152, indext20151, indext20163, indext20162, indext20161, indext201620, indextyouka, indext201720, indext20171, indext20172, indext20173, indext20183, indext20182, indext20181, indext201820, indext20193, indext20191, indext20192, indext20194, indext20202, indext20203, } from '../../services/jifenData'; import { Toast } from 'antd-mobile'; export default { namespace: 'scoreModel', state: { scoreList: [], scoreTitle: '', groupList: [], fciDogList: [], detail: {}, }, reducers: { updateState(state, { payload }) { return { ...state, ...payload, }; }, }, effects: { *getScoreList({ payload }, { call, put, select }) { const { year, scoreType } = payload; if (year >= 2020) { Toast.loading('加载中', 0, null, true); const { rc, msg, data } = yield call(getScoreList, { ...payload }); if (rc === Config.constant.codeSuccess) { Toast.hide(); yield put({ type: 'updateState', payload: { scoreList: data.list, scoreTitle: data.scoreTitle, }, }); } else { Toast.fail(msg); } } else { let scoreList = []; let scoreTitle = ''; if (scoreType === 3) { if (year === '2019') { scoreList = indext20191; scoreTitle = '(截止2019年9月29日郑州、成都犬展)'; } if (year === '2018') { scoreList = indext20183; scoreTitle = '(截止2018年12月31日杭州犬展)'; } else if (year === '2017') { scoreList = indext20173; scoreTitle = '(截止到2017年12月31日海宁犬展活动)'; } else if (year === '2016') { scoreList = indext20163; scoreTitle = '(截止到2016年12月31日宁波犬展活动)'; } else if (year === '2015') { scoreList = indext20153; scoreTitle = '(截止到2015年12月31日潍坊犬展活动)'; } else if (year === '2014') { scoreList = indext20143; scoreTitle = '(截止到2014年12月14日杭州犬展活动)'; } } else if (scoreType === 'Puppy') { if (year === '2020') { scoreList = indext20202; scoreTitle = '(2019年10月1日起,截止2020年1月6日唐山犬展)'; } if (year === '2019') { scoreList = indext20192; scoreTitle = '(截止2019年9月29日郑州、成都犬展)'; } if (year === '2018') { scoreList = indext20182; scoreTitle = '(截止2018年12月31日杭州犬展)'; } else if (year === '2017') { scoreList = indext20172; scoreTitle = '(截止到2017年12月31日海宁犬展活动)'; } else if (year === '2016') { scoreList = indext20162; scoreTitle = '(截止到2016年12月31日宁波犬展活动)'; } else if (year === '2015') { scoreList = indext20152; scoreTitle = '(截止到2015年12月31日潍坊犬展活动)'; } else if (year === '2014') { scoreList = indext20142; scoreTitle = '(截止到2014年12月14日杭州犬展活动)'; } } else if (scoreType === 'Baby') { if (year === '2020') { scoreList = indext20203; scoreTitle = '(2019年10月1日起,截止2020年1月6日唐山犬展)'; } if (year === '2019') { scoreList = indext20193; scoreTitle = '(截止2019年9月29日郑州、成都犬展)'; } if (year === '2018') { scoreList = indext20181; scoreTitle = '(截止2018年12月31日杭州犬展)'; } else if (year === '2017') { scoreList = indext20171; scoreTitle = '(截止到2017年12月31日海宁犬展活动)'; } else if (year === '2016') { scoreList = indext20161; scoreTitle = '(截止到2016年12月31日宁波犬展活动)'; } else if (year === '2015') { scoreList = indext20151; scoreTitle = '(截止到2015年12月31日潍坊犬展活动)'; } else if (year === '2014') { scoreList = indext20141; scoreTitle = '(截止到2014年12月14日杭州犬展活动)'; } } else if (scoreType === 20) { if (year === '2019') { scoreList = indext20194; scoreTitle = '(截止2019年9月29日郑州、成都犬展)'; } if (year === '2018') { scoreList = indext201820; scoreTitle = '(截止2018年12月31日杭州犬展)'; } else if (year === '2017') { scoreList = indext201720; scoreTitle = '(截止到2017年12月31日海宁犬展活动)'; } else if (year === '2016') { scoreList = indext201620; scoreTitle = '(截止到2016年12月31日宁波犬展活动)'; } } else if (scoreType === 'Eukanuba') { if (year === '2016') { scoreList = indextyouka; scoreTitle = '(截止到2016年12月31日宁波犬展活动)'; } } else if (scoreType === 'sdAdult') { scoreList = indextsd20143; scoreTitle = '(截止到2014年12月14日杭州犬展活动)'; } else if (scoreType === 'sdPuppy') { scoreList = indextsd20142; scoreTitle = '(截止到2014年12月14日杭州犬展活动)'; } else if (scoreType === 'sdBaby') { scoreList = indextsd20141; scoreTitle = '(截止到2014年12月14日杭州犬展活动)'; } yield put({ type: 'updateState', payload: { scoreList, scoreTitle, }, }); } }, *getFciGroup({ payload }, { call, put, select }) { const data = yield call(getFciGroup, { ...payload }); if (data.rc === Config.constant.codeSuccess) { let groupList = []; data['0'].forEach((item, i) => { groupList.push({ value: item.group_no, label: item.chinese_group_name, }); }); yield put({ type: 'updateState', payload: { groupList, }, }); } else { Toast.fail(data.msg); } }, *getFciDogByGroupId({ payload }, { call, put, select }) { const data = yield call(getFciDogByGroupId, { ...payload }); if (data.rc === Config.constant.codeSuccess) { let fciDogList = []; data['0'].forEach((item, i) => { fciDogList.push({ value: item.fci_standard_no, label: item.chinese_breed_name, }); }); yield put({ type: 'updateState', payload: { fciDogList, }, }); } else { Toast.fail(data.msg); } }, *detail({ payload }, { call, put, select }) { Toast.loading('加载中', 0, null, true); const { rc, msg, data } = yield call(detail, { ...payload }); if (rc === Config.constant.codeSuccess) { Toast.hide(); yield put({ type: 'updateState', payload: { detail: data, }, }); } else { Toast.fail(msg); } }, }, subscriptions: { // setupHistory({ dispatch, history }) { // history.listen(location => {}); // }, }, };