123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- //
- #import "PostQues.h"
- @interface PostQues ()<UITextViewDelegate>
- {
- UITextView* textV;
- UITextField* textF;
- UILabel* pHolder;
- }
- @end
- @implementation PostQues
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- [self myInit];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- }
- #pragma mark -
- -(void)myInit
- {
- [self configNavigationBar];
- [self setTitle:@"提问"];
- [self.view setBackgroundColor:backGroundColor];
-
- UIBarButtonItem* bbi = [[UIBarButtonItem alloc] initWithTitle:@"提交" style:UIBarButtonItemStylePlain target:self action:@selector(uploadAppQuestion)];
- [bbi setTintColor:defGreen];
- self.navigationItem.rightBarButtonItem = bbi;
-
- CGFloat y,h;
- h = 120;
- y = 0;
-
- UIView* vi;
- vi = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kSize.width, h)];
- [vi setBackgroundColor:[UIColor whiteColor]];
- [self.view addSubview:vi];
-
- UITextView* tev = [[UITextView alloc] initWithFrame:CGRectMake(10, 10, kSize.width -20 , h-20)];
- [self.view addSubview:tev];
- textV= tev;
- [tev setFont:[UIFont scaleSize:NormalFont]];
- [tev setDelegate:self];
-
- UILabel* label ;
- label = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, 100, 30)];
- [label setText:@"输入问题"];
- [label setFont:[UIFont scaleSize:NormalFont]];
- [textV addSubview:label];
- [label setTextColor:RGB_COLOR(197, 197, 202)];
- pHolder = label;
-
- y+= h +10;
- h = 50;
- vi = [[UIView alloc] initWithFrame:CGRectMake(0, y, kSize.width, h)];
- [vi setBackgroundColor:[UIColor whiteColor]];
- [self.view addSubview:vi];
- UITextField* tf = [[UITextField alloc] initWithFrame:CGRectMake( 10, 0, kSize.width -20, h)];
- [tf setPlaceholder:@"输入您的姓名"];
- [tf setFont:[UIFont scaleSize:NormalFont]];
- [vi addSubview:tf];
- textF = tf;
- }
- -(void)preFreshBlock:(void (^)(void))block
- {
- preFresh = block;
- }
- -(void)uploadAppQuestion
- {
- if (textV.text.length < 6) {
- ShowMsg(@"最少写6个字");
- return;
- }
- // NSLog(@"uploadAppQuestion");
- // NSLog(@"->%@",textV.text);
- // NSLog(@"->%@",textF.text);
-
- if (![Util connectedToNetWork]) {
- showMsgUnconnect();
- return;
- }
-
- NSMutableArray *arr=[NSMutableArray array];
- [arr addPro:@"user" Value:defUser.userDict[@"id"]];
- [arr addPro:@"userName" Value:defUser.userDict[@"userName"]];
- [arr addPro:@"content" Value:textV.text];
- [arr addPro:@"jxbh" Value:_jxbh];//14000163
- [arr addPro:@"mobile" Value:defUser.userTel];
-
-
- NSString* method = @"uploadAppQuestion";
- [MBProgressHUD showLoadToView:self.view];
- [jiaPeiManager requestAnythingWithURL:method array:arr data:nil completion:^(NSDictionary * root) {
- [MBProgressHUD hideHUDForView:self.view];
- if (!root)
- {
- ShowMsgFailed();
- return;
- }
-
- NSString* code = root[@"code"];
- if ( 1 == code.intValue ) {
- ShowMsgFailed();
- return;
- }
- if (preFresh) {
- preFresh();
- }
-
- ShowMsgSuc();
- [textF resignFirstResponder];
- [textV resignFirstResponder];
- [self.navigationController popViewControllerAnimated:YES];
- }];
-
-
- }
- -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
- {
- [self.view endEditing:YES];
- }
- #pragma mark -
- - (void)textViewDidChange:(UITextView *)textView
- {
- if (textView.text.length > 0) {
- pHolder.hidden = YES;
- }
- }
- @end
|