// // YMMineViewModel.m // MSYOUPAI // // Created by YoMi on 2024/2/4. // Copyright © 2024 MS. All rights reserved. // #import "YMMineViewModel.h" #import "YMFeesSettingViewModel.h" #import "YMSettingViewModel.h" #import "YMMineInfoModel.h" #import "YMWealthModel.h" #import "YMWealthModel.h" #import "LPBeautySetVC.h" #import "YOUPAILCIMSessionVC.h" #import "YMGreetingSettingViewModel.h" #import "MSYMineinfoEditVC.h" #import "YOUPAILZUserShowVC.h" #import "YOUPAILZProfitVC.h" @interface YMMineViewModel () /// 0未加入公会 1已加入公会 2已加入公会会长 @property (nonatomic, assign, readwrite) NSInteger userGuild; /// 用户头像 @property (nonatomic, copy, readwrite) NSString *userAvatar; /// 用户昵称 @property (nonatomic, copy, readwrite) NSString *userNickname; /// 用户性别 @property (nonatomic, assign, readwrite) NSInteger userGender; /// 用户代码 @property (nonatomic, copy, readwrite) NSString *userCode; /// 用户简介 @property (nonatomic, copy, readwrite) NSString *userIntro; /// 用户余额 @property (nonatomic, copy, readwrite) NSString *userBalance; /// 用户收益 @property (nonatomic, copy, readwrite) NSString *userEarnings; /// 违规公布链接 @property (nonatomic, copy, readwrite) NSString *offenseNoticeUrl; /// 在线客服链接 @property (nonatomic, copy, readwrite) NSString *onlineServiceUrl; /// 邀请链接 @property (nonatomic, copy, readwrite) NSString *inviteUrl; /// 任务中心链接 @property (nonatomic, copy, readwrite) NSString *taskCenterUrl; /// 用户等级 @property (nonatomic, copy, readwrite) NSString *userGrade; /// 是否完整信息 1展示 0隐藏 @property (nonatomic, assign, readwrite) BOOL isCompleteInfo; /// 是否女神认证 @property (nonatomic, assign, readwrite) BOOL isGoddessCertified; /// 是否VIP @property (nonatomic, assign, readwrite) BOOL isVIP; /// 开通会员提示 @property (nonatomic, copy, readwrite) NSString *openMembershipTips; /// 数量信息字典数据 @property (nonatomic, strong, readwrite) NSArray *quantityInfoDicDataArray; /// 数量信息模组数据 @property (nonatomic, strong, readwrite) NSArray *quantityInfoGridDataArray; /// 常用功能一字典数据 @property (nonatomic, strong, readwrite) NSArray *commonFunctionsOneDicDataArray; /// 常用功能一模组数据 @property (nonatomic, strong, readwrite) NSArray *commonFunctionsOneGridDataArray; /// 常用功能二字典数据 @property (nonatomic, strong, readwrite) NSArray *commonFunctionsTwoDicDataArray; /// 常用功能二模组数据 @property (nonatomic, strong, readwrite) NSArray *commonFunctionsTwoListDataArray; /// 常用功能三字典数据 @property (nonatomic, strong, readwrite) NSArray *commonFunctionsThreeDicDataArray; /// 常用功能三模组数据 @property (nonatomic, strong, readwrite) NSArray *commonFunctionsThreeGridDataArray; /// 数字信息操作 @property (nonatomic, strong, readwrite) RACSubject *quantityInfoOperationSubject; /// 常用功能操作 @property (nonatomic, strong, readwrite) RACSubject *commonFunctionsOperationSubject; /// 用户Id @property (nonatomic, assign) NSInteger userId; @end @implementation YMMineViewModel - (void)ym_initialize{ [super ym_initialize]; @weakify(self) [[self.quantityInfoOperationSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable value) { // @strongify(self) switch ([value intValue]) { case YMMineQuantityInfoTypeFollow: { YMFriendsViewModel *friendsVM = [[YMFriendsViewModel alloc]initWithParams:@{ ParamsDefaultIndex:@(0) }]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_FRIENDS) withUserInfo:@{ RouterViewModel:friendsVM, } completion:nil]; } break; case YMMineQuantityInfoTypeFans: { YMFriendsViewModel *friendsVM = [[YMFriendsViewModel alloc]initWithParams:@{ ParamsDefaultIndex:@(1) }]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_FRIENDS) withUserInfo:@{ RouterViewModel:friendsVM, } completion:nil]; } break; case YMMineQuantityInfoTypeSpoor: { YMSpoorViewModel *spoorVM = [[YMSpoorViewModel alloc]initWithParams:@{}]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_SPOOR) withUserInfo:@{ RouterViewModel:spoorVM } completion:nil]; } break; case YMMineQuantityInfoTypeReceivedLikes: { YMReceivedLikesViewModel *receivedLikesVM = [[YMReceivedLikesViewModel alloc]initWithParams:@{}]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_RECEIVED_LIKES) withUserInfo:@{ RouterViewModel:receivedLikesVM } completion:nil]; } break; case YMMineQuantityInfoTypeGuest: { YMGuestViewModel *guestVM = [[YMGuestViewModel alloc]initWithParams:@{}]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_GUEST) withUserInfo:@{ RouterViewModel:guestVM } completion:nil]; } break; default: break; } }]; [[self.commonFunctionsOperationSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable value) { @strongify(self) switch ([value intValue]) { case YMCommonFunctionsTypeInvitingPrizes: { YMInvitingPrizesViewModel *invitingPrizesVM = [[YMInvitingPrizesViewModel alloc]initWithParams:@{}]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_INVITING_PRIZES) withUserInfo:@{ RouterViewModel:invitingPrizesVM } completion:nil]; } break; case YMCommonFunctionsTypeRealPersonAccreditation: { YMGoddessCertifiedProtocolViewModel *goddessCertifiedProtocolVM = [[YMGoddessCertifiedProtocolViewModel alloc]initWithParams:@{}]; [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_GODDESS_CERTIFIED_PROTOCOL) withUserInfo:@{ RouterViewModel:goddessCertifiedProtocolVM } completion:nil]; } break; case YMCommonFunctionsTypeRankingList: { YMRankingViewModel *rankingVM = [[YMRankingViewModel alloc]initWithParams:@{}]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_RANKING) withUserInfo:@{ RouterViewModel:rankingVM } completion:nil]; } break; case YMCommonFunctionsTypeBeautySetting: { LPBeautySetVC *beautySet = [[LPBeautySetVC alloc]init]; [[YMGlobalUtils getCurrentVC].navigationController pushViewController:beautySet animated:YES]; } break; case YMCommonFunctionsTypeChatPrice: { if ([self isNeedGoddessCertified]) { return; } YMFeesSettingViewModel *feesSettingVM = [[YMFeesSettingViewModel alloc]initWithParams:@{}]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_FEES_SETTING) withUserInfo:@{ RouterViewModel:feesSettingVM } completion:nil]; } break; case YMCommonFunctionsTypeMyBill: { YMIncomeBreakdownViewModel *incomeBreakdownVM = [[YMIncomeBreakdownViewModel alloc]initWithParams:@{}]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_INCOME_BREAKDOWN) withUserInfo:@{ RouterViewModel:incomeBreakdownVM } completion:nil]; } break; case YMCommonFunctionsTypeVideoDoNotDisturb: { if ([self isNeedGoddessCertified]) { return; } [self videoDoNotDisturbStatus]; } break; case YMCommonFunctionsTypePrivateLetterChat: { [self privateLetterChatStatus]; } break; case YMCommonFunctionsTypePrivateLetterSound: { [self privateLetterSoundStatus]; } break; case YMCommonFunctionsTypePersonalPage: { YMPersonalPageViewModel *personalPageVM = [[YMPersonalPageViewModel alloc]initWithParams:@{ ParamsId:@(self.userId) }]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_PERSONAL_PAGE) withUserInfo:@{ RouterViewModel:personalPageVM } completion:nil]; } break; case YMCommonFunctionsTypeOnlineCustomerSupport: { // YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{ // ParamsUrl:[YMGlobalUtils shared].helpUrl // }]; // [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{ // RouterViewModel:webArticleVM // } completion:nil]; // ZCBaseWebVC * vc = [[ZCBaseWebVC alloc]init]; // vc.contentUrl = [YMGlobalUtils shared].helpUrl; // [[YMGlobalUtils getCurrentVC].navigationController pushViewController:vc animated:YES]; // 在线客服 NIMSession *session = [NIMSession session:[LCSaveData getServerId] type:NIMSessionTypeP2P]; if (session) { @weakify(self); [ZCHUDHelper show]; [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray * _Nullable users, NSError * _Nullable error) { // @strongify(self); [ZCHUDHelper dismiss]; YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session]; [[LCTools getContainNavigationControllerCurrentVC].navigationController pushViewController:vc animated:YES]; }]; } } break; case YMCommonFunctionsTypePlatformStrategy: { // YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{ // ParamsUrl:[YMGlobalUtils shared].helpUrl // }]; // [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{ // RouterViewModel:webArticleVM // } completion:nil]; // ZCBaseWebVC * vc = [[ZCBaseWebVC alloc]init]; // vc.contentUrl = [YMGlobalUtils shared].helpUrl; // [[YMGlobalUtils getCurrentVC].navigationController pushViewController:vc animated:YES]; NIMSession *session = [NIMSession session:[LCSaveData getCooperationId] type:NIMSessionTypeP2P]; if (session) { @weakify(self); [ZCHUDHelper show]; [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray * _Nullable users, NSError * _Nullable error) { // @strongify(self); [ZCHUDHelper dismiss]; YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session]; [[LCTools getContainNavigationControllerCurrentVC].navigationController pushViewController:vc animated:YES]; }]; } } break; case YMCommonFunctionsTypeSystemSetting: { YMSettingViewModel *settingVM = [[YMSettingViewModel alloc]initWithParams:@{}]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_SETTING) withUserInfo:@{ RouterViewModel:settingVM } completion:nil]; } break; case YMCommonFunctionsTypeSayHello: { if ([self isNeedGoddessCertified]) { return; } YMGreetingSettingViewModel *greetingSettingVM = [[YMGreetingSettingViewModel alloc]initWithParams:@{}]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_GREETING_SETTING) withUserInfo:@{ RouterViewModel:greetingSettingVM } completion:nil]; } break; case YMCommonFunctionsTypeGuildManagement: { YMGuildManagementViewModel *guildManagementVM = [[YMGuildManagementViewModel alloc]initWithParams:@{}]; [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_GUILD_MANAGEMENT) withUserInfo:@{ RouterViewModel:guildManagementVM } completion:nil]; } break; default: break; } }]; self.quantityInfoDicDataArray = @[ @{ @"title":@"0", @"desc":@"关注", ParamsCategoryType:@(YMMineQuantityInfoTypeFollow), }, @{ @"title":@"0", @"desc":@"粉丝", ParamsCategoryType:@(YMMineQuantityInfoTypeFans), }, @{ @"title":@"0", @"desc":@"足迹", ParamsCategoryType:@(YMMineQuantityInfoTypeSpoor), }, @{ @"title":@"0", @"desc":@"点赞", ParamsCategoryType:@(YMMineQuantityInfoTypeReceivedLikes), }, @{ @"title":@"0", @"desc":@"访客", ParamsCategoryType:@(YMMineQuantityInfoTypeGuest), }, ]; self.commonFunctionsOneDicDataArray = @[ @{ @"icon":@"ym_mine_invited_icon", @"title":@"邀请有奖", ParamsCategoryType:@(YMCommonFunctionsTypeInvitingPrizes), }, @{ @"icon":@"ym_mine_real_person_accreditation_icon", @"title":@"真人认证", ParamsCategoryType:@(YMCommonFunctionsTypeRealPersonAccreditation), }, @{ @"icon":@"ym_mine_beauty_setting_icon", @"title":@"美颜设置", ParamsCategoryType:@(YMCommonFunctionsTypeBeautySetting), }, @{ @"icon":@"ym_mine_chat_price_icon", @"title":@"聊天价格", ParamsCategoryType:@(YMCommonFunctionsTypeChatPrice), }, @{ @"icon":@"ym_mine_chat_say_hello", @"title":@"打招呼", ParamsCategoryType:@(YMCommonFunctionsTypeSayHello), }, @{ @"icon":@"ym_mine_guild_management_icon", @"title":@"公会管理", ParamsCategoryType:@(YMCommonFunctionsTypeGuildManagement), }, @{ @"icon":@"ym_mine_online_customer_support_icon", @"title":@"在线客服", ParamsCategoryType:@(YMCommonFunctionsTypeOnlineCustomerSupport), }, @{ @"icon":@"ym_mine_platform_strategy_icon", @"title":@"合作洽谈", ParamsCategoryType:@(YMCommonFunctionsTypePlatformStrategy), }, ]; self.commonFunctionsTwoDicDataArray = @[ @{ @"icon":@"ym_mine_video_do_not_disturb_icon", @"title":@"视频开关", ParamsCategoryType:@(YMCommonFunctionsTypeVideoDoNotDisturb), }, @{ @"icon":@"ym_mine_private_letter_chat_icon", @"title":@"私信聊天", ParamsCategoryType:@(YMCommonFunctionsTypePrivateLetterChat), }, @{ @"icon":@"ym_mine_private_letter_sound_icon", @"title":@"私信音效", ParamsCategoryType:@(YMCommonFunctionsTypePrivateLetterSound), }, ]; self.commonFunctionsThreeDicDataArray = @[ @{ @"icon":@"ym_mine_personal_page_icon", @"title":@"个人主页", ParamsCategoryType:@(YMCommonFunctionsTypePersonalPage), }, @{ @"icon":@"ym_mine_online_customer_support_icon", @"title":@"在线客服", ParamsCategoryType:@(YMCommonFunctionsTypeOnlineCustomerSupport), }, @{ @"icon":@"ym_mine_platform_strategy_icon", @"title":@"合作洽谈", ParamsCategoryType:@(YMCommonFunctionsTypePlatformStrategy), }, @{ @"icon":@"ym_mine_system_setting_icon", @"title":@"系统设置", ParamsCategoryType:@(YMCommonFunctionsTypeSystemSetting), }, @{ @"icon":@"ym_mine_guild_management_icon", @"title":@"公会管理", ParamsCategoryType:@(YMCommonFunctionsTypeGuildManagement), }, ]; } - (void)getMineInfoData{ @weakify(self) [LCHttpHelper requestWithURLString:UserCenter parameters:nil needToken:YES type:HttpRequestTypePost success:^(id responseObject) { @strongify(self) NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) { YMMineInfoModel *model = [YMMineInfoModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]]; self.userGuild = model.guild; self.userAvatar = model.userinfo.avatar; self.userNickname = model.userinfo.nickname; self.userGender = model.userinfo.gender; self.userCode = model.userinfo.usercode; self.userId = model.userinfo.user_id; self.userIntro = model.userinfo.sign; if (model.anchor.open_video_status == 0) { [LCSaveData saveVideoOpenStatu:NO]; }else{ [LCSaveData saveVideoOpenStatu:YES]; } if (model.anchor.order_switch == 1) { [LCSaveData saveOrderOpenStatu:YES]; }else{ [LCSaveData saveOrderOpenStatu:NO]; } if (model.userinfo.is_msg_refuse == 0) { [LCSaveData saveProfileWuraoStatus:YES]; }else{ [LCSaveData saveProfileWuraoStatus:NO]; } self.offenseNoticeUrl = model.webUrl.publish; self.onlineServiceUrl = model.webUrl.share; self.inviteUrl = model.webUrl.help; self.taskCenterUrl = model.webUrl.taskCenter; self.userGrade = model.webUrl.myGrade; self.isCompleteInfo = model.is_complete_info; self.isGoddessCertified = model.userinfo.is_anchor == 0 ? NO : YES; self.isVIP = model.userinfo.vip == 0 ? NO : YES; self.openMembershipTips = model.userinfo.vip == 0 ? @"查看开通会员10大权益" : model.userinfo.vip_des; [OCUserDefaults setBool:model.userinfo.gender == 1 ? YES : NO forKey:kIS_FEMALE_GENDER]; [OCUserDefaults setBool:model.userinfo.is_anchor == 1 ? YES : NO forKey:kIS_GODDESS_CERTIFIED]; [OCUserDefaults setBool:model.userinfo.vip == 0 ? NO : YES forKey:kIS_VIP]; if (!OCStringIsEmpty(model.webUrl.tv)) { [OCUserDefaults setObject:model.webUrl.tv forKey:kON_TV_WEB_URL]; } if (!OCStringIsEmpty(model.webUrl.anchorStarlevel)) { [OCUserDefaults setObject:model.webUrl.anchorStarlevel forKey:kINCREASE_STAR_RATING_URL]; } if (!OCStringIsEmpty(model.webUrl.help)) { [OCUserDefaults setObject:model.webUrl.anchorStarlevel forKey:kHELP_URL]; } if (!OCStringIsEmpty(model.webUrl.recharge_agreement)) { [OCUserDefaults setObject:model.webUrl.recharge_agreement forKey:kRECHARGE_AGREEMENT_URL]; } if (!OCStringIsEmpty(model.webUrl.juvenile_protection)) { [OCUserDefaults setObject:model.webUrl.juvenile_protection forKey:kMINOR_PROTECTION_PROGRAM_URL]; } [OCUserDefaults synchronize]; NSArray *quantityInfoGridDataArr = [[self.quantityInfoDicDataArray.rac_sequence filter:^BOOL(NSDictionary * _Nullable quantityInfoDic) { YMMineQuantityInfoType type = [quantityInfoDic integerValueForKey:ParamsCategoryType defaultValue:YMMineQuantityInfoTypeFollow]; /* 判断女神认证显示的功能 if (self.isGoddessCertified && type == YMMineQuantityInfoTypeReceivedLikes) { return YES; } else if (!self.isGoddessCertified && type == YMMineQuantityInfoTypeReceivedLikes) { return NO; }else if (!self.isGoddessCertified && type == YMMineQuantityInfoTypeSpoor) { return YES; } else if (self.isGoddessCertified && type == YMMineQuantityInfoTypeSpoor) { return NO; }else { return YES; } */ if (type == YMMineQuantityInfoTypeReceivedLikes) { return NO; } else { return YES; } }] map:^(NSDictionary * _Nullable quantityInfoDic) { YMMineQuantityInfoType type = [quantityInfoDic integerValueForKey:ParamsCategoryType defaultValue:YMMineQuantityInfoTypeFollow]; YMMineQuantityInfoViewModel *viewModel = [[YMMineQuantityInfoViewModel alloc]init]; viewModel.titleString = [quantityInfoDic stringValueForKey:@"title" defaultValue:@"0"]; viewModel.desc = [quantityInfoDic stringValueForKey:@"desc" defaultValue:@""]; viewModel.infoType = type; switch (type) { case YMMineQuantityInfoTypeFollow: { if (model.usercount.follow_count > 0) { viewModel.titleString = stringFormat(@"%ld",model.usercount.follow_count); } } break; case YMMineQuantityInfoTypeFans: { if (model.usercount.fans_count > 0) { viewModel.titleString = stringFormat(@"%ld",model.usercount.fans_count); } if (model.usercount.new_fans_count > 0) { viewModel.badge = model.usercount.new_fans_count > 99 ? @"99+" : stringFormat(@"%ld",model.usercount.new_fans_count); } } break; case YMMineQuantityInfoTypeSpoor: { if (model.usercount.viewer_count > 0) { viewModel.titleString = stringFormat(@"%ld",model.usercount.viewer_count); } } break; case YMMineQuantityInfoTypeReceivedLikes: { if (model.usercount.videoTrendsLike_count > 0) { viewModel.titleString = stringFormat(@"%ld",model.usercount.videoTrendsLike_count); } if (model.usercount.new_videoTrendsLike_count > 0) { viewModel.badge = model.usercount.new_videoTrendsLike_count > 99 ? @"99+" : stringFormat(@"%ld",model.usercount.new_videoTrendsLike_count); } } break; case YMMineQuantityInfoTypeGuest: { if (model.usercount.visitor_count > 0) { viewModel.titleString = stringFormat(@"%ld",model.usercount.visitor_count); } if (model.usercount.new_visitor_count > 0) { viewModel.badge = model.usercount.new_visitor_count > 99 ? @"99+" : stringFormat(@"%ld",model.usercount.new_visitor_count); } } break; default: break; } return viewModel; }].array; if (quantityInfoGridDataArr && quantityInfoGridDataArr.count > 0) { self.quantityInfoGridDataArray = quantityInfoGridDataArr; } else { self.quantityInfoGridDataArray = @[]; } NSArray *commonFunctionsOneGridDataArr = [[self.commonFunctionsOneDicDataArray.rac_sequence filter:^BOOL(NSDictionary * _Nullable commonFunctionsOneDic) { YMCommonFunctionsType type = [commonFunctionsOneDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypeInvitingPrizes]; // 是否是女性 if (self.userGender == 1) { // 是否女神认证 if (!self.isGoddessCertified && type == YMCommonFunctionsTypeRealPersonAccreditation) { return YES; }else if (self.isGoddessCertified && type == YMCommonFunctionsTypeRealPersonAccreditation) { return NO; }else if(self.userGuild != 2 && type == YMCommonFunctionsTypeGuildManagement){ return NO; }else if(self.userGuild == 2 && type == YMCommonFunctionsTypeGuildManagement){ return YES; }else{ return YES; } }else{ if (type == YMCommonFunctionsTypeRealPersonAccreditation || type == YMCommonFunctionsTypeChatPrice || type == YMCommonFunctionsTypeSayHello) { return NO; }else if(self.userGuild != 2 && type == YMCommonFunctionsTypeGuildManagement){ return NO; }else if(self.userGuild == 2 && type == YMCommonFunctionsTypeGuildManagement){ return YES; }else{ return YES; } } }] map:^(NSDictionary * _Nullable commonFunctionsOneDic) { YMCommonFunctionsType type = [commonFunctionsOneDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypeInvitingPrizes]; YMMineCommonFunctionsViewModel *viewModel = [[YMMineCommonFunctionsViewModel alloc]init]; viewModel.imageName = [commonFunctionsOneDic stringValueForKey:@"icon" defaultValue:@""]; viewModel.titleString = [commonFunctionsOneDic stringValueForKey:@"title" defaultValue:@""]; viewModel.functionsType = type; return viewModel; }].array; if (commonFunctionsOneGridDataArr && commonFunctionsOneGridDataArr.count > 0) { self.commonFunctionsOneGridDataArray = commonFunctionsOneGridDataArr; } else { self.commonFunctionsOneGridDataArray = @[]; } NSArray *commonFunctionsTwoListDataArr = [[self.commonFunctionsTwoDicDataArray.rac_sequence filter:^BOOL(NSDictionary * _Nullable commonFunctionsTwoDic) { return YES; // YMCommonFunctionsType type = [commonFunctionsTwoDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat]; // 是否是女性 // if (self.userGender != 1) { // if (type == YMCommonFunctionsTypeVideoDoNotDisturb) { // return NO; // } else { // return YES; // } // }else{ // return YES; // } }] map:^(NSDictionary * _Nullable commonFunctionsTwoDic) { NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithDictionary:commonFunctionsTwoDic]; YMCommonFunctionsType type = [dataDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat]; switch (type) { case YMCommonFunctionsTypeVideoDoNotDisturb: [dataDic setObject:@(model.anchor.open_video_status == 1 ? YES : NO) forKey:@"isOpen"]; break; case YMCommonFunctionsTypePrivateLetterChat: [dataDic setObject:@(model.userinfo.is_msg_refuse == 0 ? YES : NO) forKey:@"isOpen"]; break; case YMCommonFunctionsTypePrivateLetterSound: [dataDic setObject:@([LCSaveData getIMMsgVoice] ? YES : NO) forKey:@"isOpen"]; break; default: break; } return dataDic; }].array; if (commonFunctionsTwoListDataArr && commonFunctionsTwoListDataArr.count > 0) { self.commonFunctionsTwoListDataArray = commonFunctionsTwoListDataArr; } else { self.commonFunctionsTwoListDataArray = @[]; } NSArray *commonFunctionsThreeGridDataArr = [self.commonFunctionsThreeDicDataArray.rac_sequence map:^(NSDictionary * _Nullable commonFunctionsThreeDic) { YMCommonFunctionsType type = [commonFunctionsThreeDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePersonalPage]; YMMineCommonFunctionsViewModel *viewModel = [[YMMineCommonFunctionsViewModel alloc]init]; viewModel.imageName = [commonFunctionsThreeDic stringValueForKey:@"icon" defaultValue:@""]; viewModel.titleString = [commonFunctionsThreeDic stringValueForKey:@"title" defaultValue:@""]; viewModel.functionsType = type; return viewModel; }].array; if (commonFunctionsThreeGridDataArr && commonFunctionsThreeGridDataArr.count > 0) { self.commonFunctionsThreeGridDataArray = commonFunctionsThreeGridDataArr; } else { self.commonFunctionsThreeGridDataArray = @[]; } [self.refreshUISubject sendNext:@(YMRefreshUI)]; } } failure:^(NSError *error) { [ZCHUDHelper showTitle:error.localizedDescription]; }]; [LCHttpHelper requestWithURLString:WalletInit parameters:nil needToken:YES type:HttpRequestTypePost success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) { YMWealthModel *model = [YMWealthModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]]; self.userBalance = model.account.coin; self.userEarnings = stringFormat(@"%ld",model.account.income_coin); }else{ [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]]; } } failure:^(NSError *error) { [ZCHUDHelper showTitle:error.localizedDescription]; }]; } - (void)videoDoNotDisturbStatus{ //0不接视频 1可以接视频 NSInteger status = [LCSaveData getVideoOpenStatu] ? 0 : 1; [LCHttpHelper requestWithURLString:BigCastSetVideoStatus parameters:@{ @"status":@(status) } needToken:YES type:HttpRequestTypePost success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) { if (status == 0) { [ZCHUDHelper showTitle:@"关闭视频开关"]; [LCSaveData saveVideoOpenStatu:NO]; }else{ [ZCHUDHelper showTitle:@"打开视频开关"]; [LCSaveData saveVideoOpenStatu:YES]; } self.commonFunctionsTwoListDataArray = [[self.commonFunctionsTwoListDataArray.rac_sequence filter:^BOOL(NSDictionary * _Nullable commonFunctionsTwoDic) { // YMCommonFunctionsType type = [commonFunctionsTwoDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat]; // 是否是女性 // if (self.userGender != 1) { // if (type == YMCommonFunctionsTypeVideoDoNotDisturb) { // return NO; // } else { // return YES; // } // }else{ // return YES; // } return YES; }] map:^(NSDictionary * _Nullable commonFunctionsTwoDic) { NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithDictionary:commonFunctionsTwoDic]; YMCommonFunctionsType type = [dataDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat]; switch (type) { case YMCommonFunctionsTypeVideoDoNotDisturb: if (status == 0) { [dataDic setObject:@(NO) forKey:@"isOpen"]; }else{ [dataDic setObject:@(YES) forKey:@"isOpen"]; } break; default: break; } return dataDic; }].array; [self.refreshUISubject sendNext:@(YMRefreshUI)]; } else { [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]]; } } failure:^(NSError *error) { }]; } - (void)privateLetterChatStatus{ NSInteger status = [LCSaveData getProfileWuraoStatus] ? 1 : 0; [LCHttpHelper requestWithURLString:SetWuRaoStatus parameters:@{ @"is_msg_refuse":@(status) } needToken:YES type:HttpRequestTypePost success:^(id responseObject) { NSDictionary* dict = (NSDictionary*)responseObject; NSInteger code = [[dict objectForKey:@"code"] integerValue]; if (code == 0) { if (status == 1) { [ZCHUDHelper showTitle:@"关闭私信聊天"]; [LCSaveData saveProfileWuraoStatus:NO]; }else{ [ZCHUDHelper showTitle:@"打开私信聊天"]; [LCSaveData saveProfileWuraoStatus:YES]; } self.commonFunctionsTwoListDataArray = [[self.commonFunctionsTwoListDataArray.rac_sequence filter:^BOOL(NSDictionary * _Nullable commonFunctionsTwoDic) { // YMCommonFunctionsType type = [commonFunctionsTwoDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat]; // 是否是女性 // if (self.userGender != 1) { // if (type == YMCommonFunctionsTypeVideoDoNotDisturb) { // return NO; // } else { // return YES; // } // }else{ // return YES; // } return YES; }] map:^(NSDictionary * _Nullable commonFunctionsTwoDic) { NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithDictionary:commonFunctionsTwoDic]; YMCommonFunctionsType type = [dataDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat]; switch (type) { case YMCommonFunctionsTypePrivateLetterChat: if (status == 1) { [dataDic setObject:@(NO) forKey:@"isOpen"]; }else{ [dataDic setObject:@(YES) forKey:@"isOpen"]; } break; default: break; } return dataDic; }].array; [self.refreshUISubject sendNext:@(YMRefreshUI)]; }else{ [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]]; } } failure:^(NSError *error) { }]; } - (void)privateLetterSoundStatus{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ if ([LCSaveData getIMMsgVoice]) { [LCSaveData saveIMMsgVoice:NO]; }else{ [LCSaveData saveIMMsgVoice:YES]; } dispatch_async(dispatch_get_main_queue(), ^{ self.commonFunctionsTwoListDataArray = [[self.commonFunctionsTwoListDataArray.rac_sequence filter:^BOOL(NSDictionary * _Nullable commonFunctionsTwoDic) { // YMCommonFunctionsType type = [commonFunctionsTwoDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat]; // 是否是女性 // if (self.userGender != 1) { // if (type == YMCommonFunctionsTypeVideoDoNotDisturb) { // return NO; // } else { // return YES; // } // }else{ // return YES; // } return YES; }] map:^(NSDictionary * _Nullable commonFunctionsTwoDic) { NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithDictionary:commonFunctionsTwoDic]; YMCommonFunctionsType type = [dataDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat]; switch (type) { case YMCommonFunctionsTypePrivateLetterSound: if ([LCSaveData getIMMsgVoice]) { [dataDic setObject:@(YES) forKey:@"isOpen"]; }else{ [dataDic setObject:@(NO) forKey:@"isOpen"]; } break; default: break; } return dataDic; }].array; [self.refreshUISubject sendNext:@(YMRefreshUI)]; }); }); } - (void)copyUserId{ UIPasteboard *pab = [UIPasteboard generalPasteboard]; pab.string = self.userCode?:@""; if (pab == nil) { [ZCHUDHelper showTitle:@"复制失败"]; }else{ [ZCHUDHelper showTitle:@"已复制到剪切板"]; } // MSYMineinfoEditVC *vc = [[MSYMineinfoEditVC alloc]init]; // YOUPAILZUserShowVC *vc = [[YOUPAILZUserShowVC alloc]init]; // vc.youpaipuserId = stringFormat(@"%ld",self.userId); // YOUPAILZProfitVC *vc = [[YOUPAILZProfitVC alloc]init]; // [[YMGlobalUtils getCurrentVC].navigationController pushViewController:vc animated:YES]; } /// 前往编辑资料 - (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)gotoMemberCenter{ YMMemberCenterViewModel *memberCenterVM = [[YMMemberCenterViewModel alloc]initWithParams:@{}]; [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_MEMBER_CENTER) withUserInfo:@{ RouterViewModel:memberCenterVM } completion:nil]; } - (void)gotoAccountBalance{ YMAccountBalanceViewModel *accountBalanceVM = [[YMAccountBalanceViewModel alloc]initWithParams:@{ ParamsId:@(self.userId) }]; [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_ACCOUNT_BALANCE) withUserInfo:@{ RouterViewModel:accountBalanceVM } completion:nil]; } - (void)gotoMyEarnings{ YMMyEarningsViewModel *myEarningsVM = [[YMMyEarningsViewModel alloc]initWithParams:@{ ParamsId:@(self.userId) }]; [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_MY_EARNINGS) withUserInfo:@{ RouterViewModel:myEarningsVM } completion:nil]; } - (RACSubject *)quantityInfoOperationSubject{ if (!_quantityInfoOperationSubject) { _quantityInfoOperationSubject = [RACSubject subject]; } return _quantityInfoOperationSubject; } - (RACSubject *)commonFunctionsOperationSubject{ if (!_commonFunctionsOperationSubject) { _commonFunctionsOperationSubject = [RACSubject subject]; } return _commonFunctionsOperationSubject; } @end