// // InfoEditViewController.m // model // // Created by liufei on 2018/7/25. // Copyright © 2018年 Mine. All rights reserved. // #import "InfoEditViewController.h" @interface InfoEditViewController () @property (nonatomic, strong) UITextField *infoTextField; @end @implementation InfoEditViewController - (void)viewDidLoad { [super viewDidLoad]; [self configUI]; // Do any additional setup after loading the view. } - (void)configUI { self.view.backgroundColor = RGBValueColor(0xf7f7f7, 1.0); self.navigationController.navigationBar.tintColor = RGBValueColor(0x333333, 1); self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(handleSave)]; self.infoTextField = [[UITextField alloc] initWithFrame:CGRectMake(0, 10, ScreenWidth, 40)]; self.infoTextField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 40)]; self.infoTextField.leftViewMode = UITextFieldViewModeAlways; self.infoTextField.backgroundColor = [UIColor whiteColor]; [self.view addSubview:self.infoTextField]; switch (_editType) { case InfoEditTypeName: self.title = @"用户名"; self.infoTextField.placeholder = @"请输入用户名"; self.infoTextField.text = [ModelUser modelUser].pet; break; case InfoEditTypeAge: self.title = @"年龄"; self.infoTextField.placeholder = @"请输入年龄"; self.infoTextField.text = [ModelUser modelUser].age; self.infoTextField.keyboardType = UIKeyboardTypeNumberPad; break; case InfoEditTypeHeight: self.title = @"身高"; self.infoTextField.placeholder = @"请输入身高(cm)"; self.infoTextField.text = [ModelUser modelUser].hei; self.infoTextField.keyboardType = UIKeyboardTypeDecimalPad; break; case InfoEditTypeWeight: self.title = @"体重"; self.infoTextField.placeholder = @"请输入体重(kg)"; self.infoTextField.text = [ModelUser modelUser].wei; self.infoTextField.keyboardType = UIKeyboardTypeDecimalPad; break; case InfoEditTypeSigature: self.title = @"个性签名"; self.infoTextField.text = [ModelUser modelUser].lname; self.infoTextField.placeholder = @"请输入个性签名"; break; case InfoEditTypeVprice: self.title = @"视频单价"; self.infoTextField.text = [ModelUser modelUser].vprice; self.infoTextField.placeholder = @"请输入视频单价(6--49)元"; self.infoTextField.keyboardType = UIKeyboardTypeNumberPad; break; default: break; } } - (void)handleSave{ if (self.infoTextField.text.length != 0) { [self.infoTextField resignFirstResponder]; if (_editType == InfoEditTypeVprice) { NSInteger price = [self.infoTextField.text integerValue]; if (price < 6 || price > 49) { [MBProgressHUD showOnlyText:@"视频单价不能小于6元或大于49元" controller:self]; return; } } [self handleInfo:self.infoTextField.text]; } } - (void)handleInfo:(NSString *)info { NSString *paramterKey; switch (_editType) { case InfoEditTypeName: paramterKey = @"name"; break; case InfoEditTypeAge: paramterKey = @"age"; break; case InfoEditTypeHeight: paramterKey = @"hei"; break; case InfoEditTypeWeight: paramterKey = @"wei"; break; case InfoEditTypeSigature: paramterKey = @"lname"; break; case InfoEditTypeVprice: paramterKey = @"vprice"; break; default: break; } [MBProgressHUD showHUDAddedTo:self.view animated:YES]; [YanCNetWorkManager requestPostWithURLStr:Url_updateModelCard(PublicUrl) parameters:@{paramterKey:info,@"modelpk":[ModelUser user].modelpk} finish:^(id dataDic) { [MBProgressHUD hideHUDForView:self.view animated:YES]; if (self.complete) { self.complete(info); } [self.navigationController popViewControllerAnimated:YES]; } enError:^(NSError *error) { }]; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesBegan:touches withEvent:event]; [self.infoTextField resignFirstResponder]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end