Browse Source

Merge branch 'master' of http://code.qutaovip.com/lihai/fish_app

* 'master' of http://code.qutaovip.com/lihai/fish_app:
  自购和分享赚优化&&搜索优化
黎海 3 weeks ago
parent
commit
0b8fc934cf

+ 32 - 19
src/components/index/ProductList/index.jsx

@@ -15,15 +15,16 @@ import ShareModal from "../../shareModal";
15 15
 import joinStoreBg from "../../../images/index/jionStore.png";
16 16
 import joinStoreAc from "../../../images/index/joinStoreAc.png";
17 17
 import saveMoneyBg from "../../../images/index/save-money.png";
18
+import buy from "../../../images/index/buy.png";
18 19
 import shareEarnBg from "../../../images/index/share-earn.png";
19 20
 import seckillIcon from "../../../images/seckill/seckillIcon.png";
20
-import { isDebounce } from '../../../common/debounce';
21
+import { isDebounce } from "../../../common/debounce";
21 22
 const ProductList = forwardRef((props, ref) => {
22 23
   const {
23 24
     productList, // 商品列表数据
24 25
     loading, // 加载状态
25 26
     isSeckill, // 是否秒杀页面使用
26
-    isHighCommission, // 是否高佣金面使用
27
+    isHighCommission, // 是否高佣金��面使用
27 28
     isManagement, // 是否管理页面使用
28 29
     isManagementStatus, // 是否管理状态
29 30
     isProductClassify, // 是否分类页面使用
@@ -32,6 +33,7 @@ const ProductList = forwardRef((props, ref) => {
32 33
     onDeleteProductSelect, // 删除商品选中id数组
33 34
     isNoMore, // 是否没有更多
34 35
     shareUserId, // 分享用户id
36
+    isEmpty, // 是否为空
35 37
   } = props;
36 38
 
37 39
   const [selectedProducts, setSelectedProducts] = useState([]); // 商品选择状态
@@ -169,11 +171,11 @@ const ProductList = forwardRef((props, ref) => {
169 171
         <View key={product.id}>
170 172
           <View onClick={() => toDetail(product.id)} className="product-item">
171 173
             {isManagement && isManagementStatus && (
172
-              <View 
173
-                className="checkbox-wrapper" 
174
+              <View
175
+                className="checkbox-wrapper"
174 176
                 onClick={(e) => {
175 177
                   e.stopPropagation();
176
-                  selectProduct(product.id);  // 直接调用 selectProduct
178
+                  selectProduct(product.id); // 直接调用 selectProduct
177 179
                 }}
178 180
               >
179 181
                 <AtCheckbox
@@ -239,19 +241,26 @@ const ProductList = forwardRef((props, ref) => {
239 241
                   )}
240 242
                 </View>
241 243
                 <View className="profit-line">
242
-                  <View className="save-money">
243
-                  <Image className="bg" src={saveMoneyBg} mode="aspectFit" />
244
-                    <View className="content">
244
+                  {Number(product.estimated_commission_buy) > 0 ? (
245
+                    <View className="save-money">
246
+                      <Image
247
+                        className="bg"
248
+                        src={saveMoneyBg}
249
+                        mode="aspectFit"
250
+                      />
251
+                      <View className="content">
245 252
                         <Text className="label">自购省</Text>
246 253
                         <Text className="money">
247
-                          ¥{product.estimated_commission_promotion}
254
+                          ¥{product.estimated_commission_buy}
248 255
                         </Text>
256
+                      </View>
249 257
                     </View>
250
-                  </View>
251
-                  {/* <View className="save-money">
252
-                    <Image className="bg" src={saveMoneyBg} mode="aspectFit" />
253
-                    <View className="content">立 即 购 买</View>
254
-                  </View> */}
258
+                  ) : (
259
+                    <View className="buy">
260
+                      <Image className="bg" src={buy} mode="aspectFit" />
261
+                      <View className="content">立 即 购 买</View>
262
+                    </View>
263
+                  )}
255 264
                   <View className="share-earn">
256 265
                     <Image className="bg" src={shareEarnBg} mode="aspectFit" />
257 266
                     <View className="content">
@@ -260,7 +269,7 @@ const ProductList = forwardRef((props, ref) => {
260 269
                       >
261 270
                         <Text className="label">分享赚</Text>
262 271
                         <Text className="money">
263
-                          ¥{product.estimated_commission_buy}
272
+                          ¥{product.estimated_commission_promotion}
264 273
                         </Text>
265 274
                       </Button>
266 275
                     </View>
@@ -284,14 +293,17 @@ const ProductList = forwardRef((props, ref) => {
284 293
           />
285 294
         </View>
286 295
       )}
287
-      {isNoMore && <View className="no-more">没有更多了~</View>}
296
+      {isNoMore && !isEmpty && <View className="no-more">没有更多了~</View>}
288 297
       {/* 分享弹窗 */}
289 298
       <ShareModal
290 299
         onClose={() => {
291 300
           setShareModalOpened(false);
292
-          setCurrentShareProduct(null);
293
-          setShareTitle("");
294
-          setShareLink("");
301
+          // 添加延时,等待关闭动画完成后再重置其他状态
302
+          setTimeout(() => {
303
+            setCurrentShareProduct(null);
304
+            setShareTitle("");
305
+            setShareLink("");
306
+          }, 300); // 300ms 或根据实际动画时长调整
295 307
         }}
296 308
         isOpened={shareModalOpened}
297 309
         product={currentShareProduct}
@@ -312,6 +324,7 @@ ProductList.defaultProps = {
312 324
   isSelectAll: false,
313 325
   isNoMore: false,
314 326
   shareUserId: "",
327
+  isEmpty: false, // 是否为空
315 328
   onAddProduct: () => {}, // 添加商品方法
316 329
   onDeleteProductSelect: () => {}, // 删除商品选中id数组
317 330
 };

+ 23 - 0
src/components/index/ProductList/index.less

@@ -145,7 +145,30 @@
145 145
           //   text-align: center;
146 146
           // }
147 147
         }
148
+        .buy{
149
+          color: #F6C71A;
150
+          display: flex;
151
+          align-items: center;
152
+          justify-content: center;
153
+          position: relative;
154
+          width: 192px;
155
+          height: 84px;
148 156
 
157
+          .bg {
158
+            width: 100%;
159
+            height: 100%;
160
+            position: absolute;
161
+            top: 0;
162
+            left: 0;
163
+          }
164
+          .content {
165
+            width: 74px;
166
+            height: 80px;
167
+            font-size: 28px;
168
+            line-height: 41px;
169
+            text-align: center;
170
+          }
171
+        }
149 172
         .share-earn {
150 173
           color: #fff;
151 174
         }

BIN
src/images/index/buy.png


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

@@ -50,7 +50,6 @@
50 50
         .tab-more-img {
51 51
           width: 28px;
52 52
           height: 28px;
53
-          background-color: red;
54 53
         }
55 54
       }
56 55
 

+ 33 - 16
src/pages/indexSub/productDetail/index.jsx

@@ -70,9 +70,9 @@ export default class Index extends Component {
70 70
     });
71 71
     const { id, isShare, isHighCommission, isSeckill, shareJump, shareUserId } =
72 72
       Taro.getCurrentInstance().router.params;
73
-      let session_key = Taro.getStorageSync("session_key");
74
-      let userInfo = Taro.getStorageSync("userInfo");
75
-      let isShowSign = Taro.getStorageSync("isShowSign");
73
+    let session_key = Taro.getStorageSync("session_key");
74
+    let userInfo = Taro.getStorageSync("userInfo");
75
+    let isShowSign = Taro.getStorageSync("isShowSign");
76 76
     this.setState(
77 77
       {
78 78
         id,
@@ -99,7 +99,12 @@ export default class Index extends Component {
99 99
       }
100 100
     );
101 101
     // 判断是否显示签约弹窗
102
-    if (session_key && isShowSign!==false && userInfo && userInfo.user_identity == 0) {
102
+    if (
103
+      session_key &&
104
+      isShowSign !== false &&
105
+      userInfo &&
106
+      userInfo.user_identity == 0
107
+    ) {
103 108
       this.setState({
104 109
         isOpened: "sign",
105 110
       });
@@ -331,13 +336,22 @@ export default class Index extends Component {
331 336
                   <Image src={share} mode="aspectFit" />
332 337
                   <Text className="bottom-buy-text">分享赚</Text>
333 338
                 </View>
334
-                <View
335
-                  onClick={this.handleBuy}
336
-                  className="bottom-buy-right-share"
337
-                >
338
-                  <Image src={selfBuy} mode="aspectFit" />
339
-                  <Text className="bottom-buy-text">自购省</Text>
340
-                </View>
339
+                {Number(productDetail.estimated_commission_buy) > 0 ? (
340
+                  <View
341
+                    onClick={this.handleBuy}
342
+                    className="bottom-buy-right-share"
343
+                  >
344
+                    <Image src={selfBuy} mode="aspectFit" />
345
+                    <Text className="bottom-buy-text">自购省</Text>
346
+                  </View>
347
+                ) : (
348
+                  <View
349
+                    onClick={this.handleBuy}
350
+                    className="bottom-buy-right-share"
351
+                  >
352
+                    <Text className="bottom-buy-text">立即购买</Text>
353
+                  </View>
354
+                )}
341 355
               </>
342 356
             ) : (
343 357
               <View onClick={this.handleBuy} className="bottom-buy-right-btn">
@@ -372,11 +386,14 @@ export default class Index extends Component {
372 386
           />
373 387
         )}
374 388
         {/* 签约弹窗 */}
375
-        <SignModal isOpened={this.state.isOpened == "sign"} onClose={() => {
376
-          this.setState({
377
-            isOpened: "",
378
-          });
379
-        }}/>
389
+        <SignModal
390
+          isOpened={this.state.isOpened == "sign"}
391
+          onClose={() => {
392
+            this.setState({
393
+              isOpened: "",
394
+            });
395
+          }}
396
+        />
380 397
       </View>
381 398
     );
382 399
   }

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

@@ -51,14 +51,24 @@ export default class Index extends Component {
51 51
     }
52 52
   };
53 53
   render() {
54
+    const { productList, loading, isNoMore } = this.state;
55
+    
54 56
     return (
55 57
       <View className="index">
58
+        {/* 无搜索结果提示 */}
59
+        {!loading && productList.length === 0 && (
60
+          <View className="empty-result">
61
+            <AtIcon value="search" size="30" color="#999"></AtIcon>
62
+            <View className="empty-text">暂无相关商品</View>
63
+          </View>
64
+        )}
56 65
         {/* 搜索列表 */}
57
-          <ProductList
58
-            productList={this.state.productList}
59
-            loading={this.state.loading}
60
-            isNoMore={this.state.isNoMore}
61
-          ></ProductList>
66
+        <ProductList
67
+          productList={productList}
68
+          loading={loading}
69
+          isNoMore={isNoMore}
70
+          isEmpty={productList.length === 0}
71
+        ></ProductList>
62 72
       </View>
63 73
     );
64 74
   }

+ 14 - 0
src/pages/indexSub/searchList/index.less

@@ -4,3 +4,17 @@
4 4
     padding-top: 20px;
5 5
     box-sizing: border-box;
6 6
 }
7
+
8
+.empty-result {
9
+  display: flex;
10
+  flex-direction: column;
11
+  align-items: center;
12
+  justify-content: center;
13
+  padding: 60px 0;
14
+  
15
+  .empty-text {
16
+    color: #999;
17
+    font-size: 28px;
18
+    margin-top: 20px;
19
+  }
20
+}