悟空记账

JZFeedBackViewController.m 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. //
  2. // JZFeedBackViewController.m
  3. // JIZHANG
  4. //
  5. // Created by jikaipeng on 2017/10/19.
  6. // Copyright © 2017年 kuxuan. All rights reserved.
  7. //
  8. #import "JZFeedBackViewController.h"
  9. @interface JZFeedBackViewController ()<UITextViewDelegate,UITextFieldDelegate>
  10. @property (nonatomic, strong) UITextView *textView;
  11. @property (nonatomic, strong) UITextField *textField;
  12. @property (nonatomic, strong) UIButton *referButton;
  13. @property (nonatomic, copy) NSString *adviceText;
  14. @property (nonatomic, copy) NSString *user_contactText;
  15. @end
  16. @implementation JZFeedBackViewController
  17. {
  18. UILabel *_placeLabel;
  19. UILabel *_shouldInputLabel;
  20. }
  21. - (void)viewDidLoad {
  22. [super viewDidLoad];
  23. self.navigationController.navigationBar.hidden = NO;
  24. // Do any additional setup after loading the view.
  25. self.navTitle = @"意见反馈";
  26. self.view.backgroundColor= [UIColor JZColorWithRed:239 green:239 blue:244];
  27. [self setNavigation];
  28. [self setUpUI];
  29. }
  30. #pragma mark - event handle
  31. - (void)setNavigation{
  32. [self addLeftBarButtonItemWithImageName:@"mine_back" title:@"返回" target:self selector:@selector(backAction)];
  33. }
  34. - (void)backAction{
  35. [self.navigationController popViewControllerAnimated:YES];
  36. }
  37. - (void)referAction{
  38. NSString *urlString = [NSString stringWithFormat:@"%@/addUserMessage",URL];
  39. if (self.adviceText.length && self.user_contactText.length) {
  40. NSDictionary *params = @{@"message":self.adviceText,@"user_contact":self.user_contactText};
  41. [JZHttp post:urlString params:params success:^(id json) {
  42. if (json) {
  43. [self.navigationController popViewControllerAnimated:YES];
  44. [NSThread sleepForTimeInterval:0.5];
  45. [MBProgressHUD showSuccess:@"您的意见,程序员哥哥已经收到,谢谢您的支持"];
  46. }
  47. } failure:^(NSError *error) {
  48. [MBProgressHUD showError:@"提交失败,请重新提交,谢谢"];
  49. }];
  50. }
  51. }
  52. - (void)setUpUI{
  53. _textView = [[UITextView alloc] init];
  54. _textView.font = [UIFont systemFontOfSize:14];
  55. _textView.textColor = [UIColor titleColor];
  56. _textView.backgroundColor = [UIColor whiteColor];
  57. _textView.delegate = self;
  58. _textField = [[UITextField alloc] init];
  59. _textField.font = FONT_SYS(14);
  60. _textField.textColor = [UIColor titleColor];
  61. _textField.backgroundColor = [UIColor whiteColor];
  62. NSAttributedString *textFieldAtt = [[NSAttributedString alloc] initWithString:@"请填写您的邮箱或者微信号,以便我们给您回复" attributes:@{NSForegroundColorAttributeName:[UIColor JZColorWithHex:0x999999]}];
  63. _textField.attributedPlaceholder = textFieldAtt;
  64. [_textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  65. UILabel *wxLabel = [[UILabel alloc] initWithFrame:CGRectZero];
  66. wxLabel.font = FONT_SYS(14);
  67. wxLabel.textColor = [UIColor middleTitleColor];
  68. wxLabel.text = @"您的邮箱或者微信号:";
  69. _placeLabel = [[UILabel alloc] init];
  70. _placeLabel.font = [UIFont systemFontOfSize:14];
  71. _placeLabel.textColor = [UIColor JZColorWithHex:0x999999];
  72. _placeLabel.text = @"我们将尽快处理您的反馈,您可以留下您的微信号或者添加客服MM微信:qianduoduojizhang,详细咨询,感谢支持!";
  73. _placeLabel.numberOfLines = 0;
  74. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
  75. paragraphStyle.lineBreakMode = NSLineBreakByCharWrapping;
  76. NSDictionary *attributes = @{NSParagraphStyleAttributeName:paragraphStyle};
  77. _placeLabel.attributedText = [[NSAttributedString alloc]initWithString:_placeLabel.text attributes:attributes];
  78. [_placeLabel sizeToFit];
  79. _shouldInputLabel = [[UILabel alloc] init];
  80. _shouldInputLabel.font = [UIFont systemFontOfSize:14];
  81. _shouldInputLabel.textColor = [UIColor JZColorWithHex:0x666666];
  82. _shouldInputLabel.text = @"还可输入100字";
  83. [_textView addSubview:_placeLabel];
  84. _referButton = [[UIButton alloc]init];
  85. _referButton.backgroundColor = [UIColor baseColor];
  86. _referButton.layer.cornerRadius = 12;
  87. _referButton.layer.masksToBounds = YES;
  88. _referButton.enabled = NO;
  89. _referButton.alpha = 0.4;
  90. [_referButton addTarget:self action:@selector(referAction) forControlEvents:UIControlEventTouchUpInside];
  91. NSAttributedString *attributeString = [[NSAttributedString alloc] initWithString:@"提交" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:[UIColor blackColor
  92. ]}];
  93. [_referButton setAttributedTitle:attributeString forState:UIControlStateNormal];
  94. // 兼容iOS 8
  95. if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.3 ) {
  96. //使用KVC赋值
  97. [_textView setValue:_placeLabel forKey:@"_placeholderLabel"];
  98. }
  99. [_textView addSubview:_shouldInputLabel];
  100. [self.view addSubview:_textView];
  101. [self.view addSubview:_shouldInputLabel];
  102. [self.view addSubview:wxLabel];
  103. [self.view addSubview:_textField];
  104. [self.view addSubview:self.referButton];
  105. [_textView mas_makeConstraints:^(MASConstraintMaker *make) {
  106. make.top.equalTo(self.view.mas_top).offset(16);
  107. make.left.equalTo(self.view.mas_left).offset(15);
  108. make.right.equalTo(self.view.mas_right).offset(-15);
  109. make.height.mas_equalTo(180);
  110. }];
  111. // [_placeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  112. // make.top.equalTo(self.view.mas_top).offset(20);
  113. // make.left.equalTo(self.view.mas_left).offset(20);
  114. // make.right.equalTo(self.view.mas_right).offset(-20);
  115. // }];
  116. [_shouldInputLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  117. make.right.equalTo(self.textView.mas_right).offset(-15);
  118. make.bottom.equalTo(self.textView.mas_bottom).offset(-16);
  119. }];
  120. [wxLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.left.equalTo(self.textView);
  122. make.top.equalTo(self.textView.mas_bottom).offset(16);
  123. }];
  124. [_textField mas_makeConstraints:^(MASConstraintMaker *make) {
  125. make.left.and.right.equalTo(self.textView);
  126. make.top.equalTo(wxLabel.mas_bottom).offset(16);
  127. make.height.equalTo(@50);
  128. }];
  129. [_referButton mas_makeConstraints:^(MASConstraintMaker *make) {
  130. make.top.equalTo(self.textField.mas_bottom).offset(56);
  131. make.height.equalTo(@50);
  132. make.left.equalTo(self.textView.mas_left);
  133. make.right.equalTo(self.textView.mas_right);
  134. }];
  135. }
  136. #pragma mark textview delegate
  137. // 监控文本框文字改变
  138. - (void)textViewDidChange:(UITextView *)textView {
  139. NSString *string = textView.text;
  140. if (self.textField.text.length) {
  141. self.referButton.enabled = YES;
  142. self.referButton.alpha = 1;
  143. }
  144. else {
  145. self.referButton.enabled = NO;
  146. self.referButton.alpha = 0.4;
  147. }
  148. if (string.length == 0) {
  149. _shouldInputLabel.text = @"还可输入100字";
  150. _referButton.enabled = NO;
  151. _referButton.alpha = 0.4;
  152. }
  153. else if (string.length < 100) {
  154. if (self.textField.text.length) {
  155. self.referButton.enabled = YES;
  156. self.referButton.alpha = 1;
  157. }
  158. NSUInteger length = 100 - string.length;
  159. _shouldInputLabel.text = [NSString stringWithFormat:@"还可输入%ld字",length];
  160. }
  161. else if (string.length > 100) {
  162. _textView.text = [_textView.text substringToIndex:100];
  163. }
  164. self.adviceText = textView.text;
  165. }
  166. - (void)textFieldDidChange:(UITextField *)textField {
  167. NSString *string = textField.text;
  168. if (self.textView.text.length) {
  169. self.referButton.enabled = YES;
  170. self.referButton.alpha = 1;
  171. }
  172. else {
  173. self.referButton.enabled = NO;
  174. self.referButton.alpha = 0.4;
  175. }
  176. if (string.length == 0) {
  177. _referButton.enabled = NO;
  178. _referButton.alpha = 0.4;
  179. }
  180. else if (self.textView.text.length) {
  181. self.referButton.enabled = YES;
  182. self.referButton.alpha = 1;
  183. }
  184. self.user_contactText = textField.text;
  185. }
  186. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  187. [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
  188. }
  189. - (void)didReceiveMemoryWarning {
  190. [super didReceiveMemoryWarning];
  191. // Dispose of any resources that can be recreated.
  192. }
  193. -(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 {
  194. NSLog(@"TUwrxfCzbgP5WulDJd2NOV");
  195. NSLog(@"O0yr4v7kNLqCgcQWMP");
  196. NSLog(@"MN8nUsJ59CEHPzpZcghd");
  197. NSLog(@"Ur8Lq6B3l9To54F");
  198. NSLog(@"S1k0dtyfrPTFUnXV7NwHCQgvlJ9aEs2BhZx3");
  199. NSLog(@"kPnvtQINFA0ych5mo28RZxur");
  200. NSLog(@"VbATmz8UGK9Rl73QceELJZkn4");
  201. NSLog(@"jx6Dud2WBgn8YfIpotsFkH13SGar7czMJewNZbL");
  202. NSLog(@"walkmTOZBqL9b8cip3DVMH6");
  203. NSLog(@"l8f41OLdQMjmF3RDzsYvaHbB6hx0qWS");
  204. NSLog(@"tx1bUDcHsPO");
  205. NSLog(@"7xECb1B9ZQRJfTDGs");
  206. NSLog(@"xaF5pRoEf1");
  207. NSLog(@"9koBImXvJQ7");
  208. NSLog(@"e5dfiyBEqGQb2SP1z4Cln86DH");
  209. NSLog(@"83ZUV7qkpXy1wdAKDcNtenMov6zuj");
  210. NSLog(@"f9mlZocbk63Q0idHIRapxCYJSq2AWjnB1sN");
  211. NSLog(@"kNaYSCsWFj1hATwz5r9DMvLdK7ltyQ6JPZ");
  212. }
  213. -(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 {
  214. NSLog(@"lN97CRrvuD1");
  215. NSLog(@"ycORVU5wQ2Y3odlfarEmbX41tzZ");
  216. NSLog(@"1Khc3OEAl2aUoNy8mXHqnskv");
  217. NSLog(@"aQnG6mbYuhqOB09EvN");
  218. NSLog(@"yc7olIi5xrRuempSt6nah4Wf82ZXLP");
  219. NSLog(@"JXyjYfx6I05RK8QPqOC3mZSsbWg");
  220. NSLog(@"YJ42SWbZgdzktOj");
  221. NSLog(@"vqtw4lnLfTz7IQi3");
  222. NSLog(@"UVQ3iPHYS0doIKXrZqOy8h5BWbxzTstk1gF7pG");
  223. NSLog(@"ukRtvsZ97D20qYSOxmcUrzn5Xf");
  224. NSLog(@"TMI4WLSQBXoqyshAbNx2KdikE");
  225. NSLog(@"mYfjMgHoIwOZQDF5hqxkvu");
  226. NSLog(@"jFvf69dqtynUAo023IH4uR7Km8");
  227. NSLog(@"LTqU0mZjKHzX4");
  228. }
  229. -(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 {
  230. NSLog(@"ALmZHYvOqG0a7s");
  231. NSLog(@"aCUcBWG26w9V");
  232. NSLog(@"IrA0c3pgkM5GnWixSJREq");
  233. NSLog(@"e07lvPyKcjUsFt41kfQ8A");
  234. NSLog(@"RuPah6YO1cme9G");
  235. NSLog(@"JOSokDhKHaxp9VnB5TRI7YW6MgPNdizb4");
  236. NSLog(@"YzBTMZHdQWK25SrEmbktp6neVP9ILiNCx4Aoh");
  237. NSLog(@"uZGUFOrNEbzJgnIX3xKoRMpmy");
  238. NSLog(@"dONb6yR8LscCHSEvPGo5Mr2za");
  239. NSLog(@"qAf2Dek4ZuRwp");
  240. NSLog(@"y6pfQCjM5ZE7F9O");
  241. NSLog(@"SX7ZxCbR9fyONsjB");
  242. }
  243. @end