RQExerciseVideoExplainCell.m 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. if ((RQ_VIP_Module.isSubject1Vip && [viewModel.ydtJSModel.kemu isEqualToString:@"1"]) || (RQ_VIP_Module.isSubject4Vip && [viewModel.ydtJSModel.kemu isEqualToString:@"4"])) {
  33. self.tryLookView.hidden = YES;
  34. self.tryLookCoverImageView.hidden = YES;
  35. self.tryLookBottomView.hidden = YES;
  36. self.tryLookBgImageView.hidden = YES;
  37. } else {
  38. self.tryLookBottomView.hidden = NO;
  39. self.tryLookBgImageView.hidden = NO;
  40. if (RQ_USER_MANAGER.tryLookCount == 0) {
  41. self.tryLookView.hidden = NO;
  42. self.tryLookCoverImageView.hidden = NO;
  43. } else {
  44. self.tryLookView.hidden = YES;
  45. self.tryLookCoverImageView.hidden = YES;
  46. }
  47. }
  48. return [NSString stringWithFormat:@"第%ld题",RQ_USER_MANAGER.tryLookCount];
  49. }];
  50. }
  51. - (IBAction)playBtnAvtion:(id)sender {
  52. RQExplainVideoViewModel *explainVideoViewModel = [[RQExplainVideoViewModel alloc] initWithServices:RQ_APPDELEGATE.services params:@{RQViewModelUtilKey : self.viewModel.ydtJSModel }];
  53. [RQ_APPDELEGATE.services presentViewModel:explainVideoViewModel animated:YES completion:nil];
  54. }
  55. - (IBAction)openBtnAction:(id)sender {
  56. [RQ_VIP_Module isVipWithSubject:0 complete:^(BOOL isVip) {
  57. if (RQ_VIP_Module.isVip) {
  58. [RQ_VIP_Module gotoVipCenter];
  59. } else {
  60. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  61. }
  62. }];
  63. }
  64. #pragma mark - SystemMethods
  65. - (void)awakeFromNib {
  66. [super awakeFromNib];
  67. _openVipBtn.layer.cornerRadius = _openVipBtn.rq_height / 2.f;
  68. }
  69. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  70. [super setSelected:selected animated:animated];
  71. // Configure the view for the selected state
  72. }
  73. @end