ModelCardController.m 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. //
  2. // ModelDataController.m
  3. // model
  4. //
  5. // Created by JuYi on 2018/7/16.
  6. // Copyright © 2018年 Mine. All rights reserved.
  7. // 模卡资料
  8. #import "ModelCardController.h"
  9. #import "MeasurementsViewController.h"
  10. #import "ModelPhotoViewController.h"
  11. #import "ModelTagViewController.h"
  12. #import "ModelHonorViewController.h"
  13. #import "InfoEditViewController.h"
  14. #import <BRPickerView.h>
  15. #import "MySkillsController.h"
  16. #import "ShareCardController.h"
  17. @interface ModelCardController ()<UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate> {
  18. ModelUser *tempUser;
  19. }
  20. @property (nonatomic, strong) UITableView *tableView;
  21. @property (nonatomic, strong) NSArray *titlesArr;
  22. @property (nonatomic, strong) NSArray *conentArr;
  23. @property (nonatomic, strong) UITableViewCell *nameCell;
  24. @property (nonatomic, strong) UITableViewCell *ageCell;
  25. @property (nonatomic, strong) UITableViewCell *heiCell;
  26. @property (nonatomic, strong) UITableViewCell *weiCell;
  27. @property (nonatomic, strong) UITableViewCell *waiBustHipCell; // 三围
  28. @property (nonatomic, strong) UITableViewCell *photoCell;
  29. @property (nonatomic, strong) UITableViewCell *areaCell; //地区(int类型,可空)
  30. @property (nonatomic, strong) UITableViewCell *occupationCell; //职业
  31. @property (nonatomic, strong) UITableViewCell *spdjCell;//视频单价
  32. @property (nonatomic, strong) UITableViewCell *fgbqCell;//风格标签
  33. @property (nonatomic, strong) UITableViewCell *lnameCell; //个性签名
  34. @property (nonatomic, strong) UITableViewCell *wdryCell; // 我的荣誉
  35. @property (nonatomic, strong) UITableViewCell *constellationCell; // 星座
  36. @property (nonatomic, strong) UITableViewCell *collegeCell; // 学校
  37. @property (nonatomic, strong) UITableViewCell *hobbyCell; // 爱好
  38. @property (nonatomic, strong) NSMutableArray *areaArray;
  39. @end
  40. @implementation ModelCardController
  41. - (void)viewDidLoad {
  42. [super viewDidLoad];
  43. self.title = @"模卡资料";
  44. UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
  45. btn.frame = CGRectMake(0, 0, 40, 40);
  46. [btn setImage:[UIImage imageNamed:@"fanhui2"] forState:UIControlStateNormal];
  47. btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
  48. [btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
  49. UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
  50. UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
  51. self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem];
  52. self.titlesArr = @[@[@"照片"],
  53. @[@"姓名"],
  54. @[@"个性签名"],
  55. @[@"视频单价"],
  56. @[@"身高",@"体重",@"三围",@"地区",@"年龄",@"职业",@"星座",@"毕业院校",@"兴趣爱好"],
  57. @[@"我的标签"],
  58. @[@"我的荣誉"]];
  59. self.conentArr = @[@[@""],
  60. @[@""],
  61. @[@""],
  62. @[@""],
  63. @[@"",@"",@"",@"",@"",@"",@"",@"",@""],
  64. @[@""],
  65. @[@""]];
  66. self.areaArray = [NSMutableArray array];
  67. UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 10)];
  68. headerView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
  69. //
  70. UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight - 460)];
  71. footerView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
  72. UIButton *bindingBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  73. bindingBtn.frame = CGRectMake(20, 39, ScreenWidth - 40, 44);
  74. bindingBtn.layer.backgroundColor = [UIColor colorWithRed:255/255.0 green:64/255.0 blue:149/255.0 alpha:1].CGColor;
  75. bindingBtn.layer.cornerRadius = 22;
  76. bindingBtn.layer.shadowColor = [UIColor colorWithRed:255/255.0 green:64/255.0 blue:149/255.0 alpha:0.36].CGColor;
  77. bindingBtn.layer.shadowOffset = CGSizeMake(0,8);
  78. bindingBtn.layer.shadowOpacity = 1;
  79. bindingBtn.layer.shadowRadius = 10;
  80. if ([@"init" isEqualToString:self.type]) {
  81. [bindingBtn setTitle:@"下一步" forState:UIControlStateNormal];
  82. } else {
  83. [bindingBtn setTitle:@"查看我的模卡" forState:UIControlStateNormal];
  84. }
  85. bindingBtn.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  86. [bindingBtn setTitleColor:RGBValueColor(0xffffff, 1.0) forState:UIControlStateNormal];
  87. [bindingBtn addTarget:self action:@selector(bindingBtnAction) forControlEvents:UIControlEventTouchUpInside];
  88. [footerView addSubview:bindingBtn];
  89. self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) style:UITableViewStylePlain];
  90. // self.tableView.scrollEnabled = NO;
  91. self.tableView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
  92. self.tableView.delegate = self;
  93. self.tableView.dataSource = self;
  94. self.tableView.showsVerticalScrollIndicator = NO;
  95. // self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  96. self.tableView.tableHeaderView = headerView;
  97. self.tableView.tableFooterView = footerView;
  98. [self.view addSubview:self.tableView];
  99. self.view.backgroundColor = [UIColor colorWithRed:242/255.0 green:244/255.0 blue:245/255.0 alpha:1];
  100. [self getAreaData];
  101. }
  102. - (void)viewWillAppear:(BOOL)animated {
  103. [super viewWillAppear:animated];
  104. [self getModelData];
  105. // [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
  106. // [self.navigationController.navigationBar setShadowImage:[UIImage new]];
  107. }
  108. - (void)viewWillDisappear:(BOOL)animated {
  109. [super viewWillDisappear:animated];
  110. // [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
  111. // [self.navigationController.navigationBar setShadowImage:nil];
  112. }
  113. - (void)didReceiveMemoryWarning {
  114. [super didReceiveMemoryWarning];
  115. // Dispose of any resources that can be recreated.
  116. }
  117. - (void)getAreaData {
  118. [YanCNetWorkManager requestGETWithURLStr:Url_getArea(PublicUrl) parameters:@{} finish:^(id dataDic) {
  119. [self.areaArray addObjectsFromArray:dataDic[@"data"]];
  120. [self.tableView reloadData];
  121. } enError:^(NSError *error) {
  122. }];
  123. }
  124. - (void)getModelData {
  125. [YanCNetWorkManager requestGETWithURLStr:Url_getModelData(PublicUrl) parameters:@{@"modelpk":[ModelUser user].modelpk} finish:^(id dataDic) {
  126. [[ModelUser modelUser] setValuesForKeysWithDictionary:[dataDic[@"data"] firstObject]];
  127. tempUser = [ModelUser mj_objectWithKeyValues:[dataDic[@"data"] firstObject]];
  128. [self.tableView reloadData];
  129. } enError:^(NSError *error) {
  130. }];
  131. }
  132. - (void)backClick {
  133. [self.navigationController popViewControllerAnimated:YES];
  134. }
  135. #pragma mark -- UITableViewDelegate, UITableViewDataSource
  136. -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  137. return self.titlesArr.count;
  138. }
  139. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  140. return ((NSDictionary*)self.titlesArr[section]).count;
  141. }
  142. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  143. static NSString *reuseIdentifier=@"cellID";
  144. UITableViewCell *modelCell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
  145. if (modelCell == nil) {
  146. modelCell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier];
  147. }
  148. modelCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  149. modelCell.selectionStyle = UITableViewCellSelectionStyleNone;
  150. modelCell.detailTextLabel.textColor = RGBValueColor(0x999999, 1.0);
  151. modelCell.textLabel.textColor = RGBValueColor(0x333333, 1.0);
  152. modelCell.textLabel.font = [UIFont systemFontOfSize:14.0];
  153. modelCell.detailTextLabel.font = [UIFont systemFontOfSize:14.0];
  154. modelCell.textLabel.text = self.titlesArr[indexPath.section][indexPath.row];
  155. NSString *rowTitle = self.titlesArr[indexPath.section][indexPath.row];
  156. if ([@"照片" isEqualToString:rowTitle]) {
  157. self.photoCell = modelCell;
  158. modelCell.detailTextLabel.text = [NSString stringWithFormat:@"%@张照片",tempUser.photocount];
  159. } else if ([@"姓名" isEqualToString:rowTitle]) {
  160. self.nameCell = modelCell;
  161. modelCell.detailTextLabel.text = tempUser.pet;
  162. } else if ([@"个性签名" isEqualToString:rowTitle]) {
  163. self.lnameCell = modelCell;
  164. modelCell.detailTextLabel.text = tempUser.lname;
  165. } else if ([@"视频单价" isEqualToString:rowTitle]) {
  166. self.spdjCell = modelCell;
  167. modelCell.detailTextLabel.text = [NSString stringWithFormat:@"%@元/分钟",tempUser.vprice];
  168. } else if ([@"身高" isEqualToString:rowTitle]) {
  169. self.heiCell = modelCell;
  170. modelCell.detailTextLabel.text = [NSString stringWithFormat:@"%@cm",tempUser.hei];
  171. } else if ([@"体重" isEqualToString:rowTitle]) {
  172. self.weiCell = modelCell;
  173. modelCell.detailTextLabel.text = [NSString stringWithFormat:@"%@kg",tempUser.wei];
  174. } else if ([@"三围" isEqualToString:rowTitle]) {
  175. self.waiBustHipCell = modelCell;
  176. modelCell.detailTextLabel.text = [NSString stringWithFormat:@"%@/%@/%@",tempUser.bust,tempUser.wai,tempUser.hip];
  177. } else if ([@"地区" isEqualToString:rowTitle]) {
  178. self.areaCell = modelCell;
  179. modelCell.detailTextLabel.text = @"";
  180. for (NSDictionary *dic in self.areaArray) {
  181. if ([dic[@"pk"] isEqual:tempUser.area]) {
  182. modelCell.detailTextLabel.text = dic[@"name"];
  183. }
  184. }
  185. } else if ([@"年龄" isEqualToString:rowTitle]) {
  186. self.ageCell = modelCell;
  187. modelCell.detailTextLabel.text = tempUser.age;
  188. } else if ([@"职业" isEqualToString:rowTitle]) {
  189. self.occupationCell = modelCell;
  190. modelCell.detailTextLabel.text = tempUser.occupation;
  191. } else if ([@"星座" isEqualToString:rowTitle]) {
  192. self.constellationCell = modelCell;
  193. modelCell.detailTextLabel.text = tempUser.constellation;
  194. } else if ([@"毕业院校" isEqualToString:rowTitle]) {
  195. self.collegeCell = modelCell;
  196. modelCell.detailTextLabel.text = tempUser.college;
  197. } else if ([@"兴趣爱好" isEqualToString:rowTitle]) {
  198. self.hobbyCell = modelCell;
  199. modelCell.detailTextLabel.text = tempUser.hobby;
  200. } else if ([@"我的标签" isEqualToString:rowTitle]) {
  201. self.fgbqCell = modelCell;
  202. modelCell.detailTextLabel.text = [NSString stringWithFormat:@"%@个标签", tempUser.stylecount];
  203. } else if ([@"我的荣誉" isEqualToString:rowTitle]) {
  204. self.wdryCell = modelCell;
  205. modelCell.detailTextLabel.text = [NSString stringWithFormat:@"%@个荣誉", tempUser.honorcount];
  206. }
  207. return modelCell;
  208. }
  209. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  210. return 50;
  211. }
  212. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  213. UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
  214. NSString *rowTitle = self.titlesArr[indexPath.section][indexPath.row];
  215. if ([@"照片" isEqualToString:rowTitle]) {
  216. ModelPhotoViewController *photovc = [ModelPhotoViewController new];
  217. [self.navigationController pushViewController:photovc animated:YES];
  218. } else if ([@"姓名" isEqualToString:rowTitle]) {
  219. InfoEditViewController *infoVc = [InfoEditViewController new];
  220. infoVc.editType = InfoEditTypeName;
  221. [self.navigationController pushViewController:infoVc animated:YES];
  222. } else if ([@"个性签名" isEqualToString:rowTitle]) {
  223. InfoEditViewController *infoVc = [InfoEditViewController new];
  224. infoVc.editType = InfoEditTypeSigature;
  225. [self.navigationController pushViewController:infoVc animated:YES];
  226. } else if ([@"视频单价" isEqualToString:rowTitle]) {
  227. InfoEditViewController *infoVc = [InfoEditViewController new];
  228. infoVc.editType = InfoEditTypeVprice;
  229. [self.navigationController pushViewController:infoVc animated:YES];
  230. } else if ([@"身高" isEqualToString:rowTitle]) {
  231. InfoEditViewController *infoVc = [InfoEditViewController new];
  232. infoVc.editType = InfoEditTypeHeight;
  233. [self.navigationController pushViewController:infoVc animated:YES];
  234. } else if ([@"体重" isEqualToString:rowTitle]) {
  235. InfoEditViewController *infoVc = [InfoEditViewController new];
  236. infoVc.editType = InfoEditTypeWeight;
  237. [self.navigationController pushViewController:infoVc animated:YES];
  238. } else if ([@"三围" isEqualToString:rowTitle]) {
  239. MeasurementsViewController *bmhVc = [MeasurementsViewController new];
  240. [self.navigationController pushViewController:bmhVc animated:YES];
  241. } else if ([@"地区" isEqualToString:rowTitle]) {
  242. NSMutableArray *tempArray = [NSMutableArray array];
  243. for (NSDictionary *dic in self.areaArray) {
  244. [tempArray addObject:dic[@"name"]];
  245. }
  246. [BRStringPickerView showStringPickerWithTitle:@"请选择地区" dataSource:tempArray defaultSelValue:nil resultBlock:^(id selectValue) {
  247. for (NSDictionary *dic in self.areaArray) {
  248. if ([dic[@"name"] isEqualToString:selectValue]) {
  249. [YanCNetWorkManager requestPostWithURLStr:Url_updateModelCard(PublicUrl)
  250. parameters:@{@"area":dic[@"pk"],@"modelpk":[ModelUser user].modelpk}
  251. finish:^(id dataDic) {
  252. if ([dataDic[@"msg"] isEqualToString:@"success"]) {
  253. [MBProgressHUD showSuccess:@"修改成功"];
  254. cell.detailTextLabel.text = selectValue;
  255. } else {
  256. [MBProgressHUD showError:@"修改失败"];
  257. }
  258. }
  259. enError:^(NSError *error) {
  260. }];
  261. }
  262. }
  263. }];
  264. } else if ([@"年龄" isEqualToString:rowTitle]) {
  265. InfoEditViewController *infoVc = [InfoEditViewController new];
  266. infoVc.editType = InfoEditTypeAge;
  267. [self.navigationController pushViewController:infoVc animated:YES];
  268. } else if ([@"职业" isEqualToString:rowTitle]) {
  269. InfoEditViewController *infoVc = [InfoEditViewController new];
  270. infoVc.editType = InfoEditTypeOccupation;
  271. [self.navigationController pushViewController:infoVc animated:YES];
  272. } else if ([@"星座" isEqualToString:rowTitle]) {
  273. InfoEditViewController *infoVc = [InfoEditViewController new];
  274. infoVc.editType = InfoEditTypeConstellation;
  275. [self.navigationController pushViewController:infoVc animated:YES];
  276. } else if ([@"毕业院校" isEqualToString:rowTitle]) {
  277. InfoEditViewController *infoVc = [InfoEditViewController new];
  278. infoVc.editType = InfoEditTypeCollege;
  279. [self.navigationController pushViewController:infoVc animated:YES];
  280. } else if ([@"兴趣爱好" isEqualToString:rowTitle]) {
  281. InfoEditViewController *infoVc = [InfoEditViewController new];
  282. infoVc.editType = InfoEditTypeHobby;
  283. [self.navigationController pushViewController:infoVc animated:YES];
  284. } else if ([@"我的标签" isEqualToString:rowTitle]) {
  285. ModelTagViewController *tagVC = [ModelTagViewController new];
  286. [self.navigationController pushViewController:tagVC animated:YES];
  287. } else if ([@"我的荣誉" isEqualToString:rowTitle]) {
  288. ModelHonorViewController *honorVc = [ModelHonorViewController new];
  289. [self.navigationController pushViewController:honorVc animated:YES];
  290. }
  291. }
  292. #pragma mark -- 保存按钮
  293. - (void)bindingBtnAction {
  294. NSLog(@"name %@", self.nameCell.textLabel.text);
  295. if (self.nameCell.textLabel.text.length == 0) {
  296. [MBProgressHUD showOnlyText:@"请选择填写姓名" controller:self];
  297. return;
  298. }
  299. NSLog(@"age %@", self.ageCell.textLabel.text);
  300. if (self.ageCell.textLabel.text.length == 0) {
  301. [MBProgressHUD showOnlyText:@"请选择填写年龄" controller:self];
  302. return;
  303. }
  304. NSLog(@"heiCell %@", self.heiCell.textLabel.text);
  305. if (self.heiCell.textLabel.text.length == 0) {
  306. [MBProgressHUD showOnlyText:@"请选择填写身高" controller:self];
  307. return;
  308. }
  309. NSLog(@"体重 %@", self.weiCell.textLabel.text);
  310. if (self.weiCell.textLabel.text.length == 0) {
  311. [MBProgressHUD showOnlyText:@"请选择填写体重" controller:self];
  312. return;
  313. }
  314. NSLog(@"三围 %@", self.nameCell.textLabel.text);
  315. if (self.nameCell.textLabel.text.length == 0) {
  316. [MBProgressHUD showOnlyText:@"请选择填写三围" controller:self];
  317. return;
  318. }
  319. NSLog(@"地区 %@", self.areaCell.textLabel.text);
  320. if (self.areaCell.textLabel.text.length == 0) {
  321. [MBProgressHUD showOnlyText:@"请选择填写地区" controller:self];
  322. return;
  323. }
  324. if (![[ModelUser user].modelpk isEqualToString:@"51"]) {
  325. NSLog(@"视频单价 %@", self.spdjCell.textLabel.text);
  326. if (self.spdjCell.textLabel.text.length == 0) {
  327. [MBProgressHUD showOnlyText:@"请选择填写视频单价" controller:self];
  328. return;
  329. }
  330. }
  331. NSLog(@"风格标签 %@", self.fgbqCell.textLabel.text);
  332. if (self.fgbqCell.textLabel.text.length == 0) {
  333. [MBProgressHUD showOnlyText:@"请选择填写标签" controller:self];
  334. return;
  335. }
  336. NSLog(@"个人签名 %@", self.lnameCell.textLabel.text);
  337. if (self.lnameCell.textLabel.text.length == 0) {
  338. [MBProgressHUD showOnlyText:@"请选择填写签名" controller:self];
  339. return;
  340. }
  341. // [MBProgressHUD showSuccess:@"保存成功"];
  342. // [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(backClick) userInfo:nil repeats:NO];
  343. if ([@"init" isEqualToString:self.type]) {
  344. MySkillsController *mySkillsVC = [[MySkillsController alloc] init];
  345. [self.navigationController pushViewController:mySkillsVC animated:YES];
  346. } else {
  347. ShareCardController *shareCardVC = [[ShareCardController alloc] init];
  348. [self.navigationController pushViewController:shareCardVC animated:YES];
  349. }
  350. }
  351. #pragma mark -- 网络请求
  352. - (void)postDataFromNetworking {
  353. [MBProgressHUD showHUDAddedTo:self.view animated:YES];
  354. ModelUser *modelUser = [ModelUser user];
  355. NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:modelUser.modelpk,@"modelpk",self.lnameCell.textLabel.text,@"lname", nil];
  356. [YanCNetWorkManager requestPostWithURLStr:Url_updateModelCard(PublicUrl) parameters:dic finish:^(id dataDic) {
  357. [MBProgressHUD hideHUDForView:self.view animated:YES];
  358. NSString *issuccess = dataDic[@"msg"];
  359. if ([issuccess isEqualToString:@"success"]) {
  360. [MBProgressHUD showSuccess:@"保存成功"];
  361. } else {
  362. }
  363. } enError:^(NSError *error) {
  364. [MBProgressHUD hideHUDForView:self.view animated:YES];
  365. }];
  366. }
  367. @end