BogoInviteDetailBottomView.m 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // BogoInviteDetailBottomView.m
  3. // UniversalApp
  4. //
  5. // Created by Mac on 2021/6/10.
  6. // Copyright © 2021 voidcat. All rights reserved.
  7. //
  8. #import "BogoInviteDetailBottomView.h"
  9. #import "BogoInviteWithDrawResponseModel.h"
  10. #import "BogoInviteWithDrawItemCell.h"
  11. @interface BogoInviteDetailBottomView ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
  12. @property (weak, nonatomic) IBOutlet UILabel *authLabel;
  13. @property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
  14. @end
  15. @implementation BogoInviteDetailBottomView
  16. - (void)awakeFromNib{
  17. [super awakeFromNib];
  18. self.frame = CGRectMake(0, 98 + 15, kScreenW, 328);
  19. [self.collectionView registerNib:[UINib nibWithNibName:@"BogoInviteWithDrawItemCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"BogoInviteWithDrawItemCell"];
  20. self.collectionView.delegate = self;
  21. self.collectionView.dataSource = self;
  22. }
  23. - (void)setModel:(BogoInviteWithDrawResponseModel *)model{
  24. _model = model;
  25. [self.collectionView reloadData];
  26. self.authLabel.text = model.data.alipay_name.length ?ASLocalizedString( @"已绑定") :ASLocalizedString( @"未绑定");
  27. self.authLabel.textColor = [UIColor colorWithHexString:model.data.alipay_name.length ? @"#57A8FF" : @"#F52F03"];
  28. }
  29. - (IBAction)authBtnAction:(UIButton *)sender {
  30. if (self.delegate && [self.delegate respondsToSelector:@selector(bottomView:didClickAuthBtn:)]) {
  31. [self.delegate bottomView:self didClickAuthBtn:sender];
  32. }
  33. }
  34. - (IBAction)withDrawBtnAction:(id)sender {
  35. if (self.delegate && [self.delegate respondsToSelector:@selector(bottomView:didClickWithDrawBtn:)]) {
  36. [self.delegate bottomView:self didClickWithDrawBtn:sender];
  37. }
  38. }
  39. - (IBAction)agreementBtnAction:(id)sender {
  40. if (self.delegate && [self.delegate respondsToSelector:@selector(bottomView:didClickAgreementBtn:)]) {
  41. [self.delegate bottomView:self didClickAgreementBtn:sender];
  42. }
  43. }
  44. #pragma mark - UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout
  45. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
  46. return 1;
  47. }
  48. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
  49. return self.model.list.count;
  50. }
  51. - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
  52. BogoInviteWithDrawItemCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"BogoInviteWithDrawItemCell" forIndexPath:indexPath];
  53. if (indexPath.item < self.model.list.count) {
  54. cell.model = self.model.list[indexPath.item];
  55. }
  56. return cell;
  57. }
  58. - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
  59. return CGSizeMake(floor((kScreenW - 50) / 3), 50);
  60. }
  61. - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
  62. return UIEdgeInsetsMake(15, 15, 15, 15);
  63. }
  64. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
  65. return 10;
  66. }
  67. - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
  68. return 10;
  69. }
  70. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
  71. BogoInviteWithDrawResponseModelList *model = self.model.list[indexPath.item];
  72. for (BogoInviteWithDrawResponseModelList *subModel in self.model.list) {
  73. subModel.selected = model == subModel;
  74. }
  75. self.selectModel = model;
  76. [collectionView reloadData];
  77. }
  78. @end