// // Created by Drew on 2019-01-04. // Copyright (c) 2019 Mine. All rights reserved. // #import "GroupSendViewController.h" #import "UITextView+NTES.h" @interface GroupSendViewController () { } @property(nonatomic, strong) UITextView *textField; @end @implementation GroupSendViewController - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.title = @"群发通知"; UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"icon_back"] style:UIBarButtonItemStylePlain target:self action:@selector(backClick)]; self.navigationItem.leftBarButtonItem = leftItem; self.navigationController.navigationBar.tintColor = [UIColor blackColor]; self.view.backgroundColor = [UIColor colorWithHexString:@"#F2F4F5"]; UIView *view = [[UIView alloc] init]; [self.view addSubview:view]; [view mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.mas_topLayoutGuide).offset(10); make.left.equalTo(self.view).offset(20); make.right.equalTo(self.view).offset(-20); make.height.mas_equalTo(230); }]; view.backgroundColor = [UIColor whiteColor]; view.layer.cornerRadius = 8; view.clipsToBounds = YES; UITextView *textField = [[UITextView alloc] init]; textField.font = [UIFont systemFontOfSize:14]; textField.placeholder = @"请输入你想发送的消息内容"; textField.placeholderLabel.font = [UIFont systemFontOfSize:13]; [view addSubview:textField]; self.textField = textField; [textField mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(view).offset(15); make.left.equalTo(view).offset(20); make.right.equalTo(view).offset(-20); make.bottom.equalTo(view.mas_bottom).offset(-15); }]; UIButton *button = [[UIButton alloc] init]; [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; [button setTitle:@"确认发送" forState:UIControlStateNormal]; button.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]; button.layer.backgroundColor = [UIColor colorWithRed:1.0 green:64 / 255.f blue:149 / 255.f alpha:1.0].CGColor; button.layer.cornerRadius = 22; button.layer.shadowColor = [UIColor colorWithRed:1.0 green:64 / 255.f blue:149 / 255.f alpha:0.36].CGColor; button.layer.shadowOffset = CGSizeMake(0, 8); button.layer.shadowOpacity = 1; button.layer.shadowRadius = 10; [self.view addSubview:button]; [button mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(view).offset(20); make.right.equalTo(view).offset(-20); make.height.mas_equalTo(44); make.top.equalTo(view.mas_bottom).offset(20); }]; [button addTarget:self action:@selector(send) forControlEvents:UIControlEventTouchUpInside]; UILabel *tip = [[UILabel alloc] init]; tip.font = [UIFont systemFontOfSize:12]; tip.textColor = [UIColor colorWithHexString:@"#999999"]; [self.view addSubview:tip]; [tip mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.view); make.top.equalTo(button.mas_bottom).offset(20); }]; tip.text = @"注:群发消息会通过千模小助手帮你通知到所有粉丝"; } - (void)backClick { [self.navigationController popViewControllerAnimated:YES]; } - (void)send { if (self.textField.text.length == 0) { [MBProgressHUD showInfo:@"请输入内容"]; } else { NSString *url = [NSString stringWithFormat:@"%@/modelInfo?action=sendMsgToFans&modelpk=%@&msg=你关注的%@群发了一条消息:%@", PublicUrl, [ModelUser user].modelpk, [ModelUser user].pet, self.textField.text]; url = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [[AHHttpManager sharedManager] POST:url parameters:nil success:^(id responseObject) { if ([@"success" isEqualToString:responseObject[@"success"]]) { [self.navigationController popViewControllerAnimated:YES]; [MBProgressHUD showInfo:@"发送成功"]; } else { [MBProgressHUD showInfo:@"发送失败,请稍后再试"]; } } failure:^(NSError *error) { [MBProgressHUD showInfo:@"发送失败,请稍后再试"]; }]; } } @end