|
@@ -1,6 +1,7 @@
|
1
|
1
|
import { Component } from "react";
|
2
|
2
|
import Taro from "@tarojs/taro";
|
3
|
3
|
import { View } from "@tarojs/components";
|
|
4
|
+import { AtIcon } from "taro-ui";
|
4
|
5
|
import "./index.less";
|
5
|
6
|
import ProductList from "../../../components/index/ProductList";
|
6
|
7
|
import { getSearchProductList } from "../../../service";
|
|
@@ -11,6 +12,7 @@ export default class Index extends Component {
|
11
|
12
|
totalPages: 1,
|
12
|
13
|
loading: false,
|
13
|
14
|
keyword: "",
|
|
15
|
+ isHasData: true,
|
14
|
16
|
};
|
15
|
17
|
componentDidMount() {
|
16
|
18
|
const { keyword } = Taro.getCurrentInstance().router.params||"";
|
|
@@ -35,7 +37,11 @@ export default class Index extends Component {
|
35
|
37
|
: [...prevState.productList, ...res.goods_list],
|
36
|
38
|
totalPages: res.total_pages,
|
37
|
39
|
loading: false,
|
38
|
|
- }));
|
|
40
|
+ }),()=>{
|
|
41
|
+ this.setState({
|
|
42
|
+ isHasData: res.goods_list.length > 0,
|
|
43
|
+ });
|
|
44
|
+ });
|
39
|
45
|
};
|
40
|
46
|
// 页面上拉触底
|
41
|
47
|
onReachBottom = () => {
|
|
@@ -51,10 +57,17 @@ export default class Index extends Component {
|
51
|
57
|
return (
|
52
|
58
|
<View className="index">
|
53
|
59
|
{/* 搜索列表 */}
|
54
|
|
- <ProductList
|
55
|
|
- productList={this.state.productList}
|
56
|
|
- loading={this.state.loading}
|
57
|
|
- ></ProductList>
|
|
60
|
+ {this.state.isHasData ? (
|
|
61
|
+ <ProductList
|
|
62
|
+ productList={this.state.productList}
|
|
63
|
+ loading={this.state.loading}
|
|
64
|
+ ></ProductList>
|
|
65
|
+ ) : (
|
|
66
|
+ <View className="no-data">
|
|
67
|
+ <AtIcon value="search" size="30" color="#999"></AtIcon>
|
|
68
|
+ <View className="no-data-text">暂无数据</View>
|
|
69
|
+ </View>
|
|
70
|
+ )}
|
58
|
71
|
</View>
|
59
|
72
|
);
|
60
|
73
|
}
|