2021-09-07 23:05:43 +08:00
|
|
|
|
//
|
|
|
|
|
// ViewController.m
|
|
|
|
|
// xplan-ios
|
|
|
|
|
//
|
|
|
|
|
// Created by zu on 2021/8/31.
|
|
|
|
|
//
|
|
|
|
|
#import <UIKit/UIKit.h>
|
2021-09-13 14:22:51 +08:00
|
|
|
|
///Third
|
|
|
|
|
#import <flutter_boost/FlutterBoost.h>
|
2021-10-21 12:01:21 +08:00
|
|
|
|
#import <ReactiveObjC/ReactiveObjC.h>
|
2021-10-21 20:05:30 +08:00
|
|
|
|
#import <NIMSDK/NIMSDK.h>
|
2022-08-01 19:24:12 +08:00
|
|
|
|
#import <Masonry/Masonry.h>
|
2022-08-04 11:42:49 +08:00
|
|
|
|
#import <AudioToolbox/AudioToolbox.h>
|
2021-09-13 14:22:51 +08:00
|
|
|
|
///Tool
|
|
|
|
|
#import "XPMacro.h"
|
|
|
|
|
#import "ThemeColor.h"
|
|
|
|
|
#import "UIImage+Utils.h"
|
2022-06-17 14:56:16 +08:00
|
|
|
|
#import "NSObject+MJExtension.h"
|
2021-09-15 18:41:40 +08:00
|
|
|
|
#import "XCHUDTool.h"
|
2021-09-26 20:42:33 +08:00
|
|
|
|
#import "AccountInfoStorage.h"
|
2021-12-07 11:08:43 +08:00
|
|
|
|
#import "TTPopup.h"
|
|
|
|
|
#import "XPConstant.h"
|
2021-12-08 15:36:47 +08:00
|
|
|
|
#import "XPRoomMiniManager.h"
|
2021-12-11 16:15:40 +08:00
|
|
|
|
#import "ClientConfig.h"
|
2022-01-24 15:43:05 +08:00
|
|
|
|
#import "RtcManager.h"
|
|
|
|
|
#import "XCCurrentVCStackManager.h"
|
2022-06-02 18:53:45 +08:00
|
|
|
|
#import "Api+Home.h"
|
2022-07-27 17:12:06 +08:00
|
|
|
|
#import "XPConstant.h"
|
2022-08-08 13:15:04 +08:00
|
|
|
|
#import "StatisticsServiceHelper.h"
|
2022-08-26 17:13:20 +08:00
|
|
|
|
#import "Api+Monents.h"
|
2022-10-31 12:15:01 +08:00
|
|
|
|
#import "XPAdImageTool.h"
|
2021-10-21 12:01:21 +08:00
|
|
|
|
///Model
|
|
|
|
|
#import "AccountModel.h"
|
2021-12-08 15:36:47 +08:00
|
|
|
|
#import "RoomInfoModel.h"
|
2022-03-11 17:57:33 +08:00
|
|
|
|
#import "AttachmentModel.h"
|
|
|
|
|
#import "NobleLevelUpModel.h"
|
|
|
|
|
#import "XPMineVisitorUnReadModel.h"
|
2022-06-02 18:53:45 +08:00
|
|
|
|
#import "InviteUserInfoModel.h"
|
|
|
|
|
#import "NewUserGreetModel.h"
|
2022-06-17 14:56:16 +08:00
|
|
|
|
#import "FindNewGreetMessageModel.h"
|
2022-08-01 19:24:12 +08:00
|
|
|
|
#import "XPTabAnchorCardModel.h"
|
2022-08-02 18:13:51 +08:00
|
|
|
|
#import "FirstRechargeModel.h"
|
2022-08-26 17:13:20 +08:00
|
|
|
|
#import "MonentsUnReadModel.h"
|
2022-09-05 18:48:19 +08:00
|
|
|
|
#import "XPReceiveRedPacketModel.h"
|
2021-09-13 14:22:51 +08:00
|
|
|
|
///VC
|
2021-09-07 23:05:43 +08:00
|
|
|
|
#import "TabbarViewController.h"
|
|
|
|
|
#import "BaseViewController.h"
|
|
|
|
|
#import "LoginViewController.h"
|
2021-09-14 21:01:09 +08:00
|
|
|
|
#import "BaseNavigationController.h"
|
|
|
|
|
#import "LoginBindPhoneViewController.h"
|
|
|
|
|
#import "LoginFullInfoViewController.h"
|
2021-09-16 17:21:52 +08:00
|
|
|
|
#import "XplanFBFlutterViewContainer.h"
|
2021-09-16 19:30:22 +08:00
|
|
|
|
#import "XPMineViewController.h"
|
2021-11-26 20:25:23 +08:00
|
|
|
|
#import "SessionListViewController.h"
|
2022-02-21 20:06:09 +08:00
|
|
|
|
#import "XPHomeViewController.h"
|
2021-12-03 17:07:21 +08:00
|
|
|
|
#import "XPMiniRoomView.h"
|
2021-12-07 11:08:43 +08:00
|
|
|
|
#import "XPTeenagerAlertView.h"
|
2022-01-24 15:43:05 +08:00
|
|
|
|
#import "XPRoomViewController.h"
|
2022-03-11 17:57:33 +08:00
|
|
|
|
#import "XPNobleUpgradeLevelView.h"
|
2022-06-02 18:53:45 +08:00
|
|
|
|
#import "XPNewUserGreetRoomAlertView.h"
|
2022-06-17 14:56:16 +08:00
|
|
|
|
#import "XPSessionFindNewAlertView.h"
|
2022-07-27 17:12:06 +08:00
|
|
|
|
#import "XPHomeLivesViewController.h"
|
2022-07-28 11:56:59 +08:00
|
|
|
|
#import "XPNewUserRechargeViewController.h"
|
2022-08-01 19:24:12 +08:00
|
|
|
|
#import "XPAnchorCardView.h"
|
2022-08-02 18:13:51 +08:00
|
|
|
|
#import "XPNewUserRechargeSucessView.h"
|
|
|
|
|
#import "XPTaskCompleteTipView.h"
|
|
|
|
|
#import "XPWebViewController.h"
|
2022-08-03 16:51:06 +08:00
|
|
|
|
#import "XPMineUserInfoViewController.h"
|
2022-05-13 11:32:35 +08:00
|
|
|
|
#import "XPMonentsRecommendViewController.h"
|
2022-05-19 10:39:04 +08:00
|
|
|
|
#import "XPMonentsViewController.h"
|
2022-09-02 18:59:36 +08:00
|
|
|
|
#import "XPReceiveRedPacketView.h"
|
2021-09-13 14:22:51 +08:00
|
|
|
|
///Present
|
2021-09-07 23:05:43 +08:00
|
|
|
|
#import "MainPresenter.h"
|
|
|
|
|
#import "MainProtocol.h"
|
2022-01-24 15:43:05 +08:00
|
|
|
|
#import "RoomHostDelegate.h"
|
2021-09-13 14:22:51 +08:00
|
|
|
|
|
2022-06-02 18:53:45 +08:00
|
|
|
|
UIKIT_EXTERN NSString * kUserCompleteInfoFinishKey;
|
|
|
|
|
NSString * const kUserFirstLoginKey = @"kUserFirstLoginKey";
|
2022-08-03 18:33:59 +08:00
|
|
|
|
NSString * const kHadLaunchApp = @"kHadLaunchApp";
|
|
|
|
|
NSString * const kLastShowAnchorCardTime = @"kLastShowAnchorCardTime";
|
2022-07-28 11:56:59 +08:00
|
|
|
|
UIKIT_EXTERN NSString * kNewUserRechargeKey;
|
2022-08-01 19:24:12 +08:00
|
|
|
|
UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
2022-06-02 18:53:45 +08:00
|
|
|
|
|
2022-10-27 14:37:03 +08:00
|
|
|
|
@interface TabbarViewController () <BaseMvpProtocol, MainProtocol, NIMLoginManagerDelegate, NIMSystemNotificationManagerDelegate, NIMChatManagerDelegate, XPAnchorCardViewDelegate, NIMBroadcastManagerDelegate>
|
2021-09-07 23:05:43 +08:00
|
|
|
|
|
|
|
|
|
@property (nonatomic, strong) MainPresenter *presenter;
|
2021-12-08 15:36:47 +08:00
|
|
|
|
///房间最小化
|
|
|
|
|
@property (nonatomic,strong) XPMiniRoomView *roomMineView;
|
2022-06-16 17:15:16 +08:00
|
|
|
|
///邀请码
|
|
|
|
|
@property (nonatomic,copy) NSString *inviteCode;
|
2022-07-28 11:56:59 +08:00
|
|
|
|
///需要显示新用户充值优惠弹窗
|
|
|
|
|
@property (nonatomic, assign) BOOL needShowNewUserRecharge;
|
2022-08-01 19:24:12 +08:00
|
|
|
|
///需要展示主播卡片(首次)
|
|
|
|
|
@property (nonatomic, assign) BOOL needShowAnchorCard;
|
|
|
|
|
///延迟弹出主播卡片
|
|
|
|
|
@property (nonatomic, assign) BOOL delayShowAnchorCard;
|
|
|
|
|
///主播卡片
|
|
|
|
|
@property (nonatomic, strong) XPAnchorCardView *anchorCardView;
|
2022-08-02 18:13:51 +08:00
|
|
|
|
///任务完成提示
|
|
|
|
|
@property (nonatomic, strong) XPTaskCompleteTipView *taskTipView;
|
2022-09-05 18:48:19 +08:00
|
|
|
|
///代理
|
|
|
|
|
@property (nonatomic,weak) id<RoomHostDelegate>delegate;
|
2022-09-27 15:07:31 +08:00
|
|
|
|
///青少年模式
|
|
|
|
|
@property (nonatomic, assign) BOOL parentMode;
|
2022-07-28 11:56:59 +08:00
|
|
|
|
|
2021-09-07 23:05:43 +08:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation TabbarViewController
|
|
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
2021-12-08 15:36:47 +08:00
|
|
|
|
[super viewDidLoad];
|
2021-09-07 23:05:43 +08:00
|
|
|
|
[self configTheme];
|
2021-09-18 16:45:45 +08:00
|
|
|
|
[self initTabs:NO];
|
2021-12-11 16:15:40 +08:00
|
|
|
|
[[ClientConfig shareConfig] clientInit];
|
2021-10-21 20:05:30 +08:00
|
|
|
|
[[NIMSDK sharedSDK].loginManager addDelegate:self];
|
2022-06-17 14:56:16 +08:00
|
|
|
|
[[NIMSDK sharedSDK].chatManager addDelegate:self];
|
|
|
|
|
[[NIMSDK sharedSDK].systemNotificationManager addDelegate:self];
|
2022-10-27 14:37:03 +08:00
|
|
|
|
[[NIMSDK sharedSDK].broadcastManager addDelegate:self];
|
2021-11-01 17:17:56 +08:00
|
|
|
|
[self.presenter juliandAdCallBackApi];
|
2021-12-08 15:36:47 +08:00
|
|
|
|
[self.view addSubview:self.roomMineView];
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserverForName:kRoomMiniNotificationKey object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
|
|
|
|
|
[self configRoomMiniNView:note.userInfo];
|
|
|
|
|
}];
|
2022-06-02 18:53:45 +08:00
|
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserverForName:kUserCompleteInfoFinishKey object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
|
|
|
|
|
[self completeUserInfoFinish:note.object];
|
|
|
|
|
}];
|
2022-07-28 11:56:59 +08:00
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showNewUserRecharge) name:kNewUserRechargeKey object:nil];
|
2022-08-01 19:24:12 +08:00
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showAnchorCardKey:) name:kTabShowAnchorCardKey object:nil];
|
2022-09-27 15:07:31 +08:00
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(teenagerStatusChange:) name:kTeenagerStatusChange object:nil];
|
2021-09-07 23:05:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
|
[super viewWillAppear:animated];
|
2021-09-14 17:20:05 +08:00
|
|
|
|
[self.navigationController setNavigationBarHidden:YES animated:YES];
|
2021-09-18 16:45:45 +08:00
|
|
|
|
[self.presenter autoLogin];
|
2021-12-08 15:36:47 +08:00
|
|
|
|
if ([XPRoomMiniManager shareManager].getRoomInfo == nil) {
|
|
|
|
|
[self.roomMineView hiddenRoomMiniView];
|
|
|
|
|
}
|
2021-09-07 23:05:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 19:24:12 +08:00
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
|
|
|
|
[super viewWillDisappear:animated];
|
|
|
|
|
self.delayShowAnchorCard = NO;
|
2022-08-03 11:43:45 +08:00
|
|
|
|
[self.anchorCardView removeFromSuperview];
|
|
|
|
|
self.anchorCardView = nil;
|
2022-08-01 19:24:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-28 11:56:59 +08:00
|
|
|
|
- (void)viewDidAppear:(BOOL)animated {
|
|
|
|
|
[super viewDidAppear:animated];
|
2022-09-27 15:07:31 +08:00
|
|
|
|
if (self.needShowNewUserRecharge && !self.parentMode) {
|
2022-07-28 11:56:59 +08:00
|
|
|
|
self.needShowNewUserRecharge = NO;
|
|
|
|
|
XPNewUserRechargeViewController *vc = [[XPNewUserRechargeViewController alloc] initWithNavigation:self.selectedViewController.navigationController];
|
2022-08-03 15:57:14 +08:00
|
|
|
|
vc.hadAnimate = YES;
|
2022-07-28 11:56:59 +08:00
|
|
|
|
[self.selectedViewController.navigationController presentViewController:vc animated:YES completion:nil];
|
2022-08-08 13:15:04 +08:00
|
|
|
|
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventNugiftPopShow];
|
2022-07-28 11:56:59 +08:00
|
|
|
|
}
|
2022-08-04 11:42:49 +08:00
|
|
|
|
if ([self hadLaunchApp] && [self canShowAnchorCard]) {
|
2022-08-01 19:24:12 +08:00
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
2022-08-03 11:43:45 +08:00
|
|
|
|
if (self.view.window && self.isViewLoaded) {
|
|
|
|
|
[self.presenter getAnchorCardInfo];
|
|
|
|
|
}
|
2022-08-01 19:24:12 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2022-09-27 15:07:31 +08:00
|
|
|
|
if (self.needShowAnchorCard && !self.delayShowAnchorCard && !self.parentMode) {
|
2022-08-03 18:33:59 +08:00
|
|
|
|
[self.presenter getAnchorCardInfo];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:kHadLaunchApp];///第一次弹主播卡片
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
|
|
}
|
2022-07-28 11:56:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 23:05:43 +08:00
|
|
|
|
- (MainPresenter *)presenter {
|
|
|
|
|
if (_presenter == nil) {
|
|
|
|
|
_presenter = [[MainPresenter alloc] init];
|
|
|
|
|
[_presenter attatchView:self];
|
|
|
|
|
}
|
|
|
|
|
return _presenter;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-21 20:05:30 +08:00
|
|
|
|
/** 登录成功(通过token且换取ticket后)。
|
|
|
|
|
|
|
|
|
|
1. 登录云信。
|
|
|
|
|
2. 获取用户信息。
|
|
|
|
|
3. 其实目前多余回调V层,可以在P层里自行做这个逻辑。
|
|
|
|
|
*/
|
2021-09-14 16:57:13 +08:00
|
|
|
|
- (void)autoLoginSuccess {
|
2021-10-21 20:05:30 +08:00
|
|
|
|
[self.presenter loginNIM];
|
2021-09-14 16:57:13 +08:00
|
|
|
|
[self.presenter getUserInfo];
|
2022-03-30 20:29:12 +08:00
|
|
|
|
///登录成功之后 在验证是否有漏单的行为
|
|
|
|
|
[self.presenter checkTranscation];
|
2022-06-16 17:15:16 +08:00
|
|
|
|
if (self.inviteCode && self.inviteCode.length > 0) {
|
|
|
|
|
///邀请码进房
|
|
|
|
|
[self.presenter checkInviteUserInfo:self.inviteCode];
|
|
|
|
|
}
|
2022-10-31 12:15:01 +08:00
|
|
|
|
XPAdImageTool.shareImageTool.isImLogin = YES;
|
2021-09-14 16:57:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// 获取用户信息后检查:1、是否绑定手机号;2、是否需要完善用户信息。
|
2021-09-16 11:30:03 +08:00
|
|
|
|
/// 该逻辑仅在刷新ticket后执行一次。
|
2021-09-14 16:57:13 +08:00
|
|
|
|
/// 当前服务端接口是有未完善信息的全局拦截的,在BaseMvpPresenter里会触发1415去完善用户信息。
|
|
|
|
|
- (void)getUserInfoSuccess:(UserInfoModel *)userInfo {
|
2022-01-24 11:49:23 +08:00
|
|
|
|
if (!userInfo.isBindPhone && [ClientConfig shareConfig].iosPhoneBind) {
|
2021-11-30 18:28:21 +08:00
|
|
|
|
LoginBindPhoneViewController * bindPhoneVC = [[LoginBindPhoneViewController alloc] init];
|
|
|
|
|
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:bindPhoneVC];
|
|
|
|
|
nav.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
|
|
[self.navigationController presentViewController:nav animated:YES completion:nil];
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-09-14 16:57:13 +08:00
|
|
|
|
if (userInfo.nick == nil || userInfo.avatar == nil) {
|
|
|
|
|
[self completeUserInfo];
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-09-18 16:45:45 +08:00
|
|
|
|
[self initTabs:YES];
|
2022-06-16 17:15:16 +08:00
|
|
|
|
if (self.inviteCode.length <= 0) {
|
|
|
|
|
[self initQuickEnterRoom];
|
|
|
|
|
}
|
|
|
|
|
if (self.inviteCode) {
|
|
|
|
|
self.inviteCode = nil;
|
|
|
|
|
}
|
2021-12-07 11:08:43 +08:00
|
|
|
|
[self showTeenagerAlertView:userInfo];
|
2022-08-26 17:13:20 +08:00
|
|
|
|
[self monentsUnReadCount];
|
2022-09-27 15:07:31 +08:00
|
|
|
|
self.parentMode = userInfo.parentMode;
|
|
|
|
|
for (BaseViewController *vc in self.viewControllers) {
|
|
|
|
|
vc.parentMode = self.parentMode;
|
|
|
|
|
}
|
2021-09-14 16:57:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-02 18:53:45 +08:00
|
|
|
|
- (void)checkInviteUserInfoSuccess:(InviteUserInfoModel *)inviteInfo {
|
2022-09-27 15:07:31 +08:00
|
|
|
|
if (inviteInfo && inviteInfo.isInRoom && !self.parentMode) {
|
2022-06-02 18:53:45 +08:00
|
|
|
|
[XPRoomViewController openRoom:inviteInfo.roomUid fromNick:inviteInfo.inviteNick fromType:inviteInfo.fromType fromUid:inviteInfo.inviteUid viewController:self];
|
|
|
|
|
} else { //不在房间
|
|
|
|
|
///新用户打招呼引导
|
|
|
|
|
[self.presenter getNewUserGreetInfo];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)getNewUserGreetInfoSucces:(NewUserGreetModel *)greetInfo {
|
2022-06-13 16:19:40 +08:00
|
|
|
|
NSString * key = [NSString stringWithFormat:@"%@_%@", kUserFirstLoginKey, [AccountInfoStorage instance].getUid];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:key];
|
2022-06-02 18:53:45 +08:00
|
|
|
|
if (greetInfo.sayHello) {
|
|
|
|
|
XPNewUserGreetRoomAlertView * alertView = [[XPNewUserGreetRoomAlertView alloc] init];
|
|
|
|
|
alertView.greetInfo = greetInfo;
|
|
|
|
|
alertView.currentVC = self;
|
|
|
|
|
TTPopupService * config = [[TTPopupService alloc] init];
|
|
|
|
|
config.contentView = alertView;
|
|
|
|
|
config.shouldDismissOnBackgroundTouch = NO;
|
|
|
|
|
config.maskBackgroundAlpha = 0.8;
|
|
|
|
|
[TTPopup popupWithConfig:config];
|
|
|
|
|
} else {
|
|
|
|
|
[self.presenter getShortCutRecommendRoom];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)getShortCutRecommendRoomSuccces:(NSString *)roomUid {
|
2022-09-27 15:07:31 +08:00
|
|
|
|
if (self.parentMode) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-06-02 18:53:45 +08:00
|
|
|
|
if (roomUid.length > 0) {
|
|
|
|
|
[XPRoomViewController openRoom:roomUid viewController:self];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-21 20:05:30 +08:00
|
|
|
|
#pragma mark - BaseMvpProtocol
|
2021-09-07 23:05:43 +08:00
|
|
|
|
- (void)tokenInvalid {
|
|
|
|
|
LoginViewController *lvc = [[LoginViewController alloc] init];
|
2021-09-18 16:45:45 +08:00
|
|
|
|
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:lvc];
|
|
|
|
|
nav.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
|
|
[self.navigationController presentViewController:nav animated:YES completion:nil];
|
2022-10-31 12:15:01 +08:00
|
|
|
|
XPAdImageTool.shareImageTool.isImLogin = NO;
|
2021-09-07 23:05:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)completeUserInfo {
|
2021-09-18 16:45:45 +08:00
|
|
|
|
LoginFullInfoViewController * bindPhoneVC = [[LoginFullInfoViewController alloc] init];
|
|
|
|
|
BaseNavigationController * nav = [[BaseNavigationController alloc] initWithRootViewController:bindPhoneVC];
|
|
|
|
|
nav.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
|
|
[self.navigationController presentViewController:nav animated:YES completion:nil];
|
2021-09-14 21:01:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 19:24:12 +08:00
|
|
|
|
///获取主播卡片信息成功
|
|
|
|
|
- (void)getAnchorCardInfoSuccess:(XPTabAnchorCardModel *)cardInfo {
|
2022-09-27 15:07:31 +08:00
|
|
|
|
if (self.parentMode) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-08-01 19:24:12 +08:00
|
|
|
|
if (!self.anchorCardView.superview && cardInfo && self.isViewLoaded && self.view.window) {
|
|
|
|
|
self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90);
|
|
|
|
|
[UIView animateWithDuration:0.5 animations:^{
|
|
|
|
|
self.anchorCardView.frame = CGRectMake(0, kStatusBarHeight, KScreenWidth, 90);
|
2022-08-04 11:42:49 +08:00
|
|
|
|
} completion:nil];
|
|
|
|
|
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);//默认震动效果
|
2022-08-03 18:33:59 +08:00
|
|
|
|
long time = (long)([[NSDate date] timeIntervalSince1970]*1000);
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:@(time) forKey:kLastShowAnchorCardTime];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
2022-08-01 19:24:12 +08:00
|
|
|
|
self.anchorCardView.cardInfo = cardInfo;
|
|
|
|
|
[self.view addSubview:self.anchorCardView];
|
|
|
|
|
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleAnchorCardSwipeFrom:)];
|
|
|
|
|
[recognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];
|
|
|
|
|
[self.anchorCardView addGestureRecognizer:recognizer];
|
2022-08-08 13:15:04 +08:00
|
|
|
|
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventPersonalshowTopCardShow];
|
2022-08-01 19:24:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-21 20:05:30 +08:00
|
|
|
|
#pragma mark - NIMLoginManagerDelegate
|
|
|
|
|
- (void)onAutoLoginFailed:(NSError *)error {
|
|
|
|
|
// 如果非上次登录设备 autoLogin 会返回 417
|
|
|
|
|
if (error.code == 417) {
|
|
|
|
|
@weakify(self);
|
|
|
|
|
AccountModel* accountModel = [AccountInfoStorage instance].getCurrentAccountInfo;
|
|
|
|
|
[[NIMSDK sharedSDK].loginManager login:accountModel.uid token:accountModel.netEaseToken completion:^(NSError * _Nullable error) {
|
|
|
|
|
if (error) {
|
|
|
|
|
@strongify(self);
|
|
|
|
|
[self.presenter logout];
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
[self.presenter logout];
|
2021-09-07 23:05:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-21 20:05:30 +08:00
|
|
|
|
- (void)onKickout:(NIMLoginKickoutResult *)result {
|
2022-01-24 15:43:05 +08:00
|
|
|
|
[XCHUDTool showErrorWithMessage:@"您已被踢下线,若非正常行为,请及时修改密码"];
|
|
|
|
|
UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
|
|
|
|
|
if ([rootViewController presentedViewController]) { //有一个被present出来的控制器 要先dismiss
|
|
|
|
|
[[rootViewController presentedViewController] dismissViewControllerAnimated:YES completion:^{
|
|
|
|
|
if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) {
|
|
|
|
|
[[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES];
|
|
|
|
|
}
|
|
|
|
|
if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) {
|
|
|
|
|
UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
|
|
|
|
|
if (tabVC.selectedViewController.navigationController) {
|
|
|
|
|
[tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES];
|
|
|
|
|
}
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
[tabVC setSelectedIndex:0];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}else { //不是被present出来的 就有可能是rootvc或者是被push出来的 所以要判断nav是不是只有一个vc 如果有多个就pop
|
|
|
|
|
if ([[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController.viewControllers.count > 1) {
|
|
|
|
|
[[[XCCurrentVCStackManager shareManager] getCurrentVC].navigationController popToRootViewControllerAnimated:YES];
|
|
|
|
|
}
|
|
|
|
|
if ([[UIApplication sharedApplication].delegate.window.rootViewController isKindOfClass:[UITabBarController class]]) {
|
|
|
|
|
UITabBarController *tabVC = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
|
|
|
|
|
if (tabVC.selectedViewController) {
|
|
|
|
|
if ([tabVC.selectedViewController isKindOfClass:[UINavigationController class]]) {
|
|
|
|
|
[tabVC.selectedViewController popToRootViewControllerAnimated:YES];
|
|
|
|
|
} else {
|
|
|
|
|
[tabVC.selectedViewController.navigationController popToRootViewControllerAnimated:YES];
|
|
|
|
|
}
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
[tabVC setSelectedIndex:0];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ([XPRoomMiniManager shareManager].getRoomInfo) {
|
|
|
|
|
[[RtcManager instance] exitRoom];
|
|
|
|
|
[[NIMSDK sharedSDK].chatroomManager exitChatroom:[NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId] completion:nil];
|
|
|
|
|
[self.roomMineView hiddenRoomMiniView];
|
|
|
|
|
}
|
2021-10-21 20:05:30 +08:00
|
|
|
|
[self.presenter logout];
|
2021-10-21 12:01:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-17 14:56:16 +08:00
|
|
|
|
#pragma mark - NIMChatManagerDelegate
|
|
|
|
|
- (void)onRecvMessages:(NSArray<NIMMessage *> *)messages {
|
2022-09-27 15:07:31 +08:00
|
|
|
|
if (self.parentMode) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-06-17 14:56:16 +08:00
|
|
|
|
for (NIMMessage * message in messages) {
|
|
|
|
|
if (message.session.sessionType == NIMSessionTypeP2P) {
|
|
|
|
|
if(message.messageType == NIMMessageTypeCustom) {
|
|
|
|
|
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
|
|
|
|
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
|
|
|
|
AttachmentModel * attachment = obj.attachment;
|
|
|
|
|
if (attachment.first == CustomMessageType_FindNew && attachment.second == Custom_Message_Find_New_Greet_New_User) {
|
|
|
|
|
FindNewGreetMessageModel * greetInfo = [FindNewGreetMessageModel modelWithDictionary:attachment.data];
|
|
|
|
|
if (greetInfo.uid.integerValue != [AccountInfoStorage instance].getUid.integerValue) {
|
|
|
|
|
[TTPopup dismiss];
|
|
|
|
|
XPSessionFindNewAlertView * alertView = [[XPSessionFindNewAlertView alloc] init];
|
|
|
|
|
alertView.userInfo = greetInfo;
|
|
|
|
|
TTPopupService *service = [[TTPopupService alloc] init];
|
|
|
|
|
service.contentView = alertView;
|
|
|
|
|
service.shouldDismissOnBackgroundTouch = NO;
|
|
|
|
|
service.style = TTPopupStyleAlert;
|
|
|
|
|
[TTPopup popupWithConfig:service];
|
|
|
|
|
}
|
2022-09-02 18:59:36 +08:00
|
|
|
|
}
|
2022-06-17 14:56:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-05 18:48:19 +08:00
|
|
|
|
}
|
2022-06-17 14:56:16 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-27 14:37:03 +08:00
|
|
|
|
|
|
|
|
|
- (void)onReceiveBroadcastMessage:(NIMBroadcastMessage *)broadcastMessage {
|
|
|
|
|
if (broadcastMessage.content) {
|
|
|
|
|
NSDictionary *msgDictionary = [broadcastMessage.content toJSONObject];
|
|
|
|
|
AttachmentModel *attachment = [AttachmentModel modelWithJSON:msgDictionary[@"body"]];
|
|
|
|
|
if (attachment.first == CustomMessageType_RedPacket && attachment.second == Custom_Message_Sub_AllDiamandRedPacket) {
|
|
|
|
|
XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithDictionary:attachment.data];
|
|
|
|
|
//判断是否在房间
|
|
|
|
|
__block BOOL isInRoom;
|
|
|
|
|
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
|
|
|
|
if ([obj isKindOfClass:[XPRoomViewController class]]) {
|
|
|
|
|
XPRoomViewController<RoomHostDelegate> * roomVC = obj;
|
|
|
|
|
RoomInfoModel *roomInfo = [roomVC getRoomInfo];
|
|
|
|
|
XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
|
|
|
|
if (roomInfo.uid == data.roomUid.integerValue) {
|
|
|
|
|
view.inAllPacketRoom = YES;
|
|
|
|
|
} else {
|
|
|
|
|
view.inAllPacketRoom = NO;
|
|
|
|
|
}
|
|
|
|
|
XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithJSON:attachment.data];
|
|
|
|
|
view.redPacketModel = data;
|
|
|
|
|
[roomVC.view addSubview:view];
|
|
|
|
|
[roomVC.view bringSubviewToFront:view];
|
|
|
|
|
*stop = YES;
|
|
|
|
|
isInRoom = YES;
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
if (!isInRoom) {
|
|
|
|
|
UIViewController *currentVc = [[XCCurrentVCStackManager shareManager] getCurrentVC];
|
|
|
|
|
XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
|
|
|
|
view.inAllPacketRoom = NO;
|
|
|
|
|
XPReceiveRedPacketModel *data = [XPReceiveRedPacketModel modelWithJSON:attachment.data];
|
|
|
|
|
view.redPacketModel = data;
|
|
|
|
|
[currentVc.view addSubview:view];
|
|
|
|
|
[currentVc.view bringSubviewToFront:view];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 23:05:43 +08:00
|
|
|
|
- (void)configTheme {
|
2021-12-17 19:31:26 +08:00
|
|
|
|
self.view.backgroundColor = [ThemeColor tabbarViewColor];
|
|
|
|
|
[[UITabBar appearance] setBackgroundImage:[UIImage imageWithColor:[ThemeColor tabbarViewColor] size:CGSizeMake(KScreenWidth, kTabBarHeight)]];
|
2021-09-07 23:05:43 +08:00
|
|
|
|
[[UITabBar appearance] setShadowImage:[[UIImage alloc]init]];
|
|
|
|
|
if (@available(iOS 10.0, *)) {
|
2021-09-13 14:22:51 +08:00
|
|
|
|
[[UITabBar appearance] setUnselectedItemTintColor:[ThemeColor tabbarNormalColor]];
|
2021-09-07 23:05:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-18 16:45:45 +08:00
|
|
|
|
- (void)initTabs:(BOOL)logined {
|
2022-04-26 10:16:50 +08:00
|
|
|
|
self.viewControllers = nil;
|
2022-05-13 11:32:35 +08:00
|
|
|
|
NSArray *normalImageNames = @[@"tab_gameHome_normal",@"tab_monents_normal",@"tab_message_normal", @"tab_mine_normal"];
|
2022-11-28 15:37:33 +08:00
|
|
|
|
NSArray *selectImageNames = @[@"tab_gameHome_normal",@"tab_monents_normal",@"tab_message_normal", @"tab_mine_normal"];
|
2022-05-13 11:32:35 +08:00
|
|
|
|
NSArray *tabLabel = @[@"派对",@"广场",@"消息", @"我的"];
|
2021-09-07 23:05:43 +08:00
|
|
|
|
|
2021-09-18 16:45:45 +08:00
|
|
|
|
UIViewController *game;
|
2021-11-26 20:25:23 +08:00
|
|
|
|
UIViewController *msg;
|
2021-09-18 16:45:45 +08:00
|
|
|
|
UIViewController *me;
|
2021-11-29 21:40:11 +08:00
|
|
|
|
UIViewController * home;
|
2022-05-13 11:32:35 +08:00
|
|
|
|
UIViewController * monents;
|
2021-09-18 16:45:45 +08:00
|
|
|
|
if (logined) {
|
|
|
|
|
XplanFBFlutterViewContainer *fvcGame = XplanFBFlutterViewContainer.new;
|
2021-09-08 20:28:37 +08:00
|
|
|
|
#ifdef DEBUG
|
2021-09-18 16:45:45 +08:00
|
|
|
|
[fvcGame setName:@"debug" uniqueId:nil params:nil];
|
2021-09-08 20:28:37 +08:00
|
|
|
|
#else
|
2021-09-18 16:45:45 +08:00
|
|
|
|
[fvcGame setName:@"/" uniqueId:nil params:nil];
|
2021-09-08 20:28:37 +08:00
|
|
|
|
#endif
|
2021-11-26 20:25:23 +08:00
|
|
|
|
msg = [[SessionListViewController alloc] init];
|
2021-09-18 16:45:45 +08:00
|
|
|
|
me = [[XPMineViewController alloc] init];
|
2021-11-29 21:40:11 +08:00
|
|
|
|
|
2022-02-21 20:06:09 +08:00
|
|
|
|
home = [[XPHomeViewController alloc] init];
|
2022-05-19 10:39:04 +08:00
|
|
|
|
monents = [[XPMonentsViewController alloc] init];
|
2021-09-18 16:45:45 +08:00
|
|
|
|
} else {
|
|
|
|
|
game = [[BaseViewController alloc]init];
|
2021-12-02 20:31:29 +08:00
|
|
|
|
msg = [[SessionListViewController alloc]init];
|
2021-09-18 16:45:45 +08:00
|
|
|
|
me = [[BaseViewController alloc]init];
|
2021-11-29 21:40:11 +08:00
|
|
|
|
home = [[BaseViewController alloc] init];
|
2022-05-13 11:32:35 +08:00
|
|
|
|
monents = [[BaseViewController alloc] init];
|
2021-09-18 16:45:45 +08:00
|
|
|
|
}
|
2021-11-29 21:40:11 +08:00
|
|
|
|
[self createTabBarItem:home title:tabLabel[0] image:normalImageNames[0] selectedImage:selectImageNames[0]];
|
2022-05-13 11:32:35 +08:00
|
|
|
|
[self createTabBarItem:monents title:tabLabel[1] image:normalImageNames[1] selectedImage:selectImageNames[1]];
|
2021-11-29 21:40:11 +08:00
|
|
|
|
[self createTabBarItem:msg title:tabLabel[2] image:normalImageNames[2] selectedImage:selectImageNames[2]];
|
|
|
|
|
[self createTabBarItem:me title:tabLabel[3] image:normalImageNames[3] selectedImage:selectImageNames[3]];
|
2022-05-13 11:32:35 +08:00
|
|
|
|
self.viewControllers = @[home,monents,msg,me];
|
2021-09-18 16:04:50 +08:00
|
|
|
|
self.selectedIndex = 0;
|
2021-09-07 23:05:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-16 17:21:52 +08:00
|
|
|
|
- (BaseNavigationController *)createTabBarItem:(UIViewController *)itemVc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage{
|
2021-09-07 23:05:43 +08:00
|
|
|
|
itemVc.title = title;
|
|
|
|
|
itemVc.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
|
|
|
|
itemVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
|
2022-11-28 15:37:33 +08:00
|
|
|
|
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x333333)} forState:UIControlStateSelected];
|
|
|
|
|
[itemVc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x999999)} forState:UIControlStateNormal];
|
|
|
|
|
itemVc.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, 5);
|
2021-09-16 17:21:52 +08:00
|
|
|
|
BaseNavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:itemVc];
|
|
|
|
|
return nav;
|
2021-09-07 23:05:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-15 18:41:40 +08:00
|
|
|
|
- (void)showSuccessToast:(NSString *)msg {
|
2021-09-18 16:45:45 +08:00
|
|
|
|
[XCHUDTool showSuccessWithMessage:msg];
|
2021-09-15 18:41:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)showErrorToast:(NSString *)msg {
|
2021-09-18 16:45:45 +08:00
|
|
|
|
[XCHUDTool showErrorWithMessage:msg];
|
2021-09-15 18:41:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)showLoading {
|
2021-09-18 16:45:45 +08:00
|
|
|
|
[XCHUDTool showLoading];
|
2021-09-15 18:41:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)hideHUD {
|
2021-09-18 16:45:45 +08:00
|
|
|
|
[XCHUDTool hideHUD];
|
2021-09-15 18:41:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-26 17:13:20 +08:00
|
|
|
|
#pragma mark - 动态
|
|
|
|
|
- (void)monentsUnReadCount {
|
|
|
|
|
[Api monentsUnReadCount:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
|
|
|
if (code == 200) {
|
|
|
|
|
MonentsUnReadModel * model = [MonentsUnReadModel modelWithDictionary:data.data];
|
|
|
|
|
NSString *badge = model.total > 0 ? @(model.total).stringValue : nil;
|
|
|
|
|
if (model.total > 99) {
|
|
|
|
|
badge = @"99+";
|
|
|
|
|
}
|
|
|
|
|
NSUInteger index = 1;
|
|
|
|
|
UITabBarItem *item = self.tabBar.items.count > index ? self.tabBar.items[index] : nil;
|
|
|
|
|
[item setBadgeValue:badge];
|
|
|
|
|
}
|
|
|
|
|
} uid:[AccountInfoStorage instance].getUid];
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-03 18:12:24 +08:00
|
|
|
|
#pragma mark - 房间最小化
|
2021-12-08 15:36:47 +08:00
|
|
|
|
- (void)configRoomMiniNView:(NSDictionary *)dic {
|
|
|
|
|
UserInfoModel * userInfo = [UserInfoModel modelWithDictionary:dic[@"userInfo"]];
|
|
|
|
|
RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic[@"roomInfo"]];
|
|
|
|
|
NSMutableDictionary * microQueue = dic[@"microQueue"];
|
|
|
|
|
[self.roomMineView configRoomMiniView:roomInfo userInfo:userInfo micQueue:microQueue];
|
2021-12-03 17:07:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-07 11:08:43 +08:00
|
|
|
|
#pragma mark - 青少年模式
|
|
|
|
|
- (void)showTeenagerAlertView:(UserInfoModel *)userInfo {
|
|
|
|
|
if (!userInfo || userInfo.uid <=0) return; ///用户信息为空 不处理
|
|
|
|
|
if (userInfo.parentMode) return;// 开启了青少年模式的话 就不用处理
|
|
|
|
|
NSString * teenagerKey = [NSString stringWithFormat:@"%@_%ld", kTeenagerAlertDatekey, userInfo.uid];
|
|
|
|
|
NSDate * oldDate = [[NSUserDefaults standardUserDefaults] objectForKey:teenagerKey];
|
|
|
|
|
BOOL isSameDay = [[NSCalendar currentCalendar] isDateInToday:oldDate];
|
|
|
|
|
if (isSameDay) return;
|
2021-12-08 17:29:00 +08:00
|
|
|
|
XPTeenagerAlertView * teenagerView = [[XPTeenagerAlertView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth - 45 * 2, 260)];
|
2021-12-07 11:08:43 +08:00
|
|
|
|
teenagerView.controller = self;
|
|
|
|
|
[TTPopup popupView:teenagerView style:TTPopupStyleAlert];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:teenagerKey];
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-02 18:53:45 +08:00
|
|
|
|
#pragma mark - 快捷进房
|
|
|
|
|
- (void)initQuickEnterRoom {
|
2022-06-13 16:19:40 +08:00
|
|
|
|
NSString * key = [NSString stringWithFormat:@"%@_%@", kUserFirstLoginKey, [AccountInfoStorage instance].getUid];
|
|
|
|
|
BOOL isNotFirstLogin = [[NSUserDefaults standardUserDefaults] boolForKey:key];
|
2022-06-02 18:53:45 +08:00
|
|
|
|
if (isNotFirstLogin) {
|
2022-06-17 10:26:34 +08:00
|
|
|
|
[self.presenter getShortCutRecommendRoom];
|
2022-06-02 18:53:45 +08:00
|
|
|
|
} else {
|
|
|
|
|
///新用户
|
|
|
|
|
[self.presenter getNewUserGreetInfo];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///跳转优先级 闪屏→linkedMe→邀请码→新用户打招呼引导→渠道指定房间
|
|
|
|
|
- (void)completeUserInfoFinish:(NSString *)inviteCode {
|
2022-06-16 17:15:16 +08:00
|
|
|
|
self.inviteCode = inviteCode;
|
2022-06-02 18:53:45 +08:00
|
|
|
|
}
|
2022-03-11 17:57:33 +08:00
|
|
|
|
#pragma mark -NIMSystemNotificationManagerDelegate
|
|
|
|
|
- (void)onReceiveCustomSystemNotification:(NIMCustomSystemNotification *)notification {
|
2022-09-27 15:07:31 +08:00
|
|
|
|
if (self.parentMode) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-03-11 17:57:33 +08:00
|
|
|
|
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_Noble_LevelUp_User) { // 用户贵族升级
|
|
|
|
|
if ([dic isKindOfClass:[NSDictionary class]]) {
|
|
|
|
|
[self receiveNobleLevelUp:dic];
|
|
|
|
|
}
|
|
|
|
|
} else if ([dic[@"first"] integerValue] == CustomMessageType_First_VisitorRecord){//访客记录数量更新提示
|
|
|
|
|
AttachmentModel *attachment = [AttachmentModel modelWithJSON:notification.content];
|
|
|
|
|
XPMineVisitorUnReadModel *model = [XPMineVisitorUnReadModel modelWithJSON:attachment.data];
|
|
|
|
|
if ([model isKindOfClass:XPMineVisitorUnReadModel.class]) {
|
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:kVisitorUnReadCountNotificationKey object:model];
|
|
|
|
|
}
|
2022-08-02 18:13:51 +08:00
|
|
|
|
} else if ([dic[@"first"] intValue] == CustomMessageType_First_Recharge_Reward && [dic[@"second"] intValue] == Custom_Message_Sub_New_User_Recharge_Reward) { // 新用户充值优惠成功
|
|
|
|
|
if ([dic isKindOfClass:[NSDictionary class]]) {
|
|
|
|
|
FirstRechargeModel *model = [FirstRechargeModel modelWithDictionary:dic[@"data"]];
|
|
|
|
|
XPNewUserRechargeSucessView * firstRechargeView= [[XPNewUserRechargeSucessView alloc] init];
|
|
|
|
|
firstRechargeView.rechargeInfo = model;
|
|
|
|
|
[TTPopup popupView:firstRechargeView style:TTPopupStyleAlert];
|
2022-08-08 13:15:04 +08:00
|
|
|
|
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventnugift_pop_finish_click eventAttributes:@{@"buy_level" : [NSString stringWithFormat:@"%zd", model.chargeMoney]}];
|
2022-08-02 18:13:51 +08:00
|
|
|
|
}
|
|
|
|
|
} else if ([dic[@"first"] intValue] == CustomMessageType_Task_Complete && [dic[@"second"] intValue] == Custom_Message_Sub_TaskComplete) {///任务完成提醒
|
|
|
|
|
if ([dic isKindOfClass:[NSDictionary class]]) {
|
|
|
|
|
NSDictionary *dict = dic[@"data"];
|
|
|
|
|
[self handleActivityTaskTip:dict[@"taskCompleteMsg"] url:dic[@"taskUrl"]];
|
|
|
|
|
}
|
2022-03-11 17:57:33 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)receiveNobleLevelUp:(NSDictionary *)data {
|
2022-09-27 15:07:31 +08:00
|
|
|
|
if (self.parentMode) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-03-15 19:36:05 +08:00
|
|
|
|
XPNobleUpgradeLevelView *view = [[XPNobleUpgradeLevelView alloc] initWithFrame:CGRectMake(0, 0, 300, 285 + 22 + 44)];
|
2022-03-11 17:57:33 +08:00
|
|
|
|
NobleLevelUpModel *receiveInfo = [NobleLevelUpModel modelWithDictionary:data[@"data"]];
|
|
|
|
|
view.levelUpInfo = receiveInfo;
|
|
|
|
|
[TTPopup popupView:view style:TTPopupStyleAlert];
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 19:24:12 +08:00
|
|
|
|
#pragma mark - 主播卡片弹窗
|
|
|
|
|
//新用户专享充值弹窗
|
|
|
|
|
- (void)showNewUserRecharge {
|
|
|
|
|
self.needShowNewUserRecharge = YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///展示主播卡片
|
|
|
|
|
- (void)showAnchorCardKey:(NSNotification *)noti {
|
|
|
|
|
NSDictionary * dic = noti.object;
|
|
|
|
|
self.delayShowAnchorCard = [[dic objectForKey:@"delayShow"] boolValue];
|
|
|
|
|
self.needShowAnchorCard = YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///判断第二次启动时弹出主播卡片
|
2022-08-03 18:33:59 +08:00
|
|
|
|
- (BOOL)hadLaunchApp {
|
|
|
|
|
return [[NSUserDefaults standardUserDefaults] valueForKey:kHadLaunchApp];
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-27 15:07:31 +08:00
|
|
|
|
///青少年模式改变
|
|
|
|
|
- (void)teenagerStatusChange:(NSNotification *)noti {
|
|
|
|
|
NSDictionary * dic = noti.object;
|
|
|
|
|
self.parentMode = [[dic objectForKey:@"parentMode"] boolValue];
|
|
|
|
|
for (BaseViewController *vc in self.viewControllers) {
|
|
|
|
|
vc.parentMode = self.parentMode;
|
|
|
|
|
}
|
2022-10-09 16:47:38 +08:00
|
|
|
|
if ([XPRoomMiniManager shareManager].getRoomInfo && self.parentMode) {
|
|
|
|
|
[[RtcManager instance] exitRoom];
|
|
|
|
|
[[NIMSDK sharedSDK].chatroomManager exitChatroom:[NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.roomId] completion:nil];
|
|
|
|
|
[self.roomMineView hiddenRoomMiniView];
|
|
|
|
|
}
|
2022-09-27 15:07:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 18:33:59 +08:00
|
|
|
|
- (BOOL)canShowAnchorCard {
|
2022-09-01 11:18:13 +08:00
|
|
|
|
if ([[XPRoomMiniManager shareManager] getRoomInfo]) {//在房间时不弹
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
2022-08-01 19:24:12 +08:00
|
|
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
2022-08-03 18:33:59 +08:00
|
|
|
|
NSNumber *lastTime = [defaults objectForKey:kLastShowAnchorCardTime];
|
|
|
|
|
if ([lastTime longValue] < 1) {
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
NSDate *datenow = [NSDate date];//现在时间
|
|
|
|
|
long time2 = (long)([datenow timeIntervalSince1970]*1000);
|
|
|
|
|
long aTime = (time2 - [lastTime longValue]) / 1000;
|
|
|
|
|
if (aTime > 15*60) {
|
|
|
|
|
return YES;
|
|
|
|
|
} else {
|
|
|
|
|
return NO;
|
2022-08-01 19:24:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-02 18:13:51 +08:00
|
|
|
|
#pragma mark - 活动任务完成提示
|
|
|
|
|
- (void)handleActivityTaskTip:(NSString *)msg url:(NSString *)url {
|
|
|
|
|
if (!self.taskTipView.superview && url.length) {
|
2022-08-08 13:15:04 +08:00
|
|
|
|
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventtask_toast_show];
|
2022-08-02 18:13:51 +08:00
|
|
|
|
[self.view addSubview:self.taskTipView];
|
|
|
|
|
self.taskTipView.desc = msg;
|
|
|
|
|
self.taskTipView.url = url;
|
|
|
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jumpToTask:)];
|
|
|
|
|
[self.taskTipView addGestureRecognizer:tap];
|
|
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
if (self.taskTipView.superview) {
|
|
|
|
|
[self.taskTipView removeFromSuperview];
|
|
|
|
|
}
|
|
|
|
|
self.taskTipView = nil;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)jumpToTask:(UITapGestureRecognizer *)ges {
|
2022-08-08 13:15:04 +08:00
|
|
|
|
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventtask_toast_click];
|
2022-08-02 18:13:51 +08:00
|
|
|
|
XPWebViewController * webVC =[[XPWebViewController alloc] init];
|
|
|
|
|
webVC.url = self.taskTipView.url;
|
|
|
|
|
[self.selectedViewController.navigationController pushViewController:webVC animated:YES];
|
|
|
|
|
if (self.taskTipView.superview) {
|
|
|
|
|
[self.taskTipView removeFromSuperview];
|
|
|
|
|
}
|
|
|
|
|
self.taskTipView = nil;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 19:24:12 +08:00
|
|
|
|
#pragma mark - XPAnchorCardViewDelegate
|
|
|
|
|
- (void)xPAnchorCardViewEnterRoom:(NSString *)roomUid {
|
2022-08-05 18:08:26 +08:00
|
|
|
|
if (roomUid.length) {
|
2022-08-01 19:24:12 +08:00
|
|
|
|
[self.anchorCardView removeFromSuperview];
|
|
|
|
|
self.anchorCardView = nil;
|
|
|
|
|
self.needShowAnchorCard = NO;
|
|
|
|
|
[XPRoomViewController openRoom:roomUid viewController:self];
|
|
|
|
|
} else {
|
|
|
|
|
[UIView animateWithDuration:0.5 animations:^{
|
|
|
|
|
self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90);
|
|
|
|
|
} completion:^(BOOL finished) {
|
|
|
|
|
[self.anchorCardView removeFromSuperview];
|
|
|
|
|
self.anchorCardView = nil;
|
|
|
|
|
self.needShowAnchorCard = NO;
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 16:51:06 +08:00
|
|
|
|
- (void)xPAnchorCardViewClickAvatar:(NSString *)uid {
|
|
|
|
|
if (uid.length) {
|
|
|
|
|
XPMineUserInfoViewController * userInfoVC = [[XPMineUserInfoViewController alloc] init];
|
|
|
|
|
userInfoVC.uid = uid.integerValue;
|
|
|
|
|
[self.selectedViewController.navigationController pushViewController:userInfoVC animated:YES];
|
|
|
|
|
[self.anchorCardView removeFromSuperview];
|
|
|
|
|
self.anchorCardView = nil;
|
|
|
|
|
self.needShowAnchorCard = NO;
|
|
|
|
|
} else {
|
|
|
|
|
[self.anchorCardView removeFromSuperview];
|
|
|
|
|
self.anchorCardView = nil;
|
|
|
|
|
self.needShowAnchorCard = NO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 19:24:12 +08:00
|
|
|
|
- (void)handleAnchorCardSwipeFrom:(UISwipeGestureRecognizer *)recognizer{
|
|
|
|
|
if(recognizer.direction == UISwipeGestureRecognizerDirectionUp) {
|
|
|
|
|
[UIView animateWithDuration:0.5 animations:^{
|
|
|
|
|
self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90);
|
|
|
|
|
} completion:^(BOOL finished) {
|
|
|
|
|
[self.anchorCardView removeFromSuperview];
|
|
|
|
|
self.anchorCardView = nil;
|
|
|
|
|
self.needShowAnchorCard = NO;
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-08 15:36:47 +08:00
|
|
|
|
#pragma mark - Getters And Setters
|
|
|
|
|
- (XPMiniRoomView *)roomMineView {
|
|
|
|
|
if (!_roomMineView) {
|
|
|
|
|
_roomMineView = [[XPMiniRoomView alloc] init];
|
|
|
|
|
_roomMineView.controller = self;
|
|
|
|
|
_roomMineView.hidden = YES;
|
|
|
|
|
}
|
|
|
|
|
return _roomMineView;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 19:24:12 +08:00
|
|
|
|
- (XPAnchorCardView *)anchorCardView {
|
|
|
|
|
if (!_anchorCardView) {
|
|
|
|
|
_anchorCardView = [[XPAnchorCardView alloc] init];
|
|
|
|
|
_anchorCardView.delegate = self;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return _anchorCardView;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-02 18:13:51 +08:00
|
|
|
|
- (XPTaskCompleteTipView *)taskTipView {
|
|
|
|
|
if (!_taskTipView) {
|
|
|
|
|
_taskTipView = [[XPTaskCompleteTipView alloc] initWithFrame:CGRectMake(0, KScreenHeight - kSafeAreaBottomHeight-60-20, KScreenWidth, 20)];
|
|
|
|
|
}
|
|
|
|
|
return _taskTipView;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-07 23:05:43 +08:00
|
|
|
|
@end
|