Browse Source

feat:评论图片显示/浏览、点赞部分逻辑

“wangdongchao” 1 year ago
parent
commit
492628b43a

+ 3 - 0
Asteria/Fuction/Goods/Revies/GoodsReviewsWriteC.m

@@ -251,6 +251,9 @@ RY_baseVMprotocol>
     for (int i=0; i<self.xxx_imgUrlAry.count; i++) {
         NSString * imgUrl = self.xxx_imgUrlAry[i];
         [imageStr appendString:imgUrl];
+        if (i < self.xxx_imgUrlAry.count - 1) {
+            [imageStr appendString:@","];
+        }
     }
     NSMutableDictionary *params = [NSMutableDictionary dictionary];
     

+ 14 - 0
Asteria/Fuction/Goods/Revies/V/GoodsReviewsListTableV.m

@@ -7,6 +7,8 @@
 
 #import "GoodsReviewsListTableV.h"
 
+#import <GKPhotoBrowser/GKPhotoBrowser.h>
+
 @implementation GoodsReviewsListTableV
 
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
@@ -17,6 +19,18 @@
     cell.currencyparameterClose = ^(NSInteger type, id Data) {
         @strongify(cell) //图片选择器展示
         
+        NSArray *imageArr = (NSArray *)Data;
+        NSMutableArray *photos = [[NSMutableArray alloc]init];
+        for (NSString *imgUrl in imageArr) {
+            GKPhoto *photo = [GKPhoto new];
+            photo.placeholderImage = UIImageDefaultImg_SD;
+            photo.url = [NSURL URLWithString:imgUrl];
+            [photos addObject:photo];
+        }
+        GKPhotoBrowser *photoBrowser = [GKPhotoBrowser photoBrowserWithPhotos:photos currentIndex:type];
+        photoBrowser.showStyle = GKPhotoBrowserShowStyleNone;
+        [photoBrowser showFromVC:[Current_normalTool topViewController]];
+        
     };
 
     return cell;

+ 36 - 21
Asteria/Fuction/Goods/Revies/cell/GoodsReviewsCell.m

@@ -70,9 +70,8 @@
     self.backgroundColor = [UIColor clearColor];
     @weakify(self)
     self.reviewsImgV.ViewtapClose = ^(NSInteger num, id  _Nonnull data) {
-//        if(self.currencyparameterClose){
-//            self.currencyparameterClose(num, data);
-//        }
+
+        
         @strongify(self)
 
         
@@ -135,35 +134,51 @@
 
 #pragma mark - **************** handle ****************
 -(void)handle_addZanBtnEvent:(UIButton *)btn{
- /*   if (NIL(User_token)){ //判断登陆
-        [Fuction_Tool present_Loginpage];
+    //判断登陆
+    if (![ASUserInfoManager.shared isLogin]) {
+        [Fuction_Tool pop_toLoginVC];
         return;
     }
-    NSString *url = nil;
+    
+    NSDictionary *params = nil;
     if(btn.selected){ //取消赞
-        url = BaseRequestrUrl(GoodsDetails_productDelThumbsUp);
+        params = @{@"rid":self.reviewM.review_id, @"flag":@"del"};
     }else{
-        url = BaseRequestrUrl(GoodsDetails_productAddThumbsUp);
+        params = @{@"rid":self.reviewM.review_id, @"flag":@"add"};
     }
     UIViewController *topVC = topViewController();
     [MBProgressHUD showHUDAddedTo:topVC.view animated:YES];
-    [PPNetworkHelper POST:url parameters:@{@"entity_id":self.reviewM.review_id} success:^(id responseObject) {
+    
+    K_WEAK_SELF;
+    [ASNetTools.shared getWithPath:Reviews_rewriteProductAddReviewzan param:params success:^(id _Nonnull json) {
+        K_STRONG_SELF;
         [MBProgressHUD hideHUDForView:topVC.view animated:YES];
-        NSDictionary *tepDic = responseObject[@"data"];
-        if(RequestSuccess){
-            btn.selected = !btn.selected;
-            self.zanBtn.selected =  btn.selected;
-            self.reviewM.thumbsUp = [NSString stringWithFormat:@"%d",![self.reviewM.thumbsUp boolValue]];
-            self.reviewM.zan = [NSString stringWithFormat:@"%@",tepDic[@"num"]];
-            [btn setTitle: self.reviewM.zan forState:UIControlStateNormal];
-            [self.zanBtn setTitle: self.reviewM.zan forState:UIControlStateNormal];
+        
+        NSLog(@"=======%@", json);
+//        NSDictionary *tepDic = (NSDictionary *)json;
+        btn.selected = !btn.selected;
+        self.zanBtn.selected =  btn.selected;
+        
+        if (btn.selected) {
+            self.reviewM.zan = [NSString stringWithFormat:@"%d", [self.reviewM.zan intValue] + 1];
+            [btn setTitle:self.reviewM.zan forState:UIControlStateNormal];
+            [self.zanBtn setTitle:self.reviewM.zan forState:UIControlStateNormal];
+        } else {
+            self.reviewM.zan = [NSString stringWithFormat:@"%d", [self.reviewM.zan intValue] - 1];
+            [btn setTitle:self.reviewM.zan forState:UIControlStateNormal];
+            [self.zanBtn setTitle:self.reviewM.zan forState:UIControlStateNormal];
         }
-        [topVC.view makeToast:RequestErrorMsg duration:2 position:CSToastPositionCenter];
-    } failure:^(NSError *error) {
+////            self.reviewM.thumbsUp = [NSString stringWithFormat:@"%d",![self.reviewM.thumbsUp boolValue]];
+//        self.reviewM.zan = [NSString stringWithFormat:@"%@",tepDic[@"num"]];
+//        [btn setTitle: self.reviewM.zan forState:UIControlStateNormal];
+//        [self.zanBtn setTitle:self.reviewM.zan forState:UIControlStateNormal];
+        
+        
+    } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
+//        K_STRONG_SELF;
         [MBProgressHUD hideHUDForView:topVC.view animated:YES];
-        [topVC.view makeToast:ReqNetWorkFaild duration:2 position:CSToastPositionCenter];
     }];
-    */
+    
 }
 -(void)tap_imgFull:(UITapGestureRecognizer *)tap{
     

+ 14 - 0
Asteria/Fuction/Goods/V/ASGoodsDetailsTableView.m

@@ -21,6 +21,8 @@
 
 #import "KWMineMoreProductModel.h"
 
+#import <GKPhotoBrowser/GKPhotoBrowser.h>
+
 @interface ASGoodsDetailsTableView()
 
 @property (nonatomic, assign) BOOL couponSelect;
@@ -122,6 +124,18 @@
         cell.currencyparameterClose = ^(NSInteger type, id Data) {
             @strongify(self) //图片选择器展示
             
+            NSArray *imageArr = (NSArray *)Data;
+            NSMutableArray *photos = [[NSMutableArray alloc]init];
+            for (NSString *imgUrl in imageArr) {
+                GKPhoto *photo = [GKPhoto new];
+                photo.placeholderImage = UIImageDefaultImg_SD;
+                photo.url = [NSURL URLWithString:imgUrl];
+                [photos addObject:photo];
+            }
+            GKPhotoBrowser *photoBrowser = [GKPhotoBrowser photoBrowserWithPhotos:photos currentIndex:type];
+            photoBrowser.showStyle = GKPhotoBrowserShowStyleNone;
+            [photoBrowser showFromVC:[Current_normalTool topViewController]];
+            
         };
         return cell;
     } else if ([typeStr isEqualToString:@"reviewFoot"]) {

+ 3 - 2
Asteria/Fuction/Goods/VC/ASGoodsDetailsViewController.m

@@ -52,9 +52,10 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
     
-    [self reqNet_GoodsDetails_productGetProduct];
     [self reqNet_Goods_productGetProductsReview];
     
+    [self reqNet_GoodsDetails_productGetProduct];
+    
 }
 
 - (void)initSubviews {
@@ -185,7 +186,7 @@
 
 - (void)updateGoodsDetailsData {
         
-//    [self.TableV.infodata removeAllObjects];
+    [self.TableV.infodata removeAllObjects];
     //商品图
     NSDictionary *banner = @{@"type":@"banner", @"data":self.model};
     [self.TableV.infodata addObject:banner];