浏览代码

筛选请求逻辑更新

Abel 1 年之前
父节点
当前提交
08a3b604df

+ 6 - 2
Asteria/Fuction/Home/ASProductListViewController.m

@@ -484,7 +484,9 @@
             weakSelf.canShowMoreBt = false;
             [weakSelf.collectV.mj_footer endRefreshingWithNoMoreData];
         }
-        
+        if (!weakSelf.menuFilterV.isHidden) {
+            [weakSelf.menuFilterV reloadDatas:weakSelf.vm.selectDic];
+        }
         [self.collectV reloadData];
         if (!msg.isEmpty) {
             [weakSelf.view makeToast:msg];
@@ -510,7 +512,9 @@
             weakSelf.canShowMoreBt = false;
             [weakSelf.collectV.mj_footer endRefreshingWithNoMoreData];
         }
-        
+        if (!weakSelf.menuFilterV.isHidden) {
+            [weakSelf.menuFilterV reloadDatas:weakSelf.vm.selectDic];
+        }
         [self.collectV reloadData];
         if (!msg.isEmpty) {
             [weakSelf.view makeToast:msg];

+ 1 - 1
Asteria/Fuction/Home/Views/productList/KWProductMenuFilterView.h

@@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property (nonatomic, copy, nullable) void(^resultFilterDic)(NSDictionary<NSString *,NSMutableArray<KWProductListFilterSubModel *> *> * _Nonnull arr);
 
-
+- (void)reloadDatas:(NSMutableDictionary<NSString *,NSMutableArray<KWProductListFilterSubModel *> *> *)arr;
 
 - (void)showAnimate:(NSMutableDictionary<NSString *,NSMutableArray<KWProductListFilterSubModel *> *> *)arr;
 

+ 34 - 2
Asteria/Fuction/Home/Views/productList/KWProductMenuFilterView.m

@@ -131,6 +131,31 @@
     return _clearBt;
 }
 
+- (void)selectNetAction {
+    for (KWProductListFilterModel *mainM in self.vm.sourceArr) {
+        if ([mainM.attribute_id isEqualToString:@"price"]) {
+            KWProductListFilterSubModel *subM = mainM.attribute_data.firstObject;
+            if (subM.inputMax.length > 0 && subM.inputMin.length > 0) {
+                NSMutableArray *tempSubs = self.vm.selectDic[mainM.attribute_id];
+                if (tempSubs == nil) {
+                    tempSubs = [NSMutableArray array];
+                }
+                [tempSubs addObject:subM];
+                self.vm.selectDic[mainM.attribute_id] = tempSubs;
+                break;
+            }
+            if (subM.inputMax.length <= 0 && subM.inputMin.length <= 0) {
+                break;
+            }
+            [self makeToast:@"Both Max and Min prices need to be set or removed simultaneously"];
+            return;
+        }
+    }
+    if (self.resultFilterDic) {
+        self.resultFilterDic(self.vm.selectDic);
+    }
+}
+
 - (void)doneBtAction {
     for (KWProductListFilterModel *mainM in self.vm.sourceArr) {
         if ([mainM.attribute_id isEqualToString:@"price"]) {
@@ -174,6 +199,13 @@
     [self doneBtAction];
 }
 
+- (void)reloadDatas:(NSMutableDictionary<NSString *,NSMutableArray<KWProductListFilterSubModel *> *> *)arr {
+    self.vm.selectDic = [NSMutableDictionary dictionaryWithDictionary:arr];
+    [self.collectV reloadData];
+    
+    
+}
+
 - (void)showAnimate:(NSMutableDictionary<NSString *,NSMutableArray<KWProductListFilterSubModel *> *> *)arr {
     self.hidden = false;
     self.vm.selectDic = [NSMutableDictionary dictionaryWithDictionary:arr];
@@ -294,7 +326,7 @@
             [tempSubs removeObject:subM];
         }
         [self.collectV reloadData];
-        [self doneBtAction];
+        [self selectNetAction];
         return;
     }
     NSMutableArray *tempSubs = [NSMutableArray array];
@@ -306,7 +338,7 @@
     self.vm.selectDic[mainM.attribute_id] = tempSubs;
     
     [self.collectV reloadData];
-    [self doneBtAction];
+    [self selectNetAction];
 }
 
 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {