ComplainVC.m 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. //
  2. // ComplainVC.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/6/10.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "ComplainVC.h"
  9. #import "PickTimeV.h"
  10. @interface ComplainVC ()<UITextViewDelegate>
  11. {
  12. UIButton *typeBtn;
  13. NSString *typeString;
  14. UITextView *mainTV;
  15. UILabel *holderLabel;
  16. }
  17. @end
  18. @implementation ComplainVC
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. self.title = @"投诉";
  22. self.view.backgroundColor = backGroundColor;
  23. [self configNavigationBar];
  24. float bd,x,y,w,h;
  25. x = y = bd = 10;
  26. //y = kNavOffSet + 10;
  27. w = kSize.width - 20;
  28. h = 50;
  29. UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(x, y , w, h)];
  30. [bgView borderColor:KlineColor width:2 cornorRadios:5];
  31. [self.view addSubview:bgView];
  32. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x + bd, y , w - bd, h)];
  33. [label setText:[NSString stringWithFormat:@"统计类型:"] Font:Font17 TextColor:kTitleColor Alignment:NSTextAlignmentLeft];
  34. [self.view addSubview:label];
  35. float widt = [label.text sizeForFont:Font17].width;
  36. UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(x + widt + 10, y , w - widt - 10, h)];
  37. [button setTitle:@"请选择投诉类型" textColor:defGreen font:Font17 fotState:UIControlStateNormal];
  38. [button target:self tag:1];
  39. [self.view addSubview:button];
  40. typeBtn = button;
  41. y += h + 2*bd;
  42. h = 140;
  43. mainTV = [[UITextView alloc] setxywh];
  44. mainTV.backgroundColor = [UIColor whiteColor];
  45. mainTV.delegate = self;
  46. mainTV.returnKeyType = UIReturnKeyDone;
  47. [self.view addSubview:mainTV];
  48. holderLabel = [[UILabel alloc] initWithFrame:CGRectMake(x + 10, y, w, 30)];
  49. holderLabel.text = @"请输入投诉内容(100字以内)";
  50. [holderLabel setFont:NormalFont TextColor:contentTextColor];
  51. [self.view addSubview:holderLabel];
  52. y += h + 2 * bd;
  53. h = 50;
  54. UIButton *commentBtn = [[UIButton alloc] setxywh];
  55. [commentBtn setTitle:@"提交" textColor:[UIColor whiteColor] font:Font17 fotState:UIControlStateNormal];
  56. commentBtn.backgroundColor=[UIColor colorWithRed:242/255.0 green:130/255.0 blue:32/255.0 alpha:1];
  57. [commentBtn target:self tag:2];
  58. [self.view addSubview:commentBtn];
  59. }
  60. -(void)btnClick:(UIButton *)sender
  61. {
  62. if (sender.tag == 1) {
  63. PickTimeV *pickV = [[PickTimeV alloc] init];
  64. [pickV setWhichVC:@"ComplainVC"];
  65. [pickV complete:^(NSDictionary *obj) {
  66. [typeBtn setTitle:obj[@"RT_TITLE"] forState:UIControlStateNormal];
  67. typeString = obj[@"RT_ID"];
  68. }];
  69. [pickV show];
  70. }
  71. if (sender.tag == 2) {
  72. [self.view endEditing:YES];
  73. if (mainTV.text.length < 1) {
  74. ShowMsg(@"请填写投诉信息");
  75. return;
  76. }
  77. if (mainTV.text.length > 100) {
  78. ShowMsg(@"评论内容不能超出100字");
  79. return;
  80. }
  81. [self uploadReserveComplaints];
  82. }
  83. }
  84. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
  85. {
  86. [self.view endEditing:YES];
  87. }
  88. #pragma mark textViewDelegate
  89. -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
  90. {
  91. NSMutableString * content = [[NSMutableString alloc]initWithString:textView.text];
  92. [content replaceCharactersInRange:range withString:text];
  93. if (content.length < 1) {
  94. holderLabel.hidden = NO;
  95. }else{
  96. holderLabel.hidden = YES;
  97. }
  98. if ([@"\n" isEqualToString:text] == YES) {
  99. //如果是换行键 就隐藏键盘
  100. [self.view endEditing:YES];
  101. return NO;
  102. }
  103. return YES;
  104. }
  105. #pragma mark 数据请求
  106. -(void)uploadReserveComplaints
  107. {
  108. if (![Util connectedToNetWork]) {
  109. showMsgUnconnect();
  110. return;
  111. }
  112. NSMutableArray *arr=[NSMutableArray array];
  113. [arr addPro:@"classId" Value:_dataDic[@"CLASSID"]];
  114. [arr addPro:@"type" Value:typeString];
  115. [arr addPro:@"mark" Value:mainTV.text];
  116. [arr addPro:@"userId" Value:defUser.userDict[@"id"]];
  117. [arr addPro:@"userName" Value:_dataDic[@"STUNAME"]];
  118. [arr addPro:@"coach" Value:_dataDic[@"COACHID"]];
  119. [arr addPro:@"coachName" Value:_dataDic[@"COACHNAME"]];
  120. [arr addPro:@"mobile" Value:defUser.userTel];
  121. [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
  122. NSString* method = @"uploadReserveComplaints";
  123. [MBProgressHUD showLoadToView:self.view];
  124. [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
  125. [MBProgressHUD hideHUDForView:self.view];
  126. if (!root) {
  127. ShowMsgFailed();
  128. return;
  129. }
  130. if ([root[@"code"] isEqualToString:@"1"]) {
  131. ShowMsg(root[@"body"]);
  132. return;
  133. }
  134. UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"您的投诉已收到!" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
  135. [alertView show];
  136. [self.navigationController popViewControllerAnimated:YES];
  137. }];
  138. }
  139. - (void)didReceiveMemoryWarning {
  140. [super didReceiveMemoryWarning];
  141. // Dispose of any resources that can be recreated.
  142. }
  143. @end