ASHomeActiveView.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // ASHomeActiveView.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/6/12.
  6. //
  7. #import "ASHomeActiveView.h"
  8. #import "VerScrollTextView.h"
  9. @interface ASHomeActiveView ()
  10. @property (nonatomic, strong) UIButton *bt;
  11. @property (nonatomic, strong) VerScrollTextView *rollingV;
  12. @property (nonatomic, strong) NSArray <ASHomeBannerModel *>*topLinkModels;
  13. @end
  14. @implementation ASHomeActiveView
  15. - (void)setData:(NSArray <ASHomeBannerModel *>*)arr {
  16. self.topLinkModels = arr;
  17. NSMutableArray *tempArr = [NSMutableArray array];
  18. for (ASHomeBannerModel *m in self.topLinkModels) {
  19. [tempArr addObject:m.title];
  20. }
  21. self.rollingV.sxArry = tempArr;
  22. }
  23. - (instancetype)initWithFrame:(CGRect)frame {
  24. self = [super initWithFrame:CGRectMake(0, 0, KScreenWidth, 40)];
  25. if (self) {
  26. [self loadSubVs];
  27. }
  28. return self;
  29. }
  30. - (void)loadSubVs {
  31. self.backgroundColor = _E0FFF5;
  32. [self addSubview:self.rollingV];
  33. [self addSubview:self.bt];
  34. [self.rollingV mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.edges.equalTo(self);
  36. }];
  37. [self.bt mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.edges.equalTo(self);
  39. }];
  40. }
  41. - (UIButton *)bt {
  42. if (!_bt) {
  43. UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
  44. [b addTarget:self action:@selector(topLinkTapAction) forControlEvents:UIControlEventTouchUpInside];
  45. _bt = b;
  46. }
  47. return _bt;
  48. }
  49. - (VerScrollTextView *)rollingV {
  50. if (!_rollingV) {
  51. VerScrollTextView *v = [VerScrollTextView new];
  52. v.backgroundColor = UIColor.clearColor;
  53. _rollingV = v;
  54. }
  55. return _rollingV;
  56. }
  57. - (void)topLinkTapAction {
  58. NSLog(@"-----topLinkTapAction:%ld", self.rollingV.arrNum);
  59. if (self.topLinkModels.count > 0 && self.rollingV.arrNum < self.topLinkModels.count) {
  60. if (self.tapBlock) {
  61. ASHomeBannerModel * m = self.topLinkModels[self.rollingV.arrNum];
  62. self.tapBlock(m);
  63. }
  64. }
  65. // HomeBanerModel * m = self.vm.topLinkModels[self.topLinkV.arrNum];
  66. // if (m.type == 1) {
  67. // [self goto_WKM_GoodsDetailsC:m.tapUrl];
  68. // return;
  69. // }
  70. // if (m.type == 2) {
  71. // NSString *typeId = m.tapUrl;
  72. // [self pushToProductList:@"Products" typeid:typeId];
  73. // return;
  74. // }
  75. // if ([m.tapUrl.lowercaseString hasPrefix:@"http"]) {
  76. // [self toWebVC:m.tapUrl name:@"WESTKISS"];
  77. // }
  78. // }
  79. }
  80. @end