BGOpenRedPackView.m 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //
  2. // BGReadPackListView.m
  3. // BuguLive
  4. //
  5. // Created by 志刚杨 on 2021/12/23.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BGOpenRedPackView.h"
  9. #import "BGReadPackTableViewCell.h"
  10. #import "BGRedPackModel.h"
  11. #import "BGRedPackResultView.h"
  12. #import <QMUIKit/QMUIKit.h>
  13. @interface BGOpenRedPackView()
  14. @property(nonatomic, strong) UITableView *myTableView;
  15. @property(nonatomic, strong) UILabel *labCount;
  16. @property(nonatomic, strong) NSArray *list;
  17. @property(nonatomic, strong) UIImageView *avatar;
  18. @property(nonatomic, strong) UILabel *nickname;
  19. @end
  20. @implementation BGOpenRedPackView
  21. - (instancetype)init
  22. {
  23. self = [super init];
  24. if (self) {
  25. [self initWithTableView];
  26. }
  27. return self;
  28. }
  29. - (void)initWithTableView {
  30. self.list = [NSArray array];
  31. UIImageView *bgImg = [[UIImageView alloc] init];
  32. bgImg.image = [UIImage imageNamed:@"hongbao_bgm"];
  33. self.backgroundColor = kClearColor;
  34. [self addSubview:bgImg];
  35. UIImageView *imgOpen = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yuan"]];
  36. [self addSubview:imgOpen];
  37. [imgOpen mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.top.equalTo(@(80.5));
  39. make.height.and.width.equalTo(@(120));
  40. make.centerX.equalTo(self);
  41. }];
  42. //添加手势
  43. UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGestureRecognizer)];
  44. [imgOpen addGestureRecognizer:tapGesture];
  45. imgOpen.userInteractionEnabled = YES;
  46. UILabel *labOpen = [[UILabel alloc] init];
  47. labOpen.text = @"Get";
  48. labOpen.textColor = kRedColor;
  49. labOpen.font = [UIFont boldSystemFontOfSize:29];
  50. [self addSubview:labOpen];
  51. [labOpen mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.center.equalTo(imgOpen);
  53. }];
  54. [bgImg mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.edges.equalTo(self);
  56. }];
  57. UILabel *labtitle = [[UILabel alloc] init];
  58. labtitle.text = ASLocalizedString(@"恭喜发财,大吉大利");
  59. labtitle.font = [UIFont systemFontOfSize:24];
  60. labtitle.textColor = [UIColor colorWithHexString:@"#FFC601"];
  61. [self addSubview:labtitle];
  62. [labtitle mas_makeConstraints:^(MASConstraintMaker *make) {
  63. make.centerX.equalTo(self);
  64. make.top.mas_equalTo(imgOpen.mas_bottom).offset(12);
  65. }];
  66. self.avatar = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@""]];
  67. [self addSubview:self.avatar];
  68. [self.avatar mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.top.equalTo(labtitle.mas_bottom).offset(30);
  70. make.height.and.width.equalTo(@kRealValue(70));
  71. make.centerX.equalTo(self);
  72. }];
  73. ViewRadius(self.avatar, kRealValue(70)/2);
  74. _labCount = [[UILabel alloc] init];//Нийт
  75. _labCount.text = @"nickname";
  76. _labCount.font = [UIFont systemFontOfSize:18];
  77. _labCount.textColor = [UIColor colorWithHexString:@"#ffffff"];
  78. [self addSubview:_labCount];
  79. [_labCount mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.centerX.equalTo(self);
  81. make.top.mas_equalTo(self.avatar.mas_bottom).offset(8.5);
  82. }];
  83. // self.qmui_borderPosition = QMUIViewBorderPositionBottom;
  84. // self
  85. // self.qmui_borderWidth = 1;
  86. }
  87. - (void)handleTapGestureRecognizer {
  88. [self requestData];
  89. }
  90. - (void)setUserModel:(BGRedPackModel *)userModel
  91. {
  92. _userModel = userModel;
  93. [self.avatar sd_setImageWithURL:[NSURL URLWithString:userModel.head_image]];
  94. self.labCount.text = userModel.nick_name;
  95. }
  96. - (void)requestData{
  97. NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
  98. [dict setValue:@"surprise" forKey:@"ctl"];
  99. [dict setValue:@"requestGetSurprise" forKey:@"act"];
  100. [dict setValue:self.userModel.id forKey:@"surprise_id"];
  101. [[NetHttpsManager manager] POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) {
  102. NSLog(@"104responseJson%@",responseJson);
  103. if ([responseJson toInt:@"status"] == 1) {
  104. // BGRedPackModel *user = self.list[indexPath.row];
  105. [self hide];
  106. BGRedPackResultView *readView = [[BGRedPackResultView alloc] init];
  107. // readView.video_id = self.video_id;
  108. readView.model = self.userModel;
  109. readView.frame = CGRectMake(40, 0, kRealValue(266), kRealValue(338));
  110. readView.centerX = self.centerX;
  111. readView.centerY = self.centerY;
  112. // readView.userModel = user;
  113. // readView.backgroundColor = kRedColor;
  114. readView.diamonds = [NSString stringWithFormat:@"%@",responseJson[@"diamonds"]];
  115. [readView show:[TCUtil currentViewController].view type:FDPopTypeCenter];
  116. // [readView show:[AppDelegate sharedAppDelegate].topViewController.view type:FDPopTypeCenter];
  117. }else{
  118. //error
  119. [BGHUDHelper alert:responseJson[@"error"]];
  120. }
  121. } FailureBlock:^(NSError *error) {
  122. NSLog(NSLocalizedString(@"守护列表请求数据失败error:%@", nil),error);
  123. }];
  124. }
  125. #pragma mark UITableViewDelegate, UITableViewDataSource
  126. @end