YOUPAILCMsgVC.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. //
  2. // YOUPAILCMsgVC.m
  3. // zhimi
  4. //
  5. // Created by Apple on 2019/10/31.
  6. // Copyright © 2019 caiPro. All rights reserved.
  7. //
  8. #import "YOUPAILCMsgVC.h"
  9. #import "ZCNavMenuView.h"
  10. #import "YOUPAILCMessageVC.h"
  11. //#import "YOUPAILCMediaChatRecordVC.h"
  12. #import "JXCategoryView.h"
  13. #import "JXPagerView.h"
  14. #import "LZAlertWindow.h"
  15. #import "UIViewController+TFPresent.h"
  16. #import "QQPopMenuView.h"
  17. #import "YOUPAILZMessageGuideVC.h"
  18. #import "YOUPAILZSessionListGuideView.h"
  19. #import "YMCallRecordViewModel.h"
  20. #import "YMCallRecordViewController.h"
  21. #define LZCategoryViewHeight 54.0f
  22. @interface YOUPAILCMsgVC ()<JXCategoryViewDelegate,JXPagerViewDelegate,JXCategoryListContainerViewDelegate>
  23. //@property(nonatomic,strong)ZCNavMenuView* youpaipnavView;
  24. //@property(nonatomic,strong)UIScrollView* youpaipscrollView;
  25. //@property(nonatomic,strong)UIView* youpaipscrollBkgView;
  26. //@property(nonatomic,strong)YOUPAILCMessageVC *youpaipmsgVC;
  27. //@property(nonatomic,strong)YOUPAILCMediaChatRecordVC *youpaipphoneMsgVC;
  28. @property (nonatomic, weak) JXCategoryListContainerView *youpaippagerView;
  29. @property (nonatomic, strong) JXCategoryTitleView *youpaipcategoryView;
  30. @property (nonatomic, strong) UIView *youpaipcategoryBgV;
  31. /* titlearr */
  32. @property (strong, nonatomic) NSArray *youpaiptitlesArr;
  33. @property (strong, nonatomic) UIButton *youpaipfriendsBtn;
  34. @property (strong, nonatomic) UIButton *youpaipmoreBtn;
  35. //@property (nonatomic,weak) UIButton *youpaipapplyAnchorBtn;
  36. @property (nonatomic,weak) YOUPAILZSessionListGuideView *guideView;
  37. @end
  38. @implementation YOUPAILCMsgVC
  39. - (void)dealloc{
  40. [[NSNotificationCenter defaultCenter] removeObserver:self];
  41. }
  42. -(void)viewWillAppear:(BOOL)animated{
  43. [super viewWillAppear:animated];
  44. [self.navigationController setNavigationBarHidden:YES animated:animated];
  45. [self youpaifinitConfig];
  46. //
  47. // self.youpaipapplyAnchorBtn.hidden = !([LCSaveModel getUserModel].youpaipuserinfo.youpaipgender == 1 && [LCSaveModel getUserModel].youpaipuserinfo.youpaipis_auth != 1);
  48. }
  49. -(void)viewWillDisappear:(BOOL)animated{
  50. [super viewWillDisappear:animated];
  51. [self.navigationController setNavigationBarHidden:NO animated:animated];
  52. }
  53. /// 引导页
  54. - (void)youpaipshowGuide{
  55. // YOUPAILZGuideVC *vc = [[YOUPAILZGuideVC alloc] init];
  56. // vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
  57. // [self presentViewController:vc animated:NO completion:nil];
  58. YOUPAILZSessionListGuideView *guideView = [[YOUPAILZSessionListGuideView alloc] initWithFrame:[UIScreen mainScreen].bounds];
  59. guideView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
  60. [guideView addTarget:self action:@selector(guideViewClick:) forControlEvents:UIControlEventTouchUpInside];
  61. [self.tabBarController.view addSubview:guideView];
  62. self.guideView = guideView;
  63. }
  64. - (void)guideViewClick:(YOUPAILZSessionListGuideView *)sender{
  65. YOUPAILZMessageGuideVC *vc = [[YOUPAILZMessageGuideVC alloc] init];
  66. [self.navigationController pushViewController:vc animated:YES];
  67. [UIView animateWithDuration:0.25f animations:^{
  68. [self.guideView removeFromSuperview];
  69. }];
  70. }
  71. //- (UIStatusBarStyle)preferredStatusBarStyle{
  72. // return UIStatusBarStyleLightContent;
  73. //}
  74. - (void)viewDidLoad {
  75. [super viewDidLoad];
  76. [self.view setBackgroundColor:UIColor.whiteColor];
  77. //UIImageView *topBgImgv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ym_messages_top_bg"]];
  78. //topBgImgv.frame = CGRectMake(0, 0, kScreenWidth, adapt(97));
  79. //[self.view addSubview:topBgImgv];
  80. self.youpaiptitlesArr = @[@"消息",@"通话"];
  81. UIView *categoryBgV = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, KScreenWidth, LZCategoryViewHeight + StatusBarHeight)];
  82. categoryBgV.backgroundColor = [UIColor clearColor];
  83. [self.view addSubview:categoryBgV];
  84. self.youpaipcategoryBgV = categoryBgV;
  85. JXCategoryTitleView *categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0.0f, StatusBarHeight, KScreenWidth - 16 * 2.0f - 24, LZCategoryViewHeight)];
  86. categoryView.contentScrollView.backgroundColor = [UIColor clearColor];
  87. categoryView.titles = self.youpaiptitlesArr;
  88. categoryView.delegate = self;
  89. categoryView.titleSelectedColor = DecColorFromRGBA(0, 0, 0, 1);
  90. categoryView.titleColor = DecColorFromRGBA(0, 0, 0, 0.5);
  91. categoryView.titleColorGradientEnabled = YES;
  92. categoryView.titleFont = LCFont(17.0f);
  93. categoryView.titleSelectedFont = LCBoldFont(22.0f);
  94. categoryView.cellWidth = adapt(53);
  95. categoryView.cellSpacing = 0;
  96. categoryView.contentEdgeInsetLeft = 15;
  97. categoryView.averageCellSpacingEnabled = NO;
  98. [categoryBgV addSubview:categoryView];
  99. self.youpaipcategoryView = categoryView;
  100. JXCategoryIndicatorImageView *indicatorImageView = [[JXCategoryIndicatorImageView alloc] init];
  101. //indicatorImageView.indicatorImageView.image = [UIImage imageNamed:@"home_indicator_img"];
  102. indicatorImageView.indicatorImageViewSize = CGSizeMake(adapt(68), LZCategoryViewHeight + adapt(5));
  103. //indicatorImageView.indicatorImageViewSize = CGSizeMake(adapt(40), adapt(26));
  104. UIImageView *indicatorImgv = [[UIImageView alloc] init];
  105. indicatorImgv.image = [UIImage imageNamed:@"home_indicator_img"];
  106. indicatorImgv.contentMode = UIViewContentModeScaleAspectFit;
  107. [indicatorImageView addSubview:indicatorImgv];
  108. [indicatorImgv mas_makeConstraints:^(MASConstraintMaker *make) {
  109. make.centerX.equalTo(indicatorImageView);
  110. make.bottom.equalTo(indicatorImageView).offset(-5);
  111. make.width.mas_equalTo(40);
  112. make.height.mas_equalTo(8);
  113. }];
  114. categoryView.indicators = @[indicatorImageView];
  115. UIButton *friendsBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth - 16 - 48 - 10 - 48,(LZCategoryViewHeight - 44) / 2.0f + StatusBarHeight,48,50)];
  116. [friendsBtn setImage:[UIImage imageNamed:@"ym_messages_friends_icon"] forState:(UIControlStateNormal)];
  117. self.youpaipfriendsBtn = friendsBtn;
  118. [friendsBtn addTarget:self action:@selector(youpaiffriendsBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
  119. [categoryBgV addSubview:friendsBtn];
  120. UIButton *moreBtn = [[UIButton alloc]initWithFrame:CGRectMake(KScreenWidth - 16 - 48,(LZCategoryViewHeight - 44) / 2.0f + StatusBarHeight,48,50)];
  121. [moreBtn setImage:[UIImage imageNamed:@"ym_messages_more_icon"] forState:(UIControlStateNormal)];
  122. self.youpaipmoreBtn = moreBtn;
  123. [moreBtn addTarget:self action:@selector(youpaifmoreBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
  124. [categoryBgV addSubview:moreBtn];
  125. JXCategoryListContainerView *pagerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_CollectionView delegate:self];
  126. pagerView.listCellBackgroundColor = [UIColor clearColor];
  127. pagerView.frame = CGRectMake(0.0f, categoryBgV.mj_h, KScreenWidth, KScreenHeight - categoryBgV.mj_h - TabbarHeight);
  128. pagerView.backgroundColor = [UIColor clearColor];
  129. pagerView.scrollView.backgroundColor = [UIColor clearColor];
  130. [self.view addSubview:pagerView];
  131. self.youpaippagerView = pagerView;
  132. self.youpaipcategoryView.listContainer = self.youpaippagerView;
  133. // UIButton *youpaipapplyAnchorBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  134. // [youpaipapplyAnchorBtn setBackgroundImage:[UIImage imageNamed:@"vqu_images_im_apply_anchor"] forState:UIControlStateNormal];
  135. // [youpaipapplyAnchorBtn addTarget:self action:@selector(youpaipapplyAnchorBtnClick) forControlEvents:UIControlEventTouchUpInside];
  136. // [self.view addSubview:youpaipapplyAnchorBtn];
  137. // self.youpaipapplyAnchorBtn = youpaipapplyAnchorBtn;
  138. // [youpaipapplyAnchorBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  139. // make.right.offset(0.0f);
  140. // make.bottom.offset(-38.0f-TabbarHeight);
  141. // make.size.mas_offset(CGSizeMake(142.0f, 44.0f));
  142. // }];
  143. //
  144. if (![LCSaveData getHiddenGuideState] && ([LCSaveModel getUserModel].youpaipuserinfo.youpaipgender == 1 && [LCSaveModel getUserModel].youpaipuserinfo.youpaipis_anchor != 1) && ![LCSaveData getWhiteVersion]) {
  145. [self youpaipshowGuide];
  146. }
  147. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(youpaifgoIntimacyList) name:@"GoIntimacyList" object:nil];
  148. }
  149. - (void)youpaifgoIntimacyList{
  150. [self.youpaipcategoryView selectItemAtIndex:1];
  151. }
  152. //- (void)youpaipapplyAnchorBtnClick{
  153. // if (![LCTools isGirlsRealNameAuthentication]) {
  154. // return;
  155. // };
  156. //}
  157. - (void)youpaifinitConfig{ //系统配置信息
  158. [LCHttpHelper requestWithURLString:AppConfig parameters:nil needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  159. NSDictionary* dict = (NSDictionary*)responseObject;
  160. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  161. if (code==0) {//成功
  162. NSString* sysId = [[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"sysId"];
  163. NSString* servId = [[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"servId"];
  164. NSString* appurl = [[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"appurl"];
  165. NSArray* serviceIdArr = [[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"serviceId"];
  166. // NSString *audit_status = [NSString stringWithFormat:@"%@",[[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"audit_status"]];
  167. NSString *rankH5Url = [[dict objectForKey:@"data"]objectForKey:@"rank_url"];
  168. NSInteger free = [[[[dict objectForKey:@"data"]objectForKey:@"config"] objectForKey:@"free"] integerValue];
  169. [LCSaveData saveAppUrl:appurl];
  170. [LCSaveData saveSysId:sysId];
  171. [LCSaveData saveServerId:servId];
  172. [LCSaveData saveServiceIdArr:serviceIdArr];
  173. [LCSaveData saveRankH5Url:rankH5Url];
  174. [LCSaveData saveIMPrice:free];
  175. }
  176. } failure:^(NSError *error) {
  177. }];
  178. }
  179. #pragma mark-好友
  180. - (void)youpaiffriendsBtnClick{
  181. YMFriendsViewModel *friendsVM = [[YMFriendsViewModel alloc]initWithParams:@{
  182. ParamsDefaultIndex:@(0)
  183. }];
  184. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_FRIENDS) withUserInfo:@{
  185. RouterViewModel:friendsVM,
  186. } completion:nil];
  187. }
  188. #pragma mark-一键已读
  189. -(void)youpaifmoreBtnClick{
  190. NSArray *items = @[
  191. @{@"imageName":@"vqu_images_chat_read_chat",@"title":@"一键已读"},
  192. @{@"imageName":@"vqu_images_chat_remote_chat",@"title":@"清除消息"},
  193. ];
  194. @weakify(self);
  195. QQPopMenuView *menuView = [[QQPopMenuView alloc] initWithItems:items width:120.0f triangleLocation:CGPointMake(KScreenWidth - 40.0f, StatusBarHeight + 44.0f) action:^(NSInteger index) {
  196. @strongify(self);
  197. if (index == 0) {
  198. [self youpaifshowAlertWithTitle:@"一键已读" content:@"消息气泡会清除,但消息不会丢失" cancelBtn:@"取消" confimBtn:@"确定" confimBlock:^{
  199. //一键已读
  200. [[NIMSDK sharedSDK].conversationManager markAllMessagesRead];
  201. }];
  202. }else{
  203. [self youpaifshowAlertWithTitle:@"确定删除全部消息" content:@"删除后数据无法恢复,请谨慎操作" cancelBtn:@"再考虑下" confimBtn:@"确定删除" confimBlock:^{
  204. id<NIMConversationManager> manager = [[NIMSDK sharedSDK] conversationManager];
  205. NIMDeleteMessagesOption* deleteOption = [[NIMDeleteMessagesOption alloc]init];
  206. deleteOption.removeSession = YES;
  207. deleteOption.removeTable = YES;
  208. [manager deleteAllMessages:deleteOption];
  209. }];
  210. }
  211. }];
  212. [menuView show];
  213. }
  214. - (void)youpaifshowAlertWithTitle:(NSString *)title content:(NSString *)content cancelBtn:(NSString *)cancel confimBtn:(NSString *)confim confimBlock:(void (^)(void))block{
  215. LZAlertAction *cancelAction = [LZAlertAction actionWithTitle:cancel handler:^(LZAlertAction *action) {
  216. }];
  217. cancelAction.cornerRadius = 24.0f;
  218. cancelAction.bgColor = LZF5F4F7Color;
  219. cancelAction.color = LZ273145Color;
  220. LZAlertAction *confimAction = [LZAlertAction actionWithTitle:confim handler:^(LZAlertAction *action) {
  221. if (block != nil) {
  222. block();
  223. }
  224. }];
  225. confimAction.cornerRadius = 24.0f;
  226. confimAction.bgColor = [UIColor colorWithPatternImage:[LCTools ColorImage:CGSizeMake((KScreenWidth - 105.0f) / 2.0f, 48.0f) FromColors:@[LZBFB6FFColor,LZ7C69FEColor] ByGradientType:GradientLeftToRight]];
  227. confimAction.color = [UIColor whiteColor];
  228. LZAlertWindow *alert = [LZAlertWindow alertWithTitle:title content:content action:@[cancelAction,confimAction]];
  229. alert.contentTextAlignment = NSTextAlignmentCenter;
  230. [self TFPresentVC:alert completion:^{}];
  231. }
  232. - (void)youpaifsystemClick{
  233. NIMSession *session = [NIMSession session:[LCSaveData getSysId] type:NIMSessionTypeP2P];
  234. if (session) {
  235. @weakify(self);
  236. [ZCHUDHelper show];
  237. [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
  238. @strongify(self);
  239. [ZCHUDHelper dismiss];
  240. YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session];
  241. [self.navigationController pushViewController:vc animated:YES];
  242. }];
  243. }
  244. }
  245. // 返回列表的数量
  246. - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
  247. return self.youpaiptitlesArr.count;
  248. }
  249. // 根据下标 index 返回对应遵守并实现 `JXCategoryListContentViewDelegate` 协议的列表实例
  250. - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
  251. // if (index == 0) {
  252. if (index == 0) {
  253. YOUPAILCMessageVC *vc = [[YOUPAILCMessageVC alloc] init];
  254. vc.isIntimateList = NO;
  255. return vc;
  256. }else {
  257. YMCallRecordViewModel *callRecordVM = [[YMCallRecordViewModel alloc]initWithParams:@{}];
  258. YMCallRecordViewController *vc = [[YMCallRecordViewController alloc]initWithViewModel:callRecordVM];
  259. return vc;
  260. // vc.isIntimateList = YES;
  261. // @weakify(self);
  262. // [vc setGoMessageListPageBlock:^{
  263. // @strongify(self);
  264. // [self.youpaipcategoryView selectItemAtIndex:0];
  265. // }];
  266. }
  267. }
  268. @end