GroupSendViewController.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // Created by Drew on 2019-01-04.
  3. // Copyright (c) 2019 Mine. All rights reserved.
  4. //
  5. #import "GroupSendViewController.h"
  6. #import "UITextView+NTES.h"
  7. @interface GroupSendViewController () {
  8. }
  9. @property(nonatomic, strong) UITextView *textField;
  10. @end
  11. @implementation GroupSendViewController
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. self.navigationItem.title = @"群发通知";
  15. UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon_back"] style:UIBarButtonItemStylePlain target:self action:@selector(backClick)];
  16. self.navigationItem.leftBarButtonItem = leftItem;
  17. self.navigationController.navigationBar.tintColor = [UIColor blackColor];
  18. self.view.backgroundColor = [UIColor colorWithHexString:@"#F2F4F5"];
  19. UIView *view = [[UIView alloc] init];
  20. [self.view addSubview:view];
  21. [view mas_makeConstraints:^(MASConstraintMaker *make) {
  22. make.top.equalTo(self.mas_topLayoutGuide).offset(10);
  23. make.left.equalTo(self.view).offset(20);
  24. make.right.equalTo(self.view).offset(-20);
  25. make.height.mas_equalTo(230);
  26. }];
  27. view.backgroundColor = [UIColor whiteColor];
  28. view.layer.cornerRadius = 8;
  29. view.clipsToBounds = YES;
  30. UITextView *textField = [[UITextView alloc] init];
  31. textField.font = [UIFont systemFontOfSize:14];
  32. textField.placeholder = @"请输入你想发送的消息内容";
  33. textField.placeholderLabel.font = [UIFont systemFontOfSize:13];
  34. [view addSubview:textField];
  35. self.textField = textField;
  36. [textField mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.top.equalTo(view).offset(15);
  38. make.left.equalTo(view).offset(20);
  39. make.right.equalTo(view).offset(-20);
  40. make.bottom.equalTo(view.mas_bottom).offset(-15);
  41. }];
  42. UIButton *button = [[UIButton alloc] init];
  43. [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  44. [button setTitle:@"确认发送" forState:UIControlStateNormal];
  45. button.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  46. button.layer.backgroundColor = [UIColor colorWithRed:1.0 green:64 / 255.f blue:149 / 255.f alpha:1.0].CGColor;
  47. button.layer.cornerRadius = 22;
  48. button.layer.shadowColor = [UIColor colorWithRed:1.0 green:64 / 255.f blue:149 / 255.f alpha:0.36].CGColor;
  49. button.layer.shadowOffset = CGSizeMake(0, 8);
  50. button.layer.shadowOpacity = 1;
  51. button.layer.shadowRadius = 10;
  52. [self.view addSubview:button];
  53. [button mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.left.equalTo(view).offset(20);
  55. make.right.equalTo(view).offset(-20);
  56. make.height.mas_equalTo(44);
  57. make.top.equalTo(view.mas_bottom).offset(20);
  58. }];
  59. [button addTarget:self action:@selector(send) forControlEvents:UIControlEventTouchUpInside];
  60. UILabel *tip = [[UILabel alloc] init];
  61. tip.font = [UIFont systemFontOfSize:12];
  62. tip.textColor = [UIColor colorWithHexString:@"#999999"];
  63. [self.view addSubview:tip];
  64. [tip mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.centerX.equalTo(self.view);
  66. make.top.equalTo(button.mas_bottom).offset(20);
  67. }];
  68. tip.text = @"注:群发消息会通过千模小助手帮你通知到所有粉丝";
  69. }
  70. - (void)backClick {
  71. [self.navigationController popViewControllerAnimated:YES];
  72. }
  73. - (void)send {
  74. if (self.textField.text.length == 0) {
  75. [MBProgressHUD showInfo:@"请输入内容"];
  76. } else {
  77. NSString *url = [NSString stringWithFormat:@"%@/modelInfo?action=sendMsgToFans&modelpk=%@&msg=你关注的%@群发了一条消息:%@", PublicUrl, [ModelUser user].modelpk, [ModelUser user].pet, self.textField.text];
  78. url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
  79. [[AHHttpManager sharedManager]
  80. POST:url
  81. parameters:nil
  82. success:^(id responseObject) {
  83. if ([@"success" isEqualToString:responseObject[@"success"]]) {
  84. [self.navigationController popViewControllerAnimated:YES];
  85. [MBProgressHUD showInfo:@"发送成功"];
  86. } else {
  87. [MBProgressHUD showInfo:@"发送失败,请稍后再试"];
  88. }
  89. }
  90. failure:^(NSError *error) {
  91. [MBProgressHUD showInfo:@"发送失败,请稍后再试"];
  92. }];
  93. }
  94. }
  95. @end