123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- //
- // YOUPAILZVipHeaderView.m
- // VQU
- //
- // Created by CY on 2021/8/21.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAILZVipHeaderView.h"
- #import <SVGAPlayer.h>
- #import <SVGAParser.h>
- @interface YOUPAILZVipHeaderView ()<SVGAPlayerDelegate>
- @property (nonatomic,weak)UIImageView *youpaipvipImgV; // vip 标识
- @property (nonatomic,weak)UILabel *youpaipvipCoinL; // 贵族币
- @property (nonatomic,weak)UILabel *youpaipvalidityL;// 有效期
- /// 座驾
- @property (nonatomic,weak)UIImageView *youpaipdrivePedestalImgV;
- @property (nonatomic, strong) SVGAPlayer *youpaipsvgaPlayer;
- @property (nonatomic, strong) SVGAParser *youpaipparser;
- @property (nonatomic,weak)UILabel *youpaipvipPrivilegeTitleL; // 贵族特权
- @property (nonatomic,strong) YOUPAILZVipInfoModel *youpaipmodel;
- @end
- @implementation YOUPAILZVipHeaderView
- - (instancetype)initWithFrame:(CGRect)frame{
- if (self = [super initWithFrame:frame]) {
- [self youpaifinitUI];
- }
- return self;
- }
- - (void)youpaifinitUI{
- self.backgroundColor = LCBkgColor;
- UIImageView *bgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_ic_vip_header_bg"]];
- [self addSubview:bgV];
- [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.offset(0.0f);
- make.top.offset(ScaleSize(20.0f));
- make.height.offset(ScaleSize(232.0f));
- }];
-
- UIImageView *vipImgV = [[UIImageView alloc] init];
- vipImgV.contentMode = UIViewContentModeScaleAspectFit;
- [self addSubview:vipImgV];
- self.youpaipvipImgV = vipImgV;
- [vipImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.mas_centerX);
- make.top.offset(ScaleSize(20.0f));
- make.size.mas_offset(CGSizeMake(ScaleSize(136.0f), ScaleSize(122.0f)));
- }];
-
- UIButton *vipCoinBgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- vipCoinBgBtn.layer.cornerRadius = 10.0f;
- vipCoinBgBtn.clipsToBounds = YES;
- vipCoinBgBtn.layer.borderColor = HexColorFromRGB(0xFDCC88).CGColor;
- vipCoinBgBtn.layer.borderWidth = 0.5f;
- [vipCoinBgBtn addTarget:self action:@selector(youpaifvipCoinBgBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [self addSubview:vipCoinBgBtn];
- [vipCoinBgBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(vipImgV.mas_bottom).offset(ScaleSize(10.0f));
- make.centerX.equalTo(self.mas_centerX);
- make.height.offset(20.0f);
- make.width.greaterThanOrEqualTo(122.0f);
- }];
-
- UIImageView *rightArraw = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_ic_vip_coin_arrow"]];
- [vipCoinBgBtn addSubview:rightArraw];
- [rightArraw mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.offset(-10.0f);
- make.centerY.equalTo(vipCoinBgBtn.mas_centerY);
- make.size.mas_offset(CGSizeMake(7.0f, 10.0f));
- }];
-
- UILabel *vipCoinL = [[UILabel alloc] init];
- vipCoinL.font = LCFont14;
- vipCoinL.textAlignment = NSTextAlignmentCenter;
- vipCoinL.textColor = HexColorFromRGB(0xFDCC88);
- vipCoinL.text = @"贵族币:0";
- [vipCoinBgBtn addSubview:vipCoinL];
- self.youpaipvipCoinL = vipCoinL;
- [vipCoinL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(10.0f);
- make.top.bottom.offset(0.0f);
- make.right.equalTo(rightArraw.mas_left).offset(-8.0f);
- }];
-
- UILabel *validityL = [[UILabel alloc] init];
- validityL.font = LCFont(11.0f);
- validityL.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.65f];
- validityL.text = @"暂未开通";
- [self addSubview:validityL];
- self.youpaipvalidityL = validityL;
- [validityL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(vipCoinBgBtn.mas_bottom).offset(ScaleSize(10.0f));
- make.centerX.equalTo(self.mas_centerX);
- }];
-
- UIView *footerBgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth + 1.0f, ScaleSize(86.0f))];
- footerBgView.backgroundColor = HexColorFromRGB(0x986542);
- [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:footerBgView size:CGSizeMake(20.0f, 20.0f)];
- [self addSubview:footerBgView];
- [footerBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.offset(0.0f);
- make.left.offset(-0.5f);
- make.right.offset(0.5f);
- make.height.offset(ScaleSize(86.0f));
- }];
-
-
- UIImageView *drivePedestalImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_ic_vip_drive_pedestal"]];
- drivePedestalImgV.userInteractionEnabled = YES;
- [self addSubview:drivePedestalImgV];
- self.youpaipdrivePedestalImgV = drivePedestalImgV;
- [drivePedestalImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.offset(ScaleSize(-14.0f));
- make.bottom.equalTo(footerBgView.mas_top);
- make.size.mas_offset(CGSizeMake(ScaleSize(86.0f), ScaleSize(94.0f)));
- }];
-
- self.youpaipsvgaPlayer = [[SVGAPlayer alloc] init];
- self.youpaipsvgaPlayer.contentMode = UIViewContentModeScaleAspectFit;
- self.youpaipsvgaPlayer.delegate = self;
- [self addSubview:self.youpaipsvgaPlayer];
- [self.youpaipsvgaPlayer mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(drivePedestalImgV.mas_centerX);
- make.bottom.equalTo(drivePedestalImgV.mas_top).offset(ScaleSize(24.0f));
- make.size.mas_offset(CGSizeMake(ScaleSize(72.0f), ScaleSize(72.0f)));
- }];
- UITapGestureRecognizer *panGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaiftouchCarClick)];
- [self.youpaipsvgaPlayer addGestureRecognizer:panGes];
- UITapGestureRecognizer *panGes1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(youpaiftouchCarClick)];
- [drivePedestalImgV addGestureRecognizer:panGes1];
-
- self.youpaipsvgaPlayer.loops = 0;
- self.youpaipsvgaPlayer.clearsAfterStop = true;
- self.youpaipparser = [[SVGAParser alloc] init];
-
- UIView *footerV = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, KScreenWidth, ScaleSize(85.5f))];
- footerV.backgroundColor = HexColorFromRGB(0x2A2935);
- [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:footerV size:CGSizeMake(19.5f, 19.5f)];
- [footerBgView addSubview:footerV];
- [footerV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.offset(0.0f);
- make.left.top.offset(0.5f);
- make.right.offset(-0.5f);
- }];
-
- UILabel *vipPrivilegeTitleL = [[UILabel alloc] init];
- vipPrivilegeTitleL.textColor = HexColorFromRGB(0xFDCC88);
- vipPrivilegeTitleL.font = LCFont14;
- vipPrivilegeTitleL.text = @"专属特权 0/21";
- [footerV addSubview:vipPrivilegeTitleL];
- self.youpaipvipPrivilegeTitleL = vipPrivilegeTitleL;
- [vipPrivilegeTitleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(footerV.mas_centerX);
- make.top.offset(ScaleSize(30.0f));
- }];
-
- UIImageView *leftImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_ic_vip_privilege_left"]];
- [footerV addSubview:leftImgV];
- [leftImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(vipPrivilegeTitleL.mas_left).offset(-6.0f);
- make.centerY.equalTo(vipPrivilegeTitleL.mas_centerY);
- make.size.mas_offset(CGSizeMake(12.0f, 9.0f));
- }];
- UIImageView *rightImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_ic_vip_privilege_right"]];
- [footerV addSubview:rightImgV];
- [rightImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(vipPrivilegeTitleL.mas_right).offset(6.0f);
- make.centerY.equalTo(vipPrivilegeTitleL.mas_centerY);
- make.size.mas_offset(CGSizeMake(12.0f, 9.0f));
- }];
- UIImageView *bottomImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"vqu_images_ic_vip_privilege_bottom"]];
- [footerV addSubview:bottomImgV];
- [bottomImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(vipPrivilegeTitleL.mas_bottom).offset(4.0f);
- make.centerX.equalTo(vipPrivilegeTitleL.mas_centerX);
- make.size.mas_offset(CGSizeMake(81.0f, 8.0f));
- }];
-
- }
- - (void)youpaifreloadWithModel:(YOUPAILZVipInfoModel *)model{
- if (model == nil) {
- return;
- }
- self.youpaipmodel = model;
- [self.youpaipvipImgV sd_setImageWithURL:[LCTools getImageUrlWithAddress:model.youpaipnoble.youpaipimg]];
- self.youpaipvipCoinL.text = [NSString stringWithFormat:@"贵族币:%@",model.youpaipnoble_coin];
- if([model.youpaippay_info.youpaipstatus isEqual:@"over"]){
- self.youpaipvalidityL.textColor = HexColorFromRGB(0xF4003F);
- }else{
- self.youpaipvalidityL.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.65f];
- }
- self.youpaipvalidityL.text = model.youpaippay_info.youpaipexpire;
- self.youpaipvipPrivilegeTitleL.text = [NSString stringWithFormat:@"专属特权 %@/%@",model.youpaiphas_privilege_num,model.youpaiptotal_privilege];
-
- [self.youpaipsvgaPlayer stopAnimation];
- self.youpaipdrivePedestalImgV.hidden = YES;
- if (model.youpaipcar.youpaippreview_img.length != 0) {
- self.youpaipdrivePedestalImgV.hidden = NO;
- }
- NSString* svgaName = [[model.youpaipcar.youpaippreview_img componentsSeparatedByString:@"/"] lastObject];
- NSString* svgaCanchesPath= [[NSString alloc]initWithFormat:@"%@/%@/%@",CachesPath,@"SVGA",svgaName];
- [self.youpaipsvgaPlayer stopAnimation];
- if (![LCTools giftSVGAWithSvgaUrlStr:model.youpaipcar.youpaippreview_img]){
- NSString* urlStr = [NSString stringWithFormat:@"%@/%@",[LCSaveData getImageUrl]?[LCSaveData getImageUrl]:BaseImgUrl,model.youpaipcar.youpaippreview_img];
-
- @weakify(self);
- [self.youpaipparser parseWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
- @strongify(self);
- if (videoItem != nil) {
- self.youpaipsvgaPlayer.videoItem = videoItem;
- [self.youpaipsvgaPlayer startAnimation];
- }
- } failureBlock:^(NSError * _Nullable error) {
- }];
- [LCTools giftSVGAWithSvgaUrlStr:model.youpaipcar.youpaippreview_img];
- }else{
- @weakify(self);
- [self.youpaipparser parseWithData:[LCTools giftSVGAWithSvgaUrlStr:model.youpaipcar.youpaippreview_img] cacheKey:svgaCanchesPath completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
- @strongify(self);
- if (videoItem != nil) {
- self.youpaipsvgaPlayer.videoItem = videoItem;
- [self.youpaipsvgaPlayer startAnimation];
- }
- } failureBlock:^(NSError * _Nonnull error) {
-
- }];
- }
- }
- - (void)youpaifvipCoinBgBtnClick{
- if(self.clickVipCoinBlock != nil){
- self.clickVipCoinBlock();
- }
- }
- - (void)youpaiftouchCarClick{
- if(self.clickCarBlock != nil){
- self.clickCarBlock();
- }
- }
- @end
|