ASGoodsGuaranteeInfoCell.m 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. //
  2. // ASGoodsGuaranteeInfoCell.m
  3. // Asteria
  4. //
  5. // Created by xingyu on 2024/5/20.
  6. //
  7. #import "ASGoodsGuaranteeInfoCell.h"
  8. #import "GoodsDetailsPayV.h"
  9. #import "GoodsDetailsIntroduceV.h"
  10. #import "RadioButton.h"
  11. @interface ASGoodsGuaranteeInfoCell()
  12. @property (nonatomic, strong) GoodsDetailsPayV *datails_payV;
  13. @property (nonatomic, strong) GoodsDetailsIntroduceV *datails_IntroduceV;
  14. @property (nonatomic, strong) NSMutableArray *radioBtnAry;
  15. @property (nonatomic, strong) UIButton *leftBtn;
  16. @property (nonatomic, strong) UIButton *rightBtn;
  17. @end
  18. @implementation ASGoodsGuaranteeInfoCell
  19. - (void)setupSubviewS{
  20. _radioBtnAry = [[NSMutableArray alloc] initWithCapacity:1];
  21. [self.contentView addSubview:self.datails_payV];
  22. [self.contentView addSubview:self.datails_IntroduceV];
  23. [self.datails_payV mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.left.mas_equalTo(10);
  25. make.top.mas_equalTo(10);
  26. make.width.mas_equalTo(KScreenWidth-20);
  27. make.height.mas_equalTo(78);
  28. }];
  29. [self.datails_IntroduceV mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.left.mas_equalTo(10);
  31. make.top.equalTo(self.datails_payV.mas_bottom).offset(10);
  32. make.width.mas_equalTo(KScreenWidth-20);
  33. make.height.mas_equalTo(120);
  34. }];
  35. NSArray *titleAry = @[@"PRODUCT DETAILS",@"REVIEWS"];
  36. for (int i= 0; i<titleAry.count; i++) {
  37. UIButton *radBtn= [UIButton buttonWithType:UIButtonTypeCustom];
  38. radBtn.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
  39. radBtn.titleLabel.font = [UIFont fontWithName:Rob_Bold size:14];
  40. radBtn.layer.cornerRadius = 4;
  41. radBtn.clipsToBounds = YES;
  42. radBtn.tag = i;
  43. [radBtn setTitle:titleAry[i] forState:UIControlStateNormal];
  44. [radBtn setTitleColor:[UIColor colorWithHexString:@"#000000"] forState:UIControlStateNormal];
  45. [radBtn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateSelected];
  46. [radBtn addTarget:self action:@selector(_onButtonClick:) forControlEvents:UIControlEventTouchUpInside];
  47. [self.contentView addSubview:radBtn];
  48. // [self.radioBtnAry addObject:radBtn];
  49. CGFloat btnWidth = (KScreenWidth -30)/2;
  50. [radBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.left.mas_equalTo(10+(10+btnWidth)*i);
  52. make.height.mas_equalTo(40);
  53. make.top.equalTo(self.datails_IntroduceV.mas_bottom).offset(20);
  54. make.width.mas_equalTo(btnWidth);
  55. make.bottom.mas_equalTo(-10);
  56. }];
  57. if (i == 0) {
  58. radBtn.selected = YES;
  59. radBtn.backgroundColor = [UIColor colorWithHexString:@"#113632"];
  60. self.leftBtn = radBtn;
  61. } else {
  62. radBtn.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
  63. self.rightBtn = radBtn;
  64. }
  65. }
  66. // RadioButton *firstBtn = self.radioBtnAry[0];
  67. // [firstBtn setGroupButtons:self.radioBtnAry];
  68. // [self.radioBtnAry[0] setSelected:YES];
  69. // [self xxx_onRadioButtonValueChanged:self.radioBtnAry[0]];
  70. // self.datails_payV.titleLab.text = [NSString stringWithFormat:@"Pay in 4 interest-free payments of %@%.2f with",model.currency_symbol,[model.final_prices floatValue]/4];
  71. }
  72. - (void)configData:(id)Data{
  73. GoodsInformationM *model = (GoodsInformationM *)Data;
  74. _infoModel = model;
  75. self.datails_payV.titleLab.text = [NSString stringWithFormat:@"Pay in 4 interest-free payments of %@%.2f with",model.currency_symbol,[model.final_prices floatValue]/4];
  76. }
  77. -(void)_onButtonClick:(UIButton *)btn{
  78. int tag = (int)btn.tag;
  79. if (tag == 0) {
  80. if (self.leftBtn.isSelected) {
  81. return;
  82. }
  83. self.leftBtn.selected = YES;
  84. self.rightBtn.selected = NO;
  85. self.leftBtn.backgroundColor = [UIColor colorWithHexString:@"#113632"];
  86. self.rightBtn.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
  87. } else {
  88. if (self.rightBtn.isSelected) {
  89. return;
  90. }
  91. self.rightBtn.selected = YES;
  92. self.leftBtn.selected = NO;
  93. self.rightBtn.backgroundColor = [UIColor colorWithHexString:@"#113632"];
  94. self.leftBtn.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
  95. }
  96. if (self.currencyparameterClose) {
  97. self.currencyparameterClose(tag + 2, self.infoModel);
  98. }
  99. }
  100. -(GoodsDetailsPayV *)datails_payV{
  101. if (!_datails_payV) {
  102. _datails_payV = [[GoodsDetailsPayV alloc]initWithFrame:CGRectMake(10, 0, KScreenWidth-20, 78)];
  103. _datails_payV.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
  104. _datails_payV.layer.cornerRadius = 4;
  105. _datails_payV.clipsToBounds = YES;
  106. }
  107. return _datails_payV;
  108. }
  109. - (GoodsDetailsIntroduceV *)datails_IntroduceV {
  110. if (!_datails_IntroduceV) {
  111. _datails_IntroduceV = [[GoodsDetailsIntroduceV alloc] initWithFrame:CGRectMake(10, 0, KScreenWidth-20, 120)];
  112. _datails_IntroduceV.backgroundColor = _F5F5F5;
  113. _datails_IntroduceV.clipsToBounds = YES;
  114. }
  115. return _datails_IntroduceV;
  116. }
  117. @end