| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406 |
- //
- // ModelDataController.m
- // model
- //
- // Created by JuYi on 2018/7/16.
- // Copyright © 2018年 Mine. All rights reserved.
- // 模卡资料
- #import "ModelCardController.h"
- #import "MeasurementsViewController.h"
- #import "ModelPhotoViewController.h"
- #import "ModelTagViewController.h"
- #import "ModelHonorViewController.h"
- #import "InfoEditViewController.h"
- #import <BRPickerView.h>
- #import "MySkillsController.h"
- #import "ShareCardController.h"
- @interface ModelCardController ()<UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate> {
- ModelUser *tempUser;
- }
- @property (nonatomic, strong) UITableView *tableView;
- @property (nonatomic, strong) NSArray *titlesArr;
- @property (nonatomic, strong) NSArray *conentArr;
- @property (nonatomic, strong) UITableViewCell *nameCell;
- @property (nonatomic, strong) UITableViewCell *ageCell;
- @property (nonatomic, strong) UITableViewCell *heiCell;
- @property (nonatomic, strong) UITableViewCell *weiCell;
- @property (nonatomic, strong) UITableViewCell *waiBustHipCell; // 三围
- @property (nonatomic, strong) UITableViewCell *photoCell;
- @property (nonatomic, strong) UITableViewCell *areaCell; //地区(int类型,可空)
- @property (nonatomic, strong) UITableViewCell *occupationCell; //职业
- @property (nonatomic, strong) UITableViewCell *spdjCell;//视频单价
- @property (nonatomic, strong) UITableViewCell *fgbqCell;//风格标签
- @property (nonatomic, strong) UITableViewCell *lnameCell; //个性签名
- @property (nonatomic, strong) UITableViewCell *wdryCell; // 我的荣誉
- @property (nonatomic, strong) UITableViewCell *constellationCell; // 星座
- @property (nonatomic, strong) UITableViewCell *collegeCell; // 学校
- @property (nonatomic, strong) UITableViewCell *hobbyCell; // 爱好
- @property (nonatomic, strong) NSMutableArray *areaArray;
- @end
- @implementation ModelCardController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.title = @"模卡资料";
- 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.titlesArr = @[@[@"照片"],
- @[@"姓名"],
- @[@"个性签名"],
- @[@"视频单价"],
- @[@"身高",@"体重",@"三围",@"地区",@"年龄",@"职业",@"星座",@"毕业院校",@"兴趣爱好"],
- @[@"我的标签"],
- @[@"我的荣誉"]];
- self.conentArr = @[@[@""],
- @[@""],
- @[@""],
- @[@""],
- @[@"",@"",@"",@"",@"",@"",@"",@"",@""],
- @[@""],
- @[@""]];
-
- self.areaArray = [NSMutableArray array];
-
- UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 10)];
- headerView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
- //
- UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight - 460)];
- footerView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
- UIButton *bindingBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- bindingBtn.frame = CGRectMake(20, 39, ScreenWidth - 40, 44);
-
- bindingBtn.layer.backgroundColor = [UIColor colorWithRed:255/255.0 green:64/255.0 blue:149/255.0 alpha:1].CGColor;
- bindingBtn.layer.cornerRadius = 22;
- bindingBtn.layer.shadowColor = [UIColor colorWithRed:255/255.0 green:64/255.0 blue:149/255.0 alpha:0.36].CGColor;
- bindingBtn.layer.shadowOffset = CGSizeMake(0,8);
- bindingBtn.layer.shadowOpacity = 1;
- bindingBtn.layer.shadowRadius = 10;
- if ([@"init" isEqualToString:self.type]) {
- [bindingBtn setTitle:@"下一步" forState:UIControlStateNormal];
- } else {
- [bindingBtn setTitle:@"查看我的模卡" forState:UIControlStateNormal];
- }
- bindingBtn.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
- [bindingBtn setTitleColor:RGBValueColor(0xffffff, 1.0) forState:UIControlStateNormal];
- [bindingBtn addTarget:self action:@selector(bindingBtnAction) forControlEvents:UIControlEventTouchUpInside];
- [footerView addSubview:bindingBtn];
-
- self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) style:UITableViewStylePlain];
- // self.tableView.scrollEnabled = NO;
- self.tableView.backgroundColor = RGBValueColor(0xf7f7f7, 1.0);
- self.tableView.delegate = self;
- self.tableView.dataSource = self;
- self.tableView.showsVerticalScrollIndicator = NO;
- // self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
- self.tableView.tableHeaderView = headerView;
- self.tableView.tableFooterView = footerView;
- [self.view addSubview:self.tableView];
- self.view.backgroundColor = [UIColor colorWithRed:242/255.0 green:244/255.0 blue:245/255.0 alpha:1];
- [self getAreaData];
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- [self getModelData];
- // [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
- // [self.navigationController.navigationBar setShadowImage:[UIImage new]];
- }
- - (void)viewWillDisappear:(BOOL)animated {
- [super viewWillDisappear:animated];
- // [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
- // [self.navigationController.navigationBar setShadowImage:nil];
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (void)getAreaData {
- [YanCNetWorkManager requestGETWithURLStr:Url_getArea(PublicUrl) parameters:@{} finish:^(id dataDic) {
- [self.areaArray addObjectsFromArray:dataDic[@"data"]];
- [self.tableView reloadData];
- } enError:^(NSError *error) {
-
- }];
- }
- - (void)getModelData {
- [YanCNetWorkManager requestGETWithURLStr:Url_getModelData(PublicUrl) parameters:@{@"modelpk":[ModelUser user].modelpk} finish:^(id dataDic) {
- [[ModelUser modelUser] setValuesForKeysWithDictionary:[dataDic[@"data"] firstObject]];
- tempUser = [ModelUser mj_objectWithKeyValues:[dataDic[@"data"] firstObject]];
- [self.tableView reloadData];
- } enError:^(NSError *error) {
-
- }];
- }
- - (void)backClick {
- [self.navigationController popViewControllerAnimated:YES];
- }
- #pragma mark -- UITableViewDelegate, UITableViewDataSource
- -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
- return self.titlesArr.count;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return ((NSDictionary*)self.titlesArr[section]).count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- static NSString *reuseIdentifier=@"cellID";
- UITableViewCell *modelCell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
- if (modelCell == nil) {
- modelCell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier];
- }
- modelCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
- modelCell.selectionStyle = UITableViewCellSelectionStyleNone;
- modelCell.detailTextLabel.textColor = RGBValueColor(0x999999, 1.0);
- modelCell.textLabel.textColor = RGBValueColor(0x333333, 1.0);
- modelCell.textLabel.font = [UIFont systemFontOfSize:14.0];
- modelCell.detailTextLabel.font = [UIFont systemFontOfSize:14.0];
- modelCell.textLabel.text = self.titlesArr[indexPath.section][indexPath.row];
-
- NSString *rowTitle = self.titlesArr[indexPath.section][indexPath.row];
- if ([@"照片" isEqualToString:rowTitle]) {
- self.photoCell = modelCell;
- modelCell.detailTextLabel.text = [NSString stringWithFormat:@"%@张照片",tempUser.photocount];
- } else if ([@"姓名" isEqualToString:rowTitle]) {
- self.nameCell = modelCell;
- modelCell.detailTextLabel.text = tempUser.pet;
- } else if ([@"个性签名" isEqualToString:rowTitle]) {
- self.lnameCell = modelCell;
- modelCell.detailTextLabel.text = tempUser.lname;
- } else if ([@"视频单价" isEqualToString:rowTitle]) {
- self.spdjCell = modelCell;
- modelCell.detailTextLabel.text = [NSString stringWithFormat:@"%@元/分钟",tempUser.vprice];
- } else if ([@"身高" isEqualToString:rowTitle]) {
- self.heiCell = modelCell;
- modelCell.detailTextLabel.text = [NSString stringWithFormat:@"%@cm",tempUser.hei];
- } else if ([@"体重" isEqualToString:rowTitle]) {
- self.weiCell = modelCell;
- modelCell.detailTextLabel.text = [NSString stringWithFormat:@"%@kg",tempUser.wei];
- } else if ([@"三围" isEqualToString:rowTitle]) {
- self.waiBustHipCell = modelCell;
- modelCell.detailTextLabel.text = [NSString stringWithFormat:@"%@/%@/%@",tempUser.bust,tempUser.wai,tempUser.hip];
- } else if ([@"地区" isEqualToString:rowTitle]) {
- self.areaCell = modelCell;
- modelCell.detailTextLabel.text = @"";
- for (NSDictionary *dic in self.areaArray) {
- if ([dic[@"pk"] isEqual:tempUser.area]) {
- modelCell.detailTextLabel.text = dic[@"name"];
- }
- }
- } else if ([@"年龄" isEqualToString:rowTitle]) {
- self.ageCell = modelCell;
- modelCell.detailTextLabel.text = tempUser.age;
- } else if ([@"职业" isEqualToString:rowTitle]) {
- self.occupationCell = modelCell;
- modelCell.detailTextLabel.text = tempUser.occupation;
- } else if ([@"星座" isEqualToString:rowTitle]) {
- self.constellationCell = modelCell;
- modelCell.detailTextLabel.text = tempUser.constellation;
- } else if ([@"毕业院校" isEqualToString:rowTitle]) {
- self.collegeCell = modelCell;
- modelCell.detailTextLabel.text = tempUser.college;
- } else if ([@"兴趣爱好" isEqualToString:rowTitle]) {
- self.hobbyCell = modelCell;
- modelCell.detailTextLabel.text = tempUser.hobby;
- } else if ([@"我的标签" isEqualToString:rowTitle]) {
- self.fgbqCell = modelCell;
- modelCell.detailTextLabel.text = [NSString stringWithFormat:@"%@个标签", tempUser.stylecount];
- } else if ([@"我的荣誉" isEqualToString:rowTitle]) {
- self.wdryCell = modelCell;
- modelCell.detailTextLabel.text = [NSString stringWithFormat:@"%@个荣誉", tempUser.honorcount];
- }
- return modelCell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
- return 50;
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
- NSString *rowTitle = self.titlesArr[indexPath.section][indexPath.row];
- if ([@"照片" isEqualToString:rowTitle]) {
- ModelPhotoViewController *photovc = [ModelPhotoViewController new];
- [self.navigationController pushViewController:photovc animated:YES];
- } else if ([@"姓名" isEqualToString:rowTitle]) {
- InfoEditViewController *infoVc = [InfoEditViewController new];
- infoVc.editType = InfoEditTypeName;
- [self.navigationController pushViewController:infoVc animated:YES];
- } else if ([@"个性签名" isEqualToString:rowTitle]) {
- InfoEditViewController *infoVc = [InfoEditViewController new];
- infoVc.editType = InfoEditTypeSigature;
- [self.navigationController pushViewController:infoVc animated:YES];
- } else if ([@"视频单价" isEqualToString:rowTitle]) {
- InfoEditViewController *infoVc = [InfoEditViewController new];
- infoVc.editType = InfoEditTypeVprice;
- [self.navigationController pushViewController:infoVc animated:YES];
- } else if ([@"身高" isEqualToString:rowTitle]) {
- InfoEditViewController *infoVc = [InfoEditViewController new];
- infoVc.editType = InfoEditTypeHeight;
- [self.navigationController pushViewController:infoVc animated:YES];
- } else if ([@"体重" isEqualToString:rowTitle]) {
- InfoEditViewController *infoVc = [InfoEditViewController new];
- infoVc.editType = InfoEditTypeWeight;
- [self.navigationController pushViewController:infoVc animated:YES];
- } else if ([@"三围" isEqualToString:rowTitle]) {
- MeasurementsViewController *bmhVc = [MeasurementsViewController new];
- [self.navigationController pushViewController:bmhVc animated:YES];
- } else if ([@"地区" isEqualToString:rowTitle]) {
- NSMutableArray *tempArray = [NSMutableArray array];
- for (NSDictionary *dic in self.areaArray) {
- [tempArray addObject:dic[@"name"]];
- }
- [BRStringPickerView showStringPickerWithTitle:@"请选择地区" dataSource:tempArray defaultSelValue:nil resultBlock:^(id selectValue) {
- for (NSDictionary *dic in self.areaArray) {
- if ([dic[@"name"] isEqualToString:selectValue]) {
- [YanCNetWorkManager requestPostWithURLStr:Url_updateModelCard(PublicUrl)
- parameters:@{@"area":dic[@"pk"],@"modelpk":[ModelUser user].modelpk}
- finish:^(id dataDic) {
- if ([dataDic[@"msg"] isEqualToString:@"success"]) {
- [MBProgressHUD showSuccess:@"修改成功"];
- cell.detailTextLabel.text = selectValue;
- } else {
- [MBProgressHUD showError:@"修改失败"];
- }
-
- }
- enError:^(NSError *error) {
-
- }];
- }
- }
- }];
- } else if ([@"年龄" isEqualToString:rowTitle]) {
- InfoEditViewController *infoVc = [InfoEditViewController new];
- infoVc.editType = InfoEditTypeAge;
- [self.navigationController pushViewController:infoVc animated:YES];
- } else if ([@"职业" isEqualToString:rowTitle]) {
- InfoEditViewController *infoVc = [InfoEditViewController new];
- infoVc.editType = InfoEditTypeOccupation;
- [self.navigationController pushViewController:infoVc animated:YES];
- } else if ([@"星座" isEqualToString:rowTitle]) {
- InfoEditViewController *infoVc = [InfoEditViewController new];
- infoVc.editType = InfoEditTypeConstellation;
- [self.navigationController pushViewController:infoVc animated:YES];
- } else if ([@"毕业院校" isEqualToString:rowTitle]) {
- InfoEditViewController *infoVc = [InfoEditViewController new];
- infoVc.editType = InfoEditTypeCollege;
- [self.navigationController pushViewController:infoVc animated:YES];
- } else if ([@"兴趣爱好" isEqualToString:rowTitle]) {
- InfoEditViewController *infoVc = [InfoEditViewController new];
- infoVc.editType = InfoEditTypeHobby;
- [self.navigationController pushViewController:infoVc animated:YES];
- } else if ([@"我的标签" isEqualToString:rowTitle]) {
- ModelTagViewController *tagVC = [ModelTagViewController new];
- [self.navigationController pushViewController:tagVC animated:YES];
- } else if ([@"我的荣誉" isEqualToString:rowTitle]) {
- ModelHonorViewController *honorVc = [ModelHonorViewController new];
- [self.navigationController pushViewController:honorVc animated:YES];
- }
- }
- #pragma mark -- 保存按钮
- - (void)bindingBtnAction {
- NSLog(@"name %@", self.nameCell.textLabel.text);
- if (self.nameCell.textLabel.text.length == 0) {
- [MBProgressHUD showOnlyText:@"请选择填写姓名" controller:self];
- return;
- }
- NSLog(@"age %@", self.ageCell.textLabel.text);
- if (self.ageCell.textLabel.text.length == 0) {
- [MBProgressHUD showOnlyText:@"请选择填写年龄" controller:self];
- return;
- }
- NSLog(@"heiCell %@", self.heiCell.textLabel.text);
- if (self.heiCell.textLabel.text.length == 0) {
- [MBProgressHUD showOnlyText:@"请选择填写身高" controller:self];
- return;
- }
- NSLog(@"体重 %@", self.weiCell.textLabel.text);
- if (self.weiCell.textLabel.text.length == 0) {
- [MBProgressHUD showOnlyText:@"请选择填写体重" controller:self];
- return;
- }
- NSLog(@"三围 %@", self.nameCell.textLabel.text);
- if (self.nameCell.textLabel.text.length == 0) {
- [MBProgressHUD showOnlyText:@"请选择填写三围" controller:self];
- return;
- }
- NSLog(@"地区 %@", self.areaCell.textLabel.text);
- if (self.areaCell.textLabel.text.length == 0) {
- [MBProgressHUD showOnlyText:@"请选择填写地区" controller:self];
- return;
- }
- if (![[ModelUser user].modelpk isEqualToString:@"51"]) {
- NSLog(@"视频单价 %@", self.spdjCell.textLabel.text);
- if (self.spdjCell.textLabel.text.length == 0) {
- [MBProgressHUD showOnlyText:@"请选择填写视频单价" controller:self];
- return;
- }
- }
- NSLog(@"风格标签 %@", self.fgbqCell.textLabel.text);
- if (self.fgbqCell.textLabel.text.length == 0) {
- [MBProgressHUD showOnlyText:@"请选择填写标签" controller:self];
- return;
- }
- NSLog(@"个人签名 %@", self.lnameCell.textLabel.text);
- if (self.lnameCell.textLabel.text.length == 0) {
- [MBProgressHUD showOnlyText:@"请选择填写签名" controller:self];
- return;
- }
- // [MBProgressHUD showSuccess:@"保存成功"];
- // [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(backClick) userInfo:nil repeats:NO];
-
- if ([@"init" isEqualToString:self.type]) {
- MySkillsController *mySkillsVC = [[MySkillsController alloc] init];
- [self.navigationController pushViewController:mySkillsVC animated:YES];
- } else {
- ShareCardController *shareCardVC = [[ShareCardController alloc] init];
- [self.navigationController pushViewController:shareCardVC animated:YES];
- }
- }
- #pragma mark -- 网络请求
- - (void)postDataFromNetworking {
- [MBProgressHUD showHUDAddedTo:self.view animated:YES];
- ModelUser *modelUser = [ModelUser user];
-
- NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:modelUser.modelpk,@"modelpk",self.lnameCell.textLabel.text,@"lname", nil];
-
- [YanCNetWorkManager requestPostWithURLStr:Url_updateModelCard(PublicUrl) parameters:dic finish:^(id dataDic) {
- [MBProgressHUD hideHUDForView:self.view animated:YES];
- NSString *issuccess = dataDic[@"msg"];
- if ([issuccess isEqualToString:@"success"]) {
- [MBProgressHUD showSuccess:@"保存成功"];
- } else {
-
- }
- } enError:^(NSError *error) {
- [MBProgressHUD hideHUDForView:self.view animated:YES];
- }];
- }
- @end
|