BGRedPackSendView.m 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. //
  2. // BGReadPackListView.m
  3. // BuguLive
  4. //
  5. // Created by 志刚杨 on 2021/12/23.
  6. // Copyright © 2021 xfg. All rights reserved.
  7. //
  8. #import "BGRedPackSendView.h"
  9. #import "BGReadPackTableViewCell.h"
  10. #import "BGRedPackModel.h"
  11. #import <QMUIKit/QMUIKit.h>
  12. #import "BGReadTextView.h"
  13. @interface BGRedPackSendView()
  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. @property(nonatomic, strong) UILabel *labDiamonds;
  20. @property(nonatomic, strong) BGReadTextView *txtCoin;
  21. @property(nonatomic, strong) BGReadTextView *txtNumber;
  22. @end
  23. @implementation BGRedPackSendView
  24. - (instancetype)init
  25. {
  26. self = [super init];
  27. if (self) {
  28. [self initWithTableView];
  29. }
  30. return self;
  31. }
  32. - (void)initWithTableView {
  33. self.list = [NSArray array];
  34. UIImageView *bgImg = [[UIImageView alloc] init];
  35. bgImg.image = [UIImage imageNamed:@"fahongbao_bgm"];
  36. self.backgroundColor = kClearColor;
  37. [self addSubview:bgImg];
  38. // UIImageView *imgOpen = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yuan"]];
  39. // [self addSubview:imgOpen];
  40. // [imgOpen mas_makeConstraints:^(MASConstraintMaker *make) {
  41. // make.top.equalTo(@(80.5));
  42. // make.height.and.width.equalTo(@(120));
  43. // make.centerX.equalTo(self);
  44. // }];
  45. //
  46. // //添加手势
  47. // UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGestureRecognizer)];
  48. // [imgOpen addGestureRecognizer:tapGesture];
  49. // imgOpen.userInteractionEnabled = YES;
  50. //
  51. // UILabel *labOpen = [[UILabel alloc] init];
  52. // labOpen.text = @"Get";
  53. // labOpen.textColor = kRedColor;
  54. // labOpen.font = [UIFont boldSystemFontOfSize:29];
  55. //
  56. // [self addSubview:labOpen];
  57. // [labOpen mas_makeConstraints:^(MASConstraintMaker *make) {
  58. // make.center.equalTo(imgOpen);
  59. // }];
  60. [bgImg mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.edges.equalTo(self);
  62. }];
  63. UILabel *labtitle = [[UILabel alloc] init];
  64. labtitle.text = ASLocalizedString(@"直播间红包");
  65. labtitle.font = [UIFont systemFontOfSize:24];
  66. labtitle.textColor = [UIColor colorWithHexString:@"#FFC601"];
  67. [self addSubview:labtitle];
  68. [labtitle mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.centerX.equalTo(self);
  70. make.top.mas_equalTo(11);
  71. }];
  72. _labCount = [[UILabel alloc] init];//Нийт
  73. _labCount.text = ASLocalizedString(@"给当前直播间观众发红包");
  74. _labCount.font = [UIFont systemFontOfSize:15];
  75. _labCount.textColor = [UIColor colorWithHexString:@"#ffffff"];
  76. [self addSubview:_labCount];
  77. [_labCount mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.centerX.equalTo(self);
  79. make.top.mas_equalTo(labtitle.mas_bottom).offset(13.5);
  80. // make.height.equalTo(@25);
  81. make.left.equalTo(@10);
  82. make.right.equalTo(@(-10));
  83. }];
  84. _labCount.preferredMaxLayoutWidth = kRealValue(236);
  85. [_labCount setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical];
  86. _labCount.numberOfLines = 0;
  87. _labCount.lineBreakMode = NSLineBreakByWordWrapping;
  88. self.txtCoin = [BGReadTextView instanceView];
  89. self.txtCoin.labName.text = ASLocalizedString(@"总金额");
  90. self.txtCoin.labDes.text = ASLocalizedString(@"钻石");
  91. ViewRadius(self.txtCoin, 3);
  92. self.txtCoin.textFiled.placeholder = @"0";
  93. self.txtCoin.textFiled.textColor = [UIColor colorWithHexString:@"#FFD201"];
  94. [self addSubview:self.txtCoin];
  95. [self.txtCoin mas_makeConstraints:^(MASConstraintMaker *make) {
  96. make.left.and.equalTo(@(kRealValue(21.5)));
  97. make.right.and.equalTo(@(kRealValue(-21.5)));
  98. make.height.equalTo(@44);
  99. make.top.equalTo(_labCount.mas_bottom).offset(36);
  100. }];
  101. self.txtNumber = [BGReadTextView instanceView];
  102. self.txtNumber.labName.text = ASLocalizedString(@"数量");
  103. self.txtNumber.labDes.text = ASLocalizedString(@"个");
  104. ViewRadius(self.txtNumber, 3);
  105. self.txtNumber.textFiled.placeholder = @"0";
  106. [self addSubview:self.txtNumber];
  107. [self.txtNumber mas_makeConstraints:^(MASConstraintMaker *make) {
  108. make.left.and.equalTo(@(kRealValue(21.5)));
  109. make.right.and.equalTo(@(kRealValue(-21.5)));
  110. make.height.equalTo(@44);
  111. make.top.equalTo(self.txtCoin.mas_bottom).offset(9.5);
  112. }];
  113. // self.labDiamonds = [[UILabel alloc] init];
  114. //// labtitle.text = NSLocalizedString(@"恭喜你!", nil);
  115. // self.labDiamonds.font = [UIFont systemFontOfSize:24];
  116. // self.labDiamonds.textColor = [UIColor colorWithHexString:@"#FFC601"];
  117. // [self addSubview:self.labDiamonds];
  118. // [self.labDiamonds mas_makeConstraints:^(MASConstraintMaker *make) {
  119. // make.top.equalTo(self.labCount.mas_bottom).offset(18.5);
  120. // make.centerX.equalTo(self);
  121. // make.height.equalTo(@30);
  122. //
  123. //// make.top.mas_equalTo(imgOpen.mas_bottom).offset(12);
  124. // }];
  125. //
  126. //
  127. QMUIFillButton *btnGetList = [[QMUIFillButton alloc] initWithFillColor:[UIColor colorWithHexString:@"#FFD201"] titleTextColor:[UIColor colorWithHexString:@"#FF0303"]];;
  128. [self addSubview:btnGetList];
  129. [btnGetList setTitle:ASLocalizedString(@"发送红包") forState:UIControlStateNormal];
  130. btnGetList.titleLabel.font = [UIFont systemFontOfSize:14];
  131. [btnGetList mas_makeConstraints:^(MASConstraintMaker *make) {
  132. make.width.equalTo(@(kRealValue(122)));
  133. make.height.equalTo(@(kRealValue(40)));
  134. make.centerX.equalTo(self);
  135. make.top.equalTo(self.txtNumber.mas_bottom).offset(30);
  136. }];
  137. [btnGetList addTarget:self action:@selector(handleSendEvent) forControlEvents:UIControlEventTouchUpInside];
  138. // "request": {
  139. // "requestData": "gVNZH4R74Sq5RLDpBIHnQ9\/W1XjhpEDIXENmWhDgomVRKEDpy8StjwlNV0REKMiAi4yYiKFxOmqV\nbobIvgHSbPjeSGIevZlgBWtRAGwulo+1t0zRbytnl\/ad81ToV9l+B5fe3vW5hAfnM0fzTKlT3ega\njOURhfjucQcSoTxBaNCACDuCccc2UTvJp+EwPndQXijp2bb2NaPCg5IPU2EzMjDa0HsmstEq1wfo\nCYjxuyuYfmWBk1nMj+AqdbiAFggsZWWU\/4wcXSDZvk2ql3v7QN\/jQ14BG+ZBAhUSQwFOG8YUGqvr\nn1sPXIbt0BCbDE8kYttX6jRXuEU1yDkQEt2Odg==\n",
  140. // "i_type": "1",
  141. // "ctl": "surprise",
  142. // "act": "requestSendSurprise",
  143. // "screen_width": 1080,
  144. // "screen_height": 2356,
  145. // "sdk_type": "android",
  146. // "sdk_version_name": "3.5",
  147. // "sdk_version": 2021122101,
  148. // "session_id": "0",
  149. // "video_id": "40556",
  150. // "diamonds": "1",
  151. // "people_quantity": "1",
  152. // "content": ""
  153. // }
  154. }
  155. - (void)setDiamonds:(NSString *)diamonds
  156. {
  157. // _diamonds = diamonds;
  158. self.labDiamonds.text = [NSString stringWithFormat:@"%@%@",ASLocalizedString(@"钻石"),diamonds];
  159. }
  160. - (void)handleSendEvent {
  161. NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
  162. [dict setValue:@"surprise" forKey:@"ctl"];
  163. [dict setValue:@"requestSendSurprise" forKey:@"act"];
  164. [dict setValue:self.video_id forKey:@"video_id"];
  165. if([BGUtils isBlankString:self.txtCoin.textFiled.text])
  166. {
  167. [BGHUDHelper alert:ASLocalizedString(@"请输入金额")];
  168. return;
  169. }
  170. if([BGUtils isBlankString:self.txtNumber.textFiled.text])
  171. {
  172. [BGHUDHelper alert:ASLocalizedString(@"请输入数量")];
  173. return;
  174. }
  175. [dict setValue:self.txtCoin.textFiled.text forKey:@"diamonds"];
  176. [dict setValue:self.txtNumber.textFiled.text forKey:@"people_quantity"];
  177. // "diamonds": "1",
  178. // "people_quantity": "1",
  179. [[NetHttpsManager manager] POSTWithParameters:dict SuccessBlock:^(NSDictionary *responseJson) {
  180. NSLog(@"104responseJson%@",responseJson);
  181. if ([responseJson toInt:@"status"] == 1) {
  182. [self hide];
  183. }else{
  184. [BGHUDHelper alert:responseJson[@"error"]];
  185. //接口请求失败
  186. NSLog(NSLocalizedString(@"守护列表请求数据失败responseJson:%@", nil),responseJson);
  187. }
  188. } FailureBlock:^(NSError *error) {
  189. NSLog(NSLocalizedString(@"守护列表请求数据失败error:%@", nil),error);
  190. }];
  191. }
  192. - (void)handleTapGestureRecognizer {
  193. }
  194. - (void)setUserModel:(BGRedPackModel *)userModel
  195. {
  196. // _userModel = userModel;
  197. [self.avatar sd_setImageWithURL:[NSURL URLWithString:userModel.head_image]];
  198. self.labCount.text = userModel.nick_name;
  199. }
  200. - (void)requestData{
  201. }
  202. #pragma mark UITableViewDelegate, UITableViewDataSource
  203. @end