Files
peko-ios/YuMi/Modules/YMMine/View/Noble/View/XPNobleCenterViewController.m
QQQ 9cb71643f1 移除 A/B 相关代码。
通过 [ClientConfig shareConfig].canOpen 控制页面,现在已没有相关配置,删除/调整相关内容,[ClientConfig shareConfig].canOpen == YES 的部分将保留等价逻辑/代码
2024-05-22 18:58:09 +08:00

778 lines
30 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// XPNobleCenterViewController.m
// xplan-ios
//
// Created by GreenLand on 2021/12/28.
//
#import "XPNobleCenterViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <JXCategoryView/JXCategoryView.h>
#import <JXCategoryView/JXCategoryListContainerView.h>
#import <SDCycleScrollView/SDCycleScrollView.h>
#import <Base64/MF_Base64Additions.h>
#import <NIMSDK/NIMSDK.h>
///Tool
#import "DJDKMIMOMColor.h"
#import "ThemeColor+NobleCenter.h"
#import "Api+NobleCenter.h"
#import "Api+Main.h"
#import "RechargeStorage.h"
#import "AccountInfoStorage.h"
#import "UIImage+Utils.h"
#import "TTPopup.h"
#import "StatisticsServiceHelper.h"
///View
#import "XPNobleCenterListViewController.h"
#import "XPNobleCenterNavView.h"
#import "XPNobleCenterMyNobleView.h"
#import "XPWebViewController.h"
#import "XPNobleSettingViewController.h"
#import "XPSkillCardPlayerManager.h"
#import "SessionViewController.h"
#import "PINobleCenterTitleView.h"
#import "XPNobleCenterWindow.h"
///P
#import "XPNobleCenterPresenter.h"
#import "Api+Gift.h"
///model
#import "NobleCenterModel.h"
#import "UserInfoModel.h"
#import "NobleRechargeModel.h"
#import "AttachmentModel.h"
#import "WalletInfoModel.h"
#import "XPNobleCenterPayView.h"
#import "XPNobleCenterProtocol.h"
#import "XPIAPRechargeViewController.h"
#import "YuMi-swift.h"
#import "ClientConfig.h"
@interface XPNobleCenterViewController ()<XPNobleCenterProtocol,XPNobleCenterPayViewDelegate,JXCategoryViewDelegate, JXCategoryListContainerViewDelegate,XPNobleCenterNavViewDelegate, NIMSystemNotificationManagerDelegate,XPNobleCenterMyNobleViewDelegate>
///分页标题
@property (nonatomic, strong) NSArray<NSString *> *titles;
///分页控件
@property (nonatomic, strong) PINobleCenterTitleView *titleView;
///分页lineView
@property (nonatomic, strong) JXCategoryListContainerView *lineView;
///头饰
@property (nonatomic,strong) XPNobleCenterListViewController *nobleListView;
///头部背景图
@property (nonatomic, strong) UIImageView *headBGImgeView;
@property (nonatomic, strong) XPNobleCenterNavView *navView;
///总数据
@property (nonatomic, strong) NobleCenterModel *model;
///用户信息
@property (nonatomic, strong) UserInfoModel *userInfo;
///开通VIP
@property (nonatomic, strong) UILabel *openNobleButton;
///
@property (nonatomic,strong) UIImageView *openNobleView;
@property (nonatomic,strong) UIImageView *openNobleIconView;
///当前用户VIP信息-开通了VIP才显示
@property (nonatomic, strong) XPNobleCenterMyNobleView *myNobleView;
///更新用户信息
@property (nonatomic, assign) BOOL needUpdateUserInfo;
///充值-----
@property (nonatomic, strong) NSArray *rechargeList;
@property(nonatomic,strong) RechargeListModel *rechargeModel;
@property(nonatomic,strong) NobleInfo *vipInfo;
///订单编号
@property (nonatomic,copy) NSString *orderId;
///房间UID
@property (nonatomic, assign) NSInteger roomUid;
@property (nonatomic,strong) WalletInfoModel * infoModel;
@property(nonatomic,strong) UIButton *rankBtn;
@property(nonatomic,assign) BOOL pi_IsNative;
@end
@implementation XPNobleCenterViewController
///通过roomUid初始化从房间进入)
- (instancetype)initWithRoomUid:(NSInteger)roomUid {
if (self = [super init]) {
self.roomUid = roomUid;
}
return self;;
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
- (void)viewDidLoad {
[super viewDidLoad];
self.pi_IsNative = YES;
[[NIMSDK sharedSDK].systemNotificationManager addDelegate:self];
[self requestHttp];
[self initSubViews];
[self initSubViewConstraints];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getDiamondNot:) name:@"kNobleCenterGetDiamond" object:nil];
}
-(void)getDiamondNot:(NSNotification *)not{
PINobleRebateModel *model = not.object;
[self.presenter getNobleCenterReturnDiamond:model.returnProfitRecordId];
}
- (BOOL)isHiddenNavBar {
return YES;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self hideNavigationBar];
if (self.needUpdateUserInfo) {
[self.presenter getUserInfo];
}
if([XPSkillCardPlayerManager shareInstance].isInRoom == YES && [XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge == NO){
[XPSkillCardPlayerManager shareInstance].isInRoomFirstRecharge = YES;
}
}
- (XPNobleCenterPresenter *)createPresenter {
return [[XPNobleCenterPresenter alloc] init];
}
#pragma mark - Private Method
- (void)initSubViews {
self.view.backgroundColor = UIColorFromRGB(0x221E13);
[self.view addSubview:self.headBGImgeView];
[self.view addSubview:self.navView];
[self.view addSubview:self.titleView];
[self.view addSubview:self.lineView];
[self.view addSubview:self.openNobleView];
[self.view addSubview:self.myNobleView];
[self.openNobleView addSubview:self.openNobleIconView];
[self.openNobleView addSubview:self.openNobleButton];
[self.view addSubview:self.rankBtn];
}
- (void)initSubViewConstraints {
CGFloat height = KScreenWidth * 410 / 375.0;
[self.headBGImgeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.top.trailing.mas_equalTo(self.view);
make.height.mas_equalTo(height);
}];
[self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.top.mas_equalTo(self.view);
make.height.mas_equalTo(kNavigationHeight);
}];
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.mas_equalTo(self.view);
make.height.mas_equalTo(50);
make.top.mas_equalTo(self.navView.mas_bottom);
}];
[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.bottom.mas_equalTo(self.view);
make.top.mas_equalTo(self.titleView.mas_bottom);
}];
[self.openNobleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.bottom.mas_equalTo(-kSafeAreaBottomHeight - 5);
make.width.mas_equalTo(300);
make.height.mas_equalTo(44);
}];
[self.openNobleButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_lessThanOrEqualTo(258);
make.centerX.equalTo(self.openNobleView);
make.top.bottom.equalTo(self.openNobleView);
}];
[self.myNobleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(91+kSafeAreaBottomHeight);
make.leading.bottom.trailing.mas_equalTo(0);
}];
[self.openNobleIconView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(20);
make.centerY.equalTo(self.openNobleView);
make.trailing.equalTo(self.openNobleButton.mas_leading).mas_offset(-2);
}];
[self.rankBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(isMSZH() ? 57 : 78);
make.height.mas_equalTo(24);
make.trailing.mas_equalTo(-24);
make.top.mas_equalTo(139);
}];
}
#pragma mark - XPNobleCenterPayViewDelegate
- (void)payWithType:(NobleCenterPayType)type vipLevel:(NSString * _Nullable)vipLevel{
if(type == NobleCenterPayType_diamond){
NSString *roomUid = self.roomUid > 0 ? @(self.roomUid).stringValue : @(self.userInfo.uid).stringValue;
[self.presenter openVipWithDiamondRoomUid:roomUid vipLevel:vipLevel];
return;
}
if(self.pi_IsNative == NO){
XPWebViewController *vc = [[XPWebViewController alloc]init];
NSString *channel = @"p";
channel = [NSString stringWithFormat:@"%@a",channel];
channel = [NSString stringWithFormat:@"%@y",channel];
NSString *url = [NSString stringWithFormat:URLWithType(kChannelUrl),channel,@"5",[YYUtility deviceID]];
vc.url = url;
[self.navigationController pushViewController:vc animated:YES];
return;
}
[XNDJTDDLoadingTool showOnlyView:kWindow];
[self.presenter requestNobleIAPRechargeOrderWithChargeProdId:self.rechargeModel.chargeProdId roomUid:self.roomUid ? [NSString stringWithFormat:@"%zd", self.roomUid] : nil];
}
#pragma mark - XPNobleCenterMyNobleViewDelegate
-(void)payNobleCenterWithModel:(RechargeListModel *)rechargeModel vipInfo:(NobleInfo *)vipInfo {
XPNobleCenterWindow *window = [[XPNobleCenterWindow alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
[TTPopup popupView:window style:TTPopupStyleAlert];
window.text = [NSString stringWithFormat:YMLocalizedString(@"XPNobleCenterWindow1"),self.vipInfo.vipName,vipInfo.vipName];
@kWeakify(self);
window.confirmBlcok = ^{
@kStrongify(self);
XPNobleCenterPayView *payView = [[XPNobleCenterPayView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
payView.money = self.rechargeModel.money;
payView.diamonds = self.infoModel.diamonds;
payView.vipLevel = @(vipInfo.vipLevel).stringValue;
payView.delegate = self;
[self.view addSubview:payView];
};
}
-(void)openVipWithDiamondSuccess{
[self requestHttp];
}
-(void)openVipWithDiamondFail:(NSInteger)code{
if(code == 31005){
TTAlertConfig *config = [[TTAlertConfig alloc]init];
config.message = YMLocalizedString(@"XPNobleCenterViewController3");
config.actionStyle = TTAlertActionBothStyle;
[TTPopup alertWithConfig:config showBorder:NO confirmHandler:^{
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
webVC.type = @"4";
[self.navigationController pushViewController:webVC animated:YES];
} cancelHandler:^{
}];
}
}
///请求VIP中心数据
- (void)requestHttp {
[self.presenter getUserInfo];
[self checkTranscationIds];
[self.presenter getNobleChargeProductListWithChannelType:@"9"];
[self getWalletInfo];
@kWeakify(self);
[Api requestMineChannel:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
if(code == 200){
if(data.data[@"isNative"] != nil){
self.pi_IsNative = [data.data[@"isNative"] boolValue];
}
}
}];
}
-(void)getWalletInfo{
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * ticket = [AccountInfoStorage instance].getTicket;
@kWeakify(self);
[Api getUserWalletInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
if(code == 200){
WalletInfoModel * model = [WalletInfoModel modelWithDictionary:data.data];
self.infoModel = model;
}
} uid:uid ticket:ticket];
}
///批量验证
- (void)checkTranscationIds {
NSString * uid = [AccountInfoStorage instance].getUid;
NSArray * array = [RechargeStorage getAllReciptsWithUid:uid];
for (NSDictionary *transcation in array) {
NSString *orderId = transcation[@"orderId"];
NSString *transcationId = transcation[@"transcationId"];
///二次验证
[self.presenter checkReceiptWithOrderId:orderId transcationId:transcationId errorToast:NO];
}
}
#pragma mark - XPNobleCenterProtocol
- (void)getNobleCenterDiamondSuccess:(NSString *)recordId{
[[NSNotificationCenter defaultCenter]postNotificationName:@"kNobleCenterGetDiamondSuccess" object:recordId];
[self getWalletInfo];
}
///获取用户信息成功
- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo {
self.userInfo = userInfo;
self.needUpdateUserInfo = NO;
[self.presenter getNobleCenterInfo];
}
- (void)getNobleCenterInfoSuccess:(NobleCenterModel *)model {
self.model = model;
__block NSMutableArray<NSString *> *names = [NSMutableArray array];
NSInteger defaultSelectIndex = 0;
for (int index = 0; index < model.vipInfos.count; index++) {
NobleInfo *tagInfo = [model.vipInfos safeObjectAtIndex1:index];
[names addObject:tagInfo.vipName];
if (model.currLevel > 0){
if (tagInfo.vipLevel == model.currLevel) {
defaultSelectIndex = index;
self.vipInfo = tagInfo;
}
}else{
self.vipInfo = [model.vipInfos safeObjectAtIndex1:0];
}
}
self.titles = names.copy;
self.titleView.titles = self.titles;
self.titleView.defaultSelectedIndex = defaultSelectIndex;
[self.titleView reloadData];
[self.lineView reloadData];
self.navView.hideSettingBtn = self.model.currLevel < 9;
self.titleView.vipInfos = model.vipInfos;
[self setPayBtnStatus:self.model.currLevel];
}
-(void)setPayBtnStatus:(NSInteger)currLevel{
self.rechargeModel = nil;
if (currLevel > 0){
for (RechargeListModel *rechargeModel in self.rechargeList) {
if (rechargeModel.prodDesc.integerValue == currLevel){
self.rechargeModel = rechargeModel;
break;
}
}
}else{
for (RechargeListModel *rechargeModel in self.rechargeList) {
if (rechargeModel.prodDesc.integerValue == 1){
self.rechargeModel = rechargeModel;
break;
}
}
}
if (self.rechargeModel != nil){
self.openNobleView.hidden = self.userInfo.userVipInfoVO.vipLevel;
self.myNobleView.hidden = !self.userInfo.userVipInfoVO.vipLevel;
if (self.openNobleView.hidden == NO){
self.openNobleButton.text = [NSString stringWithFormat:YMLocalizedString(@"XPNobleCenterMyNobleView11"),self.rechargeModel.money.floatValue,self.vipInfo.vipName];
}else{
if (self.userInfo.userVipInfoVO) {
self.myNobleView.rechargeModel = self.rechargeModel;
self.myNobleView.model = self.model;
self.myNobleView.vipInfo = self.vipInfo;
}
}
if (self.vipInfo.vipLevel > self.model.currLevel){
[self.myNobleView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(150+kSafeAreaBottomHeight);
}];
}else{
[self.myNobleView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(91+kSafeAreaBottomHeight);
}];
}
}else{
self.myNobleView.hidden = !self.userInfo.userVipInfoVO.vipLevel;
if (self.userInfo.userVipInfoVO == nil){
self.openNobleView.hidden = self.rechargeModel == nil;
self.openNobleButton.text = [NSString stringWithFormat:YMLocalizedString(@"XPNobleCenterMyNobleView11"),self.rechargeModel.money.floatValue,self.vipInfo.vipName];
return;
}
self.myNobleView.rechargeModel = self.rechargeModel;
self.myNobleView.model = self.model;
self.myNobleView.vipInfo = self.vipInfo;
self.myNobleView.isHiddenPayBtn = YES;
[self.myNobleView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(91+kSafeAreaBottomHeight);
}];
}
}
///获取VIP充值信息成功
- (void)onGetNobleRechargeDataSuccess:(NSArray *)list {
self.rechargeList = list;
}
///请求充值id的状态成功
- (void)requestIAPRechargeOrderSuccess:(NSString *)orderId chargeProdId:(NSString *)chargeProdId uuid:(NSString *)uuid{
if (orderId.length > 0) {
self.orderId = orderId;
if (@available(iOS 15.0, *)) {
PIIAPRegulate *iap = [PIIAPRegulate shared];
[iap demandCommodityThingWithProductId:chargeProdId uuid:uuid completionHandler:^(NSError * _Nullable error) {
}];
@kWeakify(self);
iap.ConditionBlock = ^(enum StoreConditionResult state, NSDictionary<NSString *,id> * _Nullable result) {
@kStrongify(self);
[self rechargeNewProcessStatus:state];
switch (state) {
case StoreConditionResultVerifiedServer:
{
NSString *transactionId = result[@"transactionId"];
[self rechargeSuccess:transactionId];
}
break;
default:
{
}
break;
}
};
} else {
[XNDJTDDLoadingTool hideOnlyView:kWindow];
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController10")];
}
} else {
[XNDJTDDLoadingTool hideOnlyView:kWindow];
}
}
///请求充值账单失败
- (void)requestIAPRechargeOrderFail:(NSString *)message code:(NSInteger)code {
[XNDJTDDLoadingTool hideOnlyView:kWindow];
if(code == 50000){
TTAlertConfig *config = [[TTAlertConfig alloc]init];
config.title = YMLocalizedString(@"XPIAPRechargeViewController7");
config.message = YMLocalizedString(@"XPIAPRechargeViewController8");
TTAlertButtonConfig *confirmButtonConfig = [[TTAlertButtonConfig alloc]init];
confirmButtonConfig.title = YMLocalizedString(@"XPIAPRechargeViewController9");
UIImage *image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x13E2F5),UIColorFromRGB(0x9DB4FF),UIColorFromRGB(0xCC67FF)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(200, 200)];
confirmButtonConfig.backgroundColor = [UIColor colorWithPatternImage:image];
confirmButtonConfig.cornerRadius = 38/2;
config.confirmButtonConfig = confirmButtonConfig;
[TTPopup alertWithConfig:config confirmHandler:^{
[self.presenter getContactCustomerService];
} cancelHandler:^{
}];
return;
}
[self showErrorToast:message];
}
- (void)getContactCustomerServiceSuccessWithUid:(NSString *)uid{
[self hideHUD];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NIMSession * session = [NIMSession session:uid type:NIMSessionTypeP2P];
SessionViewController * sessionVC = [[SessionViewController alloc] initWithSession:session];
[self.navigationController pushViewController:sessionVC animated:YES];
});
}
///二次校验成功
- (void)checkReceiptSuccess:(NSString *)transcationId {
[XNDJTDDLoadingTool hideOnlyView:kWindow];
if (@available(iOS 15.0, *)) {
PIIAPRegulate *iap = [PIIAPRegulate shared];
[iap verifyBusinessAccomplishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{
}];
}
[self deleteRechageReciptWithTransactionIdentifier:transcationId];
self.orderId = nil;
//5秒之后如果没有收到开通成功的云信消息则请求一次用户信息
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
if (!self.userInfo.userVipInfoVO) {
///刷新一下用户的信息
[self requestHttp];
}
});
}
- (void)checkReceiptFailWithCode:(NSInteger)code transcationId:(NSString *)transcationId{
[XNDJTDDLoadingTool hideOnlyView:kWindow];
if(code == 1444){
if (@available(iOS 15.0, *)) {
PIIAPRegulate *iap = [PIIAPRegulate shared];
[iap verifyBusinessAccomplishWithTransaction:[NSString stringWithFormat:@"%@",transcationId] completionHandler:^{
}];
}
[self deleteRechageReciptWithTransactionIdentifier:transcationId];
}
}
///删除本地保存的
- (void)deleteRechageReciptWithTransactionIdentifier:(NSString *)transactionIdentifier {
NSString * uid = [AccountInfoStorage instance].getUid;
BOOL deleteSuccess = [RechargeStorage delegateTranscationId:transactionIdentifier uid:uid];
if (deleteSuccess) {
#warning to do 保存失败 需要埋点
}
}
- (void)checkTranscationIdsSuccess {
NSString * uid = [AccountInfoStorage instance].getUid;
[RechargeStorage delegateAllTranscationIdsWithUid:uid];
}
-(void)rankAction{
XPWebViewController * webVC =[[XPWebViewController alloc] init];
webVC.url = URLWithType(kNobleRankURL);
[self.navigationController pushViewController:webVC animated:YES];
}
#pragma mark - XPIAPHelperDelegate
///当前充值的状态
- (void)rechargeNewProcessStatus:(StoreConditionResult)status {
if (status == StoreConditionResultPay || status == StoreConditionResultStart || status == StoreConditionResultVerifiedServer) {
}else if (status == StoreConditionResultUnowned) {
[XNDJTDDLoadingTool hideOnlyView:kWindow];
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController1")];
}else{
[XNDJTDDLoadingTool hideOnlyView:kWindow];
[self showErrorToast:YMLocalizedString(@"XPIAPRechargeViewController0")];
}
}
///充值成功回调id
- (void)rechargeSuccess:(NSString *)transactionIdentifier {
///保存唯一凭证
[self saveRechageReciptWithTransactionIdentifier:transactionIdentifier];
///二次验证
[self.presenter checkReceiptWithOrderId:self.orderId transcationId:transactionIdentifier errorToast:YES];
}
///充值成功之后保存订单到钥匙串
- (void)saveRechageReciptWithTransactionIdentifier:(NSString *)transactionIdentifier {
NSData *receipt = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
NSString *encodeStr = [receipt base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
if(transactionIdentifier != nil){
[dictionary setObject:transactionIdentifier forKey:@"transcationId"];
}
if(encodeStr != nil){
[dictionary setObject:encodeStr forKey:@"recipt"];
}
if(self.orderId != nil){
[dictionary setObject:self.orderId forKey:@"orderId"];
}
if(dictionary.allKeys.count == 0)return;
NSString *reciptJson = [dictionary toJSONString];
NSString * uid = [AccountInfoStorage instance].getUid;
BOOL saveSuccess = [RechargeStorage saveTranscationId:transactionIdentifier recipt:reciptJson uid:uid];
if (!saveSuccess) {
#warning to do 保存失败 需要埋点
}
}
#pragma mark - JXCategoryViewDelegate
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
return self.titles.count;
}
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
XPNobleCenterListViewController *VC = [[XPNobleCenterListViewController alloc] init];
VC.isOpenNoble = self.userInfo.userVipInfoVO.vipLevel;
NobleInfo *vipInfo = [self.model.vipInfos safeObjectAtIndex1:index];
VC.vipInfo = vipInfo;
if (vipInfo.comingSoon != 2) {
VC.vipAuthInfos = [[NSMutableArray alloc]initWithArray:self.model.vipAuthInfos];
VC.isCurrentLevel = self.userInfo.userVipInfoVO.vipLevel == vipInfo.vipLevel;
VC.currentScore = self.model.currScore;
}
return VC;
}
// 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
// 侧滑手势处理
self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
NobleInfo *vipInfo = [self.model.vipInfos safeObjectAtIndex1:index];
self.vipInfo = vipInfo;
[self setPayBtnStatus:vipInfo.vipLevel];
}
#pragma mark -NIMSystemNotificationManagerDelegate
- (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification {
if (notification.receiverType == NIMSessionTypeP2P) {
if (notification.content != nil) {
NSData *jsonData = [notification.content dataUsingEncoding:NSUTF8StringEncoding];
NSError *err;
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&err];
if(err) {
NSLog(@"json解析失败%@",err);
return;
}
if ([dic[@"first"] intValue] == CustomMessageType_Noble_VIP && [dic[@"second"] intValue] == Custom_Message_Sub_Open_Noble_Success) { // 开通VIP成功
[self requestHttp];
}
}
}
}
#pragma mark - XPNobleCenterNavViewDelegate
- (void)xPNobleCenterNavView:(XPNobleCenterNavView *)view didClickBackButton:(UIButton *)sender {
[self.navigationController popViewControllerAnimated:YES];
}
- (void)xPNobleCenterNavView:(XPNobleCenterNavView *)view didClickHelpButton:(UIButton *)sender {
XPWebViewController * webVC =[[XPWebViewController alloc] init];
webVC.url = URLWithType(kNobleRuleURL);
[self.navigationController pushViewController:webVC animated:YES];
}
- (void)xPNobleCenterNavView:(XPNobleCenterNavView *)view didClickSettingButton:(UIButton *)sender {
XPNobleSettingViewController * settingVC =[[XPNobleSettingViewController alloc] init];
settingVC.enterHide = self.userInfo.userVipInfoVO.enterHide;
settingVC.didUpdateEnterHideBlock = ^{
self.needUpdateUserInfo = YES;
};
[self.navigationController pushViewController:settingVC animated:YES];
}
#pragma mark - events
- (void)onOpenNobleButtonClick {
XPNobleCenterPayView *payView = [[XPNobleCenterPayView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
payView.money = self.rechargeModel.money;
payView.diamonds = self.infoModel.diamonds;
payView.vipLevel = @(self.vipInfo.vipLevel).stringValue;
payView.delegate = self;
[self.view addSubview:payView];
}
#pragma mark - Getters And Setters
- (PINobleCenterTitleView *)titleView {
if (!_titleView) {
_titleView = [[PINobleCenterTitleView alloc] init];
_titleView.delegate = self;
_titleView.titles = self.titles;
_titleView.titleColor = [DJDKMIMOMColor normalNobleTextColor];
_titleView.titleSelectedColor = [DJDKMIMOMColor hightNobleLightTextColor];
_titleView.titleFont = [UIFont systemFontOfSize:14];
_titleView.titleSelectedFont = [UIFont systemFontOfSize:14 weight:UIFontWeightSemibold];
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
_titleView.defaultSelectedIndex = 0;
_titleView.listContainer = self.lineView;
_titleView.cellWidth = isMSRTL() ? 70 : 60;
_titleView.cellSpacing = 0;
JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
lineView.indicatorWidth = 26;
lineView.indicatorHeight = 3;
lineView.indicatorColor = UIColorFromRGB(0xFFD3A8);
lineView.verticalMargin = 8;
_titleView.indicators = @[lineView];
}
return _titleView;
}
- (JXCategoryListContainerView *)lineView {
if (!_lineView) {
_lineView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
_lineView.scrollView.backgroundColor = [UIColor clearColor];
_lineView.defaultSelectedIndex = 0;
_lineView.scrollView.scrollEnabled = NO;
}
return _lineView;
}
- (NSArray<NSString *> *)titles {
if (!_titles) {
_titles = @[];
}
return _titles;
}
- (XPNobleCenterListViewController *)nobleListView {
if (!_nobleListView) {
_nobleListView = [[XPNobleCenterListViewController alloc] init];
}
return _nobleListView;
}
- (UIImageView *)headBGImgeView {
if (!_headBGImgeView) {
_headBGImgeView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"nobleCenter_head_bg"]];
_headBGImgeView.contentMode = UIViewContentModeScaleAspectFit;
}
return _headBGImgeView;
}
- (XPNobleCenterNavView *)navView {
if (!_navView) {
_navView = [[XPNobleCenterNavView alloc] init];
_navView.delegate = self;
}
return _navView;
}
- (UILabel *)openNobleButton {
if (!_openNobleButton) {
NSString *title = [NSString stringWithFormat:YMLocalizedString(@"XPNobleCenterViewController0"), @"2.99"];
_openNobleButton = [UILabel new];
_openNobleButton.text = title;
_openNobleButton.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
_openNobleButton.textColor = [DJDKMIMOMColor mainTextColor];
_openNobleButton.numberOfLines = 0;
_openNobleButton.textAlignment = NSTextAlignmentCenter;
}
return _openNobleButton;
}
- (UIImageView *)openNobleView{
if (!_openNobleView){
_openNobleView = [UIImageView new];
_openNobleView.image = kImage(@"noble_open_btn_bg");
_openNobleView.userInteractionEnabled = YES;
_openNobleView.hidden = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onOpenNobleButtonClick)];
[_openNobleView addGestureRecognizer:tap];
}
return _openNobleView;
}
-(UIImageView *)openNobleIconView{
if (!_openNobleIconView){
_openNobleIconView = [UIImageView new];
_openNobleIconView.image = kImage(@"noble_open_btn");
}
return _openNobleIconView;
}
- (XPNobleCenterMyNobleView *)myNobleView {
if (!_myNobleView) {
_myNobleView = [[XPNobleCenterMyNobleView alloc] init];
_myNobleView.hidden = YES;
_myNobleView.delegate = self;
}
return _myNobleView;
}
- (UIButton *)rankBtn{
if(!_rankBtn){
_rankBtn = [UIButton new];
[_rankBtn setBackgroundImage:[UIImage getLanguageImage:@"mine_noble_center_rank"] forState:UIControlStateNormal];
[_rankBtn addTarget:self action:@selector(rankAction) forControlEvents:UIControlEventTouchUpInside];
}
return _rankBtn;
}
@end