// // JZFeedBackViewController.m // JIZHANG // // Created by jikaipeng on 2017/10/19. // Copyright © 2017年 kuxuan. All rights reserved. // #import "JZFeedBackViewController.h" @interface JZFeedBackViewController () @property (nonatomic, strong) UITextView *textView; @property (nonatomic, strong) UITextField *textField; @property (nonatomic, strong) UIButton *referButton; @property (nonatomic, copy) NSString *adviceText; @property (nonatomic, copy) NSString *user_contactText; @end @implementation JZFeedBackViewController { UILabel *_placeLabel; UILabel *_shouldInputLabel; } - (void)viewDidLoad { [super viewDidLoad]; self.navigationController.navigationBar.hidden = NO; // Do any additional setup after loading the view. self.navTitle = @"意见反馈"; self.view.backgroundColor= [UIColor JZColorWithRed:239 green:239 blue:244]; [self setNavigation]; [self setUpUI]; } #pragma mark - event handle - (void)setNavigation{ [self addLeftBarButtonItemWithImageName:@"mine_back" title:@"返回" target:self selector:@selector(backAction)]; } - (void)backAction{ [self.navigationController popViewControllerAnimated:YES]; } - (void)referAction{ NSString *urlString = [NSString stringWithFormat:@"%@/addUserMessage",URL]; if (self.adviceText.length && self.user_contactText.length) { NSDictionary *params = @{@"message":self.adviceText,@"user_contact":self.user_contactText}; [JZHttp post:urlString params:params success:^(id json) { if (json) { [self.navigationController popViewControllerAnimated:YES]; [NSThread sleepForTimeInterval:0.5]; [MBProgressHUD showSuccess:@"您的意见,程序员哥哥已经收到,谢谢您的支持"]; } } failure:^(NSError *error) { [MBProgressHUD showError:@"提交失败,请重新提交,谢谢"]; }]; } } - (void)setUpUI{ _textView = [[UITextView alloc] init]; _textView.font = [UIFont systemFontOfSize:14]; _textView.textColor = [UIColor titleColor]; _textView.backgroundColor = [UIColor whiteColor]; _textView.delegate = self; _textField = [[UITextField alloc] init]; _textField.font = FONT_SYS(14); _textField.textColor = [UIColor titleColor]; _textField.backgroundColor = [UIColor whiteColor]; NSAttributedString *textFieldAtt = [[NSAttributedString alloc] initWithString:@"请填写您的邮箱或者微信号,以便我们给您回复" attributes:@{NSForegroundColorAttributeName:[UIColor JZColorWithHex:0x999999]}]; _textField.attributedPlaceholder = textFieldAtt; [_textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged]; UILabel *wxLabel = [[UILabel alloc] initWithFrame:CGRectZero]; wxLabel.font = FONT_SYS(14); wxLabel.textColor = [UIColor middleTitleColor]; wxLabel.text = @"您的邮箱或者微信号:"; _placeLabel = [[UILabel alloc] init]; _placeLabel.font = [UIFont systemFontOfSize:14]; _placeLabel.textColor = [UIColor JZColorWithHex:0x999999]; _placeLabel.text = @"我们将尽快处理您的反馈,您可以留下您的微信号或者添加客服MM微信:qianduoduojizhang,详细咨询,感谢支持!"; _placeLabel.numberOfLines = 0; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init]; paragraphStyle.lineBreakMode = NSLineBreakByCharWrapping; NSDictionary *attributes = @{NSParagraphStyleAttributeName:paragraphStyle}; _placeLabel.attributedText = [[NSAttributedString alloc]initWithString:_placeLabel.text attributes:attributes]; [_placeLabel sizeToFit]; _shouldInputLabel = [[UILabel alloc] init]; _shouldInputLabel.font = [UIFont systemFontOfSize:14]; _shouldInputLabel.textColor = [UIColor JZColorWithHex:0x666666]; _shouldInputLabel.text = @"还可输入100字"; [_textView addSubview:_placeLabel]; _referButton = [[UIButton alloc]init]; _referButton.backgroundColor = [UIColor baseColor]; _referButton.layer.cornerRadius = 12; _referButton.layer.masksToBounds = YES; _referButton.enabled = NO; _referButton.alpha = 0.4; [_referButton addTarget:self action:@selector(referAction) forControlEvents:UIControlEventTouchUpInside]; NSAttributedString *attributeString = [[NSAttributedString alloc] initWithString:@"提交" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:[UIColor blackColor ]}]; [_referButton setAttributedTitle:attributeString forState:UIControlStateNormal]; // 兼容iOS 8 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.3 ) { //使用KVC赋值 [_textView setValue:_placeLabel forKey:@"_placeholderLabel"]; } [_textView addSubview:_shouldInputLabel]; [self.view addSubview:_textView]; [self.view addSubview:_shouldInputLabel]; [self.view addSubview:wxLabel]; [self.view addSubview:_textField]; [self.view addSubview:self.referButton]; [_textView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.view.mas_top).offset(16); make.left.equalTo(self.view.mas_left).offset(15); make.right.equalTo(self.view.mas_right).offset(-15); make.height.mas_equalTo(180); }]; // [_placeLabel mas_makeConstraints:^(MASConstraintMaker *make) { // make.top.equalTo(self.view.mas_top).offset(20); // make.left.equalTo(self.view.mas_left).offset(20); // make.right.equalTo(self.view.mas_right).offset(-20); // }]; [_shouldInputLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.textView.mas_right).offset(-15); make.bottom.equalTo(self.textView.mas_bottom).offset(-16); }]; [wxLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.textView); make.top.equalTo(self.textView.mas_bottom).offset(16); }]; [_textField mas_makeConstraints:^(MASConstraintMaker *make) { make.left.and.right.equalTo(self.textView); make.top.equalTo(wxLabel.mas_bottom).offset(16); make.height.equalTo(@50); }]; [_referButton mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.textField.mas_bottom).offset(56); make.height.equalTo(@50); make.left.equalTo(self.textView.mas_left); make.right.equalTo(self.textView.mas_right); }]; } #pragma mark textview delegate // 监控文本框文字改变 - (void)textViewDidChange:(UITextView *)textView { NSString *string = textView.text; if (self.textField.text.length) { self.referButton.enabled = YES; self.referButton.alpha = 1; } else { self.referButton.enabled = NO; self.referButton.alpha = 0.4; } if (string.length == 0) { _shouldInputLabel.text = @"还可输入100字"; _referButton.enabled = NO; _referButton.alpha = 0.4; } else if (string.length < 100) { if (self.textField.text.length) { self.referButton.enabled = YES; self.referButton.alpha = 1; } NSUInteger length = 100 - string.length; _shouldInputLabel.text = [NSString stringWithFormat:@"还可输入%ld字",length]; } else if (string.length > 100) { _textView.text = [_textView.text substringToIndex:100]; } self.adviceText = textView.text; } - (void)textFieldDidChange:(UITextField *)textField { NSString *string = textField.text; if (self.textView.text.length) { self.referButton.enabled = YES; self.referButton.alpha = 1; } else { self.referButton.enabled = NO; self.referButton.alpha = 0.4; } if (string.length == 0) { _referButton.enabled = NO; _referButton.alpha = 0.4; } else if (self.textView.text.length) { self.referButton.enabled = YES; self.referButton.alpha = 1; } self.user_contactText = textField.text; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ [[[UIApplication sharedApplication] keyWindow] endEditing:YES]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(void)akOZfoYLj2:(UIColor*) akOZfoYLj2 aNGiabc:(UIVisualEffectView*) aNGiabc aTadQ:(UIEvent*) aTadQ axUByuP3:(UIFontWeight*) axUByuP3 aaPWyVlF:(UITableView*) aaPWyVlF aaXqnWT8:(UIRegion*) aaXqnWT8 akKGpn0E8Fh:(UISwitch*) akKGpn0E8Fh awU8Fr31vB:(UIImageView*) awU8Fr31vB agPuWG8:(UIRegion*) agPuWG8 agJ4n3fO:(UIMenuItem*) agJ4n3fO aB5OsEd:(UIDocument*) aB5OsEd { NSLog(@"TUwrxfCzbgP5WulDJd2NOV"); NSLog(@"O0yr4v7kNLqCgcQWMP"); NSLog(@"MN8nUsJ59CEHPzpZcghd"); NSLog(@"Ur8Lq6B3l9To54F"); NSLog(@"S1k0dtyfrPTFUnXV7NwHCQgvlJ9aEs2BhZx3"); NSLog(@"kPnvtQINFA0ych5mo28RZxur"); NSLog(@"VbATmz8UGK9Rl73QceELJZkn4"); NSLog(@"jx6Dud2WBgn8YfIpotsFkH13SGar7czMJewNZbL"); NSLog(@"walkmTOZBqL9b8cip3DVMH6"); NSLog(@"l8f41OLdQMjmF3RDzsYvaHbB6hx0qWS"); NSLog(@"tx1bUDcHsPO"); NSLog(@"7xECb1B9ZQRJfTDGs"); NSLog(@"xaF5pRoEf1"); NSLog(@"9koBImXvJQ7"); NSLog(@"e5dfiyBEqGQb2SP1z4Cln86DH"); NSLog(@"83ZUV7qkpXy1wdAKDcNtenMov6zuj"); NSLog(@"f9mlZocbk63Q0idHIRapxCYJSq2AWjnB1sN"); NSLog(@"kNaYSCsWFj1hATwz5r9DMvLdK7ltyQ6JPZ"); } -(void)adk8q9n36AE:(UIScreen*) adk8q9n36AE aLrJl:(UIInputView*) aLrJl aP4ihnqUw5:(UITableView*) aP4ihnqUw5 abPaHMsm:(UIBarButtonItem*) abPaHMsm apscLGyx04:(UIEdgeInsets*) apscLGyx04 a7NDSK:(UIImageView*) a7NDSK aBAJk:(UITableView*) aBAJk aj1VLh4sS:(UIMotionEffect*) aj1VLh4sS { NSLog(@"lN97CRrvuD1"); NSLog(@"ycORVU5wQ2Y3odlfarEmbX41tzZ"); NSLog(@"1Khc3OEAl2aUoNy8mXHqnskv"); NSLog(@"aQnG6mbYuhqOB09EvN"); NSLog(@"yc7olIi5xrRuempSt6nah4Wf82ZXLP"); NSLog(@"JXyjYfx6I05RK8QPqOC3mZSsbWg"); NSLog(@"YJ42SWbZgdzktOj"); NSLog(@"vqtw4lnLfTz7IQi3"); NSLog(@"UVQ3iPHYS0doIKXrZqOy8h5BWbxzTstk1gF7pG"); NSLog(@"ukRtvsZ97D20qYSOxmcUrzn5Xf"); NSLog(@"TMI4WLSQBXoqyshAbNx2KdikE"); NSLog(@"mYfjMgHoIwOZQDF5hqxkvu"); NSLog(@"jFvf69dqtynUAo023IH4uR7Km8"); NSLog(@"LTqU0mZjKHzX4"); } -(void)aDzmUeVs7:(UIMenuItem*) aDzmUeVs7 acGOIio:(UIRegion*) acGOIio awxR16r:(UIScreen*) awxR16r a7vWjm:(UIView*) a7vWjm aT9WJ0H:(UIImageView*) aT9WJ0H apmod:(UITableView*) apmod agja5ev:(UIKeyCommand*) agja5ev aGBvzdHDkI2:(UIBarButtonItem*) aGBvzdHDkI2 a5qsiBu:(UIColor*) a5qsiBu abjz5ZY:(UIImage*) abjz5ZY ajNLlu:(UIMenuItem*) ajNLlu { NSLog(@"ALmZHYvOqG0a7s"); NSLog(@"aCUcBWG26w9V"); NSLog(@"IrA0c3pgkM5GnWixSJREq"); NSLog(@"e07lvPyKcjUsFt41kfQ8A"); NSLog(@"RuPah6YO1cme9G"); NSLog(@"JOSokDhKHaxp9VnB5TRI7YW6MgPNdizb4"); NSLog(@"YzBTMZHdQWK25SrEmbktp6neVP9ILiNCx4Aoh"); NSLog(@"uZGUFOrNEbzJgnIX3xKoRMpmy"); NSLog(@"dONb6yR8LscCHSEvPGo5Mr2za"); NSLog(@"qAf2Dek4ZuRwp"); NSLog(@"y6pfQCjM5ZE7F9O"); NSLog(@"SX7ZxCbR9fyONsjB"); } @end