YBOnSaleCell.m 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // YBOnSaleCell.m
  3. // YBVideo
  4. //
  5. // Created by YB007 on 2020/8/31.
  6. // Copyright © 2020 cat. All rights reserved.
  7. //
  8. #import "YBOnSaleCell.h"
  9. @implementation YBOnSaleCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. [_anchorShowBtn setTitle:YZMsg(@"展示") forState:0];
  13. [_anchorDelBtn setTitle:YZMsg(@"移除") forState:0];
  14. [_userCtrBtn setTitle:YZMsg(@"去看看") forState:0];
  15. }
  16. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  17. [super setSelected:selected animated:animated];
  18. // Configure the view for the selected state
  19. }
  20. +(YBOnSaleCell *)cellWithTab:(UITableView *)table index:(NSIndexPath *)index {
  21. YBOnSaleCell *cell = [table dequeueReusableCellWithIdentifier:@"YBOnSaleCell"];
  22. if (!cell) {
  23. cell = [[[NSBundle mainBundle]loadNibNamed:@"YBOnSaleCell" owner:nil options:nil]objectAtIndex:0];
  24. }
  25. cell.backgroundColor = UIColor.whiteColor;
  26. cell.contentView.backgroundColor = UIColor.whiteColor;
  27. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  28. return cell;
  29. }
  30. - (void)setIsAnchor:(BOOL)isAnchor{
  31. _isAnchor = isAnchor;
  32. _anchorCtrView.hidden = !_isAnchor;
  33. _userCtrBtn.hidden = _isAnchor;
  34. }
  35. - (void)setDataDic:(NSDictionary *)dataDic {
  36. _dataDic = dataDic;
  37. [_thumbIV sd_setImageWithURL:[NSURL URLWithString:minstr([_dataDic valueForKey:@"thumb"])]];
  38. _titleL.text = minstr([_dataDic valueForKey:@"name"]);
  39. _priceL.text = [NSString stringWithFormat:@"¥ %@",[_dataDic valueForKey:@"price"]];
  40. NSString *oldP = [NSString stringWithFormat:@"¥%@",[_dataDic valueForKey:@"old_price"]];
  41. _oldPriceL.hidden = _oldPL.hidden = YES;
  42. // if (![PublicObj checkNull:oldP]) {
  43. if ([minstr([_dataDic valueForKey:@"type"]) isEqual:@"1"]) {
  44. _oldPriceL.hidden = _oldPL.hidden = NO;
  45. _oldPriceL.text = oldP;
  46. }
  47. if (_isAnchor) {
  48. if ([minstr([_dataDic valueForKey:@"type"]) isEqual:@"2"]) {
  49. _oldPriceL.hidden = NO;
  50. _oldPriceL.text = [NSString stringWithFormat:YZMsg(@"佣 ¥%@"),minstr([_dataDic valueForKey:@"commission"])];
  51. _oldPriceL.textColor = Pink_Cor;
  52. }
  53. }
  54. //1-展开 0-非展开
  55. int live_isshow = [minstr([_dataDic valueForKey:@"live_isshow"]) intValue];
  56. _anchorShowBtn.selected = live_isshow;
  57. }
  58. - (IBAction)clikcAnchorShowBtn:(UIButton *)sender {
  59. sender.selected = !sender.selected;
  60. if (self.saleCellEnvent) {
  61. self.saleCellEnvent(sender.selected?OnSaleType_Show:OnSaleType_Hidden);
  62. }
  63. }
  64. - (IBAction)clickAnchorDelBtn:(id)sender {
  65. if (self.saleCellEnvent) {
  66. self.saleCellEnvent(OnSaleType_Delete);
  67. }
  68. }
  69. - (IBAction)clikcUserCtrBtn:(id)sender {
  70. if (self.saleCellEnvent) {
  71. self.saleCellEnvent(OnSaleType_Info);
  72. }
  73. }
  74. @end