@@ -1,753 +0,0 @@
//
// 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 ;
@ 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 ] ;
[ [ 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 ( 0 x221E13 ) ;
[ 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 ;
}
[ 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 ] ;
}
- ( 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 xpSafeObjectAtIndex : index ] ;
[ names addObject : tagInfo . vipName ] ;
if ( model . currentLevel > 0 ) {
if ( tagInfo . vipLevel = = model . currentLevel ) {
defaultSelectIndex = index ;
self . vipInfo = tagInfo ;
}
} else {
self . vipInfo = [ model . vipInfos xpSafeObjectAtIndex : 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 . currentLevel < 9 ;
self . titleView . vipInfos = model . vipInfos ;
[ self setPayBtnStatus : self . model . currentLevel ] ;
}
- ( 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 . currentLevel ) {
[ 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 ( 0 x13E2F5 ) , UIColorFromRGB ( 0 x9DB4FF ) , UIColorFromRGB ( 0 xCC67FF ) ] 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 xpSafeObjectAtIndex : 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 xpSafeObjectAtIndex : 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 ( 0 xFFD3A8 ) ;
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