| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- //
- // 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;
- @property(nonatomic, strong) UIButton *btnAgree;
- @end
- @implementation InfoEditViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
- btn.frame = CGRectMake(0, 0, 40, 40);
- [btn setImage:[UIImage imageNamed:@"fanhui2"] forState:UIControlStateNormal];
- btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
- [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
- UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
- UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
- self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem];
- [self configUI];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self.navigationController setNavigationBarHidden:NO animated:YES];
- }
- - (void)configUI {
- self.view.backgroundColor = [UIColor colorWithHexString:@"#F2F4F5"];
- self.navigationController.navigationBar.tintColor = [UIColor colorWithHexString:@"#F2F4F5"];
- UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(handleSave)];
- rightItem.tintColor = [UIColor blackColor];
- self.navigationItem.rightBarButtonItem = rightItem;
- UIView *container = [[UIView alloc] initWithFrame:CGRectMake(20, 10, ScreenWidth - 40, 60)];
- container.layer.cornerRadius = 8;
- container.clipsToBounds = YES;
- container.backgroundColor = [UIColor whiteColor];
- [self.view addSubview:container];
- self.infoTextField = [[UITextField alloc] init];
- self.infoTextField.backgroundColor = [UIColor whiteColor];
- [container addSubview:self.infoTextField];
- [self.infoTextField mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(container);
- make.height.equalTo(container);
- make.leftMargin.equalTo(container).offset(15);
- make.rightMargin.equalTo(container).offset(-15);
- }];
- 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;
- UILabel *yuan = [[UILabel alloc] init];
- yuan.textAlignment = NSTextAlignmentCenter;
- yuan.text = @"元";
- yuan.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
- yuan.textColor = [UIColor blackColor];
- [container addSubview:yuan];
- [yuan mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(container);
- make.rightMargin.equalTo(container);
- make.height.equalTo(container);
- make.width.mas_equalTo(60);
- }];
- UIView *border = [[UIView alloc] init];
- border.backgroundColor = [UIColor colorWithHexString:@"#F2F4F5"];
- [container addSubview:border];
- [border mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.equalTo(container);
- make.centerY.equalTo(container);
- make.width.mas_equalTo(1);
- make.rightMargin.equalTo(container).offset(-60);
- }];
- UILabel *remark1 = [[UILabel alloc] init];
- remark1.numberOfLines = 0;
- remark1.text = @"1.面试视频定价区间为6元—49元每分钟,可自行定价;\n2.面试视频定价以个人获得荣誉为参考依据,荣誉越多,可适当提高视频定价;\n3.面试视频的收益,模特本人可提现的比例为定价金额的50%;";
- remark1.font = [UIFont systemFontOfSize:13];
- remark1.textColor = [UIColor blackColor];
- [self.view addSubview:remark1];
- [remark1 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view).offset(20);
- make.right.equalTo(self.view.mas_right).offset(-20);
- make.top.equalTo(container.mas_bottom).offset(15);
- }];
- UILabel *remark2 = [[UILabel alloc] init];
- remark2.numberOfLines = 0;
- remark2.text = @"说明:\n1.面试视频采用收费模式,为避免或降低用户对模特的打扰;\n2.面试视频是增加模特收益的一种形式。";
- remark2.font = [UIFont systemFontOfSize:13];
- remark2.textColor = [UIColor colorWithHexString:@"#808080"];
- [self.view addSubview:remark2];
- [remark2 mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view).offset(20);
- make.right.equalTo(self.view.mas_right).offset(-20);
- make.top.equalTo(remark1.mas_bottom).offset(8);
- }];
- UIButton *btnAgree = [[UIButton alloc] init];
- [btnAgree setImage:[UIImage imageNamed:@"btn_allow"] forState:UIControlStateNormal];
- [btnAgree setImage:[UIImage imageNamed:@"btn_allow_check"] forState:UIControlStateSelected];
- [btnAgree setTitle:@"我已知晓并同意" forState:UIControlStateNormal];
- [btnAgree setTitleColor:[UIColor colorWithHexString:@"#FF4095"] forState:UIControlStateNormal];
- btnAgree.titleLabel.font = [UIFont systemFontOfSize:13];
- btnAgree.imageEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
- btnAgree.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, -5);
- [btnAgree addTarget:self action:@selector(allow:) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:btnAgree];
- [btnAgree mas_makeConstraints:^(MASConstraintMaker *make) {
- make.width.mas_equalTo(124);
- make.height.mas_equalTo(20);
- make.top.equalTo(remark2.mas_bottom).offset(15);
- make.left.equalTo(self.view).offset(20);
- }];
- self.btnAgree = btnAgree;
- 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)allow:(UIButton *)button {
- button.selected = !button.selected;
- }
- - (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;
- }
- }
- if (self.editType == InfoEditTypeVprice && !self.btnAgree.isSelected) {
- [MBProgressHUD showOnlyText:@"请选择同意" 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];
- }
- @end
|