| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- //
- // 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;
- case InfoEditTypeHobby:
- self.title = @"兴趣爱好";
- self.infoTextField.text = [ModelUser modelUser].hobby;
- self.infoTextField.placeholder = @"请填写兴趣爱好";
- break;
- case InfoEditTypeCollege:
- self.title = @"毕业院校";
- self.infoTextField.text = [ModelUser modelUser].college;
- self.infoTextField.placeholder = @"请填写毕业院校";
- break;
- case InfoEditTypeOccupation:
- self.title = @"职业";
- self.infoTextField.text = [ModelUser modelUser].occupation;
- self.infoTextField.placeholder = @"请填写职业";
- break;
- case InfoEditTypeConstellation:
- self.title = @"星座";
- self.infoTextField.text = [ModelUser modelUser].constellation;
- self.infoTextField.placeholder = @"请填写星座";
- 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;
- case InfoEditTypeHobby:
- paramterKey = @"hobby";
- break;
- case InfoEditTypeCollege:
- paramterKey = @"college";
- break;
- case InfoEditTypeOccupation:
- paramterKey = @"occupation";
- break;
- case InfoEditTypeConstellation:
- paramterKey = @"constellation";
- 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<UITouch *> *)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
|