// // ASHomeActiveView.m // Asteria // // Created by iOS on 2023/6/12. // #import "ASHomeActiveView.h" #import "VerScrollTextView.h" @interface ASHomeActiveView () @property (nonatomic, strong) UIButton *bt; @property (nonatomic, strong) VerScrollTextView *rollingV; @property (nonatomic, strong) NSArray *topLinkModels; @property (nonatomic, strong) NSArray *topKeyModels; @end @implementation ASHomeActiveView - (void)setData:(NSArray *)arr { self.topLinkModels = arr; NSMutableArray *tempArr = [NSMutableArray array]; for (ASHomeBannerModel *m in self.topLinkModels) { [tempArr addObject:m.title]; } self.rollingV.sxArry = tempArr; } - (void)setTopData:(NSArray *)arr; { self.topKeyModels = arr; NSMutableArray *tempArr = [NSMutableArray array]; for (KWSearchHotKeyModel *m in self.topKeyModels) { [tempArr addObject:m.title]; } self.rollingV.sxArry = tempArr; } - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:CGRectMake(0, 0, KScreenWidth, 40)]; if (self) { [self loadSubVs]; } return self; } - (void)loadSubVs { self.backgroundColor = _E0FFF5; [self addSubview:self.rollingV]; [self addSubview:self.bt]; [self.rollingV mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self); }]; [self.bt mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self); }]; } - (UIButton *)bt { if (!_bt) { UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom]; [b addTarget:self action:@selector(topLinkTapAction) forControlEvents:UIControlEventTouchUpInside]; _bt = b; } return _bt; } - (VerScrollTextView *)rollingV { if (!_rollingV) { VerScrollTextView *v = [VerScrollTextView new]; v.backgroundColor = UIColor.clearColor; _rollingV = v; } return _rollingV; } - (void)topLinkTapAction { NSLog(@"-----topLinkTapAction:%ld", self.rollingV.arrNum); if (self.topLinkModels.count > 0 && self.rollingV.arrNum < self.topLinkModels.count) { if (self.tapBlock) { ASHomeBannerModel * m = self.topLinkModels[self.rollingV.arrNum]; self.tapBlock(m); } } if (self.topKeyModels.count > 0 && self.rollingV.arrNum < self.topKeyModels.count) { if (self.tapBlock) { KWSearchHotKeyModel * m = self.topKeyModels[self.rollingV.arrNum]; self.tapTopBlock(m); } } // HomeBanerModel * m = self.vm.topLinkModels[self.topLinkV.arrNum]; // if (m.type == 1) { // [self goto_WKM_GoodsDetailsC:m.tapUrl]; // return; // } // if (m.type == 2) { // NSString *typeId = m.tapUrl; // [self pushToProductList:@"Products" typeid:typeId]; // return; // } // if ([m.tapUrl.lowercaseString hasPrefix:@"http"]) { // [self toWebVC:m.tapUrl name:@"WESTKISS"]; // } // } } @end