ASGoodsGuaranteeInfoCell.m 5.1 KB

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