import React, { Component } from 'react';
import { connect } from 'react-redux';
import 'antd-mobile/dist/antd-mobile.less';
import styles from './index.less';
import { Button, DatePicker, Tabs, Picker, Toast } from 'antd-mobile';
import { formatDateYear } from '../common/index';
import sjIcon from '../assets/sanjiao@2x.png';
import score1 from '../assets/1@2x.png';
import score2 from '../assets/2@2x.png';
import score3 from '../assets/3@2x.png';
import icon04 from '../assets/icon04.png';
const CustomChildren = props => {
return (
{props.children === props.extra ? props.children : props.extra}
);
};
@connect(({ scoreModel }) => ({ scoreModel }))
class Index extends Component {
constructor(props) {
super(props);
this.state = {
date: new Date().getFullYear(),
selectedScoreType: {
type: 'adult',
title: '成年犬组',
},
groupNo: null,
fciStandardNo: null,
dateShow: false,
showDetail: false,
};
}
componentWillMount = () => {
document.title = 'CKU年度积分榜';
};
componentDidMount = () => {
this.getScoreList();
this.props.dispatch({
type: 'scoreModel/getFciGroup',
payload: {},
});
};
getScoreList = () => {
this.props.dispatch({
type: 'scoreModel/getScoreList',
payload: {
scoreType:
this.state.selectedScoreType.type === 'adult'
? 3
: this.state.selectedScoreType.type === 'mainland'
? 20
: this.state.selectedScoreType.type === 'ohc'
? 'ohc'
: this.state.selectedScoreType.type === 'bbe'
? 'bbe'
: null,
year: this.state.date,
groupNo: this.state.groupNo,
fciStandardNo: this.state.fciStandardNo,
},
});
};
changeDate = date => {
this.setState(
{
date: formatDateYear(date),
},
() => {
this.clearState(() => {
this.getScoreList();
});
},
);
};
showDate = () => {
this.setState({
dateShow: false,
});
};
clearState = fun => {
this.setState(
{
groupNo: null,
fciStandardNo: null,
},
() => {
if (fun) {
fun();
}
},
);
};
onDismiss = type => () => {
this.setState(
{
[type]: null,
},
() => {
this.getScoreList();
},
);
if (type === 'groupNo') {
this.setState({
fciStandardNo: null,
});
this.props.dispatch({
type: 'scoreModel/updateState',
payload: {
fciDogList: [],
},
});
}
};
onOk = type => v => {
this.setState(
{
[type]: v[0],
},
() => {
if (type === 'groupNo') {
this.setState(
{
fciStandardNo: null,
},
() => {
this.getScoreList();
},
);
this.props.dispatch({
type: 'scoreModel/getFciDogByGroupId',
payload: {
scoreType:
this.state.selectedScoreType.type === 'adult'
? 3
: this.state.selectedScoreType.type === 'mainland'
? 20
: this.state.selectedScoreType.type === 'ohc'
? 'ohc'
: this.state.selectedScoreType.type === 'bbe'
? 'bbe'
: null,
year: this.state.date,
groupId: v[0],
},
});
} else {
this.getScoreList();
}
},
);
};
getDetail = pedigreeCertified => {
this.props.dispatch({
type: 'scoreModel/detail',
payload: {
scoreType:
this.state.selectedScoreType.type === 'adult'
? 3
: this.state.selectedScoreType.type === 'mainland'
? 20
: this.state.selectedScoreType.type === 'ohc'
? 'ohc'
: this.state.selectedScoreType.type === 'bbe'
? 'bbe'
: null,
year: this.state.date,
pedigreeCertified,
},
});
this.setState({
showDetail: true,
});
};
render() {
const { detail } = this.props.scoreModel;
const tabs = [
{ title: '成年犬组', type: 'adult' },
{ title: '本土繁殖', type: 'mainland' },
{ title: '犬主人组', type: 'ohc' },
{ title: '繁殖人组', type: 'bbe' },
];
const customTab = (data, index) => {
return {data.title}
;
};
const row = (rowData, index) => {
if (this.state.date >= 2020) {
return (
{
this.getDetail(rowData.pedigreeCertified);
}}
>
{rowData.ranking === 1 ? (

) : rowData.ranking === 2 ? (

) : rowData.ranking === 3 ? (

) : (
rowData.ranking
)}
);
} else {
return (
{index === 0 ? (

) : index === 1 ? (

) : index === 2 ? (

) : (
index
)}
);
}
};
return (
CKU年度积分榜
{
this.setState({ selectedScoreType: tab, dateShow: true }, () => {
this.setState({
dateShow: false,
});
this.clearState(() => {
this.getScoreList();
});
});
}}
>
CKU{this.state.selectedScoreType.title}{' '}
{this.state.date || formatDateYear(new Date()) - 1}年度积分榜
{this.props.scoreModel.scoreTitle && (
{this.props.scoreModel.scoreTitle}
)}
{this.state.date >= 2020 ? (
犬组筛选
{this.state.groupNo ? (
犬种筛选
) : (
{
Toast.fail('请先选择犬组');
}}
>
犬种筛选
)}
) : null}
名次
犬名
{this.state.selectedScoreType.type === 'bbe' ? '繁殖人' : '犬主'}
积分
{this.props.scoreModel.scoreList.map((item, index) => row(item, index))}
到达底部
{this.state.showDetail ? (
{
this.setState({
showDetail: false,
});
this.props.dispatch({
type: 'scoreModel/updateState',
payload: {
detail: {},
},
});
}}
>
{detail.pedigreeCertified ? (
{detail.dogName || '--'}
{detail.gender === '1' ? '公' : '母'} / {detail.birthdate || '--'}
/
{detail.dogBreedNameCn || '--'}
呼 名:
{detail.nickname || '--'}
犬 主 人:
{detail.dogOwner || '--'}
繁 殖 人:
{detail.breeder || '--'}
血统证书号:
{detail.pedigreeCertified || '--'}
{detail.score || '--'}
总积分
{detail.ranking ? `No.${detail.ranking}` : '--'}
全犬种排名
{detail.gorupRanking ? `No.${detail.gorupRanking}` : '--'}
犬组排名
{detail.dogBreedRanking ? `No.${detail.dogBreedRanking}` : '--'}
犬种排名
) : null}
) : null}
);
}
}
export default Index;