AuctionItemdetailsViewController.m 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865
  1. //
  2. // AuctionItemdetailsViewController.m
  3. // BuguLive
  4. //
  5. // Created by fanwe2014 on 16/8/3.
  6. // Copyright © 2016年 xfg. All rights reserved.
  7. //
  8. #import "AuctionItemdetailsViewController.h"
  9. #import "OneSectionTableViewCell.h"
  10. #import "TwoSectionTableViewCell.h"
  11. #import "ThreeSectionTableViewCell.h"
  12. #import "FourSectionTableViewCell.h"
  13. #import "FiveSectionTableViewCell.h"
  14. #import "SixSectionTableViewCell.h"
  15. #import "SevenSectionTableViewCell.h"
  16. #import "AcutionDetailModel.h"
  17. #import "InfoModel.h"
  18. #import "AcutionHistoryModel.h"
  19. #import "JoinDataModel.h"
  20. #import "areaView.h"
  21. #import "DepositViewController.h"
  22. #import "SevenSectionTableViewCell.h"
  23. #import "GoodsDetailsCell.h"
  24. #import "TitleViewCell.h"
  25. #import "ImgTableViewCell.h"
  26. #import "detailTableViewCell.h"
  27. @interface AuctionItemdetailsViewController ()<UITableViewDelegate,UITableViewDataSource,acutionButtonDelegate,UIScrollViewDelegate,CellHeightDelegate>
  28. @property (nonatomic, strong) UITableView *myTableView;
  29. @property (nonatomic, strong) NSMutableArray *bigArray; //最外层的数组
  30. @property (nonatomic, strong) NSMutableArray *dataArray; //竞拍记录的数组
  31. @property (nonatomic, strong) NSMutableArray *picturesArr; //图片的数组
  32. @property (nonatomic, strong) UIScrollView *scrollerView;
  33. @property (nonatomic, strong) OneSectionTableViewCell *oneSectionCell;
  34. @property (nonatomic, assign) int secString; //竞拍剩余时间秒
  35. @property (nonatomic, assign) int minString; //竞拍剩余时间分
  36. @property (nonatomic, assign) int hourString; //竞拍剩余时间时
  37. @property (nonatomic, assign) int has_join; //通过这个字段来判断是否有交保证金 0:未交保证金 1:已交保证金
  38. @property (nonatomic, assign) int is_true; //通过这个字段来判断是否是虚拟产品 0虚拟 1普通商品
  39. @property (nonatomic, assign) int acutionStatus; //通过这个字段来判断竞拍的状态 0竞拍中 1竞拍成功 2流拍 3失败
  40. @property (nonatomic, assign) int has_next;
  41. @property (nonatomic, assign) int page;
  42. @property (nonatomic, assign) float bz_money; //保证金
  43. @property (nonatomic, assign) int pai_left_time; //竞拍剩余时间(秒)
  44. @property (nonatomic, assign) float height;
  45. @property (nonatomic, assign) BOOL isFirst; //是否第一次加载
  46. @property (nonatomic, assign) CGFloat height2;
  47. @property (nonatomic, copy) NSString *pai_logs_url; //竞拍记录的url
  48. @property (nonatomic, copy) NSString *url; //实物竞拍的url
  49. @property (nonatomic, strong) UIView *alaphView;
  50. @property (nonatomic, strong) UIImageView *alaphImgView;
  51. @property (nonatomic, assign) int pai_nums; //竞拍次数
  52. @property (nonatomic, assign) int buttonCount; //展开或者收缩
  53. @property (nonatomic, strong) UIImageView *imgView; //返回
  54. @property (nonatomic, strong) UIButton *button;
  55. @property (nonatomic, strong) NSMutableArray *imgViewArray; //详情显示的图片
  56. @property (nonatomic, strong) UIPageControl *pageC;
  57. @property (nonatomic, strong) NSTimer *timer;
  58. @property (nonatomic, strong) NSTimer *timers;
  59. @end
  60. @implementation AuctionItemdetailsViewController
  61. - (void)viewDidLoad
  62. {
  63. [super viewDidLoad];
  64. SUS_WINDOW.window_Tap_Ges.enabled = NO;
  65. SUS_WINDOW.window_Pan_Ges.enabled = NO;
  66. self.view.backgroundColor = kBackGroundColor;
  67. self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(comeBack) image:@"com_arrow_vc_back" highImage:@"com_arrow_vc_back"];
  68. self.navigationItem.title = ASLocalizedString(@"竞拍详情");
  69. self.isFirst = YES;
  70. self.dataArray = [[NSMutableArray alloc]init];
  71. self.imgViewArray = [[NSMutableArray alloc]init];
  72. self.picturesArr = [[NSMutableArray alloc]init];
  73. self.bigArray = [[NSMutableArray alloc]init];
  74. self.myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH-kNavigationBarHeight-kStatusBarHeight)];
  75. self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  76. self.myTableView.backgroundColor = kBackGroundColor;
  77. self.myTableView.showsHorizontalScrollIndicator = NO;
  78. self.myTableView.showsVerticalScrollIndicator = NO;
  79. self.myTableView.dataSource = self;
  80. self.myTableView.delegate = self;
  81. [self.myTableView registerNib:[UINib nibWithNibName:@"OneSectionTableViewCell" bundle:nil] forCellReuseIdentifier:@"OneSectionTableViewCell"];
  82. [self.myTableView registerNib:[UINib nibWithNibName:@"TwoSectionTableViewCell" bundle:nil] forCellReuseIdentifier:@"TwoSectionTableViewCell"];
  83. [self.myTableView registerNib:[UINib nibWithNibName:@"ThreeSectionTableViewCell" bundle:nil] forCellReuseIdentifier:@"ThreeSectionTableViewCell"];
  84. [self.myTableView registerNib:[UINib nibWithNibName:@"FourSectionTableViewCell" bundle:nil] forCellReuseIdentifier:@"FourSectionTableViewCell"];
  85. [self.myTableView registerNib:[UINib nibWithNibName:@"FiveSectionTableViewCell" bundle:nil] forCellReuseIdentifier:@"FiveSectionTableViewCell"];
  86. [self.myTableView registerNib:[UINib nibWithNibName:@"SixSectionTableViewCell" bundle:nil] forCellReuseIdentifier:@"SixSectionTableViewCell"];
  87. [self.myTableView registerNib:[UINib nibWithNibName:@"TitleViewCell" bundle:nil] forCellReuseIdentifier:@"TitleViewCell"];
  88. [self.myTableView registerClass:[NSClassFromString(@"detailTableViewCell") class] forCellReuseIdentifier:@"detailTableViewCell"];
  89. [self.myTableView registerClass:[NSClassFromString(@"GoodsDetailsCell") class] forCellReuseIdentifier:@"GoodsDetailsCell"];
  90. [self.myTableView registerClass:[NSClassFromString(@"ImgTableViewCell") class] forCellReuseIdentifier:@"ImgTableViewCell"];
  91. [self.view addSubview:self.myTableView];
  92. self.scrollerView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenW)];
  93. self.scrollerView.showsVerticalScrollIndicator = NO;
  94. self.scrollerView.showsHorizontalScrollIndicator = NO;
  95. self.scrollerView.bounces = NO;
  96. self.scrollerView.delegate = self;
  97. self.scrollerView.pagingEnabled = YES;
  98. self.myTableView.tableHeaderView = self.scrollerView;
  99. [self startTimer];
  100. [self loadNetdata:1];
  101. }
  102. #pragma mark 开始定时器
  103. - (void)startTimer
  104. {
  105. if (!_timers)
  106. {
  107. _timers = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(handleTimerAction:) userInfo:nil repeats:YES];
  108. [[NSRunLoop currentRunLoop] addTimer:_timers forMode:NSRunLoopCommonModes];
  109. }
  110. }
  111. #pragma mark 关闭定时器
  112. - (void)stopTimer
  113. {
  114. [_timers invalidate];
  115. _timers = nil;
  116. }
  117. - (void)comeBack
  118. {
  119. if (self.BuguLive.liveState)
  120. {
  121. [self backLiveVC];
  122. }
  123. else
  124. {
  125. [self.navigationController popViewControllerAnimated:NO];
  126. }
  127. }
  128. #pragma mark 网络加载
  129. - (void)loadNetdata:(int)page
  130. {
  131. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  132. if (self.type == 0)//观众
  133. {
  134. [parmDict setObject:@"pai_user" forKey:@"ctl"];
  135. [parmDict setObject:@"1" forKey:@"get_joindata"];
  136. }else//主播
  137. {
  138. [parmDict setObject:@"pai_podcast" forKey:@"ctl"];
  139. [parmDict setObject:@"1" forKey:@"page_size"];
  140. }
  141. [parmDict setObject:@"goods_detail" forKey:@"act"];
  142. if (self.productId)
  143. {
  144. [parmDict setObject:self.productId forKey:@"id"];
  145. }
  146. [parmDict setObject:@"1" forKey:@"p"];
  147. [parmDict setObject:@"1" forKey:@"get_pailogs"];
  148. [parmDict setObject:@"shop" forKey:@"itype"];
  149. FWWeakify(self)
  150. [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson)
  151. {
  152. FWStrongify(self)
  153. [self.dataArray removeAllObjects];
  154. [self.picturesArr removeAllObjects];
  155. [self.imgViewArray removeAllObjects];
  156. if ([responseJson toInt:@"status"] == 1)
  157. {
  158. if ([responseJson objectForKey:@"data"])
  159. {
  160. if ([[responseJson objectForKey:@"data"] count])
  161. {
  162. self.pai_logs_url = [[[responseJson objectForKey:@"data"] objectForKey:@"info"] toString:@"pai_logs_url"];
  163. self.url = [[[responseJson objectForKey:@"data"] objectForKey:@"info"] toString:@"url"];
  164. self.is_true = [[[responseJson objectForKey:@"data"] objectForKey:@"info"] toInt:@"is_true"];
  165. self.has_join = [[responseJson objectForKey:@"data"] toInt:@"has_join"];
  166. self.acutionStatus = [[[responseJson objectForKey:@"data"] objectForKey:@"info"] toInt:@"status"];
  167. self.bz_money = [[[responseJson objectForKey:@"data"] objectForKey:@"info"] toFloat:@"bz_diamonds"];
  168. self.pai_left_time = [[[responseJson objectForKey:@"data"] objectForKey:@"info"] toInt:@"pai_left_time"];
  169. self.pai_nums = [[[responseJson objectForKey:@"data"] objectForKey:@"info"] toInt:@"pai_nums"];
  170. if (self.acutionStatus == 0)//竞拍过程
  171. {
  172. [self timeGoWithSec];
  173. }
  174. AcutionDetailModel *ADModel = [AcutionDetailModel mj_objectWithKeyValues:[responseJson objectForKey:@"data"]];
  175. [self.bigArray addObject:ADModel];
  176. //滚动图片
  177. id pics = [[[responseJson objectForKey:@"data"] objectForKey:@"info"] objectForKey:@"imgs"];
  178. if (pics && [pics isKindOfClass:[NSArray class]])
  179. {
  180. if ([pics count])
  181. {
  182. for (NSMutableDictionary *dict in pics)
  183. {
  184. [self.picturesArr addObject:dict];
  185. }
  186. }
  187. }
  188. if (self.picturesArr.count > 0)
  189. {
  190. if (self.picturesArr.count >= 2)
  191. {
  192. [self.picturesArr insertObject:_picturesArr.firstObject atIndex:_picturesArr.count];
  193. [self.picturesArr insertObject:_picturesArr[_picturesArr.count - 2] atIndex:0];
  194. }
  195. [self takeTurnsOfPictures];
  196. }
  197. id idArray = [[responseJson objectForKey:@"data"] objectForKey:@"pai_list"];
  198. if (idArray && [idArray isKindOfClass:[NSArray class]])
  199. {
  200. if ([idArray count] > 0)
  201. {
  202. for (NSMutableDictionary *dictM in idArray)
  203. {
  204. AcutionHistoryModel *model = [AcutionHistoryModel mj_objectWithKeyValues:dictM];
  205. [self.dataArray addObject:model];
  206. }
  207. }
  208. }
  209. //实物竞拍详情的图片
  210. id goods_detail = [[[[responseJson objectForKey:@"data"] objectForKey:@"info"] objectForKey:@"commodity_detail"]objectForKey:@"goods_detail"];
  211. if (goods_detail && [goods_detail isKindOfClass:[NSArray class]])
  212. {
  213. if ([goods_detail count] > 0)
  214. {
  215. for (NSMutableDictionary *dictM in goods_detail)
  216. {
  217. AcutionHistoryModel *model = [AcutionHistoryModel mj_objectWithKeyValues:dictM];
  218. [self.imgViewArray addObject:model];
  219. }
  220. }
  221. }
  222. }
  223. }
  224. }
  225. [self.myTableView reloadData];
  226. } FailureBlock:^(NSError *error)
  227. {
  228. NSLog(@"error===%@",error);
  229. }];
  230. }
  231. #pragma mark 定时器
  232. - (void)timeGoWithSec
  233. {
  234. if (!self.timer)
  235. {
  236. self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timeGo:) userInfo:nil repeats:YES];
  237. [[NSRunLoop currentRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
  238. }
  239. }
  240. #pragma mark -- dataSource/Delegate
  241. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  242. {
  243. return autionTablevCount;
  244. }
  245. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  246. {
  247. if (section == thirdSection)//判断是否是虚拟的商品 0是虚拟的商品 1不是虚拟的商品
  248. {
  249. if (self.is_true == 0)
  250. {
  251. return 1;
  252. }else
  253. {
  254. return 0;
  255. }
  256. }else if (section == firstSection)
  257. {
  258. if (self.bigArray.count)
  259. {
  260. return 1;
  261. }else
  262. {
  263. return 0;
  264. }
  265. }
  266. else if (section == fifthSection)
  267. {
  268. if (self.dataArray.count)
  269. {
  270. if (self.dataArray.count >= 3)
  271. {
  272. return 3;
  273. }else
  274. {
  275. return self.dataArray.count;
  276. }
  277. }else
  278. {
  279. return 0;
  280. }
  281. }
  282. else if (section == seventhSection)
  283. {
  284. if (self.type == 1)//是主播
  285. {
  286. return 0;
  287. }else
  288. {
  289. if (self.acutionStatus == 0)//观众处于竞拍中才有返回一段
  290. {
  291. return 1;
  292. }else
  293. {
  294. return 0;
  295. }
  296. }
  297. }
  298. else if (section == sixthSection)
  299. {
  300. if (self.is_true == 1)//实物竞拍
  301. {
  302. if (self.buttonCount == 0)
  303. {
  304. return 1;
  305. }else
  306. {
  307. return self.imgViewArray.count+1;
  308. }
  309. }else//虚拟竞拍
  310. {
  311. return 1;
  312. }
  313. }
  314. else
  315. {
  316. return 1;
  317. }
  318. }
  319. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  320. {
  321. // static NSString *CellIdentifier1 = @"CellIdentifier1";
  322. // static NSString *CellIdentifier2 = @"CellIdentifier2";
  323. // static NSString *CellIdentifier3 = @"CellIdentifier3";
  324. if (indexPath.section == zeroSection)
  325. {
  326. self.oneSectionCell = [tableView dequeueReusableCellWithIdentifier:@"OneSectionTableViewCell"];
  327. self.oneSectionCell.selectionStyle = UITableViewCellSelectionStyleNone;
  328. if (self.bigArray.count > 0)
  329. {
  330. [self.oneSectionCell creatCellWithArray:self.bigArray andStatue:self.acutionStatus];
  331. }
  332. return self.oneSectionCell;
  333. }
  334. else if (indexPath.section == firstSection)
  335. {
  336. TitleViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TitleViewCell"];
  337. if (self.bigArray.count > 0)
  338. {
  339. AcutionDetailModel *model = self.bigArray[0];
  340. [cell setCellWithString:model.info.name];
  341. }
  342. return cell;
  343. }
  344. else if (indexPath.section == secondSection)
  345. {
  346. TwoSectionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TwoSectionTableViewCell"];
  347. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  348. if (self.bigArray.count > 0)
  349. {
  350. [cell creatCellWithArray:self.bigArray];
  351. }else
  352. {
  353. [cell creatCellWithArray:nil];
  354. }
  355. return cell;
  356. }
  357. else if (indexPath.section == thirdSection)
  358. {
  359. SixSectionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SixSectionTableViewCell"];
  360. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  361. if (self.bigArray.count > 0)
  362. {
  363. AcutionDetailModel *model = self.bigArray[0];
  364. [cell setCellWithPlace:model.info.place andPlace:model.info.date_time];
  365. }
  366. return cell;
  367. }
  368. else if (indexPath.section == fourthSection)
  369. {
  370. ThreeSectionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ThreeSectionTableViewCell"];
  371. if (self.pai_nums > 0)
  372. {
  373. [cell creatCellWithNum:self.pai_nums];
  374. }else
  375. {
  376. [cell creatCellWithNum:self.pai_nums];
  377. }
  378. if (self.dataArray.count)
  379. {
  380. cell.lineView.hidden = NO;
  381. }else
  382. {
  383. cell.lineView.hidden = YES;
  384. }
  385. return cell;
  386. }
  387. else if (indexPath.section == fifthSection)
  388. {
  389. FourSectionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FourSectionTableViewCell"];
  390. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  391. if (self.dataArray.count)
  392. {
  393. AcutionHistoryModel *model = self.dataArray[indexPath.row];
  394. [cell creatCellWithModel:model withRow:(int)indexPath.row];
  395. }
  396. return cell;
  397. }else if(indexPath.section == sixthSection)
  398. {
  399. if (self.is_true == 0)
  400. {
  401. detailTableViewCell *cell = (detailTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"detailTableViewCell"];
  402. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  403. // if (cell == nil)
  404. // {
  405. // cell = [[detailTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1];
  406. // cell.selectionStyle = UITableViewCellSelectionStyleNone;
  407. // }
  408. if (self.bigArray.count > 0)
  409. {
  410. AcutionDetailModel *model = self.bigArray[0];
  411. [cell setCellWithString:model.info.Description];
  412. }
  413. return cell;
  414. }else
  415. {
  416. if (indexPath.row == 0)
  417. {
  418. GoodsDetailsCell *cell = (GoodsDetailsCell *)[tableView dequeueReusableCellWithIdentifier:@"GoodsDetailsCell"];
  419. cell.delegate = self;
  420. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  421. // if (cell == nil) {
  422. // cell = [[GoodsDetailsCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2];
  423. // cell.delegate = self;
  424. // cell.selectionStyle = UITableViewCellSelectionStyleNone;
  425. // }
  426. if (self.buttonCount == 0)
  427. {
  428. cell.downUpImgView.image = [UIImage imageNamed:@"com_arrow_down_2"];
  429. }else
  430. {
  431. cell.downUpImgView.image = [UIImage imageNamed:@"com_arrow_up_1"];
  432. }
  433. [cell setButtonCount:self.buttonCount];
  434. return cell;
  435. }else
  436. {
  437. ImgTableViewCell *cell = (ImgTableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"ImgTableViewCell"];
  438. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  439. // if (cell == nil) {
  440. // cell = [[ImgTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier3];
  441. // cell.selectionStyle = UITableViewCellSelectionStyleNone;
  442. // }
  443. if (self.imgViewArray.count > 0)
  444. {
  445. AcutionHistoryModel *model = self.imgViewArray[indexPath.row-1];
  446. [cell setCellWithModel:model];
  447. if (indexPath.row-1 == self.imgViewArray.count)
  448. {
  449. cell.lineView.hidden = NO;
  450. }
  451. }
  452. return cell;
  453. }
  454. }
  455. }else
  456. {
  457. FiveSectionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"FiveSectionTableViewCell"];
  458. cell.delegate = self;
  459. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  460. if (self.has_join == 0 && self.pai_left_time > 0)//未交保证金
  461. {
  462. cell.auctionMoneyLabel.hidden = NO;
  463. cell.goldView.hidden = NO;
  464. cell.auctionLabel.hidden = NO;
  465. cell.depositButton.hidden = NO;
  466. cell.continueButton.hidden = YES;
  467. if (self.bz_money/10000 > 1)
  468. {
  469. cell.auctionMoneyLabel.text = [NSString stringWithFormat:ASLocalizedString(@"%.2f万"),self.bz_money/10000];
  470. }else
  471. {
  472. cell.auctionMoneyLabel.text = [NSString stringWithFormat:@"%.0f",self.bz_money];
  473. }
  474. }else
  475. {
  476. cell.auctionMoneyLabel.hidden = YES;
  477. cell.goldView.hidden = YES;
  478. cell.auctionLabel.hidden = YES;
  479. cell.depositButton.hidden = YES;
  480. cell.continueButton.hidden = NO;
  481. }
  482. return cell;
  483. }
  484. }
  485. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  486. {
  487. if (indexPath.section == zeroSection)
  488. {
  489. return 50;
  490. }
  491. else if (indexPath.section == firstSection)
  492. {
  493. // CGFloat height;
  494. TitleViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"TitleViewCell"];
  495. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  496. // if (self.bigArray.count)
  497. // {
  498. AcutionDetailModel *model = self.bigArray[0];
  499. // height = [cell setCellWithString:model.info.name];
  500. // }
  501. return [cell setCellWithString:model.info.name];
  502. }
  503. else if (indexPath.section == secondSection)
  504. {
  505. return 110;
  506. }
  507. else if (indexPath.section == thirdSection)
  508. {
  509. if (self.is_true == 0) //判断是否是虚拟的商品 0是虚拟的商品 1不是虚拟的商品
  510. {
  511. SixSectionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SixSectionTableViewCell"];
  512. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  513. if (self.bigArray.count > 0)
  514. {
  515. AcutionDetailModel *model = _bigArray[0];
  516. self.height2 = [cell setCellWithPlace:model.info.place andPlace:model.info.date_time];
  517. }
  518. return self.height2;
  519. }else
  520. {
  521. return 0;
  522. }
  523. }
  524. else if (indexPath.section == seventhSection)//判断是否是主播 1是 0不是
  525. {
  526. if (self.type == 1)
  527. {
  528. return 0;
  529. }else
  530. {
  531. return 45;
  532. }
  533. }else if (indexPath.section == sixthSection)//商品详情
  534. {
  535. CGFloat height;
  536. if (self.is_true == 0)
  537. {
  538. return 45;
  539. }else
  540. {
  541. if (indexPath.row == 0)
  542. {
  543. return 50;
  544. }else
  545. {
  546. AcutionHistoryModel *model = self.imgViewArray[indexPath.row -1];
  547. if (model.image_width == 0 || model.image_height == 0)
  548. {
  549. return kScreenW+2;
  550. }else
  551. {
  552. height = (model.image_height*kScreenW/model.image_width);
  553. return height+2;
  554. }
  555. }
  556. }
  557. }
  558. else
  559. {
  560. return 44;
  561. }
  562. }
  563. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
  564. {
  565. if (section == thirdSection || section == fifthSection || section == sixthSection)
  566. {
  567. return 10;
  568. }else
  569. {
  570. return 0;
  571. }
  572. }
  573. //- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
  574. //{
  575. // if (section == thirdSection || section == fifthSection)
  576. // {
  577. // UIView *backView = [[UIView alloc]initWithFrame:CGRectMake(0, 0,kScreenW , 10)];
  578. // backView.backgroundColor = kBackGroundColor;
  579. // return backView;
  580. // }else
  581. // {
  582. // return nil;
  583. // }
  584. //}
  585. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  586. {
  587. if (indexPath.section == fourthSection)//竞拍记录的点击事件
  588. {
  589. BGMainWebViewController *tmpController = [BGMainWebViewController webControlerWithUrlStr:_pai_logs_url isShowIndicator:YES isShowNavBar:YES isShowBackBtn:YES];
  590. tmpController.navTitleStr = ASLocalizedString(@"竞拍记录");
  591. [self.navigationController pushViewController:tmpController animated:YES];
  592. }
  593. }
  594. #pragma mark -竞拍时间的倒计时
  595. - (void)timeGo:(NSTimer *)sender
  596. {
  597. if (self.pai_left_time == 0)
  598. {
  599. return;
  600. }
  601. self.pai_left_time --;
  602. self.hourString = self.pai_left_time/3600;
  603. self.minString = (self.pai_left_time%3600)/60;
  604. self.secString = (self.pai_left_time)%60;
  605. self.oneSectionCell.secLabel.text = [NSString stringWithFormat:@"%02d",self.secString];
  606. self.oneSectionCell.minuteLabel.text = [NSString stringWithFormat:@"%02d",self.minString];
  607. self.oneSectionCell.hourLabel.text = [NSString stringWithFormat:@"%02d",self.hourString];
  608. if (self.secString == 0 && self.minString == 0 && self.hourString == 0)//竞拍时间为0后cell 需要改变里面控件的状态
  609. {
  610. [self.timer invalidate];
  611. self.timer = nil;
  612. [self performSelector:@selector(loadAgain) withObject:self afterDelay:1];
  613. }
  614. }
  615. - (void)loadAgain
  616. {
  617. [self loadNetdata:1];//竞拍结束,重新刷新接口
  618. }
  619. #pragma mark -创建滚动视图
  620. - (void)takeTurnsOfPictures{
  621. self.scrollerView.contentSize = CGSizeMake(kScreenW * self.picturesArr.count, 0);
  622. self.scrollerView.bounces = YES;
  623. if (self.picturesArr.count < 4) {
  624. self.scrollerView.scrollEnabled = NO;
  625. [self.timers invalidate];
  626. }
  627. for (int i = 0; i < self.picturesArr.count; i ++) {
  628. UIImageView *imageV = [[UIImageView alloc]initWithFrame:CGRectMake(i * kScreenW, 0, kScreenW, kScreenW)];
  629. imageV.contentMode = UIViewContentModeScaleAspectFit;
  630. imageV.userInteractionEnabled = YES;
  631. [imageV sd_setImageWithURL:self.picturesArr[i]];
  632. [self.scrollerView addSubview:imageV];
  633. }
  634. if (self.picturesArr.count > 1)
  635. {
  636. [self.scrollerView setContentOffset:CGPointMake(kScreenW, 0)];
  637. }else
  638. {
  639. [self.scrollerView setContentOffset:CGPointMake(0, 0)];
  640. }
  641. //添加页控制器
  642. if (self.picturesArr.count > 3)
  643. {
  644. [self addPageControll];
  645. }
  646. }
  647. //图片上面的点
  648. - (void)addPageControll{
  649. if (!self.pageC)
  650. {
  651. self.pageC = [[UIPageControl alloc]initWithFrame:CGRectMake(40, kScreenW*0.9, kScreenW - 100, kScreenW*0.1)];
  652. self.pageC.numberOfPages = _picturesArr.count - 2;
  653. self.pageC.tag = 102;
  654. self.pageC.currentPage = 0;
  655. self.pageC.currentPageIndicatorTintColor = myPageColor;
  656. self.pageC.pageIndicatorTintColor = myCurrentPageColor;
  657. [self.myTableView addSubview:self.pageC];
  658. }
  659. }
  660. #pragma mark -定时器的方法
  661. - (void)handleTimerAction:(NSTimer *)sender
  662. {
  663. if (self.scrollerView.contentOffset.x == 0)
  664. {
  665. [self.scrollerView setContentOffset:CGPointMake( kScreenW * (self.picturesArr.count - 2), 0) animated:NO];
  666. self.pageC.currentPage = self.picturesArr.count - 2 - 1;
  667. return;
  668. }
  669. if (_scrollerView.contentOffset.x / kScreenW == self.picturesArr.count - 1)
  670. {
  671. self.pageC.currentPage = 0;
  672. [self.scrollerView setContentOffset:CGPointMake(kScreenW, 0) animated:NO];
  673. return;
  674. }
  675. [_scrollerView setContentOffset:CGPointMake(self.scrollerView.contentOffset.x + kScreenW, 0) animated:YES];
  676. NSInteger selected = self.pageC.currentPage;
  677. if (selected == self.picturesArr.count - 2 - 1)
  678. {
  679. self.pageC.currentPage = 0;
  680. }else
  681. {
  682. self.pageC.currentPage = selected + 1;
  683. }
  684. }
  685. #pragma mark -滚动视图的代理方法
  686. - (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
  687. {
  688. if ([scrollView isMemberOfClass:[UIScrollView class]])
  689. {
  690. [self stopTimer];
  691. }
  692. }
  693. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
  694. {
  695. if (self.picturesArr.count >1)
  696. {
  697. if ([scrollView isMemberOfClass:[UIScrollView class]]) {
  698. if (self.scrollerView.contentOffset.x == kScreenW * (self.picturesArr.count - 1)) {
  699. self.pageC.currentPage = 0;
  700. [self.scrollerView setContentOffset:CGPointMake(kScreenW, 0) animated:NO];
  701. }
  702. if (self.scrollerView.contentOffset.x == 0) {
  703. self.pageC.currentPage = self.picturesArr.count - 1 - 2 ;
  704. [self.scrollerView setContentOffset:CGPointMake((self.picturesArr.count - 2) * kScreenW, 0) animated:NO];
  705. }
  706. self.pageC.currentPage = scrollView.contentOffset.x / kScreenW - 1;
  707. }
  708. [self startTimer];
  709. }
  710. }
  711. #pragma mark 继续参拍和参拍交保证金额的代理事件
  712. - (void)buttonClickWithTag:(int)tag
  713. {
  714. if (tag == 0)//参拍交保金额
  715. {
  716. DepositViewController *VC = [[DepositViewController alloc]init];
  717. if (self.is_true == 0)//虚拟
  718. {
  719. VC.type = 0;
  720. }else
  721. {
  722. VC.type = 1;
  723. }
  724. VC.bzMoney = [NSString stringWithFormat:@"%.0f",_bz_money];
  725. VC.productId = self.productId;
  726. [self.navigationController pushViewController:VC animated:YES];
  727. //[[AppDelegate sharedAppDelegate] pushViewController:VC];
  728. }else if (tag == 1)//继续参拍
  729. {
  730. if (self.isFromWebView == NO)
  731. {
  732. // [[LiveCenterManager sharedInstance] showChangeAuctionLiveScreenSOfIsSmallScreen:NO nextViewController:nil delegateWindowRCNameStr:@"BGTabBarController" complete:^(BOOL finished) {
  733. //
  734. // }];
  735. [self backLiveVC];
  736. //[SuspenionWindow popNextVCGoBackFullScreenWidnowLiveWithSelfNavController:self.navigationController];
  737. }else
  738. {
  739. [self goToLiveController];//进入直播间
  740. }
  741. }
  742. }
  743. //返回直播间
  744. - (void)backLiveVC
  745. {
  746. UIViewController *viewCtl;
  747. for (int i = 0; i < [self.navigationController.viewControllers count]; i ++)
  748. {
  749. viewCtl = [self.navigationController.viewControllers objectAtIndex:(i)];
  750. if ([viewCtl isKindOfClass:[BGTLiveController class]] || [viewCtl isKindOfClass:[BGKSYLiveController class]])
  751. {
  752. [self.navigationController popToViewController:viewCtl animated:YES];
  753. }
  754. }
  755. }
  756. - (void)viewWillDisappear:(BOOL)animated
  757. {
  758. [super viewWillDisappear:animated];
  759. [self stopTimer];
  760. [self.timer invalidate];
  761. self.timer = nil;
  762. }
  763. - (void)viewWillAppear:(BOOL)animated
  764. {
  765. [super viewWillAppear:animated];
  766. [self loadNetdata:1];
  767. }
  768. #pragma mark webView跳转过来主播还在直播进入直播间
  769. - (void)goToLiveController
  770. {
  771. NSMutableDictionary *parmDict = [NSMutableDictionary dictionary];
  772. [parmDict setObject:@"pai_user" forKey:@"ctl"];
  773. [parmDict setObject:@"go_video" forKey:@"act"];
  774. [parmDict setObject:self.productId forKey:@"pai_id"];
  775. [parmDict setObject:@"shop" forKey:@"itype"];
  776. [self.httpsManager POSTWithParameters:parmDict SuccessBlock:^(NSDictionary *responseJson){
  777. if ([responseJson toInt:@"status"] == 1)
  778. {
  779. TCShowUser *showUser = [[TCShowUser alloc]init];
  780. showUser.uid = [responseJson toString:@"createrId"];
  781. showUser.avatar =[responseJson toString:@"loadingVideoImageUrl"];
  782. TCShowLiveListItem *item = [[TCShowLiveListItem alloc]init];
  783. item.chatRoomId = [responseJson toString:@"groupId"];
  784. item.avRoomId = [responseJson toInt:@"roomId"];
  785. item.title = [responseJson toString:@"roomId"];
  786. item.vagueImgUrl = [responseJson toString:@"loadingVideoImageUrl"];
  787. item.host = showUser;
  788. item.liveType = FW_LIVE_TYPE_AUDIENCE;
  789. item.host = showUser;
  790. //2020-1-7 小直播变大
  791. [LiveCenterManager sharedInstance].itemModel=item;
  792. BOOL isSusWindow = [[LiveCenterManager sharedInstance] judgeIsSusWindow];[[LiveCenterManager sharedInstance] showLiveOfAudienceLiveofTCShowLiveListItem:item modelArr:nil isSusWindow:isSusWindow isSmallScreen:NO block:^(BOOL isFinished) {
  793. }];
  794. }
  795. }FailureBlock:^(NSError *error){
  796. }];
  797. }
  798. - (void)getCellHeightWithCount:(int)count
  799. {
  800. self.buttonCount = count;
  801. [self.myTableView reloadSections:[NSIndexSet indexSetWithIndex:sixthSection] withRowAnimation:UITableViewRowAnimationAutomatic];
  802. }
  803. - (void)dealloc
  804. {
  805. [self stopTimer];
  806. }
  807. @end