Переглянути джерело

调整我的小店加载状态

viczhq 1 місяць тому
батько
коміт
77d2050285

+ 1 - 1
src/pages/memberSub/earningsOrder/index.jsx

@@ -15,7 +15,7 @@ export default class Index extends Component {
15 15
     page: 1, //页数
16 16
     loading: false, //加载状态
17 17
     totalPages: 1, // 添加总页数
18
-    isNoMore: false,
18
+    isNoMore: false, // 是否没有更多
19 19
     orderList: [], //订单列表
20 20
     userInfo: {}, //个人信息
21 21
   };

+ 1 - 0
src/pages/memberSub/earningsOrder/index.less

@@ -210,6 +210,7 @@
210 210
                 justify-content: space-between;
211 211
 
212 212
                 .product-name {
213
+                    height: 80px;
213 214
                     font-size: 28px;
214 215
                     color: #000000;
215 216
                     line-height: 41px;

+ 80 - 43
src/pages/memberSub/storeManagement/index.jsx

@@ -1,8 +1,15 @@
1 1
 import { Component } from "react";
2 2
 import { View, Text, Image, Button } from "@tarojs/components";
3
-import { AtIcon } from "taro-ui";
3
+import { AtIcon, AtActivityIndicator } from "taro-ui";
4 4
 import "./index.less";
5
-import { getMyShopList, getMyShopDetail, getShareShopDetail, getShareShopProductList, getShareJump,bindShareJump } from "../../../service";
5
+import {
6
+  getMyShopList,
7
+  getMyShopDetail,
8
+  getShareShopDetail,
9
+  getShareShopProductList,
10
+  getShareJump,
11
+  bindShareJump,
12
+} from "../../../service";
6 13
 import storeManagement from "../../../images/storeManagement/storeManagement.png";
7 14
 import storeManagementIcon from "../../../images/storeManagement/storeManagementIcon.png";
8 15
 import ProductCard from "../../../components/ProductCard"; //卡片模块
@@ -17,13 +24,16 @@ export default class Index extends Component {
17 24
     loading: false, //加载状态
18 25
     totalPages: 1, // 添加总页数
19 26
     isShare: false, // 是否是分享进入
20
-    shopId: '', // 店铺id
27
+    shopId: "", // 店铺id
28
+    isNoMore: false, // 是否没有更多
21 29
   };
22 30
   // 获取店铺详情
23 31
   getMyShopDetail = async () => {
24
-    const res = this.state.isShare ? await getShareShopDetail({
25
-      store_id: this.state.shopId
26
-    }) :  await getMyShopDetail();
32
+    const res = this.state.isShare
33
+      ? await getShareShopDetail({
34
+          store_id: this.state.shopId,
35
+        })
36
+      : await getMyShopDetail();
27 37
     this.setState({
28 38
       shopDetail: res,
29 39
     });
@@ -33,36 +43,44 @@ export default class Index extends Component {
33 43
     const { page } = this.state;
34 44
     this.setState({ loading: true });
35 45
 
36
-    const res = this.state.isShare ? await getShareShopProductList({
37
-      store_id: this.state.shopId,
38
-      page,
39
-      page_size: 10,
40
-      tag_name:'全部'
41
-    }) : await getMyShopList({
42
-      page,
43
-      page_size: 10,
44
-      tag_name:'全部'
45
-    });
46
+    const res = this.state.isShare
47
+      ? await getShareShopProductList({
48
+          store_id: this.state.shopId,
49
+          page,
50
+          page_size: 10,
51
+          tag_name: "全部",
52
+        })
53
+      : await getMyShopList({
54
+          page,
55
+          page_size: 10,
56
+          tag_name: "全部",
57
+        });
46 58
 
47 59
     this.setState((prevState) => ({
48
-      productList: isBack ? res.goods_list : [...prevState.productList, ...res.goods_list],
60
+      productList: isBack
61
+        ? res.goods_list
62
+        : [...prevState.productList, ...res.goods_list],
49 63
       totalPages: res.total_pages,
50 64
       loading: false,
65
+      isNoMore: res.total_pages <= page,
51 66
     }));
52 67
   };
53 68
 
54 69
   componentDidShow() {
55 70
     const { router } = Taro.getCurrentInstance();
56 71
     const params = router.params;
57
-    
58
-    this.setState({
59
-      isManager: JSON.parse(params.isManager), //是否是店长
60
-      isShare: params.isShare||false, // 是否是分享进入
61
-      shopId: params.shopId||'', // 店铺id
62
-    },()=>{
63
-      this.getMyShopDetail(); //获取店铺详情
64
-      this.getMyShopList(true); //获取店铺数据
65
-    });
72
+
73
+    this.setState(
74
+      {
75
+        isManager: JSON.parse(params.isManager), //是否是店长
76
+        isShare: params.isShare || false, // 是否是分享进入
77
+        shopId: params.shopId || "", // 店铺id
78
+      },
79
+      () => {
80
+        this.getMyShopDetail(); //获取店铺详情
81
+        this.getMyShopList(true); //获取店铺数据
82
+      }
83
+    );
66 84
   }
67 85
   // 页面上拉触底
68 86
   onReachBottom = () => {
@@ -82,38 +100,38 @@ export default class Index extends Component {
82 100
   };
83 101
   // 配置分享内容
84 102
   onShareAppMessage() {
85
-    const name = Taro.getStorageSync('userInfo').name;
103
+    const name = Taro.getStorageSync("userInfo").name;
86 104
     return {
87 105
       title: `${name}的店铺`,
88 106
       path: `/pages/memberSub/storeManagement/index?shopId=${this.state.shopDetail.id}&isShare=true&isManager=false`,
89
-      imageUrl: ''
90
-    }
107
+      imageUrl: "",
108
+    };
91 109
     return getShareJump({
92
-      share_type:2,
93
-      share_id: this.state.shopDetail.id
94
-    }).then(res=>{
110
+      share_type: 2,
111
+      share_id: this.state.shopDetail.id,
112
+    }).then((res) => {
95 113
       return {
96 114
         title: "店铺",
97 115
         path: `/pages/memberSub/storeManagement/index?shopId=${this.state.shopDetail.id}&isShare=true&isManager=false&&shareJump=${res.share_unique_value}`,
98
-        imageUrl: ''
99
-      }
100
-    })
116
+        imageUrl: "",
117
+      };
118
+    });
101 119
   }
102 120
   render() {
103
-    const { shopDetail, productList } = this.state;
121
+    const { shopDetail, productList, loading, isNoMore } = this.state;
104 122
     return (
105 123
       <View className="index">
106 124
         {/* 头部卡片 */}
107 125
         <View className="header-card">
108 126
           <Image className="bg-image" src={storeManagement} mode="widthFix" />
109
-          {/* 分享铺 */}
127
+          {/* 分享���铺 */}
110 128
           {!this.state.isShare && (
111
-          <View className="share-shop">
112
-            <Button onClick={this.handleShare} openType="share">
113
-            <Text>分享店铺</Text>
114
-            <AtIcon value="chevron-right" size="10" color="#fff"></AtIcon>
115
-            </Button>
116
-          </View>
129
+            <View className="share-shop">
130
+              <Button onClick={this.handleShare} openType="share">
131
+                <Text>分享店铺</Text>
132
+                <AtIcon value="chevron-right" size="10" color="#fff"></AtIcon>
133
+              </Button>
134
+            </View>
117 135
           )}
118 136
           {/* 个人信息 */}
119 137
           <View className="user-info">
@@ -169,6 +187,25 @@ export default class Index extends Component {
169 187
             </View>
170 188
           )}
171 189
         </View>
190
+        {/* 加载中 */}
191
+        {loading && (
192
+          <View className="loading-container">
193
+            <AtActivityIndicator
194
+              content="加载中..."
195
+            isOpened={loading}
196
+            mode="center"
197
+            color="#fdf764"
198
+            />
199
+          </View>
200
+        )}
201
+        {/* 没有更多 */}
202
+        {isNoMore && (
203
+          <View className="no-more">
204
+            <View className="no-more-line">
205
+              <Text className="no-more-text">我是有底线的</Text>
206
+            </View>
207
+          </View>
208
+        )}
172 209
       </View>
173 210
     );
174 211
   }

+ 107 - 53
src/pages/memberSub/storeManagement/index.less

@@ -4,6 +4,7 @@
4 4
     min-height: 100vh;
5 5
     background-color: #f9f9f9;
6 6
     padding-bottom: 150px;
7
+
7 8
     .header-card {
8 9
         width: 100%;
9 10
         height: 256px;
@@ -84,7 +85,7 @@
84 85
                 font-size: 22px;
85 86
                 line-height: 40px;
86 87
                 margin-right: 7px;
87
-            color: #FFFFFF;
88
+                color: #FFFFFF;
88 89
             }
89 90
         }
90 91
     }
@@ -98,6 +99,7 @@
98 99
         box-sizing: border-box;
99 100
         position: relative;
100 101
         z-index: 1;
102
+
101 103
         .product-list-title {
102 104
             display: flex;
103 105
             flex-direction: column;
@@ -122,59 +124,67 @@
122 124
             }
123 125
         }
124 126
     }
125
-        // 底部购买模块
126
-        .bottom-buy {
127
-            width: 100%;
128
-            background-color: #fff;
129
-            height: 126px;
130
-            padding: 19px 35px 19px 44px;
131
-            box-sizing: border-box;
132
-            position: fixed;
133
-            bottom: 0;
127
+
128
+    // 底部购买模块
129
+    .bottom-buy {
130
+        width: 100%;
131
+        background-color: #fff;
132
+        height: 126px;
133
+        padding: 19px 35px 19px 44px;
134
+        box-sizing: border-box;
135
+        position: fixed;
136
+        bottom: 0;
137
+        display: flex;
138
+        justify-content: space-between;
139
+        align-items: center;
140
+        .bottom-buy-left {
134 141
             display: flex;
135
-            justify-content: space-between;
142
+            flex-direction: column;
136 143
             align-items: center;
137
-            .bottom-buy-left {
144
+
145
+            image {
146
+                width: 36px;
147
+                height: 36px;
148
+                margin-bottom: 7px;
149
+            }
150
+
151
+            .bottom-buy-text {
152
+                font-size: 22px;
153
+                line-height: 32px;
154
+                color: #000000;
155
+            }
156
+        }
157
+
158
+        .bottom-buy-right {
159
+            width: 100%;
160
+            height: 100%;
161
+            display: flex;
162
+            border-radius: 60px;
163
+            overflow: hidden;
164
+
165
+            .bottom-buy-right-self,
166
+            .bottom-buy-right-share {
167
+                line-height: 43px;
168
+                font-size: 30px;
169
+                width: 100%;
138 170
                 display: flex;
139
-                flex-direction: column;
171
+                justify-content: center;
140 172
                 align-items: center;
173
+
141 174
                 image {
142
-                    width: 36px;
143
-                    height: 36px;
144
-                    margin-bottom: 7px;
145
-                }
146
-    
147
-                .bottom-buy-text {
148
-                    font-size: 22px;
149
-                    line-height: 32px;
150
-                    color: #000000;
175
+                    margin-right: 9px;
151 176
                 }
152 177
             }
153
-            .bottom-buy-right {
154
-                width: 100%;
155
-                height: 100%;
156
-                display: flex;
157
-                border-radius: 60px;
158
-                overflow: hidden;
159
-                .bottom-buy-right-self,.bottom-buy-right-share{
160
-                    line-height: 43px;
161
-                    font-size: 30px;
162
-                    width: 100%;
163
-                    display: flex;
164
-                    justify-content: center;
165
-                    align-items: center;
166
-                    image{
167
-                        margin-right: 9px;
168
-                    }
169
-                }
170
-                .bottom-buy-right-self{
171
-                    background-color: #fbe00f;
172
-                    color: #000000;
173
-                }
174
-                .bottom-buy-right-share{
175
-                    background-color: #ff1c14;
176
-                    color: #fff;
177
-                }
178
+
179
+            .bottom-buy-right-self {
180
+                background-color: #fbe00f;
181
+                color: #000000;
182
+            }
183
+
184
+            .bottom-buy-right-share {
185
+                background-color: #ff1c14;
186
+                color: #fff;
187
+            }
178 188
         }
179 189
     }
180 190
 }
@@ -191,11 +201,55 @@ Button {
191 201
     display: flex;
192 202
     justify-content: center;
193 203
     align-items: center;
204
+
194 205
     &::after {
195
-      border: none;
206
+        border: none;
207
+    }
208
+}
209
+
210
+.button-hover {
211
+    background-color: transparent !important;
212
+    /* 移除背景高亮 */
213
+    box-shadow: none !important;
214
+    /* 移除可能的阴影 */
215
+}
216
+// 加载中
217
+.loading-container {
218
+    width: 100%;
219
+    position: relative;
220
+    height: 60px;
221
+}
222
+// 没有更多
223
+.no-more {
224
+    padding: 20px 0;
225
+    
226
+    &-line {
227
+        position: relative;
228
+        text-align: center;
229
+        
230
+        &::before,
231
+        &::after {
232
+            content: '';
233
+            position: absolute;
234
+            top: 50%;
235
+            width: 30%;
236
+            height: 1px;
237
+            background-color: #e5e5e5;
238
+        }
239
+        
240
+        &::before {
241
+            left: 10%;
242
+        }
243
+        
244
+        &::after {
245
+            right: 10%;
246
+        }
247
+    }
248
+    
249
+    &-text {
250
+        display: inline-block;
251
+        padding: 0 15px;
252
+        font-size: 24px;
253
+        color: #949494;
196 254
     }
197
-  }
198
-  .button-hover {
199
-    background-color: transparent !important; /* 移除背景高亮 */
200
-    box-shadow: none !important;             /* 移除可能的阴影 */
201
-  }
255
+}