RQExerciseVideoExplainCell.m 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. //
  2. // RQExerciseVideoExplainCell.m
  3. // jiaPei
  4. //
  5. // Created by 张嵘 on 2022/11/23.
  6. // Copyright © 2022 JCZ. All rights reserved.
  7. //
  8. #import "RQExerciseVideoExplainCell.h"
  9. @interface RQExerciseVideoExplainCell ()
  10. @property (nonatomic, readwrite, strong) RQExerciseVideoExplainItemViewModel *viewModel;
  11. @property (weak, nonatomic) IBOutlet UIImageView *videoCoverImageView;
  12. @property (weak, nonatomic) IBOutlet UIView *videoView;
  13. @end
  14. @implementation RQExerciseVideoExplainCell
  15. #pragma mark - PublicMethods
  16. + (instancetype)cellWithTableView:(UITableView *)tableView {
  17. static NSString *ID = @"RQExerciseVideoExplainCell";
  18. RQExerciseVideoExplainCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  19. if (!cell) {
  20. cell = [self rq_viewFromXib];
  21. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  22. }
  23. return cell;
  24. }
  25. - (void)bindViewModel:(RQExerciseVideoExplainItemViewModel *)viewModel {
  26. @weakify(self)
  27. _viewModel = viewModel;
  28. [_videoCoverImageView yy_setImageWithURL:[NSURL URLWithString:viewModel.ydtJSModel.ydt_video_pic] placeholder:RQWebImagePlaceholder() options:RQWebImageOptionAutomatic completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) {
  29. }];
  30. RAC(self.tryLookLabel, text) = [[RACObserve(RQ_USER_MANAGER, tryLookCount) takeUntil:self.rac_prepareForReuseSignal] map:^id _Nullable(id _Nullable value) {
  31. @strongify(self)
  32. int tryCount = RQ_USER_MANAGER.tryLookCount;
  33. if(RQ_Exercise_Module.currentExerciseType == RQExerciseType_Recitation){//背题模式
  34. tryCount = 0;
  35. }
  36. // if ((RQ_VIP_Module.isSubject1Vip && [viewModel.ydtJSModel.kemu isEqualToString:@"1"]) || (RQ_VIP_Module.isSubject4Vip && [viewModel.ydtJSModel.kemu isEqualToString:@"4"])) {
  37. if ((RQ_VIP_Module.isSubject1Vip) || (RQ_VIP_Module.isSubject4Vip)) {
  38. self.tryLookView.hidden = YES;
  39. self.tryLookCoverImageView.hidden = YES;
  40. self.tryLookBottomView.hidden = YES;
  41. self.tryLookBgImageView.hidden = YES;
  42. } else {
  43. self.tryLookBottomView.hidden = NO;
  44. self.tryLookBgImageView.hidden = NO;
  45. if (tryCount == 0) {
  46. self.tryLookView.hidden = NO;
  47. self.tryLookCoverImageView.hidden = NO;
  48. } else {
  49. self.tryLookView.hidden = YES;
  50. self.tryLookCoverImageView.hidden = YES;
  51. }
  52. }
  53. return [NSString stringWithFormat:@"第%ld题",tryCount];
  54. }];
  55. }
  56. - (IBAction)playBtnAvtion:(id)sender {
  57. RQExplainVideoViewModel *explainVideoViewModel = [[RQExplainVideoViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelUtilKey : self.viewModel.ydtJSModel }];
  58. [RQ_APPDELEGATE.services presentViewModel:explainVideoViewModel animated:YES completion:nil];
  59. }
  60. - (IBAction)openBtnAction:(id)sender {
  61. [RQ_VIP_Module isVipWithSubject:0 complete:^(BOOL isVip) {
  62. if (RQ_VIP_Module.isVip) {
  63. [RQ_VIP_Module gotoVipCenter];
  64. } else {
  65. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  66. }
  67. }];
  68. }
  69. #pragma mark - SystemMethods
  70. - (void)awakeFromNib {
  71. [super awakeFromNib];
  72. _openVipBtn.layer.cornerRadius = _openVipBtn.rq_height / 2.f;
  73. }
  74. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  75. [super setSelected:selected animated:animated];
  76. // Configure the view for the selected state
  77. }
  78. @end