|
@@ -1,6 +1,6 @@
|
|
|
import React from 'react';
|
|
|
import './index.less';
|
|
|
-import { Link } from 'react-router-dom';
|
|
|
+
|
|
|
import { Anchor, Icon } from 'antd';
|
|
|
import Assets from '@src/components/Assets';
|
|
|
import Page from '@src/containers/Page';
|
|
@@ -8,7 +8,7 @@ import Select from '../../../components/Select';
|
|
|
import Button from '../../../components/Button';
|
|
|
import QAList from '../../../components/QAList';
|
|
|
import Tabs from '../../../components/Tabs';
|
|
|
-import { SuppleModal, SuppleFinishModal } from '../../../components/OtherModal';
|
|
|
+import { SuppleModal, SuppleFinishModal, FaqModal, FinishModal } from '../../../components/OtherModal';
|
|
|
import { Main } from '../../../stores/main';
|
|
|
import { User } from '../../../stores/user';
|
|
|
import { getMap, formatTreeData } from '../../../../../src/services/Tools';
|
|
@@ -18,6 +18,8 @@ export default class extends Page {
|
|
|
this.areaMap = {};
|
|
|
this.categoryMap = {};
|
|
|
this.loadArticleMap = {};
|
|
|
+ this.readPlateMap = {};
|
|
|
+ this.loadReadMap = {};
|
|
|
this.dataList = null;
|
|
|
return {
|
|
|
readTab: '1',
|
|
@@ -144,7 +146,13 @@ export default class extends Page {
|
|
|
});
|
|
|
this.categoryMap = getMap(result.category, 'id');
|
|
|
const list = formatTreeData(result.category, 'id', 'title', 'parentId');
|
|
|
- this.setState({ list });
|
|
|
+ const readPlates = result.read.plates.map((row, index) => {
|
|
|
+ row.title = row.plate;
|
|
|
+ row.key = `${index + 1}`;
|
|
|
+ return row;
|
|
|
+ });
|
|
|
+ this.readPlateMap = getMap(readPlates, 'key');
|
|
|
+ this.setState({ list, readPlates });
|
|
|
this.changePage(list[0].id);
|
|
|
});
|
|
|
}
|
|
@@ -205,18 +213,6 @@ export default class extends Page {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- refreshRead() {
|
|
|
- if (!this.readList) {
|
|
|
- Main.listRead({ page: 1, size: 1000, plate: 'getready' })
|
|
|
- .then(result => {
|
|
|
- this.readList = result.list;
|
|
|
- this.setState({ reads: this.readList });
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.setState({ reads: this.readList });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
refreshFaq() {
|
|
|
if (!this.faqList) {
|
|
|
Main.listFaq({ page: 1, size: 1000, channel: 'getready' })
|
|
@@ -297,8 +293,25 @@ export default class extends Page {
|
|
|
this.setState({ current: key });
|
|
|
}
|
|
|
|
|
|
+ refreshRead() {
|
|
|
+
|
|
|
+ const { readPlates } = this.state;
|
|
|
+ this.onChangeReadTab(readPlates[0].key);
|
|
|
+ }
|
|
|
+
|
|
|
onChangeReadTab(key) {
|
|
|
- this.setState({ readTab: key });
|
|
|
+ const plate = this.readPlateMap[key];
|
|
|
+ this.setState({ readTab: key, plate, reads: [] });
|
|
|
+ if (!this.loadReadMap[key]) {
|
|
|
+ Main.listRead({ page: 1, size: 100, plate: key })
|
|
|
+ .then(result => {
|
|
|
+ this.loadReadMap[key] = result.list;
|
|
|
+ this.setState({ reads: result.list });
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ const list = this.loadReadMap[key];
|
|
|
+ this.setState({ reads: list });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
renderView() {
|
|
@@ -350,7 +363,7 @@ export default class extends Page {
|
|
|
{!!detail.isFaq && this.renderFaq()}
|
|
|
</div>
|
|
|
</div>
|
|
|
- </div >
|
|
|
+ </div>
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -415,7 +428,8 @@ export default class extends Page {
|
|
|
}
|
|
|
|
|
|
renderRead() {
|
|
|
- const { readTab, reads = [] } = this.state;
|
|
|
+ const { readTab, reads = [], readPlates, plate = {} } = this.state;
|
|
|
+ console.log(plate);
|
|
|
return <div className='read-layout'>
|
|
|
<Tabs
|
|
|
className='m-b-2'
|
|
@@ -423,26 +437,31 @@ export default class extends Page {
|
|
|
theme="gray"
|
|
|
space={2.5}
|
|
|
active={readTab}
|
|
|
- tabs={[{ title: '单项攻略', key: '1' }, { title: '模考&PACE', key: '2' }, { title: '换库&机经', key: '3' }, { title: '经验分享', key: '4' }, { title: '申请相关', key: '5' }]}
|
|
|
+ tabs={readPlates}
|
|
|
onChange={key => this.onChangeReadTab(key)}
|
|
|
/>
|
|
|
- <div className='m-b-2'>
|
|
|
- <Button className='m-r-1'>CAT模考 ></Button>
|
|
|
- <Button>非CAT模考 ></Button>
|
|
|
- </div>
|
|
|
+ {!!plate.jump && <div className='m-b-2'>
|
|
|
+ <Button className='m-r-1' onClick={() => openLink(plate.link)}>{plate.text}</Button>
|
|
|
+ </div>}
|
|
|
{reads.map((item) => {
|
|
|
return <div className='m-b-5'>
|
|
|
- <Link to={item.path}>{item.title}</Link>
|
|
|
+ <a href={item.link || ''} target="_blank">{item.title}</a>
|
|
|
</div>;
|
|
|
})}
|
|
|
</div>;
|
|
|
}
|
|
|
|
|
|
renderFaq() {
|
|
|
- const { faqs = [] } = this.state;
|
|
|
+ const { faqs = [], showFaq, showFinish, faq = {} } = this.state;
|
|
|
return <div className='faq-layout'>
|
|
|
- <Button>我要提问 ></Button>
|
|
|
+ <Button onClick={() => this.setState({ showFaq: true, faq: { channel: 'getready' } })}>我要提问 ></Button>
|
|
|
<QAList data={faqs} />
|
|
|
+
|
|
|
+ <FaqModal show={showFaq} defaultData={faq} onCancel={() => this.setState({ showFaq: false, faq: {} })} onConfirm={() => this.setState({ showFaq: false, faq: {}, showFinish: true })} />
|
|
|
+ <FinishModal
|
|
|
+ show={showFinish}
|
|
|
+ onConfirm={() => this.setState({ showFinish: false })}
|
|
|
+ />
|
|
|
</div>;
|
|
|
}
|
|
|
}
|