MOGuildStartVC.m 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. //
  2. // MOGuildStartVC.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2023/10/25.
  6. //
  7. #import "MOGuildStartVC.h"
  8. #import "MOGuildApplyView.h"
  9. #import "MOSquareTopMenuView.h"
  10. #import "MOGuildStartView.h"
  11. #import "MOGuildSMSVC.h"
  12. #import "MOGuildApplyVC.h"
  13. #import "MOMyGuildInfoView.h"
  14. #import "MOGuildDataModels.h"
  15. @interface MOGuildStartVC ()
  16. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *backBtnTop;
  17. @property (weak, nonatomic) IBOutlet UILabel *leadLab;
  18. /** 顶部的容器View */
  19. @property (nonatomic, strong) UIView *topContantView;
  20. /** 没有工会或者工会在审核中 展示该View */
  21. @property (nonatomic, strong) MOGuildApplyView *guildStartView;
  22. /** 有工会则展示该View */
  23. @property (nonatomic, strong) MOMyGuildInfoView *guildInfoView;
  24. /** 切换状态栏 */
  25. @property (nonatomic, strong) MOSquareTopMenuView *guildChangeView;
  26. /** 底部tableView */
  27. @property (nonatomic, strong) MOGuildStartView *latestTableView;
  28. /** 底部tableView */
  29. @property (nonatomic, strong) MOGuildStartView *powerTableView;
  30. /** 总数据 */
  31. @property (nonatomic, strong) MOGuildData *baseData;
  32. @end
  33. @implementation MOGuildStartVC
  34. - (void)viewWillAppear:(BOOL)animated{
  35. [super viewWillAppear:animated];
  36. [self.navigationController setNavigationBarHidden:YES animated:animated];
  37. }
  38. - (void)viewDidLoad {
  39. [super viewDidLoad];
  40. // Do any additional setup after loading the view from its nib.
  41. [self setupUI];
  42. [self getHttpData];
  43. }
  44. - (void)setupUI{
  45. self.leadLab.text = NSLocalString(@"mimo_guild_application_to_settle_in");
  46. CGFloat statusBarHeight = STATUS_BAR_HEIGHT;
  47. self.backBtnTop.constant = statusBarHeight + 12.0;
  48. self.view.backgroundColor = [MOTools colorWithHexString:@"#F4F0F5" alpha:1.0];
  49. CGFloat guildStartHeight = [self.guildStartView getViewHeight];
  50. [self.view addSubview:self.guildStartView];
  51. [self.guildStartView mas_makeConstraints:^(MASConstraintMaker *make) {
  52. make.top.equalTo(self.leadLab.mas_bottom).offset(17.0);
  53. make.left.equalTo(self.view).offset(15.0);
  54. make.right.equalTo(self.view).offset(-15.0);
  55. make.height.equalTo(@(guildStartHeight));
  56. }];
  57. [self.view addSubview:self.guildChangeView];
  58. [self.guildChangeView mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.top.equalTo(self.guildStartView.mas_bottom).offset(15.0);
  60. make.left.equalTo(self.view).offset(17.0);
  61. make.height.equalTo(@30.0);
  62. make.right.equalTo(self.view).offset(-17.0);
  63. }];
  64. self.guildChangeView.currentButtonIndex = 0;
  65. [self.view addSubview:self.latestTableView];
  66. [self.latestTableView mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.top.equalTo(self.guildChangeView.mas_bottom).offset(10.0);
  68. make.left.equalTo(self.view).offset(15.0);
  69. make.right.equalTo(self.view).offset(-15.0);
  70. make.bottom.equalTo(self.view);
  71. }];
  72. [self.view addSubview:self.powerTableView];
  73. [self.powerTableView mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.top.equalTo(self.guildChangeView.mas_bottom).offset(10.0);
  75. make.left.equalTo(self.view).offset(15.0);
  76. make.right.equalTo(self.view).offset(-15.0);
  77. make.bottom.equalTo(self.view);
  78. }];
  79. }
  80. - (void)setUIWithProperty{
  81. if(self.baseData.status == 2){
  82. CGFloat newHeight = [MOMyGuildInfoView getViewHeight];
  83. //已有工会
  84. [self.guildStartView mas_updateConstraints:^(MASConstraintMaker *make) {
  85. make.height.equalTo(@(newHeight));
  86. }];
  87. self.guildStartView.hidden = YES;
  88. [self.view addSubview:self.guildInfoView];
  89. [self.guildInfoView mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.top.equalTo(self.leadLab.mas_bottom).offset(17.0);
  91. make.left.equalTo(self.view).offset(15.0);
  92. make.right.equalTo(self.view).offset(-15.0);
  93. make.height.equalTo(@(newHeight));
  94. }];
  95. MOGuildBase *meGuildModle = self.baseData.guildBase;
  96. [self.guildInfoView.iconImg sd_setImageWithURL:[NSURL URLWithString:meGuildModle.logo]];
  97. self.guildInfoView.unionNameLab.text = meGuildModle.name;
  98. [self.guildInfoView.guildIdBtn setTitle:[NSString stringWithFormat:@"ID %@",meGuildModle.no] forState:UIControlStateNormal];
  99. [self.guildInfoView.anchorNumBtn setTitle:[NSString stringWithFormat:@"Anchor %.f",meGuildModle.anchor] forState:UIControlStateNormal];
  100. MOCountryList *countryModel;
  101. if(meGuildModle.country != 0){
  102. countryModel = (MOCountryList *)[[MODataCache sharedYYCache] objectForKey:[NSString stringWithFormat:@"%@_%@",kCountryArrInfo,meGuildModle.country]];
  103. }
  104. if(countryModel){
  105. [self.guildInfoView.countryImg sd_setImageWithURL:[NSURL URLWithString:countryModel.icon]];
  106. }
  107. else{
  108. self.guildInfoView.countryImg.hidden = YES;
  109. }
  110. self.leadLab.text = NSLocalString(@"mimo_me_guild_center");
  111. }
  112. else if (self.baseData.status == 1){
  113. //申请中
  114. [self.guildStartView.doneBtn setTitle:NSLocalString(@"mimo_guild_applying") forState:UIControlStateNormal];
  115. }
  116. }
  117. - (IBAction)backBtnClick:(id)sender {
  118. [self.navigationController popViewControllerAnimated:YES];
  119. }
  120. #pragma mark - Http
  121. - (void)getHttpData{
  122. WEAKSELF
  123. [kHttpManager toGetGuildAboutGuideWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  124. if(kCode_Success){
  125. MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  126. __strong typeof(weakSelf) self = weakSelf;
  127. self.baseData = [MOGuildData modelObjectWithDictionary:data[@"data"]];
  128. self.latestTableView.dataArr = [self.baseData.guidlLatest mutableCopy];
  129. self.powerTableView.dataArr = [self.baseData.guildPower mutableCopy];
  130. [self setUIWithProperty];
  131. }
  132. else{
  133. kShowNetError(data)
  134. }
  135. }];
  136. }
  137. #pragma mark - Lazy
  138. - (MOGuildApplyView *)guildStartView{
  139. if(!_guildStartView){
  140. _guildStartView = [MOGuildApplyView moGuildApplyView];
  141. WEAKSELF
  142. //MARK: 申请工会按钮
  143. _guildStartView.doneBtnBlock = ^{
  144. //审核中
  145. if(weakSelf.baseData.status == 1){
  146. MOGuildApplyVC *vc = [[MOGuildApplyVC alloc] init];
  147. vc.isApply = YES;
  148. [weakSelf.navigationController pushViewController:vc animated:YES];
  149. }
  150. else{
  151. MOGuildSMSVC *vc = [[MOGuildSMSVC alloc] init];
  152. [weakSelf.navigationController pushViewController:vc animated:YES];
  153. }
  154. };
  155. }
  156. return _guildStartView;
  157. }
  158. - (MOMyGuildInfoView *)guildInfoView{
  159. if(!_guildInfoView){
  160. _guildInfoView = [MOMyGuildInfoView moMyGuildInfoView];
  161. }
  162. return _guildInfoView;
  163. }
  164. - (MOSquareTopMenuView *)guildChangeView{
  165. if(!_guildChangeView){
  166. CGFloat width = SCREENWIDTH - 20 * 2 - 12.0 - 10.0 - 15.0 - 5.0;
  167. _guildChangeView = [[MOSquareTopMenuView alloc] initWithFrame:CGRectMake(0.0, 0.0, width, 30.0)];
  168. _guildChangeView.titleArray = @[NSLocalString(@"mimo_Guild_Recently"),NSLocalString(@"mimo_Guild_Strength")];
  169. }
  170. return _guildChangeView;
  171. }
  172. - (void)setGuildChangeBlock{
  173. WEAKSELF
  174. //顶部直播类别切换回调
  175. self.guildChangeView.clickBtnBlock = ^(NSInteger index) {
  176. __strong typeof(weakSelf) self = weakSelf;
  177. if (index == 0){
  178. self.latestTableView.hidden = NO;
  179. self.powerTableView.hidden = YES;
  180. }
  181. else{
  182. self.latestTableView.hidden = YES;
  183. self.powerTableView.hidden = NO;
  184. }
  185. };
  186. }
  187. - (MOGuildStartView *)latestTableView{
  188. if(!_latestTableView){
  189. _latestTableView = [[MOGuildStartView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  190. _latestTableView.backgroundColor = [MOTools colorWithHexString:@"#F5F1F6" alpha:1.0];
  191. _latestTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  192. _latestTableView.separatorInset = UIEdgeInsetsZero;
  193. _latestTableView.rowHeight = 78.0;
  194. }
  195. return _latestTableView;
  196. }
  197. - (MOGuildStartView *)powerTableView{
  198. if(!_powerTableView){
  199. _powerTableView = [[MOGuildStartView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
  200. _powerTableView.backgroundColor = [MOTools colorWithHexString:@"#F5F1F6" alpha:1.0];
  201. _powerTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  202. _powerTableView.separatorInset = UIEdgeInsetsZero;
  203. _powerTableView.rowHeight = 78.0;
  204. _powerTableView.hidden = YES;
  205. }
  206. return _powerTableView;
  207. }
  208. @end