MOFanClubCreateVC.m 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. //
  2. // MOFanClubCreateVC.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2023/10/29.
  6. //
  7. #import "MOFanClubCreateVC.h"
  8. #import "MOGuildInputBaseCell.h"
  9. #import "MONameplateCell.h"
  10. #import "MOEidtNameplateVC.h"
  11. @interface MOFanClubCreateVC ()
  12. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *backBtnTop;
  13. @property (weak, nonatomic) IBOutlet UILabel *titleLab;
  14. @property (weak, nonatomic) IBOutlet UIImageView *bgImgView;
  15. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  16. @property (weak, nonatomic) IBOutlet UIButton *submitBtn;
  17. /** 粉丝团名称 */
  18. @property (nonatomic, copy) NSString *fanClubName;
  19. /** 铭牌名称 */
  20. @property (nonatomic, copy) NSString *nameplateName;
  21. @property (weak, nonatomic) IBOutlet UILabel *tipLab;
  22. @end
  23. @implementation MOFanClubCreateVC
  24. - (void)viewWillAppear:(BOOL)animated{
  25. [super viewWillAppear:animated];
  26. [self.navigationController setNavigationBarHidden:NO animated:animated];
  27. [self mo_setNavLeftItemWithImage:[UIImage imageNamed:@"icon_new_left_gray"] andBackgroundImg:[UIImage imageNamed:@"icon_mine_base_bg"]];
  28. }
  29. - (void)viewDidLoad {
  30. [super viewDidLoad];
  31. // Do any additional setup after loading the view from its nib.
  32. if(self.isEdit){
  33. self.navigationItem.title = NSLocalString(@"mimo_fans_club_settings");
  34. }
  35. else{
  36. self.navigationItem.title = @"Create Fan Club";
  37. }
  38. // [self setNavLeftItemWithImage:[UIImage imageNamed:@"icon_nav_back"]];
  39. self.titleLab.text = NSLocalString(@"mimo_fans_club_create_club");
  40. self.tipLab.text = NSLocalString(@"mimo_fans_fans_club_create_condition");
  41. [self setupUI];
  42. }
  43. - (IBAction)closeBtnClick:(id)sender {
  44. [self.navigationController popViewControllerAnimated:YES];
  45. }
  46. #pragma mark - UITableViewDelegate,UITableViewDataSource
  47. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  48. return 1;
  49. }
  50. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  51. return 2.0;
  52. }
  53. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  54. return 55.0;
  55. }
  56. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  57. if(indexPath.row == 0){
  58. MOGuildInputBaseCell *cell = [tableView dequeueReusableCellWithIdentifier:MOGuildInputBaseCell_ID];
  59. cell.titleLab.text = NSLocalString(@"mimo_fans_fans_club_name");
  60. cell.titleLab.textColor = [UIColor blackColor];
  61. cell.backgroundColor = [UIColor clearColor];
  62. cell.inputTxf.text = self.fanClubName;
  63. WEAKSELF
  64. cell.returnTxFText = ^(NSString * _Nonnull txfString) {
  65. weakSelf.fanClubName = txfString;
  66. };
  67. return cell;
  68. }
  69. else{
  70. MONameplateCell *cell = [tableView dequeueReusableCellWithIdentifier:MONameplateCell_ID];
  71. cell.backgroundColor = [UIColor clearColor];
  72. cell.titleLab.text = NSLocalString(@"mimo_fans_fans_club_nameplate_name");
  73. cell.titleLab.textColor = [UIColor blackColor];
  74. cell.nameString = self.nameplateName;
  75. return cell;
  76. }
  77. }
  78. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  79. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  80. if(indexPath.row == 1){
  81. MOEidtNameplateVC *vc = [[MOEidtNameplateVC alloc] init];
  82. WEAKSELF
  83. vc.tempNameplateString = weakSelf.nameplateName;
  84. vc.saveBlock = ^(NSString * _Nonnull nameplateString) {
  85. weakSelf.nameplateName = nameplateString;
  86. [weakSelf.tableView reloadData];
  87. };
  88. [self.navigationController pushViewController:vc animated:YES];
  89. }
  90. }
  91. - (void)setupUI{
  92. NSArray *bgColorArr = @[[MOTools colorWithHexString:@"#EEF2FD" alpha:1.0],[MOTools colorWithHexString:@"#FAFAFC" alpha:1.0]];
  93. UIImage *bgImage = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, SCREENWIDTH, (SCREENHEIGHT - NAV_BAR_HEIGHT)) Colors:bgColorArr GradientType:1];
  94. [self.bgImgView setImage:bgImage];
  95. self.tipLab.font = [MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr];
  96. [self.submitBtn setFont:[MOTextTools getTheFontWithSize:20.0 AndFontName:kNormalContentFontStr]];
  97. if(self.isEdit){
  98. self.titleLab.text = NSLocalString(@"mimo_fans_club_settings");
  99. self.fanClubName = self.fanClubData.clubName;
  100. self.nameplateName = self.fanClubData.nameplate;
  101. }
  102. NSArray *colorArr = @[kBaseBtnBgColor,kBaseBtnBgColor];
  103. UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, (SCREENWIDTH - 36.0 * 2), 50.0) Colors:colorArr GradientType:0];
  104. [self.submitBtn setBackgroundImage:image forState:UIControlStateNormal];
  105. self.submitBtn.layer.cornerRadius = 44.0 / 2;
  106. self.submitBtn.layer.masksToBounds = YES;
  107. self.tableView.estimatedRowHeight = 0;
  108. self.tableView.estimatedSectionHeaderHeight = 0;
  109. self.tableView.estimatedSectionFooterHeight = 0;
  110. //iOS15适配
  111. if (@available(iOS 15.0, *))
  112. {
  113. self.tableView.sectionHeaderTopPadding = 0;
  114. }
  115. [self.tableView registerNib:[UINib nibWithNibName:@"MONameplateCell" bundle:nil] forCellReuseIdentifier:MONameplateCell_ID];
  116. [self.tableView registerNib:[UINib nibWithNibName:@"MOGuildInputBaseCell" bundle:nil] forCellReuseIdentifier:MOGuildInputBaseCell_ID];
  117. }
  118. //提交按钮
  119. - (IBAction)submitBtnClick:(id)sender {
  120. if(self.fanClubName.length <= 0){
  121. [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_fans_fans_club_name_tips")];
  122. return;
  123. }
  124. if(self.fanClubName.length > 16){
  125. [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_fans_fans_club_name_limit_tip")];
  126. return;
  127. }
  128. if(self.nameplateName.length <= 0){
  129. [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_fans_fans_club_nameplate_name_tips")];
  130. return;
  131. }
  132. if(self.nameplateName.length > 9){
  133. [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_fans_fans_club_nameplate_limit_tip")];
  134. return;
  135. }
  136. WEAKSELF
  137. if(!self.isEdit){
  138. //创建
  139. NSDictionary *dict = @{@"name":self.fanClubName,
  140. @"nameplate":self.nameplateName};
  141. [kHttpManager toCreateFansClubWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  142. __strong typeof(weakSelf) self = weakSelf;
  143. if(kCode_Success){
  144. [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_common_success")];
  145. //已经创建过粉丝团更新
  146. [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kIsCreatFansClub];
  147. [[NSUserDefaults standardUserDefaults] synchronize];
  148. [self performSelector:@selector(backToRootVC) withObject:nil afterDelay:1.5];
  149. }
  150. else{
  151. kShowNetError(data)
  152. }
  153. }];
  154. }
  155. else{
  156. //编辑
  157. NSDictionary *dict = @{@"name":self.fanClubName,
  158. @"nameplate":self.nameplateName,
  159. @"id":self.fanClubData.id,
  160. @"show":@(YES)};
  161. [kHttpManager toEditFansClubInfoWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  162. __strong typeof(weakSelf) self = weakSelf;
  163. if(kCode_Success){
  164. [MBProgressHUD showTipMessageInView:NSLocalString(@"mimo_common_success")];
  165. weakSelf.changeSuccessBlock ? weakSelf.changeSuccessBlock() : nil;
  166. [self performSelector:@selector(closeBtnClick:) withObject:nil afterDelay:1.5];
  167. }
  168. else{
  169. kShowNetError(data)
  170. }
  171. }];
  172. }
  173. }
  174. - (void)backToRootVC{
  175. [self.navigationController popToRootViewControllerAnimated:YES];
  176. }
  177. @end