MGInvateCodeViewController.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //
  2. // MGInvateCodeViewController.m
  3. // BuguLive
  4. //
  5. // Created by 宋晨光 on 2020/1/15.
  6. // Copyright © 2020 xfg. All rights reserved.
  7. //
  8. #import "MGInvateCodeViewController.h"
  9. @interface MGInvateCodeViewController ()
  10. @property(nonatomic, strong) UITextField *textField;
  11. @end
  12. @implementation MGInvateCodeViewController
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. // Do any additional setup after loading the view.
  16. self.navigationItem.title = ASLocalizedString(@"邀请码");
  17. [self backBtnWithBlock];
  18. [self setUpView];
  19. self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
  20. }
  21. - (void)backBtnWithBlock
  22. {
  23. // 返回按钮
  24. [self setupBackBtnWithBlock:nil];
  25. }
  26. -(void)setUpView{
  27. UIView *bgView = [[UIView alloc]initWithFrame:CGRectMake(0, kTopHeight, kScreenW, kRealValue(44))];
  28. bgView.backgroundColor = kWhiteColor;
  29. UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kRealValue(80), kRealValue(44))];
  30. label.text = ASLocalizedString(@"邀请码");
  31. label.textAlignment = NSTextAlignmentCenter;
  32. label.textColor = kBlackColor;
  33. label.font = [UIFont systemFontOfSize:15];
  34. UITextField *textField = [[UITextField alloc]init];
  35. textField.placeholder = ASLocalizedString(@"请输入邀请码");
  36. textField.frame = CGRectMake(label.right, 0, kScreenW - kRealValue(80 * 2), kRealValue(44));
  37. textField.font = [UIFont systemFontOfSize:15];
  38. _textField = textField;
  39. [self.view addSubview:bgView];
  40. [bgView addSubview:label];
  41. [bgView addSubview:textField];
  42. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  43. btn.frame = CGRectMake(0, bgView.bottom + kRealValue(80), kRealValue(180), kRealValue(40));
  44. btn.centerX = kScreenW / 2;
  45. [btn setTitle:ASLocalizedString(@"提交")forState:UIControlStateNormal];
  46. btn.titleLabel.font = [UIFont systemFontOfSize:14];
  47. [btn setTitleColor:kWhiteColor forState:UIControlStateNormal];
  48. btn.layer.cornerRadius = 8;
  49. btn.layer.masksToBounds = YES;
  50. [btn setBackgroundImage:[UIImage imageNamed:@"mg_hm_topBgImgView"] forState:UIControlStateNormal];
  51. [btn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
  52. [self.view addSubview:btn];
  53. }
  54. -(void)clickBtn:(UIButton *)sender
  55. {
  56. if ([BGUtils isBlankString:self.textField.text]) {
  57. [BGHUDHelper alert:ASLocalizedString(@"邀请码不能为空")];
  58. return;
  59. }
  60. NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
  61. [mDict setObject:@"login" forKey:@"ctl"];
  62. [mDict setObject:@"invitation" forKey:@"act"];
  63. [mDict setObject:self.textField.text forKey:@"invitation_id"];
  64. [[NetHttpsManager manager] POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) {
  65. if ([responseJson toInt:@"status"] == 1)
  66. {
  67. [FanweMessage alert:ASLocalizedString(@"提交成功")];
  68. }
  69. else
  70. {
  71. // [BGHUDHelper alert:[responseJson valueForKey:@"error"] action:^{
  72. //
  73. // }];
  74. }
  75. } FailureBlock:^(NSError *error) {
  76. }];
  77. //
  78. }
  79. /*
  80. #pragma mark - Navigation
  81. // In a storyboard-based application, you will often want to do a little preparation before navigation
  82. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  83. // Get the new view controller using [segue destinationViewController].
  84. // Pass the selected object to the new view controller.
  85. }
  86. */
  87. @end