123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- //
- // ComplainVC.m
- // jiaPei
- //
- // Created by apple on 16/6/10.
- // Copyright © 2016年 JCZ. All rights reserved.
- //
- #import "ComplainVC.h"
- #import "PickTimeV.h"
- @interface ComplainVC ()<UITextViewDelegate>
- {
- UIButton *typeBtn;
- NSString *typeString;
-
- UITextView *mainTV;
- UILabel *holderLabel;
- }
- @end
- @implementation ComplainVC
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.title = @"投诉";
- self.view.backgroundColor = backGroundColor;
- [self configNavigationBar];
-
- float bd,x,y,w,h;
- x = y = bd = 10;
- //y = kNavOffSet + 10;
- w = kSize.width - 20;
- h = 50;
- UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(x, y , w, h)];
- [bgView borderColor:KlineColor width:2 cornorRadios:5];
- [self.view addSubview:bgView];
-
- UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(x + bd, y , w - bd, h)];
- [label setText:[NSString stringWithFormat:@"统计类型:"] Font:Font17 TextColor:kTitleColor Alignment:NSTextAlignmentLeft];
- [self.view addSubview:label];
-
- float widt = [label.text sizeForFont:Font17].width;
- UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(x + widt + 10, y , w - widt - 10, h)];
- [button setTitle:@"请选择投诉类型" textColor:defGreen font:Font17 fotState:UIControlStateNormal];
- [button target:self tag:1];
- [self.view addSubview:button];
- typeBtn = button;
-
- y += h + 2*bd;
- h = 140;
- mainTV = [[UITextView alloc] setxywh];
- mainTV.backgroundColor = [UIColor whiteColor];
- mainTV.delegate = self;
- mainTV.returnKeyType = UIReturnKeyDone;
- [self.view addSubview:mainTV];
-
- holderLabel = [[UILabel alloc] initWithFrame:CGRectMake(x + 10, y, w, 30)];
- holderLabel.text = @"请输入投诉内容(100字以内)";
- [holderLabel setFont:NormalFont TextColor:contentTextColor];
- [self.view addSubview:holderLabel];
-
- y += h + 2 * bd;
- h = 50;
- UIButton *commentBtn = [[UIButton alloc] setxywh];
- [commentBtn setTitle:@"提交" textColor:[UIColor whiteColor] font:Font17 fotState:UIControlStateNormal];
- commentBtn.backgroundColor=[UIColor colorWithRed:242/255.0 green:130/255.0 blue:32/255.0 alpha:1];
- [commentBtn target:self tag:2];
- [self.view addSubview:commentBtn];
- }
- -(void)btnClick:(UIButton *)sender
- {
- if (sender.tag == 1) {
- PickTimeV *pickV = [[PickTimeV alloc] init];
- [pickV setWhichVC:@"ComplainVC"];
- [pickV complete:^(NSDictionary *obj) {
-
- [typeBtn setTitle:obj[@"RT_TITLE"] forState:UIControlStateNormal];
- typeString = obj[@"RT_ID"];
- }];
- [pickV show];
- }
- if (sender.tag == 2) {
-
- [self.view endEditing:YES];
- if (mainTV.text.length < 1) {
- ShowMsg(@"请填写投诉信息");
- return;
- }
- if (mainTV.text.length > 100) {
- ShowMsg(@"评论内容不能超出100字");
- return;
- }
- [self uploadReserveComplaints];
- }
- }
- -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
- {
- [self.view endEditing:YES];
- }
- #pragma mark textViewDelegate
- -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
- {
- NSMutableString * content = [[NSMutableString alloc]initWithString:textView.text];
- [content replaceCharactersInRange:range withString:text];
-
- if (content.length < 1) {
- holderLabel.hidden = NO;
- }else{
- holderLabel.hidden = YES;
- }
-
- if ([@"\n" isEqualToString:text] == YES) {
- //如果是换行键 就隐藏键盘
- [self.view endEditing:YES];
- return NO;
- }
-
- return YES;
- }
- #pragma mark 数据请求
- -(void)uploadReserveComplaints
- {
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"classId" Value:_dataDic[@"CLASSID"]];
- [arr addPro:@"type" Value:typeString];
- [arr addPro:@"mark" Value:mainTV.text];
- [arr addPro:@"userId" Value:defUser.userDict[@"id"]];
- [arr addPro:@"userName" Value:_dataDic[@"STUNAME"]];
- [arr addPro:@"coach" Value:_dataDic[@"COACHID"]];
- [arr addPro:@"coachName" Value:_dataDic[@"COACHNAME"]];
- [arr addPro:@"mobile" Value:defUser.userTel];
- [arr addPro:@"dqbh" Value:defUser.userDict[@"city"]];
-
- NSString* method = @"uploadReserveComplaints";
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary *root) {
-
- [MBProgressHUD hideHUDForView:self.view];
- if (!root) {
- ShowMsgFailed();
- return;
- }
- if ([root[@"code"] isEqualToString:@"1"]) {
- ShowMsg(root[@"body"]);
- return;
- }
-
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"您的投诉已收到!" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
- [alertView show];
-
- [self.navigationController popViewControllerAnimated:YES];
- }];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
|