GroupNoticeEditController.m 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // GroupNoticeEditController.m
  3. // KulexiuForTeacher
  4. //
  5. // Created by Kyle on 2022/3/25.
  6. //
  7. #import "GroupNoticeEditController.h"
  8. #import "NoticeEditBodyView.h"
  9. @interface GroupNoticeEditController ()
  10. @property (nonatomic, strong) NoticeEditBodyView *bodyView;
  11. @end
  12. @implementation GroupNoticeEditController
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. // Do any additional setup after loading the view.
  16. NSString *navTitle = self.isModify ? @"编辑群公告" : @"新建群公告";
  17. [self allocTitle:navTitle];
  18. [self configUI];
  19. }
  20. - (void)configUI {
  21. self.bodyView = [NoticeEditBodyView shareInstance];
  22. [self.scrollView addSubview:self.bodyView];
  23. [self.bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
  24. make.top.mas_equalTo(self.scrollView.mas_top);
  25. make.right.left.mas_equalTo(self.view);
  26. make.height.mas_equalTo(kScreenHeight - kNaviBarHeight - iPhoneXSafeBottomMargin);
  27. }];
  28. MJWeakSelf;
  29. [self.bodyView publishCallback:^{
  30. [weakSelf submitAction];
  31. }];
  32. if (_isModify) {
  33. [self.bodyView configTitle:self.titles content:self.content];
  34. self.bodyView.isOn = self.isOn;
  35. }
  36. else {
  37. self.bodyView.isOn = YES;
  38. }
  39. }
  40. - (void)submitAction {
  41. if (_isModify) {
  42. NSString *title = self.bodyView.titleView.text;
  43. NSString *content = self.bodyView.contentArea.text;
  44. [LOADING_MANAGER showHUD];
  45. [KSNetworkingManager imGroupNoticeUpdateRequest:KS_POST groupId:self.groupId title:title content:content isTop:[NSString stringWithFormat:@"%d",self.bodyView.isOn] noticeID:self.noticeID success:^(NSDictionary * _Nonnull dic) {
  46. [LOADING_MANAGER removeHUD];
  47. if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
  48. [LOADING_MANAGER KSShowMsg:@"修改成功" promptCompletion:^{
  49. [self.navigationController popViewControllerAnimated:YES];
  50. }];
  51. }
  52. else {
  53. [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
  54. }
  55. } faliure:^(NSError * _Nonnull error) {
  56. [LOADING_MANAGER removeHUD];
  57. }];
  58. }
  59. else {
  60. NSString *title = self.bodyView.titleView.text;
  61. NSString *content = self.bodyView.contentArea.text;
  62. [LOADING_MANAGER showHUD];
  63. [KSNetworkingManager imGroupNoticeCreateRequest:KS_POST groupId:self.groupId title:title content:content isTop:[NSString stringWithFormat:@"%d",self.bodyView.isOn] success:^(NSDictionary * _Nonnull dic) {
  64. [LOADING_MANAGER removeHUD];
  65. if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
  66. [LOADING_MANAGER KSShowMsg:@"发布成功" promptCompletion:^{
  67. [self.navigationController popViewControllerAnimated:YES];
  68. }];
  69. }
  70. else {
  71. [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
  72. }
  73. } faliure:^(NSError * _Nonnull error) {
  74. [LOADING_MANAGER removeHUD];
  75. }];
  76. }
  77. }
  78. /*
  79. #pragma mark - Navigation
  80. // In a storyboard-based application, you will often want to do a little preparation before navigation
  81. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  82. // Get the new view controller using [segue destinationViewController].
  83. // Pass the selected object to the new view controller.
  84. }
  85. */
  86. @end