PrivateSpaceViewController.m 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. //
  2. // PrivateSpaceViewController.m
  3. // 千模
  4. //
  5. // Created by MUMEI on 2018/5/18.
  6. // Copyright © 2018年 MUMEI. All rights reserved.
  7. //
  8. #import "PrivateSpaceViewController.h"
  9. #import "OneImageCell.h"
  10. #import "TwoImageCell.h"
  11. #import "FourImageCell.h"
  12. #import "OnlyTextCell.h"
  13. #import "PushStateCell.h"
  14. #import "personalImage.h"
  15. #import "PrivateModel.h"
  16. #import "ImageViewController.h"
  17. #import "PublishViewController.h"
  18. #import "DetailOnlyTextViewController.h"
  19. #import "DetailOneImageViewController.h"
  20. @interface PrivateSpaceViewController ()<OneImageDelegate,TwoImageDelegate,FourImageDelegate,pushOrderDelegate>
  21. @property (weak, nonatomic) IBOutlet UIImageView *zixunImage;
  22. @property (weak, nonatomic) IBOutlet UIImageView *shipinImage;
  23. @property (weak, nonatomic) IBOutlet UITableView *tableView;
  24. @property (weak, nonatomic) IBOutlet personalImage *backView;
  25. @property (strong, nonatomic) NSString *nickName;
  26. @property (strong, nonatomic) NSString *star;
  27. @property (strong, nonatomic) NSString *fCount;//粉丝数
  28. @property (strong, nonatomic) NSString *is_A;//是否在线
  29. @property (strong, nonatomic) NSString *is_V;//是否支持视频
  30. @property (strong, nonatomic) NSString *hei;//身高
  31. @property (strong, nonatomic) NSString *wei;//体重
  32. @property (strong, nonatomic) NSString *bust;//胸围
  33. @property (strong, nonatomic) NSString *wai;//腰围
  34. @property (strong, nonatomic) NSString *hip;//臀围
  35. @property (strong, nonatomic) NSString *vPrice;//视频价格
  36. @property (strong, nonatomic) NSString *lName;//个性签名
  37. @property (strong, nonatomic) NSString *hphoto;
  38. @property (strong, nonatomic) NSMutableArray *photoArray;
  39. @property (assign, nonatomic) NSInteger photoCount;
  40. //@property (nonatomic,strong) ActorModel *model;
  41. @property (strong, nonatomic) NSMutableArray *privateArray;
  42. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomHeight;
  43. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *topHeight;
  44. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomHeight2;
  45. @end
  46. @implementation PrivateSpaceViewController
  47. {
  48. ActorModel *actModel;
  49. personalImage * backImage;
  50. int index;
  51. }
  52. - (NSMutableArray *)privateArray {
  53. if (!_privateArray) {
  54. _privateArray = [NSMutableArray arrayWithCapacity:0];
  55. }
  56. return _privateArray;
  57. }
  58. - (void)viewDidLoad {
  59. [super viewDidLoad];
  60. // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(hideNavigationBar) name:@"hideNavigationBar" object:nil];
  61. self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  62. if ([UIScreen spt_currentScreenMode]== LESScreenModeIPhoneX) {
  63. _topHeight.constant = -24;
  64. _bottomHeight.constant = 34;
  65. }
  66. backImage = [[personalImage alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenWidth+68)];
  67. self.tableView.tableHeaderView = backImage;
  68. self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
  69. [self.tableView setSeparatorInset:UIEdgeInsetsZero];
  70. self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshList)];
  71. self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
  72. _tableView.showsVerticalScrollIndicator = NO;
  73. }
  74. -(void)hideNavigationBar{
  75. self.navigationController.navigationBar.hidden = YES;
  76. }
  77. - (void)viewWillAppear:(BOOL)animated {
  78. [super viewWillAppear:animated];
  79. [self changeLoginState:@"1"];
  80. [self getPrivateModel];
  81. [self refreshList];
  82. self.navigationController.navigationBar.hidden = YES;
  83. }
  84. - (void)viewWillDisappear:(BOOL)animated{
  85. self.navigationController.navigationBar.hidden = NO;
  86. }
  87. - (void)changeLoginState:(NSString *)state{
  88. NSString *str = [NSString stringWithFormat:@"%@modelInfo?action=doPutOnline&modelpk=%@&online=%@",imageURl,[ModelUser user].modelpk,state];
  89. [[AHHttpManager sharedManager]POST:str parameters:nil success:^(id responseObject) {
  90. NSLog(@"%@",responseObject);
  91. if ([[responseObject objectForKey:@"msg"]isEqualToString:@"success"]) {
  92. }else{
  93. }
  94. } failure:^(NSError *error) {
  95. NSLog(@"error = %@",error);
  96. }];
  97. }
  98. -(void)refreshList{
  99. index = 1;
  100. [self.privateArray removeAllObjects];
  101. [self getPrivate:[NSString stringWithFormat:@"%d",index]];
  102. }
  103. - (void)loadMoreData{
  104. index++;
  105. [self getPrivate:[NSString stringWithFormat:@"%d",index]];
  106. }
  107. - (void)getPrivate:(NSString*)Index{
  108. NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:[ModelUser user].modelpk,@"ModelPK",[ModelUser user].pk,@"memberpk",Index,@"index",@"10",@"size", nil];
  109. [YanCNetWorkManager requestPostWithURLStr:Url_doGetPrivate(PublicUrl) parameters:dic finish:^(id dataDic) {
  110. [MBProgressHUD hideHUDForView:self.view animated:YES];
  111. NSString *issuccess = dataDic[@"msg"];
  112. if ([issuccess isEqualToString:@"success"]) {
  113. self.hphoto = [dataDic objectForKey:@"hphoto"];
  114. NSArray *data = dataDic[@"data"];
  115. NSArray * array = [PrivateModel arrayOfModelsFromDictionaries:data];
  116. [self.privateArray addObjectsFromArray:array];
  117. NSString *number = dataDic[@"count"];
  118. NSInteger num = [number integerValue];
  119. [self.tableView.mj_header endRefreshing];
  120. if (num == self.privateArray.count || num == 0) {
  121. [self.tableView.mj_footer endRefreshingWithNoMoreData];
  122. }else{
  123. [self.tableView.mj_footer endRefreshing];
  124. }
  125. [self.tableView reloadData];
  126. } else {
  127. [MBProgressHUD showInfo:@"请求失败!"];
  128. }
  129. } enError:^(NSError *error) {
  130. [MBProgressHUD hideHUDForView:self.view animated:YES];
  131. }];
  132. }
  133. - (void)getPrivateModel{
  134. NSString *str = [NSString stringWithFormat:@"%@model?action=getmodeluserinfo&modelpk=%@",imageURl,[ModelUser user].modelpk];
  135. [[AHHttpManager sharedManager]POST:str parameters:nil success:^(id responseObject) {
  136. NSLog(@"%@",responseObject);
  137. if ([[responseObject objectForKey:@"msg"]isEqualToString:@"success"]) {
  138. actModel = [[ActorModel alloc]initWithDictionary:[responseObject objectForKey:@"data"] error:nil];
  139. [backImage reloadModel:actModel];
  140. }else{
  141. [MBProgressHUD showTextHUD:@"超时" inView:self.view hideAfterDelay:1];
  142. }
  143. } failure:^(NSError *error) {
  144. NSLog(@"error = %@",error);
  145. [MBProgressHUD showTextHUD:@"超时" inView:self.view hideAfterDelay:1];
  146. }];
  147. }
  148. #pragma mark - deleDate
  149. -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  150. return self.privateArray.count+1;
  151. }
  152. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  153. {
  154. if (indexPath.row==0) {
  155. PushStateCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PushStateCell"];
  156. if(!cell){
  157. cell = [[[UINib nibWithNibName:@"PushStateCell" bundle:nil]instantiateWithOwner:self options:nil]lastObject];
  158. cell.delegate = self;
  159. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  160. }
  161. return cell;
  162. }else{
  163. PrivateModel *model = [self.privateArray objectAtIndex:indexPath.row-1];
  164. if (model.iteminfo.count==0) {
  165. OnlyTextCell * cell = [tableView dequeueReusableCellWithIdentifier:@"OnlyTextCell"];
  166. if (!cell) {
  167. cell = [[[UINib nibWithNibName:@"OnlyTextCell" bundle:nil]instantiateWithOwner:self options:nil]lastObject];
  168. }
  169. cell.model = model;
  170. return cell;
  171. }else if (model.iteminfo.count==1) {
  172. OneImageCell * cell = [tableView dequeueReusableCellWithIdentifier:@"OneImageCell"];
  173. if (!cell) {
  174. cell = [[[UINib nibWithNibName:@"OneImageCell" bundle:nil]instantiateWithOwner:self options:nil]lastObject];
  175. }
  176. cell.model = model;
  177. cell.delegate = self;
  178. return cell;
  179. }else if(model.iteminfo.count==2){
  180. TwoImageCell * cell = [tableView dequeueReusableCellWithIdentifier:@"TwoImageCell"];
  181. if (!cell) {
  182. cell = [[[UINib nibWithNibName:@"TwoImageCell" bundle:nil]instantiateWithOwner:self options:nil]lastObject];
  183. }
  184. cell.model = model;
  185. cell.delegate = self;
  186. return cell;
  187. }else{
  188. FourImageCell * cell = [tableView dequeueReusableCellWithIdentifier:@"FourImageCell"];
  189. if (!cell) {
  190. cell = [[[UINib nibWithNibName:@"FourImageCell" bundle:nil]instantiateWithOwner:self options:nil]lastObject];
  191. }
  192. cell.model = model;
  193. cell.delegate = self;
  194. return cell;
  195. }
  196. }
  197. }
  198. -(void)clickImage:(PrivateModel *)model andNum:(int)num{
  199. ImageViewController *ImgVc = [[ImageViewController alloc]init];
  200. ImgVc.model = model;
  201. ImgVc.i = num;
  202. ImgVc.hidesBottomBarWhenPushed = YES;
  203. [self.navigationController pushViewController:ImgVc animated:YES];
  204. }
  205. -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
  206. return 0.00001;
  207. }
  208. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  209. return 110;
  210. }
  211. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  212. [tableView deselectRowAtIndexPath:indexPath animated:NO];
  213. if (indexPath.row!=0) {
  214. PrivateModel *model = [self.privateArray objectAtIndex:indexPath.row-1];
  215. DetailOnlyTextViewController *dVc = [[DetailOnlyTextViewController alloc]init];
  216. dVc.model = model;
  217. dVc.iconImage = self.hphoto;
  218. dVc.name = actModel.name;
  219. [self.navigationController pushViewController:dVc animated:YES];
  220. }
  221. }
  222. - (void)clickImage{
  223. PublishViewController *pVc = [[PublishViewController alloc]init];
  224. [self.navigationController pushViewController:pVc animated:YES];
  225. }
  226. - (void)didReceiveMemoryWarning {
  227. [super didReceiveMemoryWarning];
  228. // Dispose of any resources that can be recreated.
  229. }
  230. @end