import React, { Component } from 'react'; import './index.less'; import { Drawer, Picker, List } from 'antd-mobile'; import Page from '@src/containers/Page'; import Assets from '@src/components/Assets'; import { getMap, formatDate } from '@src/services/Tools'; import Switch from '../../../components/Switch'; import Icon from '../../../components/Icon'; import { SpecialRadioGroup } from '../../../components/Radio'; import Button from '../../../components/Button'; import { TextbookQuality, TextbookSubject } from '../../../../Constant'; import { Textbook } from '../../../stores/textbook'; const TextbookSubjectMap = getMap(TextbookSubject, 'value', 'label'); class Detail extends Component { constructor(props) { super(props); this.state = { show: false }; } render() { const { show, data = {} } = this.state; return (
{data.no || 0}.{data.keyword}
显示答案 this.setState({ show: !show })} />
); } } export default class extends Page { initState() { return { pageData: [{ label: 1, value: 1 }] }; } init() { const { search } = this.state; search.isOld = false; search.qualitys = []; this.setState({ search }); } initData() { Textbook.getInfo() .then(result => { this.setState(result); }); const { subject } = this.params; this.setState({ filter: false }); Textbook.listTopic(Object.assign({ latest: true, subject, order: 'updateTime' }, this.state.search)) .then(result => { this.setTableData(result.list, result.total); const pageData = []; let i = 0; let page = 1; while (i < result.total) { pageData.push({ label: page, value: page }); i += this.state.search.size; page += 1; } this.setState({ pageData }); }); } prev() { const { search } = this.state; if (search.page > 1) { search.page -= 1; } else { return; } this.setState({ search }); this.refresh(); } next() { const { search, page } = this.state; if (search.page < Math.ceil(page.total / page.pageSize)) { search.page += 1; } else { return; } this.setState({ search }); this.refresh(); } changeQuality(value) { const { search = {} } = this.state; const { qualitys = [] } = search; const index = qualitys.indexOf(value); if (index >= 0) { qualitys.splice(index, 1); } else { qualitys.push(value); } search.qualitys = qualitys; this.setState({ search }); } changeOld() { const { search = {} } = this.state; search.isOld = !search.isOld; this.setState({ search }); } changeDirection(direction) { const { search = {} } = this.state; search.direction = direction; this.setState({ search }); } changePage(page) { const { search = {} } = this.state; if (search.page === page) return; search.page = page; this.refresh(); } renderView() { const { subject } = this.params; const { filter, search, pageData, list, latest = {} } = this.state; return ( this.setState({ filter: isOpen })} >
【{TextbookSubjectMap[subject]}】{latest.startDate ? formatDate(latest.startDate, 'MMDD') : ''} 起{TextbookSubjectMap[subject]}机经整理
{list.map(row => )}
{ this.prev(); }}> Previous
{ this.next(); }}> Next
{ this.changePage(i[0]); }}>跳转至第{search.page}页
); } renderFilter() { const { search } = this.state; return (
机经质量
{ this.changeQuality(value); }} />
更新时间
{ this.changeDirection(i[0]); }}>{search.direction === 'asc' ? '由远到近' : '由近到远'}
看考古
{ this.changeOld(); }} />
); } }