SelectBankerView.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //
  2. // SelectBankerView.m
  3. // BuguLive
  4. //
  5. // Created by yy on 17/2/22.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "SelectBankerView.h"
  9. @implementation SelectBankerView
  10. + (instancetype)EditNibFromXib
  11. {
  12. return [[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil].lastObject;
  13. }
  14. - (void)createStyle
  15. {
  16. _dataArray = [[NSMutableArray alloc]init];
  17. self.layer.cornerRadius = 10;
  18. self.layer.masksToBounds = YES;
  19. _titleLabel.textColor = kAppGrayColor1;
  20. _horLabel.backgroundColor = kAppSpaceColor2;
  21. _verLabel.backgroundColor = kAppSpaceColor2;
  22. [_cancelButton setTitleColor:kGrayTransparentColor5 forState:UIControlStateNormal];
  23. [_confirmButton setTitleColor:kAppMainColor forState:UIControlStateNormal];
  24. [_cancelButton addTarget:self action:@selector(cancelAuction) forControlEvents:UIControlEventTouchUpInside];
  25. [_confirmButton addTarget:self action:@selector(confirmAuction) forControlEvents:UIControlEventTouchUpInside];
  26. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  27. [_tableView registerNib:[UINib nibWithNibName:@"SelectBankerTableViewCell" bundle:nil] forCellReuseIdentifier:@"SelectBankerTableViewCell"];
  28. }
  29. #pragma mark 选择玩家上庄请求
  30. - (void)selectBanker
  31. {
  32. NSMutableDictionary *mDict = [NSMutableDictionary dictionary];
  33. [mDict setObject:@"games" forKey:@"ctl"];
  34. [mDict setObject:@"chooseBanker" forKey:@"act"];
  35. [mDict setObject:_banker_log_id forKey:@"banker_log_id"];
  36. [self.httpsManager POSTWithParameters:mDict SuccessBlock:^(NSDictionary *responseJson) {
  37. if ([responseJson toInt:@"status"] ==1)
  38. {
  39. _banker_log_id = nil;
  40. }
  41. } FailureBlock:^(NSError *error) {
  42. }];
  43. }
  44. - (void)setDataArray:(NSMutableArray *)dataArray
  45. {
  46. _dataArray = dataArray;
  47. [_tableView reloadData];
  48. }
  49. - (void)cancelAuction
  50. {
  51. _banker_log_id = nil;
  52. if (_delegate && [_delegate respondsToSelector:@selector(selectBankerViewDown)])
  53. {
  54. [_delegate selectBankerViewDown];
  55. }
  56. }
  57. - (void)confirmAuction
  58. {
  59. if (_banker_log_id != nil) {
  60. [self selectBanker];
  61. }
  62. else
  63. {
  64. if (_dataArray.count > 0)
  65. {
  66. [[BGHUDHelper sharedInstance]tipMessage:ASLocalizedString(@"请选择玩家")];
  67. }
  68. else
  69. {
  70. [[BGHUDHelper sharedInstance]tipMessage:ASLocalizedString(@"暂时没有玩家上庄")];
  71. }
  72. return;
  73. }
  74. if (_delegate && [_delegate respondsToSelector:@selector(selectBankerViewDown)])
  75. {
  76. [_delegate selectBankerViewDown];
  77. }
  78. }
  79. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  80. {
  81. return _dataArray.count;
  82. }
  83. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  84. {
  85. GameBankerModel *model;
  86. if (indexPath.row < _dataArray.count) {
  87. model = _dataArray[indexPath.row];
  88. }
  89. SelectBankerTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SelectBankerTableViewCell" forIndexPath:indexPath];
  90. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  91. cell.commentLabel.text = model.banker_name;
  92. if (self.BuguLive.appModel.open_diamond_game_module == 1)
  93. {
  94. cell.coinLabel.text = [NSString stringWithFormat:@"%@%@",model.coin,self.BuguLive.appModel.diamond_name];
  95. }
  96. else
  97. {
  98. cell.coinLabel.text = [NSString stringWithFormat:ASLocalizedString(@"%@游戏币"),model.coin];
  99. }
  100. if (model.isSelect )
  101. {
  102. cell.commentLabel.textColor = kAppGrayColor1;
  103. cell.coinLabel.textColor = kAppGrayColor1;
  104. cell.iconImageView.image = [UIImage imageNamed:@"ic_live_pop_choose_on"];
  105. }
  106. else
  107. {
  108. cell.commentLabel.textColor = kAppGrayColor1;
  109. cell.coinLabel.textColor = kAppGrayColor1;
  110. cell.iconImageView.image = [UIImage imageNamed:@"ic_live_pop_choose_off"];
  111. }
  112. return cell;
  113. }
  114. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  115. {
  116. [_tableView deselectRowAtIndexPath:indexPath animated:NO];
  117. GameBankerModel *model;
  118. if (indexPath.row < _dataArray.count) {
  119. model = _dataArray[indexPath.row];
  120. }
  121. _banker_log_id = model.banker_log_id;
  122. for (GameBankerModel *model in _dataArray) {
  123. model.isSelect = NO;
  124. }
  125. model.isSelect = YES;
  126. [_tableView reloadData];
  127. }
  128. @end