| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- //
- // MeasurementsViewController.m
- // model
- //
- // Created by liufei on 2018/7/25.
- // Copyright © 2018年 Mine. All rights reserved.
- //
- #import "MeasurementsViewController.h"
- @interface MeasurementsViewController ()
- @property (nonatomic, strong) UIView *backView;
- @property (nonatomic, strong) UITextField *bustTF;
- @property (nonatomic, strong) UITextField *waistTF;
- @property (nonatomic, strong) UITextField *hipsTF;
- @property (nonatomic, strong) UIButton *saveBtn;
- @end
- @implementation MeasurementsViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self configUI];
- // Do any additional setup after loading the view.
- }
- - (void)configUI {
- self.view.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
- self.title = @"三围";
- self.navigationController.navigationBar.tintColor = RGBValueColor(0x333333, 1);
- self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(handleSave)];
- self.backView = [[UIView alloc] initWithFrame:CGRectMake(0, 10, ScreenWidth, 150)];
- self.backView.backgroundColor = [UIColor whiteColor];
- [self.view addSubview:self.backView];
- self.bustTF = [self createTF:@"输入您的胸围" leftText:@"胸围"];
- self.waistTF = [self createTF:@"输入您的腰围" leftText:@"腰围"];
- self.hipsTF = [self createTF:@"输入您的臀围" leftText:@"臀围"];
- self.bustTF.text = [ModelUser modelUser].bust;
- self.waistTF.text = [ModelUser modelUser].wai;
- self.hipsTF.text = [ModelUser modelUser].hip;
- self.bustTF.center = CGPointMake(ScreenWidth/2 + 10, 25);
- self.waistTF.center = CGPointMake(ScreenWidth/2 + 10, 75);
- self.hipsTF.center = CGPointMake(ScreenWidth/2 + 10, 125);
-
- for (int i = 0; i < 2; i++) {
- UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 49, ScreenWidth - 20, 0.5)];
- lineView.backgroundColor = RGBValueColor(0xdfdfdf, 1);
- if (i ==0) {
- [self.bustTF addSubview:lineView];
- } else {
- [self.waistTF addSubview:lineView];
- }
- }
- self.saveBtn = [[UIButton alloc] initWithFrame:CGRectMake(20,CGRectGetMaxY(self.hipsTF.frame) + 40, ScreenWidth - 40, 48)];
- self.saveBtn.layer.cornerRadius = 24.f;
- self.saveBtn.layer.masksToBounds = YES;
- [self.saveBtn setTitle:@"保存" forState:UIControlStateNormal];
- [self.saveBtn addTarget:self action:@selector(handleSave) forControlEvents:UIControlEventTouchUpInside];
- [self.saveBtn setBackgroundImage:[UIImage imageNamed:@"tixian-1"] forState:UIControlStateNormal];
- [self.backView addSubview:self.bustTF];
- [self.backView addSubview:self.waistTF];
- [self.backView addSubview:self.hipsTF];
- [self.view addSubview:self.saveBtn];
- }
- #pragma mark -
- - (void)handleSave {
- if (self.bustTF.text.length !=0 && self.waistTF.text.length !=0 && self.hipsTF.text.length !=0) {
- [YanCNetWorkManager requestPostWithURLStr:Url_updateModelCard(PublicUrl) parameters:@{@"bust":self.bustTF.text,@"wai":self.waistTF.text,@"hip":self.hipsTF.text,@"modelpk":[ModelUser user].modelpk} finish:^(id dataDic) {
- if ([dataDic[@"msg"] isEqualToString:@"success"]) {
- if (self.completion) {
- self.completion(@[self.bustTF.text, self.waistTF.text, self.hipsTF.text]);
- }
- [self.navigationController popViewControllerAnimated:YES];
- } else {
- [MBProgressHUD showError:@"保存失败"];
- }
- } enError:^(NSError *error) {
- [MBProgressHUD showError:@"保存失败"];
- }];
- }
- }
- - (UITextField *)createTF:(NSString *)placeHolder leftText:(NSString *)leftText {
- UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth - 20, 50)];
- textField.placeholder = placeHolder;
- UILabel *leftLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
- leftLabel.text = leftText;
- textField.leftView = leftLabel;
- textField.leftViewMode = UITextFieldViewModeAlways;
- textField.keyboardType = UIKeyboardTypeNumberPad;
- return textField;
- }
- - (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
|