ASHomeActiveView.m 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. @property (nonatomic, strong) NSArray <KWSearchHotKeyModel *>*topKeyModels;
  14. @end
  15. @implementation ASHomeActiveView
  16. - (void)setData:(NSArray <ASHomeBannerModel *>*)arr {
  17. self.topLinkModels = arr;
  18. NSMutableArray *tempArr = [NSMutableArray array];
  19. for (ASHomeBannerModel *m in self.topLinkModels) {
  20. [tempArr addObject:m.title];
  21. }
  22. self.rollingV.sxArry = tempArr;
  23. }
  24. - (void)setTopData:(NSArray <KWSearchHotKeyModel *>*)arr; {
  25. self.topKeyModels = arr;
  26. NSMutableArray *tempArr = [NSMutableArray array];
  27. for (KWSearchHotKeyModel *m in self.topKeyModels) {
  28. [tempArr addObject:m.title];
  29. }
  30. self.rollingV.sxArry = tempArr;
  31. }
  32. - (instancetype)initWithFrame:(CGRect)frame {
  33. self = [super initWithFrame:CGRectMake(0, 0, KScreenWidth, 40)];
  34. if (self) {
  35. [self loadSubVs];
  36. }
  37. return self;
  38. }
  39. - (void)loadSubVs {
  40. self.backgroundColor = _E0FFF5;
  41. [self addSubview:self.rollingV];
  42. [self addSubview:self.bt];
  43. [self.rollingV mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.edges.equalTo(self);
  45. }];
  46. [self.bt mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.edges.equalTo(self);
  48. }];
  49. }
  50. - (UIButton *)bt {
  51. if (!_bt) {
  52. UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
  53. [b addTarget:self action:@selector(topLinkTapAction) forControlEvents:UIControlEventTouchUpInside];
  54. _bt = b;
  55. }
  56. return _bt;
  57. }
  58. - (VerScrollTextView *)rollingV {
  59. if (!_rollingV) {
  60. VerScrollTextView *v = [VerScrollTextView new];
  61. v.backgroundColor = UIColor.clearColor;
  62. _rollingV = v;
  63. }
  64. return _rollingV;
  65. }
  66. - (void)topLinkTapAction {
  67. NSLog(@"-----topLinkTapAction:%ld", self.rollingV.arrNum);
  68. if (self.topLinkModels.count > 0 && self.rollingV.arrNum < self.topLinkModels.count) {
  69. if (self.tapBlock) {
  70. ASHomeBannerModel * m = self.topLinkModels[self.rollingV.arrNum];
  71. self.tapBlock(m);
  72. }
  73. }
  74. if (self.topKeyModels.count > 0 && self.rollingV.arrNum < self.topKeyModels.count) {
  75. if (self.tapBlock) {
  76. KWSearchHotKeyModel * m = self.topKeyModels[self.rollingV.arrNum];
  77. self.tapTopBlock(m);
  78. }
  79. }
  80. // HomeBanerModel * m = self.vm.topLinkModels[self.topLinkV.arrNum];
  81. // if (m.type == 1) {
  82. // [self goto_WKM_GoodsDetailsC:m.tapUrl];
  83. // return;
  84. // }
  85. // if (m.type == 2) {
  86. // NSString *typeId = m.tapUrl;
  87. // [self pushToProductList:@"Products" typeid:typeId];
  88. // return;
  89. // }
  90. // if ([m.tapUrl.lowercaseString hasPrefix:@"http"]) {
  91. // [self toWebVC:m.tapUrl name:@"WESTKISS"];
  92. // }
  93. // }
  94. }
  95. @end