语音vip限制ai弹窗

This commit is contained in:
2026-02-04 20:23:20 +08:00
parent dd59094a16
commit b73f225d15
15 changed files with 164 additions and 98 deletions

View File

@@ -8,21 +8,25 @@
#import "KBChatLimitPopView.h"
#import <Masonry/Masonry.h>
static CGFloat const kKBChatLimitIconSize = 252.0;
static CGFloat const kKBChatLimitGotoWidth = 251.0;
static CGFloat const kKBChatLimitGotoHeight = 53.0;
static CGFloat const kKBChatLimitCloseSize = 28.0;
static CGFloat const kKBChatLimitSpacing1 = 18.0;
static CGFloat const kKBChatLimitSpacing2 = 18.0;
@interface KBChatLimitPopView ()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIImageView *iconImageView;
@property (nonatomic, strong) UILabel *messageLabel;
@property (nonatomic, strong) UIButton *cancelButton;
@property (nonatomic, strong) UIButton *rechargeButton;
@property (nonatomic, strong) UIView *buttonDivider;
@property (nonatomic, strong) UIButton *gotoButton;
@property (nonatomic, strong) UIButton *closeButton;
@end
@implementation KBChatLimitPopView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
self.backgroundColor = [UIColor whiteColor];
self.layer.cornerRadius = 16.0;
self.layer.masksToBounds = YES;
self.backgroundColor = [UIColor clearColor];
[self setupUI];
}
return self;
@@ -31,51 +35,37 @@
#pragma mark - UI
- (void)setupUI {
[self addSubview:self.titleLabel];
[self addSubview:self.messageLabel];
[self addSubview:self.buttonDivider];
[self addSubview:self.cancelButton];
[self addSubview:self.rechargeButton];
[self addSubview:self.iconImageView];
[self.iconImageView addSubview:self.messageLabel];
[self addSubview:self.gotoButton];
[self addSubview:self.closeButton];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self).offset(20);
make.left.equalTo(self).offset(20);
make.right.equalTo(self).offset(-20);
}];
[self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.titleLabel.mas_bottom).offset(8);
make.left.equalTo(self).offset(20);
make.right.equalTo(self).offset(-20);
}];
[self.buttonDivider mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.equalTo(self);
make.height.mas_equalTo(1);
make.top.greaterThanOrEqualTo(self.messageLabel.mas_bottom).offset(16);
make.bottom.equalTo(self).offset(-48);
}];
[self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.bottom.equalTo(self);
make.top.equalTo(self.buttonDivider.mas_bottom);
make.right.equalTo(self.mas_centerX);
}];
[self.rechargeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.bottom.equalTo(self);
make.top.equalTo(self.buttonDivider.mas_bottom);
make.left.equalTo(self.mas_centerX);
}];
UIView *verticalLine = [[UIView alloc] init];
verticalLine.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0];
[self addSubview:verticalLine];
[verticalLine mas_makeConstraints:^(MASConstraintMaker *make) {
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self);
make.centerX.equalTo(self);
make.top.equalTo(self.buttonDivider.mas_bottom);
make.width.height.mas_equalTo(kKBChatLimitIconSize);
}];
//
[self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
// make.centerX.equalTo(self.iconImageView);
make.centerY.equalTo(self.iconImageView).offset(10);
make.left.equalTo(self.iconImageView).offset(26);
make.right.equalTo(self.iconImageView).offset(-46);
}];
[self.gotoButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.iconImageView.mas_bottom).offset(kKBChatLimitSpacing1);
make.centerX.equalTo(self);
make.width.mas_equalTo(kKBChatLimitGotoWidth);
make.height.mas_equalTo(kKBChatLimitGotoHeight);
}];
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.gotoButton.mas_bottom).offset(kKBChatLimitSpacing2);
make.centerX.equalTo(self);
make.width.height.mas_equalTo(kKBChatLimitCloseSize);
make.bottom.equalTo(self);
make.width.mas_equalTo(1);
}];
}
@@ -102,56 +92,46 @@
#pragma mark - Lazy
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.text = KBLocalized(@"提示");
_titleLabel.font = [UIFont boldSystemFontOfSize:18];
_titleLabel.textColor = [UIColor blackColor];
_titleLabel.textAlignment = NSTextAlignmentCenter;
- (UIImageView *)iconImageView {
if (!_iconImageView) {
_iconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ai_limit_icon"]];
_iconImageView.contentMode = UIViewContentModeScaleAspectFit;
_iconImageView.userInteractionEnabled = YES;
}
return _titleLabel;
return _iconImageView;
}
- (UILabel *)messageLabel {
if (!_messageLabel) {
_messageLabel = [[UILabel alloc] init];
_messageLabel.font = [UIFont systemFontOfSize:14];
_messageLabel.textColor = [UIColor colorWithWhite:0.2 alpha:1.0];
_messageLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
_messageLabel.textColor = [UIColor colorWithWhite:0.18 alpha:1.0];
_messageLabel.textAlignment = NSTextAlignmentCenter;
_messageLabel.numberOfLines = 0;
}
return _messageLabel;
}
- (UIButton *)cancelButton {
if (!_cancelButton) {
_cancelButton = [UIButton buttonWithType:UIButtonTypeSystem];
[_cancelButton setTitle:KBLocalized(@"取消") forState:UIControlStateNormal];
_cancelButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
[_cancelButton setTitleColor:[UIColor colorWithWhite:0.2 alpha:1.0] forState:UIControlStateNormal];
[_cancelButton addTarget:self action:@selector(onTapCancel) forControlEvents:UIControlEventTouchUpInside];
- (UIButton *)gotoButton {
if (!_gotoButton) {
_gotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_gotoButton setBackgroundImage:[UIImage imageNamed:@"ai_limit_goto"] forState:UIControlStateNormal];
[_gotoButton setTitle:KBLocalized(@"Go To Recharge") forState:UIControlStateNormal];
[_gotoButton setTitleColor:[UIColor colorWithWhite:0.1 alpha:1.0] forState:UIControlStateNormal];
_gotoButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
[_gotoButton addTarget:self action:@selector(onTapRecharge) forControlEvents:UIControlEventTouchUpInside];
}
return _cancelButton;
return _gotoButton;
}
- (UIButton *)rechargeButton {
if (!_rechargeButton) {
_rechargeButton = [UIButton buttonWithType:UIButtonTypeSystem];
[_rechargeButton setTitle:KBLocalized(@"去充值") forState:UIControlStateNormal];
_rechargeButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
[_rechargeButton setTitleColor:[UIColor colorWithRed:0.28 green:0.45 blue:0.94 alpha:1.0] forState:UIControlStateNormal];
[_rechargeButton addTarget:self action:@selector(onTapRecharge) forControlEvents:UIControlEventTouchUpInside];
- (UIButton *)closeButton {
if (!_closeButton) {
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_closeButton setImage:[UIImage imageNamed:@"ai_limit_close"] forState:UIControlStateNormal];
[_closeButton addTarget:self action:@selector(onTapCancel) forControlEvents:UIControlEventTouchUpInside];
}
return _rechargeButton;
}
- (UIView *)buttonDivider {
if (!_buttonDivider) {
_buttonDivider = [[UIView alloc] init];
_buttonDivider.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0];
}
return _buttonDivider;
return _closeButton;
}
@end

View File

@@ -14,7 +14,7 @@
#import "AiVM.h"
#import "KBHUD.h"
#import "KBChatLimitPopView.h"
#import "KBVipPay.h"
#import "KBPayMainVC.h"
#import "KBUserSessionManager.h"
#import "LSTPopView.h"
#import "KBAIMessageVC.h"
@@ -764,8 +764,9 @@ static NSString * const KBAISelectedPersonaIdKey = @"KBAISelectedPersonaId";
[self.chatLimitPopView dismiss];
}
CGFloat width = KB_SCREEN_WIDTH - 60;
KBChatLimitPopView *content = [[KBChatLimitPopView alloc] initWithFrame:CGRectMake(0, 0, width, 180)];
CGFloat width = 252.0;
CGFloat height = 252.0 + 18.0 + 53.0 + 18.0 + 28.0;
KBChatLimitPopView *content = [[KBChatLimitPopView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
content.message = message;
content.delegate = self;
@@ -841,7 +842,8 @@ static NSString * const KBAISelectedPersonaIdKey = @"KBAISelectedPersonaId";
[[KBUserSessionManager shared] goLoginVC];
return;
}
KBVipPay *vc = [[KBVipPay alloc] init];
KBPayMainVC *vc = [[KBPayMainVC alloc] init];
vc.initialSelectedIndex = 1; // SVIP
[KB_CURRENT_NAV pushViewController:vc animated:true];
}
@@ -1051,8 +1053,21 @@ static NSString * const KBAISelectedPersonaIdKey = @"KBAISelectedPersonaId";
dispatch_async(dispatch_get_main_queue(), ^{
KBPersonaChatCell *cell = [strongSelf currentPersonaCell];
//
if (error) {
NSInteger bizCode = [error.userInfo[@"code"] integerValue];
NSString *messageError = error.localizedDescription;
if (bizCode == 50030) {
if (cell) {
[cell removeLoadingUserMessage];
}
NSString *message = messageError ?: @"";
strongSelf.isVoiceProcessing = NO;
[strongSelf updateCollectionViewScrollState];
[strongSelf showChatLimitPopWithMessage:message];
return;
}
NSLog(@"[KBAIHomeVC] 语音转文字失败:%@", error.localizedDescription);
[KBHUD showError:KBLocalized(@"语音转文字失败,请重试")];
if (cell) {

View File

@@ -15,7 +15,7 @@
#import "KBAiRecordButton.h"
#import "KBHUD.h"
#import "KBChatLimitPopView.h"
#import "KBVipPay.h"
#import "KBPayMainVC.h"
#import "LSTPopView.h"
#import "VoiceChatStreamingManager.h"
#import "KBUserSessionManager.h"
@@ -430,9 +430,10 @@
[self.limitPopView dismiss];
}
CGFloat width = KB_SCREEN_WIDTH - 60;
CGFloat width = 252.0;
CGFloat height = 252.0 + 18.0 + 53.0 + 18.0 + 28.0;
KBChatLimitPopView *content =
[[KBChatLimitPopView alloc] initWithFrame:CGRectMake(0, 0, width, 180)];
[[KBChatLimitPopView alloc] initWithFrame:CGRectMake(0, 0, width, height)];
content.message = message;
content.delegate = self;
@@ -461,7 +462,8 @@
[[KBUserSessionManager shared] goLoginVC];
return;
}
KBVipPay *vc = [[KBVipPay alloc] init];
KBPayMainVC *vc = [[KBPayMainVC alloc] init];
vc.initialSelectedIndex = 1; // SVIP
[KB_CURRENT_NAV pushViewController:vc animated:true];
}