浏览代码

feat:推荐商品、商品价格

“wangdongchao” 1 年之前
父节点
当前提交
de3bd332f8

+ 1 - 1
Asteria/Fuction/Cart/Cell/MyCartCouponCell.m

@@ -109,7 +109,7 @@
 - (void)configData:(id)Data{
     MyCartCouponCellData *model = (MyCartCouponCellData *)Data;
     self.cellData = model;
-    NSString *disountStr = @"0";
+    NSString *disountStr = @"";
     if([model.discount_amount floatValue] <0.00){
         CGFloat temF =fabsf([model.discount_amount floatValue]);
         disountStr =   [NSString stringWithFormat:@"-%@%.2f",model.currency_symbol,temF];

+ 13 - 8
Asteria/Fuction/Cart/Cell/MyCartGrandTotalCell.m

@@ -73,7 +73,7 @@
         if([code isEqualToString:@"amasty_extrafee"]){ //subLostV
             
             if ([dic[@"value"] qmui_CGFloatValue] > 0) {
-                NSString *tips = [NSString stringWithFormat:@"%@%@%@",dic[@"title"],model.currency_symbol,dic[@"value"]];
+                NSString *tips = [NSString stringWithFormat:@"%@%@%.2f",dic[@"title"],model.currency_symbol, [dic[@"value"] floatValue]];
                 [self.subLostV xxx_configTips:tips isLost:YES];
             } else {
                 [self.subLostV xxx_configTips:@"Extra Fee (insurance for lost)" isLost:NO];
@@ -92,7 +92,7 @@
                     priceStr =   [NSString stringWithFormat:@"-%@%.2f",model.currency_symbol,temF];
                 }
             } else{
-                priceStr = [NSString stringWithFormat:@"%@%@",model.currency_symbol,dic[@"value"]];
+                priceStr = [NSString stringWithFormat:@"%@%.2f",model.currency_symbol, [dic[@"value"] floatValue]];
             }
             SubtotalCellItemV *itemV = [[SubtotalCellItemV alloc] init];
             [self.stackSubTopV addArrangedSubview:itemV];
@@ -176,18 +176,22 @@
 - (void)tt_setupViews{
     [self addSubview:self.tipsLab];
     [self addSubview:self.priceLab];
-    [self.tipsLab mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.left.mas_equalTo(0);
+    
+    [self.priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
+//        make.left.equalTo(self.tipsLab.mas_right).offset(10);
+        make.right.mas_equalTo(0);
         make.top.mas_equalTo(0);
         make.height.mas_equalTo(30);
-        make.right.mas_equalTo(-100);
+        make.width.mas_lessThanOrEqualTo(150);
     }];
-    [self.priceLab mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.left.equalTo(self.tipsLab.mas_right).offset(10);
-        make.right.mas_equalTo(0);
+    
+    [self.tipsLab mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.left.mas_equalTo(0);
         make.top.mas_equalTo(0);
         make.height.mas_equalTo(30);
+        make.right.mas_equalTo(self.priceLab.mas_left).offset(-4);
     }];
+    
 }
 -(void)xxx_configTips:(NSString *)tips price:(NSString *)priceStr{
     self.tipsLab.text = tips;
@@ -206,6 +210,7 @@
     if(!_priceLab){
         _priceLab = [[UILabel alloc]init];
         _priceLab.textColor = [UIColor colorWithHexString:@"#0B0B0B"];
+        _priceLab.adjustsFontSizeToFitWidth = YES;
         _priceLab.font = [UIFont fontWithName:Rob_Regular size:14];
         _priceLab.textAlignment = NSTextAlignmentRight;
     }

+ 4 - 1
Asteria/Fuction/Cart/Checkout/ASCheckoutPointApplyCell.m

@@ -124,7 +124,10 @@
         self.applyBtn.selected = NO;
     }
     
-    self.priceLab.text = [NSString stringWithFormat:@"-%@%@", model.priceSymbol, model.usePrice];
+    if ([model.usePrice floatValue] > 0.00) {
+        self.priceLab.text = [NSString stringWithFormat:@"-%@%@", model.priceSymbol, model.usePrice];
+    }
+    
     
     NSString *pointStr = [NSString stringWithFormat:@"You have %@ Reward Points available.", model.pointBalance];
     NSString *pointLastStr = [NSString stringWithFormat:@"%@ point = %@%@. Input points value below to redeem.", model.pointScale, model.priceSymbol, model.priceScale];

+ 1 - 0
Asteria/Fuction/Cart/V/ASMyCartNoDataView.m

@@ -37,6 +37,7 @@
         
         K_WEAK_SELF;
         dispatch_async(dispatch_get_main_queue(), ^{
+            
             K_STRONG_SELF;
             [UIView viewAddHorColorBg:self.emptyV colorArr:@[
                 (id)_E0FFF5.CGColor,

+ 5 - 0
Asteria/Fuction/Goods/M/GoodsInformationM.h

@@ -17,9 +17,14 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, copy)NSString *name;
 @property (nonatomic, copy) NSString *price; 
 @property (nonatomic, copy) NSString *final_prices;
+
+@property (nonatomic, copy) NSString *show_prices;//选择规格后最终显示原价
+@property (nonatomic, copy) NSString *show_final_prices;//选择规格后最终显示优惠之后的价格
+
 @property (nonatomic, copy) NSString *currency_symbol;
 @property (nonatomic, copy) NSString *sold;
 @property (nonatomic, copy) NSString *review_nums;
+@property (nonatomic, copy) NSString *percent;
 
 @property (nonatomic, copy) NSString *xxx_showImg;
 

+ 24 - 4
Asteria/Fuction/Goods/V/ASGoodsTitlePriceCell.m

@@ -21,6 +21,8 @@
 
 - (void)setupSubviewS{
     
+    [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(setData) name:GoodsDetailsUpdatePrice object:nil];
+    
 //    self.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
     
     [self.contentView addSubview:self.titleLab];
@@ -60,6 +62,10 @@
     
 }
 
+- (void)setData {
+    [self configData:self.infoModel];
+}
+
 - (void)configData:(id)Data{
     GoodsInformationM *model = (GoodsInformationM *)Data;
     
@@ -74,18 +80,28 @@
     self.reviewsLab.attributedText = reviewsStr;
     self.reviewsLab.textAlignment = NSTextAlignmentRight;
     
-    NSMutableAttributedString *priceAtr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",model.currency_symbol,model.final_prices]];
+    //总价 (优惠前价格)
+    NSString *noDiscountPrice = model.show_prices;
+    if (!AS_String_valid(model.show_prices) || [model.show_prices isEqualToString:@"0"]) {
+        noDiscountPrice = model.price;
+    }
+    NSString *discountPrice = model.show_final_prices;
+    if (!AS_String_valid(model.show_final_prices) || [model.show_final_prices isEqualToString:@"0"]) {
+        discountPrice = model.final_prices;
+    }
+    
+    NSMutableAttributedString *priceAtr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",model.currency_symbol,discountPrice]];
     [priceAtr addAttribute: NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#0B0B0B"] range:NSMakeRange(0, priceAtr.length)];
     [priceAtr addAttribute:NSFontAttributeName value:[UIFont fontWithName:Rob_Bold size:20] range:NSMakeRange(0, priceAtr.length)];
     NSString *saveStr = @"";
-    if(model.final_prices == model.price){
+    if(noDiscountPrice == discountPrice){
         self.saveLab.hidden = YES;
     }else{
         self.saveLab.hidden = NO;
-        double savePrice = [model.price doubleValue]-[model.final_prices doubleValue];
+        double savePrice = [noDiscountPrice doubleValue]-[discountPrice doubleValue];
         saveStr = [NSString stringWithFormat:@"Save %@%.2f",model.currency_symbol,savePrice];
         [priceAtr appendAttributedString:[[NSAttributedString alloc]initWithString:@"  "]];
-        NSMutableAttributedString *priceAtrSub1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",model.price]];
+        NSMutableAttributedString *priceAtrSub1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",model.currency_symbol, noDiscountPrice]];
         [priceAtrSub1 addAttribute:NSForegroundColorAttributeName
                         value:[UIColor colorWithHexString:@"#8c8c8c"]
                         range:NSMakeRange(0, priceAtrSub1.length)];
@@ -163,4 +179,8 @@
     return  _saveLab;
 }
 
+- (void)dealloc {
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
 @end

+ 38 - 0
Asteria/Fuction/Goods/VC/ASGoodsDetailsViewController.m

@@ -127,6 +127,10 @@
             [self.navigationController pushViewController:vc animated:YES];
         } else if (num == 100) {
             self.sizeParam = (NSDictionary *)data;
+            
+//            self.model.final_prices = @""
+            
+            [self refresh_optionChangePrice];
         } else if (num == 101) {//推荐商品跳转
             ASProductBaseModel *model = (ASProductBaseModel *)data;
             UIViewController *viewController = [[CTMediator sharedInstance] Goods_GoodsDetailsC:@{@"entity_id":model.Id}];
@@ -141,6 +145,40 @@
     };
 }
 
+#pragma mark - **************** fresh 选择不同规格后的金额变化 ****************
+-(void)refresh_optionChangePrice{
+    CGFloat add_price = 0.00;
+    for (OptionsModel *optionM in self.model.options) {
+        OptionsValuesM *valuesM = optionM.values[optionM.optionSelectTag];
+        add_price  =  add_price + valuesM.price;
+    }
+    
+    NSInteger num = [[self.sizeParam objectForKey:@"qty"] integerValue];
+
+    float discount = [self.model.percent floatValue];
+    if (discount == 0) {
+        //优惠价
+        CGFloat add_final_price_f = (add_price + [self.model.final_prices floatValue]) * num;
+        self.model.show_final_prices = [NSString stringWithFormat:@"%.2lf", add_final_price_f];
+        //原价
+        CGFloat show_prices = (add_price + [self.model.price floatValue]) * num;
+        self.model.show_prices = [NSString stringWithFormat:@"%.2lf", show_prices];
+    } else {
+        //优惠价
+        discount = (100.00 - discount) / 100.00;
+        CGFloat add_final_price_f = (add_price * discount + [self.model.final_prices floatValue]) * num;
+        self.model.show_final_prices = [NSString stringWithFormat:@"%.2lf", add_final_price_f];
+        //原价
+        CGFloat show_prices = (add_price + [self.model.price floatValue]) * num;
+        self.model.show_prices = [NSString stringWithFormat:@"%.2lf", show_prices];
+    }
+    
+    
+
+    
+    [NSNotificationCenter.defaultCenter postNotificationName:GoodsDetailsUpdatePrice object:nil];
+}
+
 //请求尺寸
 -(void)action_GoodsSizeC:(NSString *)entity_id {
     if (!ASUserInfoManager.shared.isLogin) {

+ 25 - 6
Asteria/Fuction/Goods/VC/AS_GoodsSizeC.m

@@ -156,17 +156,36 @@
         OptionsValuesM *valuesM = optionM.values[optionM.optionSelectTag];
         add_price  =  add_price + valuesM.price;
     }
+    
+    float discount = [self.model.percent floatValue];
+    if (discount == 0) {
+        //优惠价
+        CGFloat add_final_price_f = (add_price + [self.model.final_prices floatValue]) * self.xxx_quantityNum;
+        self.model.show_final_prices = [NSString stringWithFormat:@"%.2lf", add_final_price_f];
+        //原价
+        CGFloat show_prices = (add_price + [self.model.price floatValue]) * self.xxx_quantityNum;
+        self.model.show_prices = [NSString stringWithFormat:@"%.2lf", show_prices];
+    } else {
+        //优惠价
+        discount = (100.00 - discount) / 100.00;
+        CGFloat add_final_price_f = (add_price * discount + [self.model.final_prices floatValue]) * self.xxx_quantityNum;
+        self.model.show_final_prices = [NSString stringWithFormat:@"%.2lf", add_final_price_f];
+        //原价
+        CGFloat show_prices = (add_price + [self.model.price floatValue]) * self.xxx_quantityNum;
+        self.model.show_prices = [NSString stringWithFormat:@"%.2lf", show_prices];
+    }
+    
     self.priceLab.attributedText = [ASGoodsDetailsVM tool_addOptionPrice:add_price quantity:self.xxx_quantityNum infoMoel:self.model];
     
-    CGFloat savePrice = ([self.model.price doubleValue]-[self.model.final_prices doubleValue])*self.xxx_quantityNum;
+    CGFloat savePrice = ([self.model.show_prices doubleValue]-[self.model.show_final_prices doubleValue]);
     self.saveLab.text = [NSString stringWithFormat:@"Save %@%.2f",self.model.currency_symbol,savePrice];
     
-    CGFloat add_final_price_f = (add_price+[self.model.final_prices floatValue])*self.xxx_quantityNum;
+    CGFloat add_final_price_f = [self.model.show_final_prices doubleValue];
     [self refresh_PayViewchangeValueCell:add_final_price_f];
 }
 -(void)refresh_PayViewchangeValueCell:(CGFloat )change_final_prices_f{
-    GoodsSizePayMentCellData *payModel = (GoodsSizePayMentCellData *)[self.TableV.infodata lastObject];
-    payModel.final_prices_f = change_final_prices_f;
+//    GoodsSizePayMentCellData *payModel = (GoodsSizePayMentCellData *)[self.TableV.infodata lastObject];
+//    payModel.final_prices_f = change_final_prices_f;
     NSIndexPath *indexPath = [NSIndexPath indexPathForRow:self.TableV.infodata.count-1 inSection:0];
     [self.TableV reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
 }
@@ -214,9 +233,9 @@
                 }];
             }else{
 //                [self handle_closeVC];
-                K_WEAK_SELF;
+//                K_WEAK_SELF;
                 [self dismissViewControllerAnimated:YES completion:^{
-                    K_STRONG_SELF;
+//                    K_STRONG_SELF;
                     Cart_CheckoutC *vc = [[Cart_CheckoutC alloc] init];
                     [[Current_normalTool topViewController].navigationController pushViewController:vc animated:YES];
                 }];

+ 4 - 4
Asteria/Fuction/Goods/VM/ASGoodsDetailsVM.m

@@ -58,17 +58,17 @@
 }
 
 +(NSMutableAttributedString *)tool_addOptionPrice:(CGFloat)addPrice quantity:(NSInteger)quantity infoMoel:(GoodsInformationM *)model{
-    CGFloat add_final_price_f = (addPrice+[model.final_prices floatValue])*quantity;
+    CGFloat add_final_price_f = [model.show_final_prices floatValue];
     NSString *add_final_price = [NSString stringWithFormat:@"%.2f",add_final_price_f];
     
     NSMutableAttributedString *priceAtr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",model.currency_symbol,add_final_price]];
     [priceAtr addAttribute: NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#0B0B0B"] range:NSMakeRange(0, priceAtr.length)];
     [priceAtr addAttribute:NSFontAttributeName value:[UIFont fontWithName:Rob_Bold size:20] range:NSMakeRange(0, priceAtr.length)];
-    if([model.final_prices floatValue] == [model.price floatValue]){
+    if([model.show_final_prices floatValue] == [model.show_prices floatValue]){
         return  priceAtr;
     }else{
-        CGFloat add_price_f = (addPrice+[model.price floatValue])*quantity;
-        NSString *add_price = [NSString stringWithFormat:@"%.2f",add_price_f];
+        CGFloat add_price_f = [model.show_prices floatValue];
+        NSString *add_price = [NSString stringWithFormat:@"%@%.2f",model.currency_symbol, add_price_f];
         [priceAtr appendAttributedString:[[NSAttributedString alloc]initWithString:@"  "]];
         NSMutableAttributedString *priceAtrSub1 = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@",add_price]];
         [priceAtrSub1 addAttribute:NSForegroundColorAttributeName

+ 1 - 0
Asteria/NetTools/ASUserNotifyStatic.h

@@ -20,6 +20,7 @@
 /// 通知用户信息更新
 #define UserInfoUpdate @"ASUserInfoUpdate"
 
+#define GoodsDetailsUpdatePrice  @"GoodsDetailsUpdatePrice"
 
 
 #endif /* ASUserNotifyStatic_h */