| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 | 
							- //
 
- //  MyCartGrandTotalCell.m
 
- //  Asteria
 
- //
 
- //  Created by 王猛 on 2024/2/2.
 
- //
 
- #import "MyCartGrandTotalCell.h"
 
- @implementation MyCartGrandTotalCellData
 
- @end
 
- @interface MyCartGrandTotalCell  ()
 
- @property (nonatomic, strong) UIView *bgV;
 
- @property (nonatomic, strong) UIStackView *stackV;
 
- @property (nonatomic, strong) UIStackView *stackSubTopV;
 
- @property (nonatomic, strong) SubLoastSelectItemV *subLostV;
 
- @property (nonatomic, strong) SubtotalCellItemV *subBottomV;
 
- //总金额
 
- @property (nonatomic, copy) NSString *totalPriceStr;
 
- //丢件金额
 
- @property (nonatomic, copy) NSString *lostPriceStr;
 
- @end
 
- @implementation MyCartGrandTotalCell
 
- - (void)awakeFromNib {
 
-     [super awakeFromNib];
 
-     // Initialization code
 
- }
 
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
 
-     [super setSelected:selected animated:animated];
 
-     // Configure the view for the selected state
 
- }
 
- - (void)setupSubviewS{
 
-     self.contentView.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
 
-     [self.contentView addSubview:self.bgV];
 
-     [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(10, 10, 0, 10));
 
-     }];
 
-     [self.bgV addSubview:self.stackV];
 
-     [self.stackV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.edges.equalTo(self.bgV).insets(UIEdgeInsetsMake(0, 10, 0, 10));
 
-     }];
 
-     
 
-     [self.stackV addArrangedSubview:self.stackSubTopV];
 
-     [self.stackV addArrangedSubview:self.subLostV];
 
-     [self.stackV addArrangedSubview:self.subBottomV];
 
-   
 
-     [self.subLostV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.height.mas_equalTo(60);
 
-     }];
 
-     [self.subBottomV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.height.mas_equalTo(60);
 
-     }];
 
- }
 
- - (void)configData:(id)Data{
 
-     MyCartGrandTotalCellData *model = (MyCartGrandTotalCellData *)Data;
 
- ///当一个元素被 removeFromSuperview ,则 arrangedSubviews也会同步移除
 
-     [self.stackSubTopV.arrangedSubviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
 
-     for (int i=0; i<model.total_segments.count; i++) {
 
-         NSDictionary *dic = model.total_segments[i];
 
-         NSString *code = MM_str(dic[@"code"]);
 
-         if([code isEqualToString:@"amasty_extrafee"]){ //subLostV
 
-             NSString *tips = [NSString stringWithFormat:@"%@%@%@",dic[@"title"],model.currency_symbol,dic[@"value"]];
 
-             //wm_todo 需要 获取丢件险状态 carts/mine/fees-information 
 
-             [self.subLostV xxx_configTips:tips isLost:[dic[@"value"] qmui_CGFloatValue] > 0 ? YES : NO];
 
-         }else if ([code isEqualToString:@"grand_total"]){ //subBottomV
 
-             NSString *priceStr = [NSString stringWithFormat:@"%@%@",model.currency_symbol,dic[@"value"]];
 
-             [self.subBottomV xxx_configTips:dic[@"title"] price:priceStr];
 
-         }else{ //stackSubTopV
 
-             NSString *priceStr = @"0";
 
-             if([code isEqualToString:@"discount"]){
 
-                 if([dic[@"value"] floatValue] <0.00){
 
-                     CGFloat temF =fabsf([dic[@"value"] floatValue]);
 
-                     priceStr =   [NSString stringWithFormat:@"-%@%.2f",model.currency_symbol,temF];
 
-                 }
 
-             }else{
 
-                 priceStr = [NSString stringWithFormat:@"%@%@",model.currency_symbol,dic[@"value"]];
 
-             }
 
-             SubtotalCellItemV *itemV = [[SubtotalCellItemV alloc] init];
 
-             [self.stackSubTopV addArrangedSubview:itemV];
 
-             [itemV xxx_configTips:dic[@"title"] price:priceStr];
 
-             [itemV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-                 make.height.mas_equalTo(30);
 
-             }];
 
-             
 
-         }
 
-     }
 
-     
 
- }
 
- - (UIView *)bgV {
 
-     if (!_bgV) {
 
-         _bgV = [[UIView alloc] init];
 
-         _bgV.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
 
-         _bgV.layer.cornerRadius = 4;
 
-         _bgV.clipsToBounds = YES;
 
-     }
 
-     return _bgV;
 
- }
 
- - (UIStackView *)stackV { ///根据高度进行变化
 
-     if (!_stackV) {
 
-         UIStackView *stv = [[UIStackView alloc] init];
 
-         stv.backgroundColor = [UIColor colorWithHexString:@"#F4F4F4"];
 
-         stv.axis = UILayoutConstraintAxisVertical;
 
-         stv.distribution = UIStackViewDistributionFill;
 
-         stv.alignment = UIStackViewAlignmentFill;
 
-         stv.spacing = 1;
 
-         _stackV = stv;
 
-     }
 
-     return _stackV;
 
- }
 
- - (UIStackView *)stackSubTopV {
 
-     if (!_stackSubTopV) {
 
-         UIStackView *stv = [[UIStackView alloc] init];
 
-         stv.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
 
-         stv.axis = UILayoutConstraintAxisVertical;
 
-         stv.distribution = UIStackViewDistributionFill;
 
-         stv.alignment = UIStackViewAlignmentFill;
 
-         stv.spacing = 5;
 
-         _stackSubTopV = stv;
 
-     }
 
-     return _stackSubTopV;
 
- }
 
- - (SubLoastSelectItemV *)subLostV {
 
-     if (!_subLostV) {
 
-         _subLostV = [[SubLoastSelectItemV alloc] init];
 
-         _subLostV.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
 
-         _subLostV.ViewtapClose = ^(NSInteger num, id  _Nonnull data) {
 
-             NSLog(@"=====%ld=====%@", num, data);
 
-             
 
-             
 
-         };
 
-     }
 
-     return _subLostV;
 
- }
 
- - (SubtotalCellItemV *)subBottomV {
 
-     if (!_subBottomV) {
 
-         _subBottomV = [[SubtotalCellItemV alloc] init];
 
-         _subBottomV.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
 
-         _subBottomV.tipsLab.font = [UIFont fontWithName:Rob_Bold size:14];
 
-         _subBottomV.priceLab.font = [UIFont fontWithName:Rob_Bold size:24];
 
-     }
 
-     return _subBottomV;
 
- }
 
- @end
 
- @interface SubtotalCellItemV ()
 
- @end
 
- @implementation SubtotalCellItemV
 
- - (void)tt_setupViews{
 
-     [self addSubview:self.tipsLab];
 
-     [self addSubview:self.priceLab];
 
-     [self.tipsLab mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.left.mas_equalTo(0);
 
-         make.top.mas_equalTo(0);
 
-         make.height.mas_equalTo(30);
 
-     }];
 
-     [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);
 
-     }];
 
- }
 
- -(void)xxx_configTips:(NSString *)tips price:(NSString *)priceStr{
 
-     self.tipsLab.text = tips;
 
-     self.priceLab.text = priceStr;
 
- }
 
- -(UILabel *)tipsLab{
 
-     if(!_tipsLab){
 
-         _tipsLab = [[UILabel alloc]init];
 
-         _tipsLab.textColor = [UIColor colorWithHexString:@"#0B0B0B"];
 
-         _tipsLab.font = [UIFont fontWithName:Rob_Regular size:14];
 
-         _tipsLab.numberOfLines =2;
 
-     }
 
-     return _tipsLab;
 
- }
 
- -(UILabel *)priceLab{
 
-     if(!_priceLab){
 
-         _priceLab = [[UILabel alloc]init];
 
-         _priceLab.textColor = [UIColor colorWithHexString:@"#0B0B0B"];
 
-         _priceLab.font = [UIFont fontWithName:Rob_Regular size:14];
 
-         _priceLab.textAlignment = NSTextAlignmentRight;
 
-     }
 
-     return _priceLab;
 
- }
 
- @end
 
- ///点击cell
 
- @interface SubLoastSelectItemV ()
 
- @end
 
- @implementation SubLoastSelectItemV
 
- - (void)tt_setupViews{
 
-     [self addSubview:self.tipsLab];
 
-     [self addSubview:self.ridoBtn];
 
-     [self.tipsLab mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.left.equalTo(self);
 
-         make.centerY.equalTo(self);
 
-         make.right.mas_equalTo(-50);
 
-     }];
 
-     [self.ridoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.width.mas_equalTo(50);
 
-         make.height.mas_equalTo(50);
 
-         make.right.equalTo(self);
 
-     }];
 
- }
 
- -(void)handle_ridoBtnEvent:(UIButton *)btn{
 
-     btn.selected = !btn.selected;
 
-     if(self.ViewtapClose){
 
-         self.ViewtapClose(btn.selected, @"");
 
-     }
 
- }
 
- - (void)xxx_configTips:(NSString *)tips isLost:(BOOL)isLost{
 
-     self.tipsLab.text = tips;
 
-     self.ridoBtn.selected = isLost;
 
- }
 
- -(UILabel *)tipsLab{
 
-     if(!_tipsLab){
 
-         _tipsLab = [[UILabel alloc]init];
 
-         _tipsLab.textColor = [UIColor colorWithHexString:@"#0B0B0B"];
 
-         _tipsLab.font = [UIFont fontWithName:Rob_Regular size:14];
 
-         _tipsLab.numberOfLines =2;
 
-     }
 
-     return _tipsLab;
 
- }
 
- -(UIButton *)ridoBtn{
 
-     if(!_ridoBtn){
 
-         _ridoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
 
-         [_ridoBtn setImage:[UIImage imageNamed:@"base_radio_unselect"] forState:UIControlStateNormal];
 
-         [_ridoBtn setImage:[UIImage imageNamed:@"base_radio_select"] forState:UIControlStateSelected];
 
-         [_ridoBtn addTarget:self action:@selector(handle_ridoBtnEvent:) forControlEvents:UIControlEventTouchUpInside];
 
-     }
 
-     return _ridoBtn;
 
- }
 
- @end
 
 
  |