12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- //
- // GroupNoticeEditController.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/25.
- //
- #import "GroupNoticeEditController.h"
- #import "NoticeEditBodyView.h"
- @interface GroupNoticeEditController ()
- @property (nonatomic, strong) NoticeEditBodyView *bodyView;
- @end
- @implementation GroupNoticeEditController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- NSString *navTitle = self.isModify ? @"编辑群公告" : @"新建群公告";
- [self allocTitle:navTitle];
- [self configUI];
- }
- - (void)configUI {
- self.bodyView = [NoticeEditBodyView shareInstance];
- [self.scrollView addSubview:self.bodyView];
- [self.bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.scrollView.mas_top);
- make.right.left.mas_equalTo(self.view);
- make.height.mas_equalTo(kScreenHeight - kNaviBarHeight - iPhoneXSafeBottomMargin);
- }];
- MJWeakSelf;
- [self.bodyView publishCallback:^{
- [weakSelf submitAction];
- }];
- if (_isModify) {
- [self.bodyView configTitle:self.titles content:self.content];
- self.bodyView.isOn = self.isOn;
- }
- else {
- self.bodyView.isOn = YES;
- }
- }
- - (void)submitAction {
- if (_isModify) {
- NSString *title = self.bodyView.titleView.text;
- NSString *content = self.bodyView.contentArea.text;
- [LOADING_MANAGER showHUD];
- [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) {
- [LOADING_MANAGER removeHUD];
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- [LOADING_MANAGER KSShowMsg:@"修改成功" promptCompletion:^{
- [self.navigationController popViewControllerAnimated:YES];
- }];
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [LOADING_MANAGER removeHUD];
- }];
- }
- else {
- NSString *title = self.bodyView.titleView.text;
- NSString *content = self.bodyView.contentArea.text;
- [LOADING_MANAGER showHUD];
- [KSNetworkingManager imGroupNoticeCreateRequest:KS_POST groupId:self.groupId title:title content:content isTop:[NSString stringWithFormat:@"%d",self.bodyView.isOn] success:^(NSDictionary * _Nonnull dic) {
- [LOADING_MANAGER removeHUD];
- if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
- [LOADING_MANAGER KSShowMsg:@"发布成功" promptCompletion:^{
- [self.navigationController popViewControllerAnimated:YES];
- }];
- }
- else {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
- }
- } faliure:^(NSError * _Nonnull error) {
- [LOADING_MANAGER removeHUD];
- }];
-
- }
- }
- /*
- #pragma mark - Navigation
- // In a storyboard-based application, you will often want to do a little preparation before navigation
- - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
- // Get the new view controller using [segue destinationViewController].
- // Pass the selected object to the new view controller.
- }
- */
- @end
|