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