Ter_SendMsg.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. //
  2. // Ter_SendMsg.m
  3. // LN_School
  4. //
  5. // Created by EchoShacolee on 2017/8/16.
  6. // Copyright © 2017年 Danson. All rights reserved.
  7. //
  8. #import "Ter_SendMsg.h"
  9. @interface Ter_SendMsg ()<UIScrollViewDelegate>
  10. {
  11. UITextField * _tf;
  12. UITextView * _tx;
  13. }
  14. @end
  15. @implementation Ter_SendMsg
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. self.navigationItem.title = @"编辑通知";
  19. self.view.backgroundColor = KBackGroundColor;
  20. [self goBackByNavigation];
  21. //
  22. UIScrollView * scrV = [[UIScrollView alloc]initWithFrame:kFrame];
  23. scrV.contentSize = CGSizeMake(0, kSize.height);
  24. scrV.showsVerticalScrollIndicator = NO;
  25. scrV.delegate = self;
  26. [self.view addSubview:scrV];
  27. UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapHandle)];
  28. [scrV addGestureRecognizer:tap];
  29. // UILabel *lab1 = [[UILabel alloc]initWithFrame:CGRectMake(20, 20, kSize.width-40, 40)];
  30. // lab1.text = @"请输入通知标题:";
  31. // lab1.font = [UIFont systemFontOfSize:17];
  32. // [scrV addSubview:lab1];
  33. //
  34. // _tf = [[UITextField alloc]initWithFrame:CGRectMake(20, 60, kSize.width-40, 35)];
  35. // _tf.backgroundColor = [UIColor whiteColor];
  36. // _tf.font = [UIFont systemFontOfSize:15];
  37. // _tf.clipsToBounds = YES;
  38. // _tf.layer.cornerRadius = 5;
  39. // _tf.layer.borderWidth = .2;
  40. // [scrV addSubview:_tf];
  41. UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(20, 115-95, kSize.width-40, 30)];
  42. lab.text = @"请输入通知内容:";
  43. lab.font = [UIFont systemFontOfSize:17];
  44. [scrV addSubview:lab];
  45. _tx = [[UITextView alloc]initWithFrame:CGRectMake(20, 145-95, kSize.width-40, 180)];
  46. _tx.backgroundColor = [UIColor whiteColor];
  47. _tx.font = [UIFont systemFontOfSize:14];
  48. _tx.textColor = [UIColor darkGrayColor];
  49. _tx.clipsToBounds = YES;
  50. _tx.layer.cornerRadius = 5;
  51. _tx.layer.borderWidth = .2;
  52. [scrV addSubview:_tx];
  53. UIButton * btn = [[UIButton alloc]initWithFrame:CGRectMake(20, 350-95, kSize.width-40, 50)];
  54. btn.backgroundColor = RQMianColor;
  55. btn.clipsToBounds = YES;
  56. btn.layer.cornerRadius = 5;
  57. [btn setTitle:@"发送" textColor:[UIColor whiteColor] font:18 fotState:0];
  58. [btn addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
  59. [scrV addSubview:btn];
  60. }
  61. -(void)btnClick{
  62. if (_tx.text.length == 0) {
  63. ShowMsg(@"通知内容不能为空");//或标题
  64. return;
  65. }
  66. if (![NetManager connectedToNetWork]) {
  67. showMsgUnconnect();
  68. return;
  69. }
  70. NSMutableDictionary *mdic = [NSMutableDictionary new];
  71. [mdic setValue:_sim forKey:@"sim"];
  72. [mdic setValue:_tx.text forKey:@"msg"];
  73. NSString *method = @"sendMsg";
  74. [NetManager requestAnythingWithURL:method dictionary:mdic dataArray:nil completion:^(NSDictionary *root) {
  75. if (!root) {
  76. ShowMsg(@"数据请求失败,请重试");
  77. return;
  78. }
  79. if ([root[@"code"] integerValue] == 1) {
  80. ShowMsg(root[@"msg"]);
  81. return;
  82. }
  83. ShowMsg(@"发送成功");
  84. [self.navigationController popViewControllerAnimated:YES];
  85. }];
  86. }
  87. -(void)tapHandle{
  88. [self.view endEditing:YES];
  89. }
  90. -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
  91. [self.view endEditing:YES];
  92. }
  93. - (void)didReceiveMemoryWarning {
  94. [super didReceiveMemoryWarning];
  95. // Dispose of any resources that can be recreated.
  96. }
  97. /*
  98. #pragma mark - Navigation
  99. // In a storyboard-based application, you will often want to do a little preparation before navigation
  100. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  101. // Get the new view controller using [segue destinationViewController].
  102. // Pass the selected object to the new view controller.
  103. }
  104. */
  105. @end