123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587 |
- //
- // YMPersonalPageViewModel.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/17.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMPersonalPageViewModel.h"
- #import "YMPersonalInfoModel.h"
- #import "YMFeesSettingInfoModel.h"
- #import "YOUPAIBBVideoRequestVC.h"
- #import "YOUPAILCIMSessionVC.h"
- @interface YMPersonalPageViewModel ()
- /// 相册数据
- @property (nonatomic, strong, readwrite) NSArray <YMPersonalPageAlbumCellViewModel *>*albumDataArray;
- /// 展示语音
- @property (nonatomic, strong, readwrite) NSString *showcaseVoice;
- /// 展示语音秒数
- @property (nonatomic, assign, readwrite) NSInteger showcaseVoiceSeconds;
- /// 用户昵称
- @property (nonatomic, strong, readwrite) NSString *userNickname;
- /// 用户昵称颜色
- @property (nonatomic, strong, readwrite) UIColor *userNicknameColor;
- /// 用户在线状态颜色
- @property (nonatomic, strong, readwrite) UIColor *userOnlineStatusColor;
- /// 用户在线状态文本
- @property (nonatomic, strong, readwrite) NSString *userOnlineStatusText;
- @property (nonatomic, strong, readwrite) NSString *userOnlineImgStr;
- /// 用户性别和年龄图标
- @property (nonatomic, strong, readwrite) UIImage *userGenderAndAgeIcon;
- /// 用户性别和年龄文本
- @property (nonatomic, strong, readwrite) NSString *userGenderAndAgeText;
- /// 是否真人认证
- @property (nonatomic, assign, readwrite) BOOL isRealPersonCert;
- /// 是否VIP
- @property (nonatomic, assign, readwrite) BOOL isVIP;
- /// 余额
- @property (nonatomic, assign, readwrite) NSInteger balance;
- /// 用户费用金额
- @property (nonatomic, copy, readwrite) NSString * userVideoFeesAmount;
- /// 是否隐藏用户收费金额
- @property (nonatomic, assign, readwrite) BOOL isHideUserFeesAmount;
- /// 用户性别
- @property (nonatomic, strong, readwrite) NSString *userGender;
- /// 用户简介
- @property (nonatomic, strong, readwrite) NSString *userIntro;
- /// 是否关注
- @property (nonatomic, assign, readwrite) BOOL isFollow;
- /// 信息数据
- @property (nonatomic, strong, readwrite) NSArray <YMPersonalPageInfoCellViewModel *>*infoDataArray;
- /// 动态数量
- @property (nonatomic, strong, readwrite) NSString *dynamicNumber;
- /// 动态数据
- @property (nonatomic, strong, readwrite) NSArray <YMPersonalPageDynamicCellViewModel *>*dynamicDataArray;
- /// 标签数据
- @property (nonatomic, strong, readwrite) NSArray <YMPersonalPageTagCellViewModel *>*tagDataArray;
- /// 礼物墙数据
- @property (nonatomic, strong, readwrite) NSArray <YMPersonalPageGiftWallCellViewModel *>*giftWallDataArray;
- /// 是否隐藏动态
- @property (nonatomic, assign, readwrite) BOOL isHideDynamic;
- /// 是否隐藏标签
- @property (nonatomic, assign, readwrite) BOOL isHideTag;
- /// 是否隐藏礼物墙
- @property (nonatomic, assign, readwrite) BOOL isHideGiftWall;
- /// 是否他人主页
- @property (nonatomic, assign, readwrite) BOOL isOtherPersonalPage;
- /// 是否可私聊
- @property (nonatomic, assign, readwrite) BOOL isCanPrivateChat;
- @property (nonatomic, assign, readwrite) BOOL bottomHidden;
- /// 心动或搭讪按钮标题 “心动”字样是给女用户的 “搭讪”字样是给男用户
- @property (nonatomic, strong, readwrite) NSString *heartbeatOrAccostButtonTitle;
- /// 心动或搭讪按钮图片
- @property (nonatomic, strong, readwrite) NSString *heartbeatOrAccostButtonImage;
- /// 用户Id
- @property (nonatomic, assign) NSInteger userId;
- @end
- @implementation YMPersonalPageViewModel
- - (void)ym_initialize{
- [super ym_initialize];
- self.userId = [self.params integerValueForKey:ParamsId defaultValue:0];
- }
- - (void)getPersonalPageData{
-
- @weakify(self)
- [ZCHUDHelper showWithStatus:@"加载中..."];
- [LCHttpHelper requestWithURLString:PersonalPageInfo parameters:@{
- @"user_id":@(self.userId)
- } needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- @strongify(self)
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- [ZCHUDHelper dismiss];
- YMPersonalInfoModel *model = [YMPersonalInfoModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]];
-
- self.albumDataArray = [model.albums.rac_sequence map:^(YMAlbumsModel * _Nullable model) {
- YMPersonalPageAlbumCellViewModel *viewModel = [[YMPersonalPageAlbumCellViewModel alloc]initWithParams:@{
- ParamsModel:model
- }];
- return viewModel;
- }].array;
-
- self.showcaseVoice = model.voice.voice;
- self.showcaseVoiceSeconds = model.voice.voice_time;
-
- self.userNickname = model.nickname;
- if (model.vip != 1) {
- self.userNicknameColor = HexColorFromRGB(0x333333);
- } else {
- self.userNicknameColor = HexColorFromRGB(0x954403);
- }
-
- self.balance = model.balance;
- self.isHideUserFeesAmount = model.gender == 1 ? NO : YES;
-
- if (!self.isHideUserFeesAmount) {
- [self getFeesSettingBaseInfoData];
- }
- self.userGender = model.gender == 1 ? @"女" : @"男";
-
- if (model.online.status == 0) {
- self.userOnlineStatusColor = kColors(@"#888888");
- self.userOnlineStatusText = @"离线";
- self.userOnlineImgStr = @"ym_personal_status_lx";
- } else if (model.online.status == 1) {
- self.userOnlineStatusColor = kColors(@"#6ED473");
- self.userOnlineStatusText = @"空闲";
- self.userOnlineImgStr = @"ym_personal_status_kx";
- } else if (model.online.status == 1){
- self.userOnlineStatusColor = kColors(@"#FF5473");
- self.userOnlineStatusText = @"在聊";
- self.userOnlineImgStr = @"ym_personal_status_zl";
- }else{
- self.userOnlineStatusColor = kColors(@"#FF5473");
- self.userOnlineStatusText = @"勿扰";
- self.userOnlineImgStr = @"ym_personal_status_wr";
- }
-
-
- self.userGenderAndAgeIcon = model.gender == 1 ? ImageByName(@"ym_personal_page_female_icon") : ImageByName(@"ym_personal_page_male_icon");
- self.userGenderAndAgeText = stringFormat(@"%ld",model.age);
-
- self.isRealPersonCert = model.is_anchor == 1 ? YES : NO;
-
- self.isVIP = model.vip == 0 ? NO : YES;
-
- self.userIntro = model.sign;
-
- self.isFollow = model.is_follow;
-
- self.infoDataArray = [model.basic_info.rac_sequence map:^(YMBasicInfoModel * _Nullable model) {
- YMPersonalPageInfoCellViewModel *viewModel = [[YMPersonalPageInfoCellViewModel alloc]initWithParams:@{
- ParamsModel:model
- }];
- if ([model.key isEqualToString:@"usercode"]) {
- viewModel.isHideCopy = NO;
- } else {
- viewModel.isHideCopy = YES;
- }
- return viewModel;
- }].array;
-
- self.dynamicNumber = stringFormat(@"(%ld)",model.dynamic_num);
-
- self.dynamicDataArray = [model.dynamic.rac_sequence map:^id _Nullable(YMDynamicModel * _Nullable model) {
- YMPersonalPageDynamicCellViewModel *viewModel = [[YMPersonalPageDynamicCellViewModel alloc]initWithParams:@{
- ParamsModel:model
- }];
- return viewModel;
- }].array;
-
- self.tagDataArray = [model.label.rac_sequence map:^(YMTagModel * _Nullable model) {
- YMPersonalPageTagCellViewModel *viewModel = [[YMPersonalPageTagCellViewModel alloc]initWithParams:@{
- ParamsModel:model
- }];
- return viewModel;
- }].array;
-
- self.giftWallDataArray = [model.gifts.rac_sequence map:^id _Nullable(YMGiftModel * _Nullable model) {
- YMPersonalPageGiftWallCellViewModel *viewModel = [[YMPersonalPageGiftWallCellViewModel alloc]initWithParams:@{
- ParamsModel:model
- }];
- return viewModel;
- }].array;
-
- self.isHideDynamic = self.dynamicDataArray.count <= 0 ? YES : NO;
-
- self.isHideTag = self.tagDataArray.count <= 0 ? YES : NO;
-
- self.isHideGiftWall = self.giftWallDataArray.count <= 0 ? YES : NO;
-
- self.bottomHidden = YES;
- self.isOtherPersonalPage = [self currentUserId] == model.userid ? NO : YES;
-
- /// 是否为其他人主页是则走后台返回值控制私聊按钮显示
- /// 是自己的主页直接设置为YES,这样可以直接隐藏掉按钮
- if (self.isOtherPersonalPage) {
- self.isCanPrivateChat = model.is_beckon;
- } else {
- self.isCanPrivateChat = YES;
- }
-
- if (self.isCanPrivateChat) {
- self.heartbeatOrAccostButtonTitle = @"私聊";
- self.heartbeatOrAccostButtonImage = @"ym_personal_page_msg";
- } else {
- self.heartbeatOrAccostButtonTitle = [self isFemaleGender] ? @"心动" : @"搭讪";
- self.heartbeatOrAccostButtonImage = @"ym_personal_page_like";
- }
-
- [self.refreshUISubject sendNext:@(YMRefreshUI)];
-
- }else{
- [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- /// 打开更多弹窗
- - (void)openMoreAlert{
-
- if ([self currentUserId] == self.userId) {
- YMSheetPopupView *customView = [[YMSheetPopupView alloc]init];
- [customView configutationWithItemList:@[@"编辑"]];
- YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
- popupView.priority = 999;
- popupView.cornerRadius = adapt(10);
- popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
- popupView.positionStyle = YMPositionStyleBottom;
- popupView.isClickBgDismiss = YES;
- popupView.isHideBg = NO;
- popupView.bgAlpha = 0.5;
- @weakify(popupView)
- customView.selectIndexBlock = ^(NSInteger index) {
- @strongify(popupView)
- [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
-
- YMEditProfileViewModel *editProfileVM = [[YMEditProfileViewModel alloc]initWithParams:@{
- ParamsId:@(self.userId)
- }];
- [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_EDIT_PROFILE) withUserInfo:@{
- RouterViewModel:editProfileVM
- } completion:nil];
- };
- customView.closeBlock = ^{
- @strongify(popupView)
- [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
- };
- [popupView pop];
- }else{
-
- YMSheetPopupView *customView = [[YMSheetPopupView alloc]init];
- [customView configutationWithItemList:@[@"修改备注名",@"举报",@"拉黑"]];
- YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleSmoothFromBottom dismissStyle:YMDismissStyleSmoothToBottom];
- popupView.priority = 999;
- popupView.cornerRadius = adapt(10);
- popupView.rectCorners = UIRectCornerTopLeft|UIRectCornerTopRight;
- popupView.positionStyle = YMPositionStyleBottom;
- popupView.isClickBgDismiss = YES;
- popupView.isHideBg = NO;
- popupView.bgAlpha = 0.5;
- @weakify(popupView)
- customView.selectIndexBlock = ^(NSInteger index) {
- @strongify(popupView)
- [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
-
- switch (index) {
- case 0:
- {
-
- if (!self.isFollow) {
- [ZCHUDHelper showTitle:@"未关注对方不能设置备注名"];
- return;
- }
- YMInputPopupView *customView = [[YMInputPopupView alloc]init];
- customView.titleText = @"备注";
- customView.textAlignment = NSTextAlignmentCenter;
- [customView configutationWithContentText:@"" ofInputHeight:adapt(30) IsHideTitle:NO IsHideSingleButton:YES];
- YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleFade dismissStyle:YMDismissStyleFade];
- popupView.priority = 999;
- popupView.cornerRadius = adapt(10);
- popupView.rectCorners = UIRectCornerAllCorners;
- popupView.positionStyle = YMPositionStyleCenter;
- popupView.isHideBg = NO;
- popupView.bgAlpha = 0.3;
- @weakify(popupView)
- customView.buttonBlock = ^(BOOL isConfirm, NSString * _Nonnull contentText) {
- @strongify(popupView)
- if (isConfirm) {
- if (contentText.length > 15) {
- [ZCHUDHelper showTitle:@"备注长度最多为10个字符"];
- return;
- }else{
- [LCHttpHelper requestWithURLString:UpdateRemark parameters:@{
- @"user_id":@(self.userId),
- @"remark":contentText
- } needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {//成功
- [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
- }
- } failure:^(NSError *error) {
-
- }];
- }
- }
- [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
- };
- [popupView pop];
-
- }
- break;
- case 1:
- {
- YMReportViewModel *reportVM = [[YMReportViewModel alloc]initWithParams:@{
- ParamsCategoryType:@(YMReportTypePersonalPage),
- ParamsId:@(self.userId)
- }];
- [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_REPORT) withUserInfo:@{
- RouterViewModel:reportVM
- } completion:nil];
-
- }
- break;
- case 2:
- {
- YMTipsPopupView *customView = [[YMTipsPopupView alloc]init];
- [customView configutationWithTips:@"拉黑后,你将不再收到对方的消息,并且你们互相看不到对方的动态更新。可以在“设置-黑名单”中解除。" TipsAlignment:NSTextAlignmentLeft IsHideTitle:NO IsHideSingleButton:YES];
- YMPopupView *popupView = [YMPopupView initWithCustomView:customView parentView:nil popStyle:YMPopupStyleFade dismissStyle:YMDismissStyleFade];
- popupView.priority = 999;
- popupView.cornerRadius = adapt(10);
- popupView.rectCorners = UIRectCornerAllCorners;
- popupView.positionStyle = YMPositionStyleCenter;
- popupView.isHideBg = NO;
- popupView.bgAlpha = 0.3;
- @weakify(popupView)
- customView.buttonBlock = ^(BOOL isConfirm) {
- @strongify(popupView)
- if (isConfirm) {
- [LCCommonHttp blackUserId:stringFormat(@"%ld",self.userId)];
- }
- [popupView dismissWithStyle:YMDismissStyleFade duration:2.0];
- };
- [popupView pop];
- }
- break;
- default:
- break;
- }
- };
- customView.closeBlock = ^{
- @strongify(popupView)
- [popupView dismissWithStyle:YMDismissStyleSmoothToBottom duration:2.0];
- };
- [popupView pop];
- }
- }
- - (void)followUser{
- [LCHttpHelper requestWithURLString:UserFollow parameters:@{
- @"follow_uid":@(self.userId),
- } needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
-
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- NSDictionary *data = [dict dictionaryValueForKey:@"data" defaultValue:@{}];
- NSString *action = [data stringValueForKey:@"action" defaultValue:@""];
- if ([action isEqualToString:@"add"]) {
- [ZCHUDHelper showTitle:@"已关注"];
- self.isFollow = YES;
- }else if ([action isEqualToString:@"delete"]){
- [ZCHUDHelper showTitle:@"已取消关注"];
- self.isFollow = NO;
- }
- }else{
- [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- - (void)getFeesSettingBaseInfoData{
- @weakify(self)
- [LCHttpHelper requestWithURLString:AnchorGetPrice parameters:@{
- @"anchor_id":@(self.userId),
- @"is_new":@(1)
- } needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self)
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- [ZCHUDHelper dismiss];
-
- YMFeesSettingInfoModel *mdoel = [YMFeesSettingInfoModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]];
-
- self.userVideoFeesAmount = mdoel.video_price;
-
- }else{
- [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
-
- }
- - (void)gotoPersonalDynamic{
- YMPersonalDynamicViewModel *personalDynamicVM = [[YMPersonalDynamicViewModel alloc]initWithParams:@{
- ParamsId:@(self.userId)
- }];
- [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_PERSONAL_DYNAMIC) withUserInfo:@{
- RouterViewModel:personalDynamicVM
- } completion:nil];
- }
- - (void)gotoEditProfile{
- YMEditProfileViewModel *editProfileVM = [[YMEditProfileViewModel alloc]initWithParams:@{
- ParamsId:@(self.userId)
- }];
- [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_EDIT_PROFILE) withUserInfo:@{
- RouterViewModel:editProfileVM
- } completion:nil];
- }
- - (void)sendAccostRequest{
- if ([self isNeedGoddessCertified]) {
- return;
- }
- if(self.isCanPrivateChat){
- [self gotoPrivateChat];
- }else{
- @weakify(self)
- [LCHttpHelper requestWithURLString:HomeBeckonSend parameters:@{
- @"user_ids":stringFormat(@"[%ld]",self.userId)
- } needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self)
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {
- NSDictionary *data = [dict dictionaryValueForKey:@"data" defaultValue:@{}];
- BOOL boole = [data boolValueForKey:@"boole" defaultValue:NO];
-
- if (boole) {
- self.isCanPrivateChat = YES;
- self.heartbeatOrAccostButtonTitle = @"私聊";
- self.heartbeatOrAccostButtonImage = @"ym_personal_page_msg";
- }
-
- }else{
- [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
- }
- } failure:^(NSError *error) {
- [ZCHUDHelper showTitle:error.localizedDescription];
- }];
- }
- }
- - (void)callVideo{
- // if (self.youpaipshowModel.youpaipskill_list.count == 0) {
- // [ZCHUDHelper showTitle:@"暂时无法视频通话"];
- // return;
- // }
- if ([YOUPAILZChatRoomManager shareManager].chatroomWindow != nil && [YOUPAILZChatRoomManager shareManager].chatroomWindow.hidden == NO) {
- [ZCHUDHelper showTitle:@"你正在房间中,暂不可拨打视频"];
- return;
- }
-
- [UMengRecordTool umengEventCountWithId:StartVideoPersonal];
- [UCAuthorityManager cameraAuthority:^{
- if ([LCSaveData getWhiteVersion]) {//1
- [LCHttpHelper requestWithURLString:UserShowPage parameters:@{
- @"user_id":@(self.userId)
- } needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
-
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- NSDictionary *data = [dict objectForKey:@"data"];
- YOUPAILCUserShowInfo *info = [YOUPAILCUserShowInfo mj_objectWithKeyValues:[data objectForKey:@"info"]];
-
- YOUPAIBBVideoRequestVC* chatRequest = [[YOUPAIBBVideoRequestVC alloc]init];
- YOUPAILCVideoChatModel *videoModel = [[YOUPAILCVideoChatModel alloc] init];
- videoModel.youpaiproom_id = [NSString stringWithFormat:@"C%@",[LCTools randomNumberWithLength:6]];
- videoModel.youpaipauditState = 1;
- videoModel.youpaipfrom_uid = [LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id;
- videoModel.youpaipfrom_nickname = [LCSaveModel getUserModel].youpaipuserinfo.youpaipnickname;
- videoModel.youpaipfrom_avatar = [LCSaveModel getUserModel].youpaipuserinfo.youpaipavatar;
-
- videoModel.youpaipto_uid = stringFormat(@"%ld",self.userId);
- videoModel.youpaipto_nickname = info.youpaipnickname;
- videoModel.youpaipto_avatar = info.youpaipavatar;
- chatRequest.youpaipvideoModel = videoModel;
- ZCBaseNavigationVC *nav = [[ZCBaseNavigationVC alloc]initWithRootViewController:chatRequest];
- //modify by leo fix bug ios13
- nav.modalPresentationStyle =0;
- [[YMGlobalUtils getCurrentVC].navigationController presentViewController:nav animated:YES completion:^{
- }];
-
- }
- } failure:^(NSError *error) {
-
- }];
- }else{//0
- [LCHttpHelper requestWithURLString:CallChatType parameters:@{
- @"to_uid":@(self.userId),
- @"type":@"0"
- } needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code==0) {//成功
- YOUPAILCVideoChatModel* videoModel = [YOUPAILCVideoChatModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
- [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom];
- [[NSNotificationCenter defaultCenter] postNotificationName:@"MeCallVideo" object:nil userInfo:nil];
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-
- YOUPAILCVideoRequestVC* chatRequest = [[YOUPAILCVideoRequestVC alloc]init];
- chatRequest.youpaipvideoModel = videoModel;
- //modify by leo fix bug ios13
- ZCBaseNavigationVC *nav = [[ZCBaseNavigationVC alloc]initWithRootViewController:chatRequest];
- chatRequest.definesPresentationContext = YES;
- nav.modalPresentationStyle = UIModalPresentationOverCurrentContext&UIModalPresentationOverFullScreen;
- chatRequest.view.backgroundColor=HexColorFromRGBA(0x000000, 0.55);
- [[YMGlobalUtils getCurrentVC].navigationController presentViewController:nav animated:YES completion:^{
- }];
- });
- }
- } failure:^(NSError *error) {
-
-
- }];
- }
-
- } denied:^{
-
- dispatch_async(dispatch_get_main_queue(), ^{
- UIAlertController *systemAlert = [UIAlertController alertControllerWithTitle:@"请在iphone的“设置-隐私-相机”选项中,允许APP访问您的相机。" message:nil preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"现在去设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){
- if ([[UIDevice currentDevice].systemVersion floatValue] < 10.0)
- {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
-
- }
- else
- {
- // 去系统设置页面
- if (@available(iOS 10.0, *)) {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
- } else {
- // Fallback on earlier versions
- }
- }
- }];
- UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
- [systemAlert addAction:cancelAction];
- [systemAlert addAction:action];
- [[YMGlobalUtils getCurrentVC] presentViewController: systemAlert animated: YES completion: nil];
- });
-
- }];
- }
- - (void)gotoPrivateChat{
- NIMSession *session = [NIMSession session:stringFormat(@"%ld",self.userId) type:NIMSessionTypeP2P];
- if (session) {
- [ZCHUDHelper show];
- [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
- [ZCHUDHelper dismiss];
- YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session];
- vc.type = @"1";
- [[YMGlobalUtils getCurrentVC].navigationController pushViewController:vc animated:YES];
- }];
- }
- }
- @end
|