|
@@ -22,13 +22,18 @@ export default class extends Page {
|
|
|
}
|
|
|
|
|
|
init() {
|
|
|
- Main.dataStruct().then((list) => {
|
|
|
- const structTree = formatTreeData(list.map(row => {
|
|
|
- row.title = `${row.titleZh} ${row.titleEn}`;
|
|
|
- row.label = row.title;
|
|
|
- row.key = row.id;
|
|
|
- return row;
|
|
|
- }), 'id', 'title', 'parentId');
|
|
|
+ Main.dataStruct().then(list => {
|
|
|
+ const structTree = formatTreeData(
|
|
|
+ list.map(row => {
|
|
|
+ row.title = `${row.titleZh} ${row.titleEn}`;
|
|
|
+ row.label = row.title;
|
|
|
+ row.key = row.id;
|
|
|
+ return row;
|
|
|
+ }),
|
|
|
+ 'id',
|
|
|
+ 'title',
|
|
|
+ 'parentId',
|
|
|
+ );
|
|
|
this.setState({ structTree });
|
|
|
});
|
|
|
|
|
@@ -38,15 +43,14 @@ export default class extends Page {
|
|
|
}
|
|
|
|
|
|
initData() {
|
|
|
- return this.initListKeys(['data'])
|
|
|
- .then(() => {
|
|
|
- return this.getList('data', 1);
|
|
|
- });
|
|
|
+ return this.initListKeys(['data']).then(() => {
|
|
|
+ return this.getList('data', 1);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
initListKeys(keys) {
|
|
|
const { listMap = {} } = this.state;
|
|
|
- keys.forEach((key) => {
|
|
|
+ keys.forEach(key => {
|
|
|
listMap[key] = new ListData();
|
|
|
});
|
|
|
this.setState({ listMap });
|
|
@@ -54,15 +58,15 @@ export default class extends Page {
|
|
|
}
|
|
|
|
|
|
getList(key, page) {
|
|
|
- Course.listData(Object.assign({ page }, this.state.search))
|
|
|
- .then((result) => {
|
|
|
- const { listMap = {} } = this.state;
|
|
|
- if (page === 1) { // todo 是否重新读取第一页为刷新所有数据
|
|
|
- listMap[key] = new ListData();
|
|
|
- }
|
|
|
- listMap[key].get(page, result, this.state.search.size);
|
|
|
- this.setState({ listMap });
|
|
|
- });
|
|
|
+ Course.listData(Object.assign({ page }, this.state.search)).then(result => {
|
|
|
+ const { listMap = {} } = this.state;
|
|
|
+ if (page === 1) {
|
|
|
+ // todo 是否重新读取第一页为刷新所有数据
|
|
|
+ listMap[key] = new ListData();
|
|
|
+ }
|
|
|
+ listMap[key].get(page, result, this.state.search.size);
|
|
|
+ this.setState({ listMap });
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
changeOrder(order, direction) {
|
|
@@ -103,27 +107,38 @@ export default class extends Page {
|
|
|
|
|
|
renderView() {
|
|
|
const { filter, search = {} } = this.state;
|
|
|
- return (<Drawer
|
|
|
- style={{ minHeight: document.documentElement.clientHeight }}
|
|
|
- position="right"
|
|
|
- open={filter}
|
|
|
- sidebar={this.renderFilter()}
|
|
|
- onOpenChange={isOpen => this.setState({ filter: isOpen })}
|
|
|
- >
|
|
|
- <div className="top">
|
|
|
- <div className={search.order === 'saleNumber' ? 'tab active' : 'tab'} onClick={() => {
|
|
|
- if (search.order !== 'saleNumber') this.changeOrder('saleNumber', 'desc');
|
|
|
- }}>销量</div>
|
|
|
- <div className={search.order === 'updateTime' ? 'tab active' : 'tab'} onClick={() => {
|
|
|
- if (search.order !== 'updateTime') this.changeOrder('updateTime', 'desc');
|
|
|
- }}>更新时间</div>
|
|
|
- <div className="right" onClick={() => this.setState({ filter: true })}>
|
|
|
- 筛选
|
|
|
+ return (
|
|
|
+ <Drawer
|
|
|
+ style={{ minHeight: document.documentElement.clientHeight }}
|
|
|
+ position="right"
|
|
|
+ open={filter}
|
|
|
+ sidebar={this.renderFilter()}
|
|
|
+ onOpenChange={isOpen => this.setState({ filter: isOpen })}
|
|
|
+ >
|
|
|
+ <div className="top">
|
|
|
+ <div
|
|
|
+ className={search.order === 'saleNumber' ? 'tab active' : 'tab'}
|
|
|
+ onClick={() => {
|
|
|
+ if (search.order !== 'saleNumber') this.changeOrder('saleNumber', 'desc');
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 销量
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ className={search.order === 'updateTime' ? 'tab active' : 'tab'}
|
|
|
+ onClick={() => {
|
|
|
+ if (search.order !== 'updateTime') this.changeOrder('updateTime', 'desc');
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 更新时间
|
|
|
+ </div>
|
|
|
+ <div className="right" onClick={() => this.setState({ filter: true })}>
|
|
|
+ 筛选
|
|
|
<Assets name="screen" />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- {this.renderList()}
|
|
|
- </Drawer>
|
|
|
+ {this.renderList()}
|
|
|
+ </Drawer>
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -136,33 +151,37 @@ export default class extends Page {
|
|
|
const { data = {} } = listMap;
|
|
|
const { dataSource = {}, bottom, loading, finish, maxSectionId = 1, total } = data;
|
|
|
if (total === 0) return this.renderEmpty();
|
|
|
- return <ListView
|
|
|
- className="list"
|
|
|
- ref={el => { this.lv = el; }}
|
|
|
- dataSource={dataSource}
|
|
|
- renderFooter={() => (<div style={{ padding: 30, textAlign: 'center' }}>
|
|
|
- {loading ? '加载中...' : (bottom ? '没有更多了' : '')}
|
|
|
- </div>)}
|
|
|
- renderRow={(rowData, sectionID, rowID) => this.renderRow(rowData, sectionID, rowID)}
|
|
|
- style={{
|
|
|
- height: this.state.height,
|
|
|
- overflow: 'auto',
|
|
|
- }}
|
|
|
- pageSize={this.state.search.size}
|
|
|
- scrollRenderAheadDistance={500}
|
|
|
- onEndReached={() => {
|
|
|
- if (loading) return;
|
|
|
- if (bottom) {
|
|
|
- if (!finish) {
|
|
|
- data.finish = true;
|
|
|
- // this.setState({ time: new Date() })
|
|
|
+ return (
|
|
|
+ <ListView
|
|
|
+ className="list"
|
|
|
+ ref={el => {
|
|
|
+ this.lv = el;
|
|
|
+ }}
|
|
|
+ dataSource={dataSource}
|
|
|
+ renderFooter={() => (
|
|
|
+ <div style={{ padding: 30, textAlign: 'center' }}>{loading ? '加载中...' : bottom ? '没有更多了' : ''}</div>
|
|
|
+ )}
|
|
|
+ renderRow={(rowData, sectionID, rowID) => this.renderRow(rowData, sectionID, rowID)}
|
|
|
+ style={{
|
|
|
+ height: this.state.height,
|
|
|
+ overflow: 'auto',
|
|
|
+ }}
|
|
|
+ pageSize={this.state.search.size}
|
|
|
+ scrollRenderAheadDistance={500}
|
|
|
+ onEndReached={() => {
|
|
|
+ if (loading) return;
|
|
|
+ if (bottom) {
|
|
|
+ if (!finish) {
|
|
|
+ data.finish = true;
|
|
|
+ // this.setState({ time: new Date() })
|
|
|
+ }
|
|
|
+ return;
|
|
|
}
|
|
|
- return;
|
|
|
- }
|
|
|
- this.getList('data', maxSectionId + 1);
|
|
|
- }}
|
|
|
- onEndReachedThreshold={10}
|
|
|
- />;
|
|
|
+ this.getList('data', maxSectionId + 1);
|
|
|
+ }}
|
|
|
+ onEndReachedThreshold={10}
|
|
|
+ />
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
renderEmpty() {
|
|
@@ -177,17 +196,23 @@ export default class extends Page {
|
|
|
<div className="item">
|
|
|
<div className="label left">适合新手</div>
|
|
|
<div className="value right">
|
|
|
- <Switch checked={search.isNovice} onClick={() => {
|
|
|
- this.changeNovice();
|
|
|
- }} />
|
|
|
+ <Switch
|
|
|
+ checked={search.isNovice}
|
|
|
+ onClick={() => {
|
|
|
+ this.changeNovice();
|
|
|
+ }}
|
|
|
+ />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div className="item">
|
|
|
<div className="label left">原创资料</div>
|
|
|
<div className="value right">
|
|
|
- <Switch checked={search.isOriginal} onClick={() => {
|
|
|
- this.changeOriginal();
|
|
|
- }} />
|
|
|
+ <Switch
|
|
|
+ checked={search.isOriginal}
|
|
|
+ onClick={() => {
|
|
|
+ this.changeOriginal();
|
|
|
+ }}
|
|
|
+ />
|
|
|
</div>
|
|
|
</div>
|
|
|
<div className="item">
|
|
@@ -196,7 +221,7 @@ export default class extends Page {
|
|
|
<SpecialRadioGroup
|
|
|
list={DataType}
|
|
|
value={search.dataType}
|
|
|
- onChange={(value) => {
|
|
|
+ onChange={value => {
|
|
|
this.changeDataType(value);
|
|
|
}}
|
|
|
/>
|
|
@@ -204,32 +229,44 @@ export default class extends Page {
|
|
|
</div>
|
|
|
<div className="sub">
|
|
|
<div className="title">筛选学科</div>
|
|
|
- {structTree.map((row) => {
|
|
|
- return <div className="item">
|
|
|
- <div className={row.children.length > 0 ? 'label' : 'label left'}>{row.title}</div>
|
|
|
- {row.children.length > 0 && <div className="value">
|
|
|
- <SpecialRadioGroup
|
|
|
- list={row.children}
|
|
|
- value={search.structId}
|
|
|
- onChange={(value) => {
|
|
|
- this.changeStruct(value);
|
|
|
- }}
|
|
|
- />
|
|
|
- </div>}
|
|
|
- {row.children.length === 0 && <div className="value right">
|
|
|
- <Checkbox checked={search.structId === row.id} onClick={() => {
|
|
|
- this.changeStruct(row.id);
|
|
|
- }} />
|
|
|
- </div>}
|
|
|
-
|
|
|
- </div>;
|
|
|
+ {structTree.map(row => {
|
|
|
+ return (
|
|
|
+ <div className="item">
|
|
|
+ <div className={row.children.length > 0 ? 'label' : 'label left'}>{row.title}</div>
|
|
|
+ {row.children.length > 0 && (
|
|
|
+ <div className="value">
|
|
|
+ <SpecialRadioGroup
|
|
|
+ list={row.children}
|
|
|
+ value={search.structId}
|
|
|
+ onChange={value => {
|
|
|
+ this.changeStruct(value);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+ {row.children.length === 0 && (
|
|
|
+ <div className="value right">
|
|
|
+ <Checkbox
|
|
|
+ checked={search.structId === row.id}
|
|
|
+ onClick={() => {
|
|
|
+ this.changeStruct(row.id);
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ );
|
|
|
})}
|
|
|
</div>
|
|
|
</div>
|
|
|
<div className="footer">
|
|
|
- <Button radius width={90} onClick={() => {
|
|
|
- this.getList('data', 1);
|
|
|
- }}>
|
|
|
+ <Button
|
|
|
+ radius
|
|
|
+ width={90}
|
|
|
+ onClick={() => {
|
|
|
+ this.getList('data', 1);
|
|
|
+ }}
|
|
|
+ >
|
|
|
确定
|
|
|
</Button>
|
|
|
</div>
|