SendNotifyVC.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //
  2. // SendNotifyVC.m
  3. // LNManager
  4. //
  5. // Created by EchoShacolee on 2017/6/21.
  6. // Copyright © 2017年 lee. All rights reserved.
  7. //
  8. #import "SendNotifyVC.h"
  9. @interface SendNotifyVC ()<UIScrollViewDelegate>
  10. {
  11. UITextField * _tf;
  12. UITextView * _tx;
  13. }
  14. @end
  15. @implementation SendNotifyVC
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. self.navigationItem.title = @"编辑通知";
  19. //
  20. UIScrollView * scrV = [[UIScrollView alloc]initWithFrame:kFrame];
  21. scrV.contentSize = CGSizeMake(0, kSize.height);
  22. scrV.showsVerticalScrollIndicator = NO;
  23. scrV.delegate = self;
  24. [self.view addSubview:scrV];
  25. UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapHandle)];
  26. [scrV addGestureRecognizer:tap];
  27. UILabel *lab1 = [[UILabel alloc]initWithFrame:CGRectMake(20, 20, kSize.width-40, 40)];
  28. lab1.text = @"请输入通知标题:";
  29. lab1.font = [UIFont systemFontOfSize:17];
  30. [scrV addSubview:lab1];
  31. _tf = [[UITextField alloc]initWithFrame:CGRectMake(20, 60, kSize.width-40, 35)];
  32. _tf.backgroundColor = [UIColor whiteColor];
  33. _tf.font = [UIFont systemFontOfSize:15];
  34. _tf.clipsToBounds = YES;
  35. _tf.layer.cornerRadius = 5;
  36. _tf.layer.borderWidth = .2;
  37. [scrV addSubview:_tf];
  38. UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(20, 115, kSize.width-40, 30)];
  39. lab.text = @"请输入通知内容:";
  40. lab.font = [UIFont systemFontOfSize:17];
  41. [scrV addSubview:lab];
  42. _tx = [[UITextView alloc]initWithFrame:CGRectMake(20, 145, kSize.width-40, 180)];
  43. _tx.backgroundColor = [UIColor whiteColor];
  44. _tx.font = [UIFont systemFontOfSize:14];
  45. _tx.textColor = [UIColor darkGrayColor];
  46. _tx.clipsToBounds = YES;
  47. _tx.layer.cornerRadius = 5;
  48. _tx.layer.borderWidth = .2;
  49. [scrV addSubview:_tx];
  50. UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(20, 350, kSize.width-40, 50)];
  51. btn.backgroundColor = COLOR_THEME;
  52. btn.clipsToBounds = YES;
  53. btn.layer.cornerRadius = 5;
  54. [btn setTitle:@"发送" textColor:[UIColor whiteColor] font:15 fotState:0];
  55. [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
  56. [scrV addSubview:btn];
  57. }
  58. -(void)btnClick{
  59. if (_tf.text.length == 0 || _tx.text.length == 0) {
  60. [self showMsgByAlertVCWithString:@"通知内容或标题不能为空"];
  61. return;
  62. }
  63. NSMutableString *str = [NSMutableString new];
  64. for (NSString *obj in self.ids) {
  65. [str appendFormat:@",%@",obj];
  66. }
  67. NSString * idsStr = [str substringFromIndex:1];
  68. NSMutableDictionary *mdic = [NSMutableDictionary new];
  69. [mdic setValue:idsStr forKey:@"ids"];
  70. [mdic setValue:_tf.text forKey:@"title"];
  71. [mdic setValue:_tx.text forKey:@"content"];
  72. [mdic setValue:_type forKey:@"type"];
  73. [mdic setValue:MYAPPDELEGATE.userDic[@"crUserName"] forKey:@"sendUserName"];
  74. __weak typeof(self) weakSelf = self;
  75. [self getDataWithDic:mdic method:@"addNotice" block:^(NSDictionary *successdic) {
  76. UIAlertController *alertFind = [UIAlertController alertControllerWithTitle:nil message:successdic[@"msg"] preferredStyle:UIAlertControllerStyleAlert];
  77. [alertFind addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  78. [weakSelf.navigationController popToRootViewControllerAnimated:YES];
  79. }]];
  80. [weakSelf presentViewController:alertFind animated:true completion:nil];
  81. }];
  82. }
  83. -(void)tapHandle{
  84. [self.view endEditing:YES];
  85. }
  86. -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
  87. [self.view endEditing:YES];
  88. }
  89. - (void)didReceiveMemoryWarning {
  90. [super didReceiveMemoryWarning];
  91. // Dispose of any resources that can be recreated.
  92. }
  93. /*
  94. #pragma mark - Navigation
  95. // In a storyboard-based application, you will often want to do a little preparation before navigation
  96. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  97. // Get the new view controller using [segue destinationViewController].
  98. // Pass the selected object to the new view controller.
  99. }
  100. */
  101. @end