MeasurementsViewController.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //
  2. // MeasurementsViewController.m
  3. // model
  4. //
  5. // Created by liufei on 2018/7/25.
  6. // Copyright © 2018年 Mine. All rights reserved.
  7. //
  8. #import "MeasurementsViewController.h"
  9. @interface MeasurementsViewController ()
  10. @property (nonatomic, strong) UIView *backView;
  11. @property (nonatomic, strong) UITextField *bustTF;
  12. @property (nonatomic, strong) UITextField *waistTF;
  13. @property (nonatomic, strong) UITextField *hipsTF;
  14. @property (nonatomic, strong) UIButton *saveBtn;
  15. @end
  16. @implementation MeasurementsViewController
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. [self configUI];
  20. // Do any additional setup after loading the view.
  21. }
  22. - (void)configUI {
  23. self.view.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
  24. self.title = @"三围";
  25. self.navigationController.navigationBar.tintColor = RGBValueColor(0x333333, 1);
  26. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(handleSave)];
  27. self.backView = [[UIView alloc] initWithFrame:CGRectMake(0, 10, ScreenWidth, 150)];
  28. self.backView.backgroundColor = [UIColor whiteColor];
  29. [self.view addSubview:self.backView];
  30. self.bustTF = [self createTF:@"输入您的胸围" leftText:@"胸围"];
  31. self.waistTF = [self createTF:@"输入您的腰围" leftText:@"腰围"];
  32. self.hipsTF = [self createTF:@"输入您的臀围" leftText:@"臀围"];
  33. self.bustTF.text = [ModelUser modelUser].bust;
  34. self.waistTF.text = [ModelUser modelUser].wai;
  35. self.hipsTF.text = [ModelUser modelUser].hip;
  36. self.bustTF.center = CGPointMake(ScreenWidth/2 + 10, 25);
  37. self.waistTF.center = CGPointMake(ScreenWidth/2 + 10, 75);
  38. self.hipsTF.center = CGPointMake(ScreenWidth/2 + 10, 125);
  39. for (int i = 0; i < 2; i++) {
  40. UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 49, ScreenWidth - 20, 0.5)];
  41. lineView.backgroundColor = RGBValueColor(0xdfdfdf, 1);
  42. if (i ==0) {
  43. [self.bustTF addSubview:lineView];
  44. } else {
  45. [self.waistTF addSubview:lineView];
  46. }
  47. }
  48. self.saveBtn = [[UIButton alloc] initWithFrame:CGRectMake(20,CGRectGetMaxY(self.hipsTF.frame) + 40, ScreenWidth - 40, 48)];
  49. self.saveBtn.layer.cornerRadius = 24.f;
  50. self.saveBtn.layer.masksToBounds = YES;
  51. [self.saveBtn setTitle:@"保存" forState:UIControlStateNormal];
  52. [self.saveBtn addTarget:self action:@selector(handleSave) forControlEvents:UIControlEventTouchUpInside];
  53. [self.saveBtn setBackgroundImage:[UIImage imageNamed:@"tixian-1"] forState:UIControlStateNormal];
  54. [self.backView addSubview:self.bustTF];
  55. [self.backView addSubview:self.waistTF];
  56. [self.backView addSubview:self.hipsTF];
  57. [self.view addSubview:self.saveBtn];
  58. }
  59. #pragma mark -
  60. - (void)handleSave {
  61. if (self.bustTF.text.length !=0 && self.waistTF.text.length !=0 && self.hipsTF.text.length !=0) {
  62. [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) {
  63. if ([dataDic[@"msg"] isEqualToString:@"success"]) {
  64. if (self.completion) {
  65. self.completion(@[self.bustTF.text, self.waistTF.text, self.hipsTF.text]);
  66. }
  67. [self.navigationController popViewControllerAnimated:YES];
  68. } else {
  69. [MBProgressHUD showError:@"保存失败"];
  70. }
  71. } enError:^(NSError *error) {
  72. [MBProgressHUD showError:@"保存失败"];
  73. }];
  74. }
  75. }
  76. - (UITextField *)createTF:(NSString *)placeHolder leftText:(NSString *)leftText {
  77. UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth - 20, 50)];
  78. textField.placeholder = placeHolder;
  79. UILabel *leftLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
  80. leftLabel.text = leftText;
  81. textField.leftView = leftLabel;
  82. textField.leftViewMode = UITextFieldViewModeAlways;
  83. textField.keyboardType = UIKeyboardTypeNumberPad;
  84. return textField;
  85. }
  86. - (void)didReceiveMemoryWarning {
  87. [super didReceiveMemoryWarning];
  88. // Dispose of any resources that can be recreated.
  89. }
  90. /*
  91. #pragma mark - Navigation
  92. // In a storyboard-based application, you will often want to do a little preparation before navigation
  93. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  94. // Get the new view controller using [segue destinationViewController].
  95. // Pass the selected object to the new view controller.
  96. }
  97. */
  98. @end