InfoEditViewController.m 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. //
  2. // InfoEditViewController.m
  3. // model
  4. //
  5. // Created by liufei on 2018/7/25.
  6. // Copyright © 2018年 Mine. All rights reserved.
  7. //
  8. #import "InfoEditViewController.h"
  9. @interface InfoEditViewController ()
  10. @property(nonatomic, strong) UITextField *infoTextField;
  11. @end
  12. @implementation InfoEditViewController
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. [self configUI];
  16. // Do any additional setup after loading the view.
  17. }
  18. - (void)configUI {
  19. self.view.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
  20. self.navigationController.navigationBar.tintColor = RGBValueColor(0x333333, 1);
  21. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStylePlain target:self action:@selector(handleSave)];
  22. self.infoTextField = [[UITextField alloc] initWithFrame:CGRectMake(0, 10, ScreenWidth, 40)];
  23. self.infoTextField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 40)];
  24. self.infoTextField.leftViewMode = UITextFieldViewModeAlways;
  25. self.infoTextField.backgroundColor = [UIColor whiteColor];
  26. [self.view addSubview:self.infoTextField];
  27. switch (_editType) {
  28. case InfoEditTypeName:
  29. self.title = @"用户名";
  30. self.infoTextField.placeholder = @"请输入用户名";
  31. self.infoTextField.text = [ModelUser modelUser].pet;
  32. break;
  33. case InfoEditTypeAge:
  34. self.title = @"年龄";
  35. self.infoTextField.placeholder = @"请输入年龄";
  36. self.infoTextField.text = [ModelUser modelUser].age;
  37. self.infoTextField.keyboardType = UIKeyboardTypeNumberPad;
  38. break;
  39. case InfoEditTypeHeight:
  40. self.title = @"身高";
  41. self.infoTextField.placeholder = @"请输入身高(cm)";
  42. self.infoTextField.text = [ModelUser modelUser].hei;
  43. self.infoTextField.keyboardType = UIKeyboardTypeDecimalPad;
  44. break;
  45. case InfoEditTypeWeight:
  46. self.title = @"体重";
  47. self.infoTextField.placeholder = @"请输入体重(kg)";
  48. self.infoTextField.text = [ModelUser modelUser].wei;
  49. self.infoTextField.keyboardType = UIKeyboardTypeDecimalPad;
  50. break;
  51. case InfoEditTypeSigature:
  52. self.title = @"个性签名";
  53. self.infoTextField.text = [ModelUser modelUser].lname;
  54. self.infoTextField.placeholder = @"请输入个性签名";
  55. break;
  56. case InfoEditTypeVprice:
  57. self.title = @"视频单价";
  58. self.infoTextField.text = [ModelUser modelUser].vprice;
  59. self.infoTextField.placeholder = @"请输入视频单价(6--49)元";
  60. self.infoTextField.keyboardType = UIKeyboardTypeNumberPad;
  61. break;
  62. case InfoEditTypeHobby:
  63. self.title = @"兴趣爱好";
  64. self.infoTextField.text = [ModelUser modelUser].hobby;
  65. self.infoTextField.placeholder = @"请填写兴趣爱好";
  66. break;
  67. case InfoEditTypeCollege:
  68. self.title = @"毕业院校";
  69. self.infoTextField.text = [ModelUser modelUser].college;
  70. self.infoTextField.placeholder = @"请填写毕业院校";
  71. break;
  72. case InfoEditTypeOccupation:
  73. self.title = @"职业";
  74. self.infoTextField.text = [ModelUser modelUser].occupation;
  75. self.infoTextField.placeholder = @"请填写职业";
  76. break;
  77. case InfoEditTypeConstellation:
  78. self.title = @"星座";
  79. self.infoTextField.text = [ModelUser modelUser].constellation;
  80. self.infoTextField.placeholder = @"请填写星座";
  81. break;
  82. default:
  83. break;
  84. }
  85. }
  86. - (void)handleSave {
  87. if (self.infoTextField.text.length != 0) {
  88. [self.infoTextField resignFirstResponder];
  89. if (_editType == InfoEditTypeVprice) {
  90. NSInteger price = [self.infoTextField.text integerValue];
  91. if (price < 6 || price > 49) {
  92. [MBProgressHUD showOnlyText:@"视频单价不能小于6元或大于49元" controller:self];
  93. return;
  94. }
  95. }
  96. [self handleInfo:self.infoTextField.text];
  97. }
  98. }
  99. - (void)handleInfo:(NSString *)info {
  100. NSString *paramterKey;
  101. switch (_editType) {
  102. case InfoEditTypeName:
  103. paramterKey = @"name";
  104. break;
  105. case InfoEditTypeAge:
  106. paramterKey = @"age";
  107. break;
  108. case InfoEditTypeHeight:
  109. paramterKey = @"hei";
  110. break;
  111. case InfoEditTypeWeight:
  112. paramterKey = @"wei";
  113. break;
  114. case InfoEditTypeSigature:
  115. paramterKey = @"lname";
  116. break;
  117. case InfoEditTypeVprice:
  118. paramterKey = @"vprice";
  119. break;
  120. case InfoEditTypeHobby:
  121. paramterKey = @"hobby";
  122. break;
  123. case InfoEditTypeCollege:
  124. paramterKey = @"college";
  125. break;
  126. case InfoEditTypeOccupation:
  127. paramterKey = @"occupation";
  128. break;
  129. case InfoEditTypeConstellation:
  130. paramterKey = @"constellation";
  131. break;
  132. default:
  133. break;
  134. }
  135. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  136. [YanCNetWorkManager requestPostWithURLStr:Url_updateModelCard(PublicUrl) parameters:@{paramterKey: info, @"modelpk": [ModelUser user].modelpk} finish:^(id dataDic) {
  137. [MBProgressHUD hideHUDForView:self.view animated:YES];
  138. if (self.complete) {
  139. self.complete(info);
  140. }
  141. [self.navigationController popViewControllerAnimated:YES];
  142. } enError:^(NSError *error) {
  143. }];
  144. }
  145. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  146. [super touchesBegan:touches withEvent:event];
  147. [self.infoTextField resignFirstResponder];
  148. }
  149. - (void)didReceiveMemoryWarning {
  150. [super didReceiveMemoryWarning];
  151. // Dispose of any resources that can be recreated.
  152. }
  153. /*
  154. #pragma mark - Navigation
  155. // In a storyboard-based application, you will often want to do a little preparation before navigation
  156. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  157. // Get the new view controller using [segue destinationViewController].
  158. // Pass the selected object to the new view controller.
  159. }
  160. */
  161. @end