Browse Source

优惠券、签到按钮状态

“wangdongchao” 1 year ago
parent
commit
2f496669c2

+ 1 - 1
Asteria/Fuction/Cart/PayManager/ASCheckoutPayManager.m

@@ -80,7 +80,7 @@ static ASCheckoutPayManager *_instance = nil;
                 //二次验证
                 [self stripePayCreateOrderid:orderid];
             } else if (statusInt == 2) {
-//                [topVC.view makeToast:@"您已取消支付"];
+//                [topVC.view makeToast:@"您 已取消支付"];
             } else {
                 if (self.payFinishBlock) {
                     self.payFinishBlock(self.payType, 0, @{@"msg":@"支付失败"});

+ 19 - 1
Asteria/Fuction/Goods/V/ASGoodsCouponCell.h

@@ -8,10 +8,11 @@
 #import <WMBase/WMBase.h>
 #import "GoodsInformationM.h"
 
-@class ASGoodsCouponItemView;
+@class ASGoodsCouponItemView, ASGoodsCouponModel;
 
 NS_ASSUME_NONNULL_BEGIN
 
+
 @interface ASGoodsCouponCell : TT_BaseCell
 
 - (void)configData:(id)Data isSelect:(BOOL)isSelect;
@@ -21,7 +22,24 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface ASGoodsCouponItemView : UIView
 
+@property (nonatomic, strong) ASGoodsCouponModel *couponModel;
+
+
+@end
+
+@interface ASGoodsCouponModel : NSObject
+
+@property (nonatomic, copy) NSString *code;
+@property (nonatomic, copy) NSString *value;
+@property (nonatomic, copy) NSString *detail;
+@property (nonatomic, copy) NSString *gt;
+@property (nonatomic, assign) NSInteger type;
 
+//code = MY15;
+//value = 5;
+//detail = get $5 OFF ;
+//gt = For Order ≥ $199;
+//type = 2;
 
 @end
 

+ 112 - 29
Asteria/Fuction/Goods/V/ASGoodsCouponCell.m

@@ -43,11 +43,11 @@
             make.width.mas_equalTo(60);
         }];
         
-        [self.titleDescLab mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.left.mas_equalTo(self.titleLab.mas_right).offset(4);
-            make.centerY.mas_equalTo(self.titleLab);
-            make.right.mas_equalTo(-40);
-        }];
+//        [self.titleDescLab mas_makeConstraints:^(MASConstraintMaker *make) {
+//            make.left.mas_equalTo(self.titleLab.mas_right).offset(4);
+//            make.centerY.mas_equalTo(self.titleLab);
+//            make.right.mas_equalTo(-40);
+//        }];
         
         [self.rTopBtn mas_makeConstraints:^(MASConstraintMaker *make) {
             make.centerY.equalTo(self.titleLab);
@@ -75,23 +75,24 @@
 }
 
 - (void)configData:(id)Data isSelect:(BOOL)isSelect{
-    GoodsInformationM *model = (GoodsInformationM *)Data;
+    
+    NSArray *couponArray = (NSArray *)Data;
     
     self.rTopBtn.selected = isSelect;
     
     if (self.rTopBtn.selected) {//展开
         
-        
-        
-        NSArray *array = @[@"1", @"2",  @"3",  @"4",  @"5",  @"6"];
-        
         float itemWidth = (KScreenWidth - 50)/2;
         float itemX = 10;
         float itemY = 10;
-        for (int i = 0; i < array.count; i++) {
+        for (int i = 0; i < couponArray.count; i++) {
+            
+            ASGoodsCouponModel *couponModel = [couponArray objectAtIndex:i];
+            
             ASGoodsCouponItemView *itemView = [[ASGoodsCouponItemView alloc] initWithFrame:CGRectMake(itemX, itemY, itemWidth, 100)];
             itemView.tag = i;
             [self.couponView addSubview:itemView];
+            itemView.couponModel = couponModel;
             
             itemView.userInteractionEnabled = YES;
             UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_clickAction:)];
@@ -107,7 +108,7 @@
             
         }
         
-        if (array.count % 2 != 0) {
+        if (couponArray.count % 2 != 0) {
             itemY = itemY + 100 + 10;
         }
         
@@ -186,30 +187,16 @@
 
 @property (nonatomic, strong) UIImageView *bgImaegView;
 @property (nonatomic, strong) UILabel *couponCodeLab;
-@property (nonatomic, strong) UILabel *couponPriceLab;
+@property (nonatomic, strong) UILabel *couponTitleLab;
 @property (nonatomic, strong) UILabel *couponDescLab;
 
+@property (nonatomic, strong) UIButton *copyBtn;
+
 @end
 
 
 @implementation ASGoodsCouponItemView
 
-- (UIImageView *)bgImaegView {
-    if (!_bgImaegView) {
-        _bgImaegView = [[UIImageView alloc] init];
-        _bgImaegView.image = [UIImage imageNamed:@"goods_coupon_bg"];
-    }
-    return _bgImaegView;
-}
-
-- (UILabel *)couponCodeLab {
-    if (!_couponCodeLab) {
-        _couponCodeLab = [UILabel labelCreateWithText:@"code:1238" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
-        _couponCodeLab.textAlignment = NSTextAlignmentCenter;
-    }
-    return _couponCodeLab;
-}
-
 - (instancetype)initWithFrame:(CGRect)frame {
     if (self = [super initWithFrame:frame]) {
         
@@ -217,6 +204,9 @@
         [self addSubview:self.bgImaegView];
         
         [self.bgImaegView addSubview:self.couponCodeLab];
+        [self.bgImaegView addSubview:self.couponDescLab];
+        [self.bgImaegView addSubview:self.couponTitleLab];
+        [self.bgImaegView addSubview:self.copyBtn];
         
         
         [self.bgImaegView mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -228,8 +218,101 @@
             make.centerX.equalTo(self.bgImaegView.mas_centerX).offset(-25);
             make.width.mas_equalTo((KScreenWidth - 50)/2 - 80);
         }];
+        
+        [self.couponDescLab mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.centerX.equalTo(self.bgImaegView.mas_centerX).offset(-25);
+            make.width.mas_equalTo((KScreenWidth - 50)/2 - 80);
+            make.centerY.equalTo(self.bgImaegView.mas_centerY).offset(4);
+        }];
+        
+        [self.couponTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.centerX.equalTo(self.bgImaegView.mas_centerX).offset(-25);
+            make.width.mas_equalTo((KScreenWidth - 50)/2 - 80);
+            make.top.mas_equalTo(16);
+        }];
+        
+        [self.copyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
+            make.bottom.top.right.mas_equalTo(0);
+            make.width.mas_equalTo(45);
+        }];
+        
     }
     return self;
 }
 
+- (void)setCouponModel:(ASGoodsCouponModel *)couponModel {
+    _couponModel = couponModel;
+    
+    self.couponCodeLab.text = [NSString stringWithFormat:@"Code:%@", AS_String_NotNull(couponModel.code)];
+    
+    if (AS_String_NotNull(couponModel.gt).length > 1) {
+        self.couponDescLab.text = AS_String_NotNull(couponModel.gt);
+    } else {
+        self.couponDescLab.text = @"";
+    }
+    
+    self.couponTitleLab.text = AS_String_NotNull(couponModel.detail);
+}
+
+- (void)_copyClick {
+    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
+    pasteboard.string = _couponModel.code;
+    
+    UIViewController *topVC = topViewController();
+    [topVC.view makeToast:@"Copy success" duration:2 position:CSToastPositionCenter];
+}
+
+- (UIImageView *)bgImaegView {
+    if (!_bgImaegView) {
+        _bgImaegView = [[UIImageView alloc] init];
+        _bgImaegView.image = [UIImage imageNamed:@"goods_coupon_bg"];
+        _bgImaegView.userInteractionEnabled = YES;
+    }
+    return _bgImaegView;
+}
+
+- (UILabel *)couponCodeLab {
+    if (!_couponCodeLab) {
+        _couponCodeLab = [UILabel labelCreateWithText:@"code:1238" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_0B0B0B];
+        _couponCodeLab.adjustsFontSizeToFitWidth = YES;
+        _couponCodeLab.textAlignment = NSTextAlignmentCenter;
+    }
+    return _couponCodeLab;
+}
+
+- (UILabel *)couponDescLab {
+    if (!_couponDescLab) {
+        _couponDescLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_Regular size:12] textColor:_043632];
+        _couponDescLab.adjustsFontSizeToFitWidth = YES;
+        _couponDescLab.textAlignment = NSTextAlignmentCenter;
+    }
+    return _couponDescLab;
+}
+
+- (UILabel *)couponTitleLab {
+    if (!_couponTitleLab) {
+        _couponTitleLab = [UILabel labelCreateWithText:@"" font:[UIFont fontWithName:Rob_BoldItalic size:18] textColor:_043632];
+        _couponTitleLab.adjustsFontSizeToFitWidth = YES;
+        _couponTitleLab.textAlignment = NSTextAlignmentCenter;
+    }
+    return _couponTitleLab;
+}
+
+- (UIButton *)copyBtn {
+    if (!_copyBtn) {
+        _copyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+        _copyBtn.backgroundColor = [UIColor clearColor];
+        [_copyBtn addTarget:self action:@selector(_copyClick) forControlEvents:UIControlEventTouchUpInside];
+    }
+    return _copyBtn;
+}
+
+
+@end
+
+
+@implementation ASGoodsCouponModel
+
+
+
 @end

+ 4 - 1
Asteria/Fuction/Goods/V/ASGoodsDetailsTableView.m

@@ -66,9 +66,12 @@
         
         return  cell;
     } else if ([typeStr isEqualToString:@"coupon"]) {
+        
+        NSArray *couponArr = (NSArray *)objectM;
+        
         ASGoodsCouponCell *cell = [ASGoodsCouponCell cellWithTableView:tableView CellClass:[ASGoodsCouponCell class]];
         
-        [cell configData:(GoodsInformationM *)objectM isSelect:self.couponSelect];
+        [cell configData:couponArr isSelect:self.couponSelect];
         
         @weakify(self)
         cell.currencyparameterClose = ^(NSInteger type, id Data) {

+ 21 - 5
Asteria/Fuction/Goods/VC/ASGoodsDetailsViewController.m

@@ -31,11 +31,12 @@
 @property (nonatomic, strong) ASGoodsDetailsTableView *TableV;
 
 @property (nonatomic, strong) GoodsInformationM *model;
-
+//优惠券数据
+@property (nonatomic, strong) NSArray *couponDataArray;
 //评论数据
-@property (nonatomic, strong) NSArray *reviewDataArray;;
+@property (nonatomic, strong) NSArray *reviewDataArray;
 //推荐商品数据
-@property (nonatomic, strong) NSArray *recommendGoodsArr;;
+@property (nonatomic, strong) NSArray *recommendGoodsArr;
 
 @property (nonatomic, strong)  UIView *footView;
 
@@ -56,6 +57,8 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
         
+    [self reqNet_GoodsDetailsCouponData];
+    
     [self reqNet_Goods_productGetProductsReview];
     
     [self reqNet_GoodsDetails_productGetProduct];
@@ -254,6 +257,11 @@
     [self.VM ry_requestGetApi:Goods_RecommendGoods param:@{}];
 }
 
+//商品优惠券
+- (void)reqNet_GoodsDetailsCouponData {
+    [self.VM ry_requestGetApi:Goods_productCoupon param:@{}];
+}
+
 -(void)ry_respnsData:(nullable id)data
             parseAry:(nullable NSMutableArray *)arry
               sucess:(BOOL)sucessOrFail
@@ -295,6 +303,12 @@
             if (self.model) {
                 [self updateGoodsDetailsData];
             }
+        } else if ([mark isEqualToString:Goods_productCoupon]) {
+            
+            self.couponDataArray = arry;
+            if (self.model) {
+                [self updateGoodsDetailsData];
+            }
         }
     } else {
         [MBProgressHUD hideHUDForView:self.view animated:YES];
@@ -311,8 +325,10 @@
     NSDictionary *titlePrice = @{@"type":@"titlePrice", @"data":self.model};
     [self.TableV.infodata addObject:titlePrice];
     //优惠券
-    NSDictionary *coupon = @{@"type":@"coupon", @"data":self.model};
-    [self.TableV.infodata addObject:coupon];
+    if (AS_Array_valid(self.couponDataArray)) {
+        NSDictionary *coupon = @{@"type":@"coupon", @"data":self.couponDataArray};
+        [self.TableV.infodata addObject:coupon];
+    }
     //规格
     NSDictionary *goodsSize = @{@"type":@"size", @"data":self.model};
     [self.TableV.infodata addObject:goodsSize];

+ 3 - 1
Asteria/Fuction/Goods/VM/ASGoodsDetailsVM.h

@@ -9,11 +9,13 @@
 #import "GoodsInformationM.h"
 #import "GoodsReviewsListM.h"
 #import "HomeFilterModel.h"
+#import "ASGoodsCouponCell.h"
 
 #define Goods_productGetProductsById  BaseRequestrUrl(@"rewrite/product/getProductsById")
 #define Goods_productGetProductsReview  BaseRequestrUrl(@"rewrite/product/getProductReview")
 
-
+///商品详情优惠券/V1/rewrite/product/getCoupon
+#define Goods_productCoupon       BaseRequestrUrl(@"rewrite/product/getCoupon")
 ///评论点赞
 #define Reviews_rewriteProductAddReviewzan BaseRequestrUrl(@"rewrite/product/addReviewzan")
 ///添加评论图片

+ 3 - 0
Asteria/Fuction/Goods/VM/ASGoodsDetailsVM.m

@@ -20,6 +20,9 @@
     }else if ([mark isEqualToString:Goods_RecommendGoods]){
         NSMutableArray <HomeFilterModel *>*array = [HomeFilterModel mj_objectArrayWithKeyValuesArray:data];
         [self ry_VMconfigDelegateData:data parseAry:array success:YES mark:mark reqNetType:reqNetType];
+    }else if ([mark isEqualToString:Goods_productCoupon]){
+        NSMutableArray <ASGoodsCouponModel *>*array = [ASGoodsCouponModel mj_objectArrayWithKeyValuesArray:data];
+        [self ry_VMconfigDelegateData:data parseAry:array success:YES mark:mark reqNetType:reqNetType];
     }else{
         [self ry_VMconfigDelegateData:data parseAry:[NSMutableArray array] success:YES mark:mark reqNetType:reqNetType];
     }

+ 2 - 2
Asteria/Fuction/Login/V/LoginSignUpV.m

@@ -72,8 +72,8 @@
         self.xxx_dateLab.textColor = [UIColor qmui_colorWithHexString:@"#000000"];
         
         NSDateFormatter *netFormartter= [[NSDateFormatter alloc]init];
-        [formartter setDateFormat:@"yyyy/MM/dd"];
-        NSString *netDateStr = [formartter stringFromDate:selectDate];
+        [netFormartter setDateFormat:@"yyyy/MM/dd"];
+        NSString *netDateStr = [netFormartter stringFromDate:selectDate];
         self.xxx_netDateStr = netDateStr;
     };
     [datePickerView show];

+ 2 - 0
Asteria/Fuction/UserCenter/ConponsAndGiftCard/m/ASCouponsModel.h

@@ -31,6 +31,8 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, copy) NSString *title;
 @property (nonatomic, copy) NSString *desc;
 
+
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 2 - 0
Asteria/Fuction/UserCenter/UserCenterHome/ASSginViewModel.h

@@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
 - (void)getSignData:(void(^)(NSArray *arr))compBlock;
 - (void)signToday:(void(^)(void))compBlock;
 
+- (void)requestGetUserIsSign:(void(^)(BOOL isSign))compBlock;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 12 - 0
Asteria/Fuction/UserCenter/UserCenterHome/ASSginViewModel.m

@@ -29,4 +29,16 @@
     }];
 }
 
+- (void)requestGetUserIsSign:(void(^)(BOOL isSign))compBlock {
+    [ASNetTools.shared getWithPath:getUserIsSign param:@{} success:^(id _Nonnull json) {
+        
+        BOOL isSign = [json boolValue];
+//        NSLog(@"====%@", isSign);
+        compBlock(isSign);
+        
+    } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
+        compBlock(NO);
+    }];
+}
+
 @end

+ 15 - 6
Asteria/Fuction/UserCenter/UserCenterHome/views/ASSginView.m

@@ -27,10 +27,14 @@
 @implementation ASSginView
 
 - (void)signBtAction {
+    K_WEAK_SELF;
     [MBProgressHUD showHUDAddedTo:UIApplication.sharedApplication.keyWindow animated:true];
     [self.vm signToday:^{
+        K_STRONG_SELF;
         [ASUserInfoManager.shared getInfo];
         [MBProgressHUD hideHUDForView:UIApplication.sharedApplication.keyWindow animated:true];
+        
+        [self requestUserIsSignData];
     }];
 }
 
@@ -39,6 +43,15 @@
     [self.vm getSignData:^(NSArray * _Nonnull arr) {
         [weakSelf setData:arr];
     }];
+    
+    [self requestUserIsSignData];
+}
+
+- (void)requestUserIsSignData {
+    [self.vm requestGetUserIsSign:^(BOOL isSign) {
+        self.signBt.backgroundColor = isSign ? Col_999 : Col_000;
+        self.signBt.userInteractionEnabled = !isSign;
+    }];
 }
 
 - (void)setData:(NSArray<NSDictionary<NSString *, NSString*> *> *)data {
@@ -91,10 +104,6 @@
             }
         }
         
-        
-        
-        
-        
         [v mas_makeConstraints:^(MASConstraintMaker *make) {
             make.centerX.equalTo(self.baseLineV.mas_left).offset((i)*(space + 11)+5.5);
             make.bottom.equalTo(self.baseLineV.mas_centerY).offset(5.5);
@@ -121,8 +130,8 @@
         make.centerY.equalTo(self.baseLineV);
     }];
     
-    self.signBt.backgroundColor = todayIsSign ? Col_999 : Col_000;
-    self.signBt.userInteractionEnabled = !todayIsSign;
+//    self.signBt.backgroundColor = todayIsSign ? Col_999 : Col_000;
+//    self.signBt.userInteractionEnabled = !todayIsSign;
     
 }
 

+ 1 - 0
Asteria/Fuction/UserCenter/VipCenter/ASVipCouponModel.h

@@ -21,6 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property (nonatomic, copy) NSString *desc;
 
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 1 - 0
Asteria/NetTools/ASNetApis.h

@@ -75,6 +75,7 @@
 #define postLogOut BaseRequestrUrl(@"integration/customer/revoke-customer-token")
 #define getSignStateUrl BaseRequestrUrl(@"sign/index")
 #define postSignUrl BaseRequestrUrl(@"sign/add")
+#define getUserIsSign BaseRequestrUrl(@"sign/isSign")
 #define deleteUser BaseRequestrUrl(@"customers/remove")
 /// 通用接口
 #define getAllOrders BaseRequestrUrl(@"format")