// // QXSeductionAlertView.m // QXLive // // Created by 启星 on 2026/1/5. // #import "QXSeductionAlertView.h" #import "QXMineNetwork.h" @interface QXSeductionAlertView() @property (nonatomic,strong)UIView *bgView; @property (nonatomic,strong)UILabel *titleLabel; @property (nonatomic,strong)UILabel *messageLabel; @property (nonatomic,strong)UIButton *noShowBtn; @property (nonatomic,strong)UIButton *cancelBtn; @property (nonatomic,strong)UIButton *commitBtn; @end @implementation QXSeductionAlertView - (instancetype)init { self = [super init]; if (self) { self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); [self initSubviews]; } return self; } -(void)initSubviews{ self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5]; self.bgView = [[UIView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-ScaleWidth(275))/2.0, 0, ScaleWidth(275), ScaleWidth(202))]; self.bgView.backgroundColor = [UIColor whiteColor]; self.bgView.layer.masksToBounds = YES; self.bgView.layer.cornerRadius = 16; [self addSubview:self.bgView]; self.titleLabel = [[UILabel alloc] init]; self.titleLabel.font = [UIFont boldSystemFontOfSize:16]; self.titleLabel.text = QXText(@"温馨提示"); self.titleLabel.textColor = RGB16(0x333333); [self.bgView addSubview:self.titleLabel]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.bgView); make.top.equalTo(self.bgView).offset(16); make.height.mas_equalTo(24); }]; self.commitBtn = [[UIButton alloc] init]; [self.commitBtn addRoundedCornersWithRadius:21]; self.commitBtn.backgroundColor = QXConfig.themeColor; [self.commitBtn setTitle:QXText(@"确认") forState:(UIControlStateNormal)]; [self.commitBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)]; self.commitBtn.titleLabel.font = [UIFont systemFontOfSize:14]; [self.commitBtn addTarget:self action:@selector(commitAction) forControlEvents:(UIControlEventTouchUpInside)]; [self.bgView addSubview:self.commitBtn]; [self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.bgView).offset(-12); make.height.mas_equalTo(42); make.width.mas_equalTo(ScaleWidth(110)); make.right.mas_equalTo(-20); }]; self.cancelBtn = [[UIButton alloc] init]; [self.cancelBtn addRoundedCornersWithRadius:21]; self.cancelBtn.backgroundColor = RGB16(0xF3F3F3); [self.cancelBtn setTitle:QXText(@"取消") forState:(UIControlStateNormal)]; [self.cancelBtn setTitleColor:RGB16(0x999999) forState:(UIControlStateNormal)]; self.cancelBtn.titleLabel.font = [UIFont systemFontOfSize:14]; [self.cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:(UIControlEventTouchUpInside)]; [self.bgView addSubview:self.cancelBtn]; [self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.bgView).offset(-12); make.height.mas_equalTo(42); make.width.mas_equalTo(ScaleWidth(110)); make.left.mas_equalTo(20); }]; self.noShowBtn = [[UIButton alloc] init]; [self.noShowBtn setTitle:@" 以后不再提示" forState:(UIControlStateNormal)]; [self.noShowBtn setTitleColor:RGB16(0x999999) forState:(UIControlStateNormal)]; self.noShowBtn.titleLabel.font = [UIFont systemFontOfSize:12]; self.noShowBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [self.noShowBtn setImage:[[UIImage imageNamed:@"login_agreement_nor"] imageByTintColor:RGB16(0x999999)] forState:(UIControlStateNormal)]; [self.noShowBtn setImage:[UIImage imageNamed:@"login_agreement_sel"] forState:(UIControlStateSelected)]; [self.noShowBtn addTarget:self action:@selector(noShowAction) forControlEvents:(UIControlEventTouchUpInside)]; [self.bgView addSubview:self.noShowBtn]; [self.noShowBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.bgView).offset(16); make.right.equalTo(self.bgView).offset(-16); make.height.mas_equalTo(25); make.bottom.equalTo(self.commitBtn.mas_top).offset(-10); }]; self.messageLabel = [[UILabel alloc] init]; self.messageLabel.font = [UIFont systemFontOfSize:13]; self.messageLabel.text = @"确定要撩一撩台上的 夏沫002 吗?共计需要 10个 金币。"; self.messageLabel.textColor = RGB16(0x000000); self.messageLabel.textAlignment = NSTextAlignmentCenter; self.messageLabel.numberOfLines = 0; [self.bgView addSubview:self.messageLabel]; [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.bgView).offset(16); make.right.equalTo(self.bgView).offset(-16); make.top.equalTo(self.titleLabel.mas_bottom).offset(13); make.bottom.equalTo(self.noShowBtn.mas_top).offset(-14); }]; } -(void)setRoomId:(NSString *)roomId{ _roomId = roomId; } -(void)setSexy_coin:(NSString *)sexy_coin{ _sexy_coin = sexy_coin; } -(void)setPitModel:(QXRoomPitModel *)pitModel{ _pitModel = pitModel; NSString *str = [NSString stringWithFormat:@"确定要撩一撩台上的 %@ 吗?共计需要 %@个 金币。",pitModel.nickname,self.sexy_coin]; NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:str]; [attr yy_setColor:QXConfig.themeColor range:[str rangeOfString:pitModel.nickname]]; [attr yy_setColor:QXConfig.themeColor range:[str rangeOfString:self.sexy_coin]]; self.messageLabel.attributedText = attr; } - (void)setGiftModel:(QXGiftModel *)giftModel{ _giftModel = giftModel; NSString *str = [NSString stringWithFormat:@"将送出 %@ 需要消费 %@个 金币。",giftModel.gift_name,giftModel.gift_price]; NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:str]; [attr yy_setColor:QXConfig.themeColor range:[str rangeOfString:giftModel.gift_name]]; [attr yy_setColor:QXConfig.themeColor range:[str rangeOfString:giftModel.gift_price]]; self.messageLabel.attributedText = attr; } -(void)noShowAction{ self.noShowBtn.selected = !self.noShowBtn.selected; switch (self.alertType) { case QXSeductionAlertTypeSeduction:{ [[NSUserDefaults standardUserDefaults] setBool:self.noShowBtn.isSelected forKey:kIsCloseSeductionAlert]; [[NSUserDefaults standardUserDefaults] synchronize]; } break; case QXSeductionAlertTypeSendGift:{ } break; default: break; } } -(void)setAlertType:(QXSeductionAlertType)alertType{ _alertType = alertType; switch (alertType) { case QXSeductionAlertTypeSeduction:{ [self.noShowBtn setTitle:@" 以后不再提示" forState:(UIControlStateNormal)]; } break; case QXSeductionAlertTypeSendGift:{ [self.noShowBtn setTitle:@" 此交友小屋以后不再提示" forState:(UIControlStateNormal)]; } break; default: break; } } -(void)cancelAction{ if (self.cancelBlock) { self.cancelBlock(); } [self hide]; } -(void)commitAction{ if (self.commitBlock) { self.commitBlock(self.noShowBtn.selected); } switch (self.alertType) { case QXSeductionAlertTypeSeduction:{ [QXMineNetwork roomSeductionWithRoomId:self.roomId to_user_id:self.pitModel.user_id type:@"1" successBlock:^(NSDictionary * _Nonnull dict) { } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { showToast(msg); }]; } break; case QXSeductionAlertTypeSendGift:{ } break; default: break; } [self hide]; } -(void)showInView:(UIView *)view{ self.bgView.y = -view.height; [view addSubview:self]; [UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ self.bgView.y = (view.height-self.bgView.height)/2.0; } completion:^(BOOL finished) { }]; } -(void)hide{ [UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ self.bgView.y = SCREEN_HEIGHT; } completion:^(BOOL finished) { [self removeFromSuperview]; }]; } @end