|
@@ -12,14 +12,14 @@ class Search extends PureComponent {
|
|
|
key: props.match.params.key,
|
|
|
finished: false,
|
|
|
loading: true,
|
|
|
- page: 1,
|
|
|
+ current: 1,
|
|
|
list: []
|
|
|
};
|
|
|
this.getList = this.getList.bind(this);
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
- const {list, page, finished, loading, key} = this.state;
|
|
|
+ const {list, current, finished, loading, key} = this.state;
|
|
|
return (
|
|
|
<SearchWrapper>
|
|
|
<div className='pattern-center-blank'/>
|
|
@@ -28,7 +28,7 @@ class Search extends PureComponent {
|
|
|
<h1 className="page-title">{`搜索结果:${key}`}</h1>
|
|
|
</header>
|
|
|
<CatList list={list}/>
|
|
|
- <PagInation page={page} id={key} finished={finished} loading={loading} getList={this.getList}/>
|
|
|
+ <PagInation page={current} id={key} finished={finished} loading={loading} getList={this.getList}/>
|
|
|
</MainWrapper>
|
|
|
</SearchWrapper>
|
|
|
)
|
|
@@ -40,20 +40,27 @@ class Search extends PureComponent {
|
|
|
|
|
|
getList(current, key, override) {
|
|
|
this.setState({loading: true});
|
|
|
- axios.get('api/v1/post/list', {
|
|
|
+ axios.get('/api/v1/post/list', {
|
|
|
params: {
|
|
|
current: current,
|
|
|
size: 10,
|
|
|
- keywords: key
|
|
|
+ keyword: key
|
|
|
}
|
|
|
}).then((res) => {
|
|
|
if (res.code === 0) {
|
|
|
- let current = res.data.current * res.data.size;
|
|
|
let total = res.data.total;
|
|
|
- const data = res.data.records;
|
|
|
const Img = this.props.ListImg;
|
|
|
let arr = [];
|
|
|
- data.forEach((item) => {
|
|
|
+
|
|
|
+ const {records = []} = res.data;
|
|
|
+ if (records == null) {
|
|
|
+ this.setState({
|
|
|
+ finished: true
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ records.forEach((item) => {
|
|
|
arr.push({
|
|
|
id: item.id,
|
|
|
title: item.title,
|
|
@@ -77,7 +84,7 @@ class Search extends PureComponent {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- if (current > total) {
|
|
|
+ if ((res.data.current * res.data.size) > total) {
|
|
|
this.setState({
|
|
|
finished: true
|
|
|
})
|