viczhq дней назад: 3
Родитель
Сommit
9f206da706
2 измененных файлов с 27 добавлено и 6 удалено
  1. 18 5
      src/pages/indexSub/searchList/index.jsx
  2. 9 1
      src/pages/indexSub/searchList/index.less

+ 18 - 5
src/pages/indexSub/searchList/index.jsx

@@ -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
   }

+ 9 - 1
src/pages/indexSub/searchList/index.less

@@ -3,4 +3,12 @@
3 3
     background-color: #f9f9f9;
4 4
     padding-top: 20px;
5 5
     box-sizing: border-box;
6
-}
6
+    .no-data{
7
+        display: flex;
8
+        flex-direction: column;
9
+        align-items: center;
10
+        justify-content: center;
11
+        height: 100vh;
12
+        color: #999;
13
+    }
14
+}