BogoInviteViewController.m 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. //
  2. // BogoInviteViewController.m
  3. // UniversalApp
  4. //
  5. // Created by Mac on 2021/6/9.
  6. // Copyright © 2021 voidcat. All rights reserved.
  7. //
  8. #import "BogoInviteViewController.h"
  9. #import "BogoInviteResponseModel.h"
  10. #import "BogoInviteListCell.h"
  11. #import "BogoInviteDetailViewController.h"
  12. #import "CommonShareView.h"
  13. #import "BogoInviteRuleViewController.h"
  14. #import "BogoShareViewController.h"
  15. #import "BogoNetworkKit.h"
  16. #import "UITableView+XY.h"
  17. @interface BogoInviteViewController ()<UITableViewDelegate,UITableViewDataSource,CommonShareViewDelegate>
  18. @property (weak, nonatomic) IBOutlet QMUIButton *logBtn;
  19. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  20. @property (weak, nonatomic) IBOutlet QMUIButton *moreBtn;
  21. @property (weak, nonatomic) IBOutlet UILabel *total_moneyLabel;
  22. @property (weak, nonatomic) IBOutlet UILabel *countLabel;
  23. @property (weak, nonatomic) IBOutlet UILabel *two_countLabel;
  24. @property (weak, nonatomic) IBOutlet UILabel *man_oneLabel;
  25. @property (weak, nonatomic) IBOutlet UILabel *man_twoLabel;
  26. @property (weak, nonatomic) IBOutlet UILabel *wman_oneLabel;
  27. @property (weak, nonatomic) IBOutlet UILabel *wman_twoLabel;
  28. @property (weak, nonatomic) IBOutlet UIButton *inviteBtn;
  29. @property(nonatomic, strong) BogoInviteResponseModel *model;
  30. @property(nonatomic, strong) CommonShareView *shareView;
  31. @property (weak, nonatomic) IBOutlet UIView *logView;
  32. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *contentHeight;
  33. @property (nonatomic,strong) UIImageView* noDataView;
  34. @property (nonatomic,strong) UILabel* noDataLabel;
  35. @end
  36. @implementation BogoInviteViewController
  37. - (void)viewDidLoad {
  38. [super viewDidLoad];
  39. // Do any additional setup after loading the view from its nib.
  40. self.title =ASLocalizedString( @"邀请好友");
  41. self.logBtn.imagePosition = QMUIButtonImagePositionRight;
  42. self.logBtn.spacingBetweenImageAndTitle = 5;
  43. self.logBtn.layer.borderWidth = 1;
  44. self.logBtn.layer.borderColor = [UIColor colorWithHexString:@"F42416"].CGColor;
  45. self.tableView.delegate = self;
  46. self.tableView.dataSource = self;
  47. [self.tableView registerNib:[UINib nibWithNibName:@"BogoInviteListCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"BogoInviteListCell"];
  48. self.moreBtn.imagePosition = QMUIButtonImagePositionRight;
  49. self.moreBtn.spacingBetweenImageAndTitle = 5;
  50. CAGradientLayer *gl = [CAGradientLayer layer];
  51. gl.frame = self.inviteBtn.bounds;
  52. gl.startPoint = CGPointMake(1, 0.5);
  53. gl.endPoint = CGPointMake(0, 0.5);
  54. gl.colors = @[(__bridge id)[UIColor colorWithHexString:@"#FF9D45"].CGColor, (__bridge id)[UIColor colorWithHexString:@"#F4491F"].CGColor];
  55. gl.locations = @[@(0), @(1.0f)];
  56. [self.inviteBtn.layer insertSublayer:gl atIndex:0];
  57. [self setUpLocalizationString];
  58. [self requestData];
  59. }
  60. - (IBAction)ruleBtnAction:(UIButton *)sender {
  61. BogoInviteRuleViewController *ruleVC = [[BogoInviteRuleViewController alloc]init];
  62. ruleVC.content = self.model.protal;
  63. [self.navigationController pushViewController:ruleVC animated:YES];
  64. }
  65. - (IBAction)logBtnAction:(QMUIButton *)sender {
  66. BogoInviteDetailViewController *detailVC = [[BogoInviteDetailViewController alloc]init];
  67. [self.navigationController pushViewController:detailVC animated:YES];
  68. }
  69. - (void)requestData{
  70. // /mapi/index.php?ctl=invite_vue&act=invite_index_new
  71. [[BogoNetwork shareInstance] POSTV4:@"" param:@{@"ctl":@"invite_vue",@"act":@"invite_index_new"} success:^(id _Nonnull result) {
  72. self.model = [BogoInviteResponseModel mj_objectWithKeyValues:result];
  73. self.moreBtn.hidden = self.model.lists.count < 3;
  74. self.logView.hidden = NO;
  75. // !self.model.lists.count;
  76. // if (self.model.lists.count) {
  77. self.contentHeight.constant = 773;
  78. if (self.model.lists.count < 1) {
  79. // [self xy_noDataViewImage];
  80. // [self xy_noDataViewMessage];
  81. [self showNoDataImage];
  82. }else{
  83. [self removeNoDataImage];
  84. }
  85. [self.tableView reloadData];
  86. // }else{
  87. // self.contentHeight.constant = 508;
  88. // }
  89. self.total_moneyLabel.text = self.model.data.total_money;
  90. self.countLabel.text = self.model.data.count;
  91. self.two_countLabel.text = self.model.data.two_count;
  92. self.man_oneLabel.text = [NSString stringWithFormat:@"%@%%",self.model.reward.one];
  93. self.man_twoLabel.text = [NSString stringWithFormat:@"%@%%",self.model.reward.two];
  94. } failure:^(NSString * _Nonnull error) {
  95. [[BGHUDHelper sharedInstance] tipMessage:error];
  96. }];
  97. }
  98. - (IBAction)inviteBtnAction:(UIButton *)sender {
  99. // [self.shareView show:self.view];
  100. BogoShareViewController *shareVC = [[BogoShareViewController alloc]init];
  101. [self.navigationController pushViewController:shareVC animated:YES];
  102. }
  103. #pragma mark - CommonShareViewDelegate
  104. - (void)shareView:(CommonShareView *)shareView didClickBtn:(QMUIButton *)sender{
  105. UMSocialMessageObject *messageObject = [UMSocialMessageObject messageObject];
  106. UMShareWebpageObject *shareObject = [UMShareWebpageObject shareObjectWithTitle:@"" descr:@"" thumImage:nil];
  107. // shareObject.webpageUrl = [NSString stringWithFormat:@"%@?invite_code=%@",[GlobalVariable sharedGlobalVariable].appmodel.app_h5.download_url,[IMAPlatform sharedInstance].host.userId];
  108. [UIPasteboard generalPasteboard].string = shareObject.webpageUrl;
  109. messageObject.shareObject = shareObject;
  110. if (sender.tag - kRoomShareViewBaseBtnTag == UMSocialPlatformType_WechatSession) {
  111. // if (![WXApi isWXAppInstalled]) {
  112. // [[BGHUDHelper sharedInstance] tipMessage:ASLocalizedString(@"未安装微信")];
  113. // return;
  114. // }
  115. }
  116. [[UMSocialManager defaultManager] shareToPlatform:sender.tag - kRoomShareViewBaseBtnTag messageObject:messageObject currentViewController:self completion:^(id result, NSError *error) {
  117. if (error) {
  118. [[BGHUDHelper sharedInstance] tipMessage:error.localizedDescription];
  119. }else{
  120. [[BGHUDHelper sharedInstance] tipMessage:NSLocalizedString(@"分享成功",nil)];
  121. }
  122. }];
  123. }
  124. #pragma mark - UITableViewDelegate,UITableViewDataSource
  125. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  126. return 1;
  127. }
  128. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  129. return self.model.lists.count > 3 ? 3 : self.model.lists.count;
  130. }
  131. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  132. BogoInviteListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BogoInviteListCell" forIndexPath:indexPath];
  133. if (indexPath.row < self.model.lists.count) {
  134. cell.model = self.model.lists[indexPath.row];
  135. }
  136. return cell;
  137. }
  138. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  139. return 54;
  140. }
  141. - (CommonShareView *)shareView{
  142. if (!_shareView) {
  143. _shareView = [[CommonShareView alloc]initWithFrame:CGRectMake(0, kScreenHeight, kScreenW, 190+FD_Bottom_SafeArea_Height)];
  144. _shareView.delegate = self;
  145. }
  146. return _shareView;
  147. }
  148. - (UIImage *)xy_noDataViewImage{
  149. return imageNamed(@"暂无数据");
  150. }
  151. - (NSString *)xy_noDataViewMessage{
  152. return ASLocalizedString( @"暂无记录");
  153. }
  154. -(void)showNoDataImage
  155. {
  156. UIImage *image=[UIImage imageNamed:@"bogo_common_empty"];
  157. // 计算位置, 垂直居中, 图片默认中心偏上.
  158. CGFloat sW = self.tableView.width;
  159. CGFloat cX = sW / 2;
  160. CGFloat cY = self.tableView.height * (1 - 0.618) + 0;
  161. CGFloat iW = image.size.width;
  162. CGFloat iH = image.size.height;
  163. // 图片
  164. _noDataView=[[UIImageView alloc] init];
  165. [_noDataView setImage:image];
  166. _noDataView.contentMode = UIViewContentModeScaleAspectFit;
  167. _noDataView.frame = CGRectMake(cX - iW / 2, cY - iH / 2, iW, iH);
  168. // 文字
  169. _noDataLabel = [[UILabel alloc] init];
  170. _noDataLabel.font = [UIFont systemFontOfSize:17];
  171. _noDataLabel.textColor = [UIColor lightGrayColor];;
  172. _noDataLabel.text =ASLocalizedString( @"暂无数据");
  173. _noDataLabel.textAlignment = NSTextAlignmentCenter;
  174. _noDataLabel.frame = CGRectMake(0, CGRectGetMaxY(_noDataView.frame) + 24, sW, _noDataLabel.font.lineHeight);
  175. [self.tableView addSubview:_noDataView];
  176. [self.tableView addSubview:_noDataLabel];
  177. }
  178. -(void)removeNoDataImage{
  179. if (_noDataView) {
  180. [_noDataView removeFromSuperview];
  181. _noDataView = nil;
  182. [_noDataLabel removeAllSubviews];
  183. _noDataLabel=nil;
  184. }
  185. }
  186. @end