YMPersonalPageViewModel.m 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. //
  2. // YMPersonalPageViewModel.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/17.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMPersonalPageViewModel.h"
  9. #import "YMPersonalInfoModel.h"
  10. #import "YMFeesSettingInfoModel.h"
  11. #import "YOUPAIBBVideoRequestVC.h"
  12. #import "YOUPAILCIMSessionVC.h"
  13. @interface YMPersonalPageViewModel ()
  14. /// 相册数据
  15. @property (nonatomic, strong, readwrite) NSArray <YMPersonalPageAlbumCellViewModel *>*albumDataArray;
  16. /// 展示语音
  17. @property (nonatomic, strong, readwrite) NSString *showcaseVoice;
  18. /// 展示语音秒数
  19. @property (nonatomic, assign, readwrite) NSInteger showcaseVoiceSeconds;
  20. /// 用户昵称
  21. @property (nonatomic, strong, readwrite) NSString *userNickname;
  22. /// 用户昵称颜色
  23. @property (nonatomic, strong, readwrite) UIColor *userNicknameColor;
  24. /// 用户在线状态颜色
  25. @property (nonatomic, strong, readwrite) UIColor *userOnlineStatusColor;
  26. /// 用户在线状态文本
  27. @property (nonatomic, strong, readwrite) NSString *userOnlineStatusText;
  28. @property (nonatomic, strong, readwrite) NSString *userOnlineImgStr;
  29. /// 用户性别和年龄图标
  30. @property (nonatomic, strong, readwrite) UIImage *userGenderAndAgeIcon;
  31. /// 用户性别和年龄文本
  32. @property (nonatomic, strong, readwrite) NSString *userGenderAndAgeText;
  33. /// 是否真人认证
  34. @property (nonatomic, assign, readwrite) BOOL isRealPersonCert;
  35. /// 是否VIP
  36. @property (nonatomic, assign, readwrite) BOOL isVIP;
  37. /// 余额
  38. @property (nonatomic, assign, readwrite) NSInteger balance;
  39. /// 用户费用金额
  40. @property (nonatomic, copy, readwrite) NSString * userVideoFeesAmount;
  41. /// 是否隐藏用户收费金额
  42. @property (nonatomic, assign, readwrite) BOOL isHideUserFeesAmount;
  43. /// 用户性别
  44. @property (nonatomic, strong, readwrite) NSString *userGender;
  45. /// 用户简介
  46. @property (nonatomic, strong, readwrite) NSString *userIntro;
  47. /// 是否关注
  48. @property (nonatomic, assign, readwrite) BOOL isFollow;
  49. /// 信息数据
  50. @property (nonatomic, strong, readwrite) NSArray <YMPersonalPageInfoCellViewModel *>*infoDataArray;
  51. /// 动态数量
  52. @property (nonatomic, strong, readwrite) NSString *dynamicNumber;
  53. /// 动态数据
  54. @property (nonatomic, strong, readwrite) NSArray <YMPersonalPageDynamicCellViewModel *>*dynamicDataArray;
  55. /// 标签数据
  56. @property (nonatomic, strong, readwrite) NSArray <YMPersonalPageTagCellViewModel *>*tagDataArray;
  57. /// 礼物墙数据
  58. @property (nonatomic, strong, readwrite) NSArray <YMPersonalPageGiftWallCellViewModel *>*giftWallDataArray;
  59. /// 是否隐藏动态
  60. @property (nonatomic, assign, readwrite) BOOL isHideDynamic;
  61. /// 是否隐藏标签
  62. @property (nonatomic, assign, readwrite) BOOL isHideTag;
  63. /// 是否隐藏礼物墙
  64. @property (nonatomic, assign, readwrite) BOOL isHideGiftWall;
  65. /// 是否他人主页
  66. @property (nonatomic, assign, readwrite) BOOL isOtherPersonalPage;
  67. /// 是否可私聊
  68. @property (nonatomic, assign, readwrite) BOOL isCanPrivateChat;
  69. @property (nonatomic, assign, readwrite) BOOL bottomHidden;
  70. /// 心动或搭讪按钮标题 “心动”字样是给女用户的 “搭讪”字样是给男用户
  71. @property (nonatomic, strong, readwrite) NSString *heartbeatOrAccostButtonTitle;
  72. /// 心动或搭讪按钮图片
  73. @property (nonatomic, strong, readwrite) NSString *heartbeatOrAccostButtonImage;
  74. /// 用户Id
  75. @property (nonatomic, assign) NSInteger userId;
  76. @end
  77. @implementation YMPersonalPageViewModel
  78. - (void)ym_initialize{
  79. [super ym_initialize];
  80. self.userId = [self.params integerValueForKey:ParamsId defaultValue:0];
  81. }
  82. - (void)getPersonalPageData{
  83. @weakify(self)
  84. [ZCHUDHelper showWithStatus:@"加载中..."];
  85. [LCHttpHelper requestWithURLString:PersonalPageInfo parameters:@{
  86. @"user_id":@(self.userId)
  87. } needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  88. @strongify(self)
  89. NSDictionary* dict = (NSDictionary*)responseObject;
  90. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  91. if (code == 0) {
  92. [ZCHUDHelper dismiss];
  93. YMPersonalInfoModel *model = [YMPersonalInfoModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]];
  94. self.albumDataArray = [model.albums.rac_sequence map:^(YMAlbumsModel * _Nullable model) {
  95. YMPersonalPageAlbumCellViewModel *viewModel = [[YMPersonalPageAlbumCellViewModel alloc]initWithParams:@{
  96. ParamsModel:model
  97. }];
  98. return viewModel;
  99. }].array;
  100. self.showcaseVoice = model.voice.voice;
  101. self.showcaseVoiceSeconds = model.voice.voice_time;
  102. self.userNickname = model.nickname;
  103. if (model.vip != 1) {
  104. self.userNicknameColor = HexColorFromRGB(0x333333);
  105. } else {
  106. self.userNicknameColor = HexColorFromRGB(0x954403);
  107. }
  108. self.balance = model.balance;
  109. self.isHideUserFeesAmount = model.gender == 1 ? NO : YES;
  110. if (!self.isHideUserFeesAmount) {
  111. [self getFeesSettingBaseInfoData];
  112. }
  113. self.userGender = model.gender == 1 ? @"女" : @"男";
  114. if (model.online.status == 0) {
  115. self.userOnlineStatusColor = kColors(@"#888888");
  116. self.userOnlineStatusText = @"离线";
  117. self.userOnlineImgStr = @"ym_personal_status_lx";
  118. } else if (model.online.status == 1) {
  119. self.userOnlineStatusColor = kColors(@"#6ED473");
  120. self.userOnlineStatusText = @"空闲";
  121. self.userOnlineImgStr = @"ym_personal_status_kx";
  122. } else if (model.online.status == 1){
  123. self.userOnlineStatusColor = kColors(@"#FF5473");
  124. self.userOnlineStatusText = @"在聊";
  125. self.userOnlineImgStr = @"ym_personal_status_zl";
  126. }else{
  127. self.userOnlineStatusColor = kColors(@"#FF5473");
  128. self.userOnlineStatusText = @"勿扰";
  129. self.userOnlineImgStr = @"ym_personal_status_wr";
  130. }
  131. self.userGenderAndAgeIcon = model.gender == 1 ? ImageByName(@"ym_personal_page_female_icon") : ImageByName(@"ym_personal_page_male_icon");
  132. self.userGenderAndAgeText = stringFormat(@"%ld",model.age);
  133. self.isRealPersonCert = model.is_anchor == 1 ? YES : NO;
  134. self.isVIP = model.vip == 0 ? NO : YES;
  135. self.userIntro = model.sign;
  136. self.isFollow = model.is_follow;
  137. self.infoDataArray = [model.basic_info.rac_sequence map:^(YMBasicInfoModel * _Nullable model) {
  138. YMPersonalPageInfoCellViewModel *viewModel = [[YMPersonalPageInfoCellViewModel alloc]initWithParams:@{
  139. ParamsModel:model
  140. }];
  141. if ([model.key isEqualToString:@"usercode"]) {
  142. viewModel.isHideCopy = NO;
  143. } else {
  144. viewModel.isHideCopy = YES;
  145. }
  146. return viewModel;
  147. }].array;
  148. self.dynamicNumber = stringFormat(@"(%ld)",model.dynamic_num);
  149. self.dynamicDataArray = [model.dynamic.rac_sequence map:^id _Nullable(YMDynamicModel * _Nullable model) {
  150. YMPersonalPageDynamicCellViewModel *viewModel = [[YMPersonalPageDynamicCellViewModel alloc]initWithParams:@{
  151. ParamsModel:model
  152. }];
  153. return viewModel;
  154. }].array;
  155. self.tagDataArray = [model.label.rac_sequence map:^(YMTagModel * _Nullable model) {
  156. YMPersonalPageTagCellViewModel *viewModel = [[YMPersonalPageTagCellViewModel alloc]initWithParams:@{
  157. ParamsModel:model
  158. }];
  159. return viewModel;
  160. }].array;
  161. self.giftWallDataArray = [model.gifts.rac_sequence map:^id _Nullable(YMGiftModel * _Nullable model) {
  162. YMPersonalPageGiftWallCellViewModel *viewModel = [[YMPersonalPageGiftWallCellViewModel alloc]initWithParams:@{
  163. ParamsModel:model
  164. }];
  165. return viewModel;
  166. }].array;
  167. self.isHideDynamic = self.dynamicDataArray.count <= 0 ? YES : NO;
  168. self.isHideTag = self.tagDataArray.count <= 0 ? YES : NO;
  169. self.isHideGiftWall = self.giftWallDataArray.count <= 0 ? YES : NO;
  170. self.bottomHidden = YES;
  171. self.isOtherPersonalPage = [self currentUserId] == model.userid ? NO : YES;
  172. /// 是否为其他人主页是则走后台返回值控制私聊按钮显示
  173. /// 是自己的主页直接设置为YES,这样可以直接隐藏掉按钮
  174. if (self.isOtherPersonalPage) {
  175. self.isCanPrivateChat = model.is_beckon;
  176. } else {
  177. self.isCanPrivateChat = YES;
  178. }
  179. if (self.isCanPrivateChat) {
  180. self.heartbeatOrAccostButtonTitle = @"私聊";
  181. self.heartbeatOrAccostButtonImage = @"ym_personal_page_msg";
  182. } else {
  183. self.heartbeatOrAccostButtonTitle = [self isFemaleGender] ? @"心动" : @"搭讪";
  184. self.heartbeatOrAccostButtonImage = @"ym_personal_page_like";
  185. }
  186. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  187. }else{
  188. [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
  189. }
  190. } failure:^(NSError *error) {
  191. [ZCHUDHelper showTitle:error.localizedDescription];
  192. }];
  193. }
  194. /// 打开更多弹窗
  195. - (void)openMoreAlert{
  196. if ([self currentUserId] == self.userId) {
  197. YMSheetPopupView *customView = [[YMSheetPopupView alloc]init];
  198. [customView configutationWithItemList:@[@"编辑"]];
  199. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
  200. popupView.priority = 999;
  201. popupView.cornerRadius = adapt(10);
  202. popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
  203. popupView.positionStyle = YMPositionStyleBottom;
  204. popupView.isClickBgDismiss = YES;
  205. popupView.isHideBg = NO;
  206. popupView.bgAlpha = 0.5;
  207. @weakify(popupView)
  208. customView.selectIndexBlock = ^(NSInteger index) {
  209. @strongify(popupView)
  210. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  211. YMEditProfileViewModel *editProfileVM = [[YMEditProfileViewModel alloc]initWithParams:@{
  212. ParamsId:@(self.userId)
  213. }];
  214. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_EDIT_PROFILE) withUserInfo:@{
  215. RouterViewModel:editProfileVM
  216. } completion:nil];
  217. };
  218. customView.closeBlock = ^{
  219. @strongify(popupView)
  220. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  221. };
  222. [popupView pop];
  223. }else{
  224. YMSheetPopupView *customView = [[YMSheetPopupView alloc]init];
  225. [customView configutationWithItemList:@[@"修改备注名",@"举报",@"拉黑"]];
  226. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
  227. popupView.priority = 999;
  228. popupView.cornerRadius = adapt(10);
  229. popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
  230. popupView.positionStyle = YMPositionStyleBottom;
  231. popupView.isClickBgDismiss = YES;
  232. popupView.isHideBg = NO;
  233. popupView.bgAlpha = 0.5;
  234. @weakify(popupView)
  235. customView.selectIndexBlock = ^(NSInteger index) {
  236. @strongify(popupView)
  237. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  238. switch (index) {
  239. case 0:
  240. {
  241. if (!self.isFollow) {
  242. [ZCHUDHelper showTitle:@"未关注对方不能设置备注名"];
  243. return;
  244. }
  245. YMInputPopupView *customView = [[YMInputPopupView alloc]init];
  246. customView.titleText = @"备注";
  247. customView.textAlignment = NSTextAlignmentCenter;
  248. [customView configutationWithContentText:@"" ofInputHeight:adapt(30) IsHideTitle:NO IsHideSingleButton:YES];
  249. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleFade dismissStyle:YMDismissStyleFade];
  250. popupView.priority = 999;
  251. popupView.cornerRadius = adapt(10);
  252. popupView.rectCorners = UIRectCornerAllCorners;
  253. popupView.positionStyle = YMPositionStyleCenter;
  254. popupView.isHideBg = NO;
  255. popupView.bgAlpha = 0.3;
  256. @weakify(popupView)
  257. customView.buttonBlock = ^(BOOL isConfirm, NSString * _Nonnull contentText) {
  258. @strongify(popupView)
  259. if (isConfirm) {
  260. if (contentText.length > 15) {
  261. [ZCHUDHelper showTitle:@"备注长度最多为10个字符"];
  262. return;
  263. }else{
  264. [LCHttpHelper requestWithURLString:UpdateRemark parameters:@{
  265. @"user_id":@(self.userId),
  266. @"remark":contentText
  267. } needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  268. NSDictionary* dict = (NSDictionary*)responseObject;
  269. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  270. if (code == 0) {//成功
  271. [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
  272. }
  273. } failure:^(NSError *error) {
  274. }];
  275. }
  276. }
  277. [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
  278. };
  279. [popupView pop];
  280. }
  281. break;
  282. case 1:
  283. {
  284. YMReportViewModel *reportVM = [[YMReportViewModel alloc]initWithParams:@{
  285. ParamsCategoryType:@(YMReportTypePersonalPage),
  286. ParamsId:@(self.userId)
  287. }];
  288. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_REPORT) withUserInfo:@{
  289. RouterViewModel:reportVM
  290. } completion:nil];
  291. }
  292. break;
  293. case 2:
  294. {
  295. YMTipsPopupView *customView = [[YMTipsPopupView alloc]init];
  296. [customView configutationWithTips:@"拉黑后,你将不再收到对方的消息,并且你们互相看不到对方的动态更新。可以在“设置-黑名单”中解除。" TipsAlignment:NSTextAlignmentLeft IsHideTitle:NO IsHideSingleButton:YES];
  297. YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleFade dismissStyle:YMDismissStyleFade];
  298. popupView.priority = 999;
  299. popupView.cornerRadius = adapt(10);
  300. popupView.rectCorners = UIRectCornerAllCorners;
  301. popupView.positionStyle = YMPositionStyleCenter;
  302. popupView.isHideBg = NO;
  303. popupView.bgAlpha = 0.3;
  304. @weakify(popupView)
  305. customView.buttonBlock = ^(BOOL isConfirm) {
  306. @strongify(popupView)
  307. if (isConfirm) {
  308. [LCCommonHttp blackUserId:stringFormat(@"%ld",self.userId)];
  309. }
  310. [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
  311. };
  312. [popupView pop];
  313. }
  314. break;
  315. default:
  316. break;
  317. }
  318. };
  319. customView.closeBlock = ^{
  320. @strongify(popupView)
  321. [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
  322. };
  323. [popupView pop];
  324. }
  325. }
  326. - (void)followUser{
  327. [LCHttpHelper requestWithURLString:UserFollow parameters:@{
  328. @"follow_uid":@(self.userId),
  329. } needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  330. NSDictionary* dict = (NSDictionary*)responseObject;
  331. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  332. if (code == 0) {
  333. NSDictionary *data = [dict dictionaryValueForKey:@"data" defaultValue:@{}];
  334. NSString *action = [data stringValueForKey:@"action" defaultValue:@""];
  335. if ([action isEqualToString:@"add"]) {
  336. [ZCHUDHelper showTitle:@"已关注"];
  337. self.isFollow = YES;
  338. }else if ([action isEqualToString:@"delete"]){
  339. [ZCHUDHelper showTitle:@"已取消关注"];
  340. self.isFollow = NO;
  341. }
  342. }else{
  343. [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
  344. }
  345. } failure:^(NSError *error) {
  346. [ZCHUDHelper showTitle:error.localizedDescription];
  347. }];
  348. }
  349. - (void)getFeesSettingBaseInfoData{
  350. @weakify(self)
  351. [LCHttpHelper requestWithURLString:AnchorGetPrice parameters:@{
  352. @"anchor_id":@(self.userId),
  353. @"is_new":@(1)
  354. } needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  355. @strongify(self)
  356. NSDictionary* dict = (NSDictionary*)responseObject;
  357. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  358. if (code == 0) {
  359. [ZCHUDHelper dismiss];
  360. YMFeesSettingInfoModel *mdoel = [YMFeesSettingInfoModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]];
  361. self.userVideoFeesAmount = mdoel.video_price;
  362. }else{
  363. [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
  364. }
  365. } failure:^(NSError *error) {
  366. [ZCHUDHelper showTitle:error.localizedDescription];
  367. }];
  368. }
  369. - (void)gotoPersonalDynamic{
  370. YMPersonalDynamicViewModel *personalDynamicVM = [[YMPersonalDynamicViewModel alloc]initWithParams:@{
  371. ParamsId:@(self.userId)
  372. }];
  373. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_PERSONAL_DYNAMIC) withUserInfo:@{
  374. RouterViewModel:personalDynamicVM
  375. } completion:nil];
  376. }
  377. - (void)gotoEditProfile{
  378. YMEditProfileViewModel *editProfileVM = [[YMEditProfileViewModel alloc]initWithParams:@{
  379. ParamsId:@(self.userId)
  380. }];
  381. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_EDIT_PROFILE) withUserInfo:@{
  382. RouterViewModel:editProfileVM
  383. } completion:nil];
  384. }
  385. - (void)sendAccostRequest{
  386. if ([self isNeedGoddessCertified]) {
  387. return;
  388. }
  389. if(self.isCanPrivateChat){
  390. [self gotoPrivateChat];
  391. }else{
  392. @weakify(self)
  393. [LCHttpHelper requestWithURLString:HomeBeckonSend parameters:@{
  394. @"user_ids":stringFormat(@"[%ld]",self.userId)
  395. } needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  396. @strongify(self)
  397. NSDictionary* dict = (NSDictionary*)responseObject;
  398. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  399. if (code == 0) {
  400. NSDictionary *data = [dict dictionaryValueForKey:@"data" defaultValue:@{}];
  401. BOOL boole = [data boolValueForKey:@"boole" defaultValue:NO];
  402. if (boole) {
  403. self.isCanPrivateChat = YES;
  404. self.heartbeatOrAccostButtonTitle = @"私聊";
  405. self.heartbeatOrAccostButtonImage = @"ym_personal_page_msg";
  406. }
  407. }else{
  408. [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
  409. }
  410. } failure:^(NSError *error) {
  411. [ZCHUDHelper showTitle:error.localizedDescription];
  412. }];
  413. }
  414. }
  415. - (void)callVideo{
  416. // if (self.youpaipshowModel.youpaipskill_list.count == 0) {
  417. // [ZCHUDHelper showTitle:@"暂时无法视频通话"];
  418. // return;
  419. // }
  420. if ([YOUPAILZChatRoomManager shareManager].chatroomWindow != nil && [YOUPAILZChatRoomManager shareManager].chatroomWindow.hidden == NO) {
  421. [ZCHUDHelper showTitle:@"你正在房间中,暂不可拨打视频"];
  422. return;
  423. }
  424. [UMengRecordTool umengEventCountWithId:StartVideoPersonal];
  425. [UCAuthorityManager cameraAuthority:^{
  426. if ([LCSaveData getWhiteVersion]) {//1
  427. [LCHttpHelper requestWithURLString:UserShowPage parameters:@{
  428. @"user_id":@(self.userId)
  429. } needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  430. NSDictionary* dict = (NSDictionary*)responseObject;
  431. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  432. if (code==0) {//成功
  433. NSDictionary *data = [dict objectForKey:@"data"];
  434. YOUPAILCUserShowInfo *info = [YOUPAILCUserShowInfo mj_objectWithKeyValues:[data objectForKey:@"info"]];
  435. YOUPAIBBVideoRequestVC* chatRequest = [[YOUPAIBBVideoRequestVC alloc]init];
  436. YOUPAILCVideoChatModel *videoModel = [[YOUPAILCVideoChatModel alloc] init];
  437. videoModel.youpaiproom_id = [NSString stringWithFormat:@"C%@",[LCTools randomNumberWithLength:6]];
  438. videoModel.youpaipauditState = 1;
  439. videoModel.youpaipfrom_uid = [LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id;
  440. videoModel.youpaipfrom_nickname = [LCSaveModel getUserModel].youpaipuserinfo.youpaipnickname;
  441. videoModel.youpaipfrom_avatar = [LCSaveModel getUserModel].youpaipuserinfo.youpaipavatar;
  442. videoModel.youpaipto_uid = stringFormat(@"%ld",self.userId);
  443. videoModel.youpaipto_nickname = info.youpaipnickname;
  444. videoModel.youpaipto_avatar = info.youpaipavatar;
  445. chatRequest.youpaipvideoModel = videoModel;
  446. ZCBaseNavigationVC *nav = [[ZCBaseNavigationVC alloc]initWithRootViewController:chatRequest];
  447. //modify by leo fix bug ios13
  448. nav.modalPresentationStyle =0;
  449. [[YMGlobalUtils getCurrentVC].navigationController presentViewController:nav animated:YES completion:^{
  450. }];
  451. }
  452. } failure:^(NSError *error) {
  453. }];
  454. }else{//0
  455. [LCHttpHelper requestWithURLString:CallChatType parameters:@{
  456. @"to_uid":@(self.userId),
  457. @"type":@"0"
  458. } needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  459. NSDictionary* dict = (NSDictionary*)responseObject;
  460. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  461. if (code==0) {//成功
  462. YOUPAILCVideoChatModel* videoModel = [YOUPAILCVideoChatModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
  463. [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom];
  464. [[NSNotificationCenter defaultCenter] postNotificationName:@"MeCallVideo" object:nil userInfo:nil];
  465. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  466. YOUPAILCVideoRequestVC* chatRequest = [[YOUPAILCVideoRequestVC alloc]init];
  467. chatRequest.youpaipvideoModel = videoModel;
  468. //modify by leo fix bug ios13
  469. ZCBaseNavigationVC *nav = [[ZCBaseNavigationVC alloc]initWithRootViewController:chatRequest];
  470. chatRequest.definesPresentationContext = YES;
  471. nav.modalPresentationStyle = UIModalPresentationOverCurrentContext&UIModalPresentationOverFullScreen;
  472. chatRequest.view.backgroundColor=HexColorFromRGBA(0x000000, 0.55);
  473. [[YMGlobalUtils getCurrentVC].navigationController presentViewController:nav animated:YES completion:^{
  474. }];
  475. });
  476. }
  477. } failure:^(NSError *error) {
  478. }];
  479. }
  480. } denied:^{
  481. dispatch_async(dispatch_get_main_queue(), ^{
  482. UIAlertController *systemAlert = [UIAlertController alertControllerWithTitle:@"请在iphone的“设置-隐私-相机”选项中,允许APP访问您的相机。" message:nil preferredStyle:UIAlertControllerStyleAlert];
  483. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"现在去设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){
  484. if ([[UIDevice currentDevice].systemVersion floatValue] < 10.0)
  485. {
  486. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
  487. }
  488. else
  489. {
  490. // 去系统设置页面
  491. if (@available(iOS 10.0, *)) {
  492. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
  493. } else {
  494. // Fallback on earlier versions
  495. }
  496. }
  497. }];
  498. UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
  499. [systemAlert addAction:cancelAction];
  500. [systemAlert addAction:action];
  501. [[YMGlobalUtils getCurrentVC] presentViewController: systemAlert animated: YES completion: nil];
  502. });
  503. }];
  504. }
  505. - (void)gotoPrivateChat{
  506. NIMSession *session = [NIMSession session:stringFormat(@"%ld",self.userId) type:NIMSessionTypeP2P];
  507. if (session) {
  508. [ZCHUDHelper show];
  509. [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
  510. [ZCHUDHelper dismiss];
  511. YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session];
  512. vc.type = @"1";
  513. [[YMGlobalUtils getCurrentVC].navigationController pushViewController:vc animated:YES];
  514. }];
  515. }
  516. }
  517. @end