123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- //
- // YOUPAILCMsgVC.m
- // zhimi
- //
- // Created by Apple on 2019/10/31.
- // Copyright © 2019 caiPro. All rights reserved.
- //
- #import "YOUPAILCMsgVC.h"
- #import "ZCNavMenuView.h"
- #import "YOUPAILCMessageVC.h"
- //#import "YOUPAILCMediaChatRecordVC.h"
- #import "JXCategoryView.h"
- #import "JXPagerView.h"
- #import "LZAlertWindow.h"
- #import "UIViewController+TFPresent.h"
- #import "QQPopMenuView.h"
- #import "YOUPAILZMessageGuideVC.h"
- #import "YOUPAILZSessionListGuideView.h"
- #import "YMCallRecordViewModel.h"
- #import "YMCallRecordViewController.h"
- #define LZCategoryViewHeight 54.0f
- @interface YOUPAILCMsgVC ()<JXCategoryViewDelegate,JXPagerViewDelegate,JXCategoryListContainerViewDelegate>
- //@property(nonatomic,strong)ZCNavMenuView* youpaipnavView;
- //@property(nonatomic,strong)UIScrollView* youpaipscrollView;
- //@property(nonatomic,strong)UIView* youpaipscrollBkgView;
- //@property(nonatomic,strong)YOUPAILCMessageVC *youpaipmsgVC;
- //@property(nonatomic,strong)YOUPAILCMediaChatRecordVC *youpaipphoneMsgVC;
- @property (nonatomic, weak) JXCategoryListContainerView *youpaippagerView;
- @property (nonatomic, strong) JXCategoryTitleView *youpaipcategoryView;
- @property (nonatomic, strong) UIView *youpaipcategoryBgV;
- /* titlearr */
- @property (strong, nonatomic) NSArray *youpaiptitlesArr;
- @property (strong, nonatomic) UIButton *youpaipfriendsBtn;
- @property (strong, nonatomic) UIButton *youpaipmoreBtn;
- //@property (nonatomic,weak) UIButton *youpaipapplyAnchorBtn;
- @property (nonatomic,weak) YOUPAILZSessionListGuideView *guideView;
- @end
- @implementation YOUPAILCMsgVC
- - (void)dealloc{
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- -(void)viewWillAppear:(BOOL)animated{
- [super viewWillAppear:animated];
- [self.navigationController setNavigationBarHidden:YES animated:animated];
- [self youpaifinitConfig];
- //
- // self.youpaipapplyAnchorBtn.hidden = !([LCSaveModel getUserModel].youpaipuserinfo.youpaipgender == 1 && [LCSaveModel getUserModel].youpaipuserinfo.youpaipis_auth != 1);
- }
- -(void)viewWillDisappear:(BOOL)animated{
- [super viewWillDisappear:animated];
- [self.navigationController setNavigationBarHidden:NO animated:animated];
- }
- /// 引导页
- - (void)youpaipshowGuide{
- // YOUPAILZGuideVC *vc = [[YOUPAILZGuideVC alloc] init];
- // vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
- // [self presentViewController:vc animated:NO completion:nil];
- YOUPAILZSessionListGuideView *guideView = [[YOUPAILZSessionListGuideView alloc] initWithFrame:[UIScreen mainScreen].bounds];
- guideView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
- [guideView addTarget:self action:@selector(guideViewClick:) forControlEvents:UIControlEventTouchUpInside];
- [self.tabBarController.view addSubview:guideView];
- self.guideView = guideView;
- }
- - (void)guideViewClick:(YOUPAILZSessionListGuideView *)sender{
- YOUPAILZMessageGuideVC *vc = [[YOUPAILZMessageGuideVC alloc] init];
- [self.navigationController pushViewController:vc animated:YES];
- [UIView animateWithDuration:0.25f animations:^{
- [self.guideView removeFromSuperview];
- }];
- }
- //- (UIStatusBarStyle)preferredStatusBarStyle{
- // return UIStatusBarStyleLightContent;
- //}
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self.view setBackgroundColor:UIColor.whiteColor];
-
- //UIImageView *topBgImgv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ym_messages_top_bg"]];
- //topBgImgv.frame = CGRectMake(0, 0, kScreenWidth, adapt(97));
- //[self.view addSubview:topBgImgv];
-
- self.youpaiptitlesArr = @[@"消息",@"通话"];
- UIView *categoryBgV = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, KScreenWidth, LZCategoryViewHeight + StatusBarHeight)];
- categoryBgV.backgroundColor = [UIColor clearColor];
- [self.view addSubview:categoryBgV];
- self.youpaipcategoryBgV = categoryBgV;
-
- JXCategoryTitleView *categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0.0f, StatusBarHeight, KScreenWidth - 16 * 2.0f - 24, LZCategoryViewHeight)];
- categoryView.contentScrollView.backgroundColor = [UIColor clearColor];
- categoryView.titles = self.youpaiptitlesArr;
- categoryView.delegate = self;
- categoryView.titleSelectedColor = DecColorFromRGBA(0, 0, 0, 1);
- categoryView.titleColor = DecColorFromRGBA(0, 0, 0, 0.5);
- categoryView.titleColorGradientEnabled = YES;
- categoryView.titleFont = LCFont(17.0f);
- categoryView.titleSelectedFont = LCBoldFont(22.0f);
- categoryView.cellWidth = adapt(53);
- categoryView.cellSpacing = 0;
- categoryView.contentEdgeInsetLeft = 15;
- categoryView.averageCellSpacingEnabled = NO;
- [categoryBgV addSubview:categoryView];
- self.youpaipcategoryView = categoryView;
-
- JXCategoryIndicatorImageView *indicatorImageView = [[JXCategoryIndicatorImageView alloc] init];
- //indicatorImageView.indicatorImageView.image = [UIImage imageNamed:@"home_indicator_img"];
- indicatorImageView.indicatorImageViewSize = CGSizeMake(adapt(68), LZCategoryViewHeight + adapt(5));
- //indicatorImageView.indicatorImageViewSize = CGSizeMake(adapt(40), adapt(26));
-
- UIImageView *indicatorImgv = [[UIImageView alloc] init];
- indicatorImgv.image = [UIImage imageNamed:@"home_indicator_img"];
- indicatorImgv.contentMode = UIViewContentModeScaleAspectFit;
- [indicatorImageView addSubview:indicatorImgv];
- [indicatorImgv mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(indicatorImageView);
- make.bottom.equalTo(indicatorImageView).offset(-5);
- make.width.mas_equalTo(40);
- make.height.mas_equalTo(8);
- }];
-
- categoryView.indicators = @[indicatorImageView];
-
-
-
- UIButton *friendsBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth - 16 - 48 - 10 - 48,(LZCategoryViewHeight - 44) / 2.0f + StatusBarHeight,48,50)];
- [friendsBtn setImage:[UIImage imageNamed:@"ym_messages_friends_icon"] forState:(UIControlStateNormal)];
- self.youpaipfriendsBtn = friendsBtn;
- [friendsBtn addTarget:self action:@selector(youpaiffriendsBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
- [categoryBgV addSubview:friendsBtn];
-
-
- UIButton *moreBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth - 16 - 48,(LZCategoryViewHeight - 44) / 2.0f + StatusBarHeight,48,50)];
- [moreBtn setImage:[UIImage imageNamed:@"ym_messages_more_icon"] forState:(UIControlStateNormal)];
- self.youpaipmoreBtn = moreBtn;
- [moreBtn addTarget:self action:@selector(youpaifmoreBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
- [categoryBgV addSubview:moreBtn];
-
-
- JXCategoryListContainerView *pagerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_CollectionView delegate:self];
- pagerView.listCellBackgroundColor = [UIColor clearColor];
- pagerView.frame = CGRectMake(0.0f, categoryBgV.mj_h, KScreenWidth, KScreenHeight - categoryBgV.mj_h - TabbarHeight);
- pagerView.backgroundColor = [UIColor clearColor];
- pagerView.scrollView.backgroundColor = [UIColor clearColor];
- [self.view addSubview:pagerView];
- self.youpaippagerView = pagerView;
-
- self.youpaipcategoryView.listContainer = self.youpaippagerView;
-
-
- // UIButton *youpaipapplyAnchorBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- // [youpaipapplyAnchorBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_im_apply_anchor"] forState:UIControlStateNormal];
- // [youpaipapplyAnchorBtn addTarget:self action:@selector(youpaipapplyAnchorBtnClick) forControlEvents:UIControlEventTouchUpInside];
- // [self.view addSubview:youpaipapplyAnchorBtn];
- // self.youpaipapplyAnchorBtn = youpaipapplyAnchorBtn;
- // [youpaipapplyAnchorBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.right.offset(0.0f);
- // make.bottom.offset(-38.0f-TabbarHeight);
- // make.size.mas_offset(CGSizeMake(142.0f, 44.0f));
- // }];
- //
- if (![LCSaveData getHiddenGuideState] && ([LCSaveModel getUserModel].youpaipuserinfo.youpaipgender == 1 && [LCSaveModel getUserModel].youpaipuserinfo.youpaipis_anchor != 1) && ![LCSaveData getWhiteVersion]) {
- [self youpaipshowGuide];
- }
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youpaifgoIntimacyList) name:@"GoIntimacyList" object:nil];
-
- }
- - (void)youpaifgoIntimacyList{
- [self.youpaipcategoryView selectItemAtIndex:1];
- }
- //- (void)youpaipapplyAnchorBtnClick{
- // if (![LCTools isGirlsRealNameAuthentication]) {
- // return;
- // };
- //}
- - (void)youpaifinitConfig{ //系统配置信息
- [LCHttpHelper requestWithURLString:AppConfig parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- NSString* sysId = [[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"sysId"];
- NSString* servId = [[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"servId"];
- NSString* appurl = [[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"appurl"];
- NSArray* serviceIdArr = [[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"serviceId"];
- // NSString *audit_status = [NSString stringWithFormat:@"%@",[[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"audit_status"]];
- NSString *rankH5Url = [[dict objectForKey:@"data"]objectForKey:@"rank_url"];
- NSInteger free = [[[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"free"] integerValue];
- [LCSaveData saveAppUrl:appurl];
- [LCSaveData saveSysId:sysId];
- [LCSaveData saveServerId:servId];
- [LCSaveData saveServiceIdArr:serviceIdArr];
- [LCSaveData saveRankH5Url:rankH5Url];
- [LCSaveData saveIMPrice:free];
- }
- } failure:^(NSError *error) {
-
- }];
- }
- #pragma mark-好友
- - (void)youpaiffriendsBtnClick{
- YMFriendsViewModel *friendsVM = [[YMFriendsViewModel alloc]initWithParams:@{
- ParamsDefaultIndex:@(0)
- }];
- [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_FRIENDS) withUserInfo:@{
- RouterViewModel:friendsVM,
- } completion:nil];
- }
- #pragma mark-一键已读
- -(void)youpaifmoreBtnClick{
- NSArray *items = @[
- @{@"imageName":@"vqu_images_chat_read_chat",@"title":@"一键已读"},
- @{@"imageName":@"vqu_images_chat_remote_chat",@"title":@"清除消息"},
- ];
- @weakify(self);
- QQPopMenuView *menuView = [[QQPopMenuView alloc] initWithItems:items width:120.0f triangleLocation:CGPointMake(KScreenWidth - 40.0f, StatusBarHeight + 44.0f) action:^(NSInteger index) {
- @strongify(self);
- if (index == 0) {
- [self youpaifshowAlertWithTitle:@"一键已读" content:@"消息气泡会清除,但消息不会丢失" cancelBtn:@"取消" confimBtn:@"确定" confimBlock:^{
- //一键已读
- [[NIMSDK sharedSDK].conversationManager markAllMessagesRead];
- }];
- }else{
- [self youpaifshowAlertWithTitle:@"确定删除全部消息" content:@"删除后数据无法恢复,请谨慎操作" cancelBtn:@"再考虑下" confimBtn:@"确定删除" confimBlock:^{
- id<NIMConversationManager> manager = [[NIMSDK sharedSDK] conversationManager];
- NIMDeleteMessagesOption* deleteOption = [[NIMDeleteMessagesOption alloc]init];
- deleteOption.removeSession = YES;
- deleteOption.removeTable = YES;
- [manager deleteAllMessages:deleteOption];
- }];
- }
- }];
- [menuView show];
-
-
-
- }
- - (void)youpaifshowAlertWithTitle:(NSString *)title content:(NSString *)content cancelBtn:(NSString *)cancel confimBtn:(NSString *)confim confimBlock:(void (^)(void))block{
- LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:cancel handler:^(LZAlertAction *action) {
- }];
- cancelAction.cornerRadius = 24.0f;
- cancelAction.bgColor = LZF5F4F7Color;
- cancelAction.color = LZ273145Color;
- LZAlertAction *confimAction = [LZAlertAction actionWithTitle:confim handler:^(LZAlertAction *action) {
- if (block != nil) {
- block();
- }
- }];
- confimAction.cornerRadius = 24.0f;
- confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]];
- confimAction.color = [UIColor whiteColor];
- LZAlertWindow *alert = [LZAlertWindow alertWithTitle:title content:content action:@[cancelAction,confimAction]];
- alert.contentTextAlignment = NSTextAlignmentCenter;
- [self TFPresentVC:alert completion:^{}];
- }
- - (void)youpaifsystemClick{
- NIMSession *session = [NIMSession session:[LCSaveData getSysId] type:NIMSessionTypeP2P];
- if (session) {
- @weakify(self);
- [ZCHUDHelper show];
- [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
- @strongify(self);
- [ZCHUDHelper dismiss];
- YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session];
- [self.navigationController pushViewController:vc animated:YES];
- }];
- }
- }
- // 返回列表的数量
- - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
- return self.youpaiptitlesArr.count;
- }
- // 根据下标 index 返回对应遵守并实现 `JXCategoryListContentViewDelegate` 协议的列表实例
- - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
- // if (index == 0) {
- if (index == 0) {
- YOUPAILCMessageVC *vc = [[YOUPAILCMessageVC alloc] init];
- vc.isIntimateList = NO;
- return vc;
- }else {
- YMCallRecordViewModel *callRecordVM = [[YMCallRecordViewModel alloc]initWithParams:@{}];
- YMCallRecordViewController *vc = [[YMCallRecordViewController alloc]initWithViewModel:callRecordVM];
- return vc;
- // vc.isIntimateList = YES;
- // @weakify(self);
- // [vc setGoMessageListPageBlock:^{
- // @strongify(self);
- // [self.youpaipcategoryView selectItemAtIndex:0];
- // }];
- }
-
- }
- @end
|