BogoNoblePayView.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. //
  2. // BogoNoblePayView.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2021/4/24.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BogoNoblePayView.h"
  9. #import "BogoNoblePayCell.h"
  10. @implementation BogoNoblePayView
  11. /*
  12. // Only override drawRect: if you perform custom drawing.
  13. // An empty implementation adversely affects performance during animation.
  14. - (void)drawRect:(CGRect)rect {
  15. // Drawing code
  16. }
  17. */
  18. - (void)awakeFromNib{
  19. [super awakeFromNib];
  20. for (UIView *subView in self.subviews) {
  21. [subView setLocalizedString];
  22. }
  23. }
  24. -(void)reloadNetSourse{
  25. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  26. [parmDict setObject:@"noble" forKey:@"ctl"];
  27. [parmDict setObject:@"select_coin" forKey:@"act"];
  28. [parmDict setObject:self.model.id forKey:@"id"];
  29. [[NetHttpsManager manager] POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
  30. if ([[responseJson valueForKey:@"status"] integerValue] == 1) {
  31. BogoNoblePayModel *model = [BogoNoblePayModel mj_objectWithKeyValues:responseJson];
  32. self.payModel = model;
  33. self.paySelectModel = model.list.firstObject;
  34. self.titleL.text = model.name;
  35. [self.collectionView reloadData];
  36. }else{
  37. }
  38. } FailureBlock:^(NSError *error) {
  39. }];
  40. }
  41. - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
  42. return 1;
  43. }
  44. - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
  45. return self.payModel.list.count;
  46. }
  47. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
  48. BogoNoblePayCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"BogoNoblePayCell" forIndexPath:indexPath];
  49. BogoNoblePayListModel *model = self.payModel.list[indexPath.row];
  50. // modelself.payModel.list[indexPath.row];
  51. if (self.paySelectModel == model) {
  52. model.isSelect = YES;
  53. }else{
  54. model.isSelect = NO;
  55. }
  56. cell.model = model;
  57. return cell;
  58. }
  59. - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
  60. self.paySelectModel = self.payModel.list[indexPath.row];
  61. [self.collectionView reloadData];
  62. }
  63. - (IBAction)clickConfirmBtn:(UIButton *)sender {
  64. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  65. [parmDict setObject:@"noble" forKey:@"ctl"];
  66. [parmDict setObject:@"pay" forKey:@"act"];
  67. [parmDict setObject:self.paySelectModel.id forKey:@"id"];
  68. [[NetHttpsManager manager] POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson) {
  69. if ([[responseJson valueForKey:@"status"] integerValue] == 1) {
  70. // [MBProgressHUD ]
  71. if (self.delegate && [self.delegate respondsToSelector:@selector(protocolBuySuccessWithModel:)]) {
  72. [self.delegate protocolBuySuccessWithModel:self.model];
  73. }
  74. [FanweMessage alertHUD:[responseJson objectForKey:@"error"]];
  75. }else{
  76. }
  77. } FailureBlock:^(NSError *error) {
  78. }];
  79. }
  80. #pragma mark - Lazy Load
  81. - (UIView *)shadowView{
  82. if (!_shadowView) {
  83. _shadowView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenHeight)];
  84. _shadowView.backgroundColor = kGrayTransparentColor2_1;
  85. // [kBlackColor colorWithAlphaComponent:0.3];
  86. _shadowView.alpha = 0;
  87. _shadowView.userInteractionEnabled = YES;
  88. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hide)];
  89. [_shadowView addGestureRecognizer:tap];
  90. }
  91. return _shadowView;
  92. }
  93. //- (void)setSelectModel:(BogoNobleListSubTypeModel *)selectModel{
  94. //
  95. //}
  96. - (void)show:(UIView *)superView{
  97. // [self requestWardData];
  98. [superView addSubview:self.shadowView];
  99. [superView addSubview:self];
  100. [self.collectionView registerNib:[UINib nibWithNibName:@"BogoNoblePayCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"BogoNoblePayCell"];
  101. self.collectionView.delegate = self;
  102. self.collectionView.dataSource = self;
  103. [self reloadNetSourse];
  104. [UIView animateWithDuration:0.25 animations:^{
  105. // self.center = CGPointMake(kScreenW / 2, kScreenH / 2);
  106. self.bottom = kScreenHeight;
  107. self.shadowView.alpha = 1;
  108. }];
  109. }
  110. - (void)hide{
  111. [UIView animateWithDuration:0.25 animations:^{
  112. self.frame = CGRectMake(0, kScreenHeight, self.width, self.height);
  113. self.shadowView.alpha = 0;
  114. } completion:^(BOOL finished) {
  115. [self removeFromSuperview];
  116. [self.shadowView removeFromSuperview];
  117. }];
  118. }
  119. @end