YMMineViewModel.m 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928
  1. //
  2. // YMMineViewModel.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/4.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMMineViewModel.h"
  9. #import "YMFeesSettingViewModel.h"
  10. #import "YMSettingViewModel.h"
  11. #import "YMMineInfoModel.h"
  12. #import "YMWealthModel.h"
  13. #import "YMWealthModel.h"
  14. #import "LPBeautySetVC.h"
  15. #import "YOUPAILCIMSessionVC.h"
  16. #import "YMGreetingSettingViewModel.h"
  17. #import "MSYMineinfoEditVC.h"
  18. #import "YOUPAILZUserShowVC.h"
  19. #import "YOUPAILZProfitVC.h"
  20. @interface YMMineViewModel ()
  21. /// 0未加入公会 1已加入公会 2已加入公会会长
  22. @property (nonatomic, assign, readwrite) NSInteger userGuild;
  23. /// 用户头像
  24. @property (nonatomic, copy, readwrite) NSString *userAvatar;
  25. /// 用户昵称
  26. @property (nonatomic, copy, readwrite) NSString *userNickname;
  27. /// 用户性别
  28. @property (nonatomic, assign, readwrite) NSInteger userGender;
  29. /// 用户代码
  30. @property (nonatomic, copy, readwrite) NSString *userCode;
  31. /// 用户简介
  32. @property (nonatomic, copy, readwrite) NSString *userIntro;
  33. /// 用户余额
  34. @property (nonatomic, copy, readwrite) NSString *userBalance;
  35. /// 用户收益
  36. @property (nonatomic, copy, readwrite) NSString *userEarnings;
  37. /// 违规公布链接
  38. @property (nonatomic, copy, readwrite) NSString *offenseNoticeUrl;
  39. /// 在线客服链接
  40. @property (nonatomic, copy, readwrite) NSString *onlineServiceUrl;
  41. /// 邀请链接
  42. @property (nonatomic, copy, readwrite) NSString *inviteUrl;
  43. /// 任务中心链接
  44. @property (nonatomic, copy, readwrite) NSString *taskCenterUrl;
  45. /// 用户等级
  46. @property (nonatomic, copy, readwrite) NSString *userGrade;
  47. /// 是否完整信息 1展示 0隐藏
  48. @property (nonatomic, assign, readwrite) BOOL isCompleteInfo;
  49. /// 是否女神认证
  50. @property (nonatomic, assign, readwrite) BOOL isGoddessCertified;
  51. /// 是否VIP
  52. @property (nonatomic, assign, readwrite) BOOL isVIP;
  53. /// 开通会员提示
  54. @property (nonatomic, copy, readwrite) NSString *openMembershipTips;
  55. /// 数量信息字典数据
  56. @property (nonatomic, strong, readwrite) NSArray <NSDictionary *> *quantityInfoDicDataArray;
  57. /// 数量信息模组数据
  58. @property (nonatomic, strong, readwrite) NSArray <YMMineQuantityInfoViewModel *> *quantityInfoGridDataArray;
  59. /// 常用功能一字典数据
  60. @property (nonatomic, strong, readwrite) NSArray <NSDictionary *> *commonFunctionsOneDicDataArray;
  61. /// 常用功能一模组数据
  62. @property (nonatomic, strong, readwrite) NSArray <YMMineCommonFunctionsViewModel *> *commonFunctionsOneGridDataArray;
  63. /// 常用功能二字典数据
  64. @property (nonatomic, strong, readwrite) NSArray <NSDictionary *> *commonFunctionsTwoDicDataArray;
  65. /// 常用功能二模组数据
  66. @property (nonatomic, strong, readwrite) NSArray <NSDictionary *> *commonFunctionsTwoListDataArray;
  67. /// 常用功能三字典数据
  68. @property (nonatomic, strong, readwrite) NSArray <NSDictionary *> *commonFunctionsThreeDicDataArray;
  69. /// 常用功能三模组数据
  70. @property (nonatomic, strong, readwrite) NSArray <YMMineCommonFunctionsViewModel *> *commonFunctionsThreeGridDataArray;
  71. /// 数字信息操作
  72. @property (nonatomic, strong, readwrite) RACSubject *quantityInfoOperationSubject;
  73. /// 常用功能操作
  74. @property (nonatomic, strong, readwrite) RACSubject *commonFunctionsOperationSubject;
  75. /// 用户Id
  76. @property (nonatomic, assign) NSInteger userId;
  77. @end
  78. @implementation YMMineViewModel
  79. - (void)ym_initialize{
  80. [super ym_initialize];
  81. @weakify(self)
  82. [[self.quantityInfoOperationSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable value) {
  83. // @strongify(self)
  84. switch ([value intValue]) {
  85. case YMMineQuantityInfoTypeFollow:
  86. {
  87. YMFriendsViewModel *friendsVM = [[YMFriendsViewModel alloc]initWithParams:@{
  88. ParamsDefaultIndex:@(0)
  89. }];
  90. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_FRIENDS) withUserInfo:@{
  91. RouterViewModel:friendsVM,
  92. } completion:nil];
  93. }
  94. break;
  95. case YMMineQuantityInfoTypeFans:
  96. {
  97. YMFriendsViewModel *friendsVM = [[YMFriendsViewModel alloc]initWithParams:@{
  98. ParamsDefaultIndex:@(1)
  99. }];
  100. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_FRIENDS) withUserInfo:@{
  101. RouterViewModel:friendsVM,
  102. } completion:nil];
  103. }
  104. break;
  105. case YMMineQuantityInfoTypeSpoor:
  106. {
  107. YMSpoorViewModel *spoorVM = [[YMSpoorViewModel alloc]initWithParams:@{}];
  108. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_SPOOR) withUserInfo:@{
  109. RouterViewModel:spoorVM
  110. } completion:nil];
  111. }
  112. break;
  113. case YMMineQuantityInfoTypeReceivedLikes:
  114. {
  115. YMReceivedLikesViewModel *receivedLikesVM = [[YMReceivedLikesViewModel alloc]initWithParams:@{}];
  116. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_RECEIVED_LIKES) withUserInfo:@{
  117. RouterViewModel:receivedLikesVM
  118. } completion:nil];
  119. }
  120. break;
  121. case YMMineQuantityInfoTypeGuest:
  122. {
  123. YMGuestViewModel *guestVM = [[YMGuestViewModel alloc]initWithParams:@{}];
  124. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_GUEST) withUserInfo:@{
  125. RouterViewModel:guestVM
  126. } completion:nil];
  127. }
  128. break;
  129. default:
  130. break;
  131. }
  132. }];
  133. [[self.commonFunctionsOperationSubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable value) {
  134. @strongify(self)
  135. switch ([value intValue]) {
  136. case YMCommonFunctionsTypeInvitingPrizes:
  137. {
  138. YMInvitingPrizesViewModel *invitingPrizesVM = [[YMInvitingPrizesViewModel alloc]initWithParams:@{}];
  139. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_INVITING_PRIZES) withUserInfo:@{
  140. RouterViewModel:invitingPrizesVM
  141. } completion:nil];
  142. }
  143. break;
  144. case YMCommonFunctionsTypeRealPersonAccreditation:
  145. {
  146. YMGoddessCertifiedProtocolViewModel *goddessCertifiedProtocolVM = [[YMGoddessCertifiedProtocolViewModel alloc]initWithParams:@{}];
  147. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_GODDESS_CERTIFIED_PROTOCOL) withUserInfo:@{
  148. RouterViewModel:goddessCertifiedProtocolVM
  149. } completion:nil];
  150. }
  151. break;
  152. case YMCommonFunctionsTypeRankingList:
  153. {
  154. YMRankingViewModel *rankingVM = [[YMRankingViewModel alloc]initWithParams:@{}];
  155. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_RANKING) withUserInfo:@{
  156. RouterViewModel:rankingVM
  157. } completion:nil];
  158. }
  159. break;
  160. case YMCommonFunctionsTypeBeautySetting:
  161. {
  162. LPBeautySetVC *beautySet = [[LPBeautySetVC alloc]init];
  163. [[YMGlobalUtils getCurrentVC].navigationController pushViewController:beautySet animated:YES];
  164. }
  165. break;
  166. case YMCommonFunctionsTypeChatPrice:
  167. {
  168. if ([self isNeedGoddessCertified]) {
  169. return;
  170. }
  171. YMFeesSettingViewModel *feesSettingVM = [[YMFeesSettingViewModel alloc]initWithParams:@{}];
  172. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_FEES_SETTING) withUserInfo:@{
  173. RouterViewModel:feesSettingVM
  174. } completion:nil];
  175. }
  176. break;
  177. case YMCommonFunctionsTypeMyBill:
  178. {
  179. YMIncomeBreakdownViewModel *incomeBreakdownVM = [[YMIncomeBreakdownViewModel alloc]initWithParams:@{}];
  180. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_INCOME_BREAKDOWN) withUserInfo:@{
  181. RouterViewModel:incomeBreakdownVM
  182. } completion:nil];
  183. }
  184. break;
  185. case YMCommonFunctionsTypeVideoDoNotDisturb:
  186. {
  187. if ([self isNeedGoddessCertified]) {
  188. return;
  189. }
  190. [self videoDoNotDisturbStatus];
  191. }
  192. break;
  193. case YMCommonFunctionsTypePrivateLetterChat:
  194. {
  195. [self privateLetterChatStatus];
  196. }
  197. break;
  198. case YMCommonFunctionsTypePrivateLetterSound:
  199. {
  200. [self privateLetterSoundStatus];
  201. }
  202. break;
  203. case YMCommonFunctionsTypePersonalPage:
  204. {
  205. YMPersonalPageViewModel *personalPageVM = [[YMPersonalPageViewModel alloc]initWithParams:@{
  206. ParamsId:@(self.userId)
  207. }];
  208. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_PERSONAL_PAGE) withUserInfo:@{
  209. RouterViewModel:personalPageVM
  210. } completion:nil];
  211. }
  212. break;
  213. case YMCommonFunctionsTypeOnlineCustomerSupport:
  214. {
  215. // YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{
  216. // ParamsUrl:[YMGlobalUtils shared].helpUrl
  217. // }];
  218. // [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{
  219. // RouterViewModel:webArticleVM
  220. // } completion:nil];
  221. // ZCBaseWebVC * vc = [[ZCBaseWebVC alloc]init];
  222. // vc.contentUrl = [YMGlobalUtils shared].helpUrl;
  223. // [[YMGlobalUtils getCurrentVC].navigationController pushViewController:vc animated:YES];
  224. // 在线客服
  225. NIMSession *session = [NIMSession session:[LCSaveData getServerId] type:NIMSessionTypeP2P];
  226. if (session) {
  227. @weakify(self);
  228. [ZCHUDHelper show];
  229. [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
  230. // @strongify(self);
  231. [ZCHUDHelper dismiss];
  232. YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session];
  233. [[LCTools getContainNavigationControllerCurrentVC].navigationController pushViewController:vc animated:YES];
  234. }];
  235. }
  236. }
  237. break;
  238. case YMCommonFunctionsTypePlatformStrategy:
  239. {
  240. // YMWebArticleViewModel *webArticleVM = [[YMWebArticleViewModel alloc]initWithParams:@{
  241. // ParamsUrl:[YMGlobalUtils shared].helpUrl
  242. // }];
  243. // [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_WEB_ARTICLE) withUserInfo:@{
  244. // RouterViewModel:webArticleVM
  245. // } completion:nil];
  246. // ZCBaseWebVC * vc = [[ZCBaseWebVC alloc]init];
  247. // vc.contentUrl = [YMGlobalUtils shared].helpUrl;
  248. // [[YMGlobalUtils getCurrentVC].navigationController pushViewController:vc animated:YES];
  249. NIMSession *session = [NIMSession session:[LCSaveData getCooperationId] type:NIMSessionTypeP2P];
  250. if (session) {
  251. @weakify(self);
  252. [ZCHUDHelper show];
  253. [[[NIMSDK sharedSDK] userManager] fetchUserInfos:@[session.sessionId] completion:^(NSArray<NIMUser *> * _Nullable users, NSError * _Nullable error) {
  254. // @strongify(self);
  255. [ZCHUDHelper dismiss];
  256. YOUPAILCIMSessionVC *vc = [[YOUPAILCIMSessionVC alloc] initWithSession:session];
  257. [[LCTools getContainNavigationControllerCurrentVC].navigationController pushViewController:vc animated:YES];
  258. }];
  259. }
  260. }
  261. break;
  262. case YMCommonFunctionsTypeSystemSetting:
  263. {
  264. YMSettingViewModel *settingVM = [[YMSettingViewModel alloc]initWithParams:@{}];
  265. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_SETTING) withUserInfo:@{
  266. RouterViewModel:settingVM
  267. } completion:nil];
  268. }
  269. break;
  270. case YMCommonFunctionsTypeSayHello:
  271. {
  272. if ([self isNeedGoddessCertified]) {
  273. return;
  274. }
  275. YMGreetingSettingViewModel *greetingSettingVM = [[YMGreetingSettingViewModel alloc]initWithParams:@{}];
  276. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_GREETING_SETTING) withUserInfo:@{
  277. RouterViewModel:greetingSettingVM
  278. } completion:nil];
  279. }
  280. break;
  281. case YMCommonFunctionsTypeGuildManagement:
  282. {
  283. YMGuildManagementViewModel *guildManagementVM = [[YMGuildManagementViewModel alloc]initWithParams:@{}];
  284. [YMRouter openURL:stringFormat(@"%@%@", YM_ROUTER_URL_PREFIX, YM_ROUTER_GUILD_MANAGEMENT) withUserInfo:@{
  285. RouterViewModel:guildManagementVM
  286. } completion:nil];
  287. }
  288. break;
  289. default:
  290. break;
  291. }
  292. }];
  293. self.quantityInfoDicDataArray = @[
  294. @{
  295. @"title":@"0",
  296. @"desc":@"关注",
  297. ParamsCategoryType:@(YMMineQuantityInfoTypeFollow),
  298. },
  299. @{
  300. @"title":@"0",
  301. @"desc":@"粉丝",
  302. ParamsCategoryType:@(YMMineQuantityInfoTypeFans),
  303. },
  304. @{
  305. @"title":@"0",
  306. @"desc":@"足迹",
  307. ParamsCategoryType:@(YMMineQuantityInfoTypeSpoor),
  308. },
  309. @{
  310. @"title":@"0",
  311. @"desc":@"点赞",
  312. ParamsCategoryType:@(YMMineQuantityInfoTypeReceivedLikes),
  313. },
  314. @{
  315. @"title":@"0",
  316. @"desc":@"访客",
  317. ParamsCategoryType:@(YMMineQuantityInfoTypeGuest),
  318. },
  319. ];
  320. self.commonFunctionsOneDicDataArray = @[
  321. @{
  322. @"icon":@"ym_mine_invited_icon",
  323. @"title":@"邀请有奖",
  324. ParamsCategoryType:@(YMCommonFunctionsTypeInvitingPrizes),
  325. },
  326. @{
  327. @"icon":@"ym_mine_real_person_accreditation_icon",
  328. @"title":@"真人认证",
  329. ParamsCategoryType:@(YMCommonFunctionsTypeRealPersonAccreditation),
  330. },
  331. @{
  332. @"icon":@"ym_mine_beauty_setting_icon",
  333. @"title":@"美颜设置",
  334. ParamsCategoryType:@(YMCommonFunctionsTypeBeautySetting),
  335. },
  336. @{
  337. @"icon":@"ym_mine_chat_price_icon",
  338. @"title":@"聊天价格",
  339. ParamsCategoryType:@(YMCommonFunctionsTypeChatPrice),
  340. },
  341. @{
  342. @"icon":@"ym_mine_chat_say_hello",
  343. @"title":@"打招呼",
  344. ParamsCategoryType:@(YMCommonFunctionsTypeSayHello),
  345. },
  346. @{
  347. @"icon":@"ym_mine_guild_management_icon",
  348. @"title":@"公会管理",
  349. ParamsCategoryType:@(YMCommonFunctionsTypeGuildManagement),
  350. },
  351. @{
  352. @"icon":@"ym_mine_online_customer_support_icon",
  353. @"title":@"在线客服",
  354. ParamsCategoryType:@(YMCommonFunctionsTypeOnlineCustomerSupport),
  355. },
  356. @{
  357. @"icon":@"ym_mine_platform_strategy_icon",
  358. @"title":@"合作洽谈",
  359. ParamsCategoryType:@(YMCommonFunctionsTypePlatformStrategy),
  360. },
  361. ];
  362. self.commonFunctionsTwoDicDataArray = @[
  363. @{
  364. @"icon":@"ym_mine_video_do_not_disturb_icon",
  365. @"title":@"视频开关",
  366. ParamsCategoryType:@(YMCommonFunctionsTypeVideoDoNotDisturb),
  367. },
  368. @{
  369. @"icon":@"ym_mine_private_letter_chat_icon",
  370. @"title":@"私信聊天",
  371. ParamsCategoryType:@(YMCommonFunctionsTypePrivateLetterChat),
  372. },
  373. @{
  374. @"icon":@"ym_mine_private_letter_sound_icon",
  375. @"title":@"私信音效",
  376. ParamsCategoryType:@(YMCommonFunctionsTypePrivateLetterSound),
  377. },
  378. ];
  379. self.commonFunctionsThreeDicDataArray = @[
  380. @{
  381. @"icon":@"ym_mine_personal_page_icon",
  382. @"title":@"个人主页",
  383. ParamsCategoryType:@(YMCommonFunctionsTypePersonalPage),
  384. },
  385. @{
  386. @"icon":@"ym_mine_online_customer_support_icon",
  387. @"title":@"在线客服",
  388. ParamsCategoryType:@(YMCommonFunctionsTypeOnlineCustomerSupport),
  389. },
  390. @{
  391. @"icon":@"ym_mine_platform_strategy_icon",
  392. @"title":@"合作洽谈",
  393. ParamsCategoryType:@(YMCommonFunctionsTypePlatformStrategy),
  394. },
  395. @{
  396. @"icon":@"ym_mine_system_setting_icon",
  397. @"title":@"系统设置",
  398. ParamsCategoryType:@(YMCommonFunctionsTypeSystemSetting),
  399. },
  400. @{
  401. @"icon":@"ym_mine_guild_management_icon",
  402. @"title":@"公会管理",
  403. ParamsCategoryType:@(YMCommonFunctionsTypeGuildManagement),
  404. },
  405. ];
  406. }
  407. - (void)getMineInfoData{
  408. @weakify(self)
  409. [LCHttpHelper requestWithURLString:UserCenter parameters:nil needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  410. @strongify(self)
  411. NSDictionary* dict = (NSDictionary*)responseObject;
  412. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  413. if (code == 0) {
  414. YMMineInfoModel *model = [YMMineInfoModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]];
  415. self.userGuild = model.guild;
  416. self.userAvatar = model.userinfo.avatar;
  417. self.userNickname = model.userinfo.nickname;
  418. self.userGender = model.userinfo.gender;
  419. self.userCode = model.userinfo.usercode;
  420. self.userId = model.userinfo.user_id;
  421. self.userIntro = model.userinfo.sign;
  422. if (model.anchor.open_video_status == 0) {
  423. [LCSaveData saveVideoOpenStatu:NO];
  424. }else{
  425. [LCSaveData saveVideoOpenStatu:YES];
  426. }
  427. if (model.anchor.order_switch == 1) {
  428. [LCSaveData saveOrderOpenStatu:YES];
  429. }else{
  430. [LCSaveData saveOrderOpenStatu:NO];
  431. }
  432. if (model.userinfo.is_msg_refuse == 0) {
  433. [LCSaveData saveProfileWuraoStatus:YES];
  434. }else{
  435. [LCSaveData saveProfileWuraoStatus:NO];
  436. }
  437. self.offenseNoticeUrl = model.webUrl.publish;
  438. self.onlineServiceUrl = model.webUrl.share;
  439. self.inviteUrl = model.webUrl.help;
  440. self.taskCenterUrl = model.webUrl.taskCenter;
  441. self.userGrade = model.webUrl.myGrade;
  442. self.isCompleteInfo = model.is_complete_info;
  443. self.isGoddessCertified = model.userinfo.is_anchor == 0 ? NO : YES;
  444. self.isVIP = model.userinfo.vip == 0 ? NO : YES;
  445. self.openMembershipTips = model.userinfo.vip == 0 ? @"查看开通会员10大权益" : model.userinfo.vip_des;
  446. [OCUserDefaults setBool:model.userinfo.gender == 1 ? YES : NO forKey:kIS_FEMALE_GENDER];
  447. [OCUserDefaults setBool:model.userinfo.is_anchor == 1 ? YES : NO forKey:kIS_GODDESS_CERTIFIED];
  448. [OCUserDefaults setBool:model.userinfo.vip == 0 ? NO : YES forKey:kIS_VIP];
  449. if (!OCStringIsEmpty(model.webUrl.tv)) {
  450. [OCUserDefaults setObject:model.webUrl.tv forKey:kON_TV_WEB_URL];
  451. }
  452. if (!OCStringIsEmpty(model.webUrl.anchorStarlevel)) {
  453. [OCUserDefaults setObject:model.webUrl.anchorStarlevel forKey:kINCREASE_STAR_RATING_URL];
  454. }
  455. if (!OCStringIsEmpty(model.webUrl.help)) {
  456. [OCUserDefaults setObject:model.webUrl.anchorStarlevel forKey:kHELP_URL];
  457. }
  458. if (!OCStringIsEmpty(model.webUrl.recharge_agreement)) {
  459. [OCUserDefaults setObject:model.webUrl.recharge_agreement forKey:kRECHARGE_AGREEMENT_URL];
  460. }
  461. if (!OCStringIsEmpty(model.webUrl.juvenile_protection)) {
  462. [OCUserDefaults setObject:model.webUrl.juvenile_protection forKey:kMINOR_PROTECTION_PROGRAM_URL];
  463. }
  464. [OCUserDefaults synchronize];
  465. NSArray *quantityInfoGridDataArr = [[self.quantityInfoDicDataArray.rac_sequence filter:^BOOL(NSDictionary * _Nullable quantityInfoDic) {
  466. YMMineQuantityInfoType type = [quantityInfoDic integerValueForKey:ParamsCategoryType defaultValue:YMMineQuantityInfoTypeFollow];
  467. /*
  468. 判断女神认证显示的功能
  469. if (self.isGoddessCertified && type == YMMineQuantityInfoTypeReceivedLikes) {
  470. return YES;
  471. } else if (!self.isGoddessCertified && type == YMMineQuantityInfoTypeReceivedLikes) {
  472. return NO;
  473. }else if (!self.isGoddessCertified && type == YMMineQuantityInfoTypeSpoor) {
  474. return YES;
  475. } else if (self.isGoddessCertified && type == YMMineQuantityInfoTypeSpoor) {
  476. return NO;
  477. }else {
  478. return YES;
  479. }
  480. */
  481. if (type == YMMineQuantityInfoTypeReceivedLikes) {
  482. return NO;
  483. } else {
  484. return YES;
  485. }
  486. }] map:^(NSDictionary * _Nullable quantityInfoDic) {
  487. YMMineQuantityInfoType type = [quantityInfoDic integerValueForKey:ParamsCategoryType defaultValue:YMMineQuantityInfoTypeFollow];
  488. YMMineQuantityInfoViewModel *viewModel = [[YMMineQuantityInfoViewModel alloc]init];
  489. viewModel.titleString = [quantityInfoDic stringValueForKey:@"title" defaultValue:@"0"];
  490. viewModel.desc = [quantityInfoDic stringValueForKey:@"desc" defaultValue:@""];
  491. viewModel.infoType = type;
  492. switch (type) {
  493. case YMMineQuantityInfoTypeFollow:
  494. {
  495. if (model.usercount.follow_count > 0) {
  496. viewModel.titleString = stringFormat(@"%ld",model.usercount.follow_count);
  497. }
  498. }
  499. break;
  500. case YMMineQuantityInfoTypeFans:
  501. {
  502. if (model.usercount.fans_count > 0) {
  503. viewModel.titleString = stringFormat(@"%ld",model.usercount.fans_count);
  504. }
  505. if (model.usercount.new_fans_count > 0) {
  506. viewModel.badge = model.usercount.new_fans_count > 99 ? @"99+" : stringFormat(@"%ld",model.usercount.new_fans_count);
  507. }
  508. }
  509. break;
  510. case YMMineQuantityInfoTypeSpoor:
  511. {
  512. if (model.usercount.viewer_count > 0) {
  513. viewModel.titleString = stringFormat(@"%ld",model.usercount.viewer_count);
  514. }
  515. }
  516. break;
  517. case YMMineQuantityInfoTypeReceivedLikes:
  518. {
  519. if (model.usercount.videoTrendsLike_count > 0) {
  520. viewModel.titleString = stringFormat(@"%ld",model.usercount.videoTrendsLike_count);
  521. }
  522. if (model.usercount.new_videoTrendsLike_count > 0) {
  523. viewModel.badge = model.usercount.new_videoTrendsLike_count > 99 ? @"99+" : stringFormat(@"%ld",model.usercount.new_videoTrendsLike_count);
  524. }
  525. }
  526. break;
  527. case YMMineQuantityInfoTypeGuest:
  528. {
  529. if (model.usercount.visitor_count > 0) {
  530. viewModel.titleString = stringFormat(@"%ld",model.usercount.visitor_count);
  531. }
  532. if (model.usercount.new_visitor_count > 0) {
  533. viewModel.badge = model.usercount.new_visitor_count > 99 ? @"99+" : stringFormat(@"%ld",model.usercount.new_visitor_count);
  534. }
  535. }
  536. break;
  537. default:
  538. break;
  539. }
  540. return viewModel;
  541. }].array;
  542. if (quantityInfoGridDataArr && quantityInfoGridDataArr.count > 0) {
  543. self.quantityInfoGridDataArray = quantityInfoGridDataArr;
  544. } else {
  545. self.quantityInfoGridDataArray = @[];
  546. }
  547. NSArray *commonFunctionsOneGridDataArr = [[self.commonFunctionsOneDicDataArray.rac_sequence filter:^BOOL(NSDictionary * _Nullable commonFunctionsOneDic) {
  548. YMCommonFunctionsType type = [commonFunctionsOneDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypeInvitingPrizes];
  549. // 是否是女性
  550. if (self.userGender == 1) {
  551. // 是否女神认证
  552. if (!self.isGoddessCertified && type == YMCommonFunctionsTypeRealPersonAccreditation) {
  553. return YES;
  554. }else if (self.isGoddessCertified && type == YMCommonFunctionsTypeRealPersonAccreditation) {
  555. return NO;
  556. }else if(self.userGuild != 2 && type == YMCommonFunctionsTypeGuildManagement){
  557. return NO;
  558. }else if(self.userGuild == 2 && type == YMCommonFunctionsTypeGuildManagement){
  559. return YES;
  560. }else{
  561. return YES;
  562. }
  563. }else{
  564. if (type == YMCommonFunctionsTypeRealPersonAccreditation || type == YMCommonFunctionsTypeChatPrice
  565. || type == YMCommonFunctionsTypeSayHello) {
  566. return NO;
  567. }else if(self.userGuild != 2 && type == YMCommonFunctionsTypeGuildManagement){
  568. return NO;
  569. }else if(self.userGuild == 2 && type == YMCommonFunctionsTypeGuildManagement){
  570. return YES;
  571. }else{
  572. return YES;
  573. }
  574. }
  575. }] map:^(NSDictionary * _Nullable commonFunctionsOneDic) {
  576. YMCommonFunctionsType type = [commonFunctionsOneDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypeInvitingPrizes];
  577. YMMineCommonFunctionsViewModel *viewModel = [[YMMineCommonFunctionsViewModel alloc]init];
  578. viewModel.imageName = [commonFunctionsOneDic stringValueForKey:@"icon" defaultValue:@""];
  579. viewModel.titleString = [commonFunctionsOneDic stringValueForKey:@"title" defaultValue:@""];
  580. viewModel.functionsType = type;
  581. return viewModel;
  582. }].array;
  583. if (commonFunctionsOneGridDataArr && commonFunctionsOneGridDataArr.count > 0) {
  584. self.commonFunctionsOneGridDataArray = commonFunctionsOneGridDataArr;
  585. } else {
  586. self.commonFunctionsOneGridDataArray = @[];
  587. }
  588. NSArray *commonFunctionsTwoListDataArr = [[self.commonFunctionsTwoDicDataArray.rac_sequence filter:^BOOL(NSDictionary * _Nullable commonFunctionsTwoDic) {
  589. return YES;
  590. // YMCommonFunctionsType type = [commonFunctionsTwoDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat];
  591. // 是否是女性
  592. // if (self.userGender != 1) {
  593. // if (type == YMCommonFunctionsTypeVideoDoNotDisturb) {
  594. // return NO;
  595. // } else {
  596. // return YES;
  597. // }
  598. // }else{
  599. // return YES;
  600. // }
  601. }] map:^(NSDictionary * _Nullable commonFunctionsTwoDic) {
  602. NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithDictionary:commonFunctionsTwoDic];
  603. YMCommonFunctionsType type = [dataDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat];
  604. switch (type) {
  605. case YMCommonFunctionsTypeVideoDoNotDisturb:
  606. [dataDic setObject:@(model.anchor.open_video_status == 1 ? YES : NO) forKey:@"isOpen"];
  607. break;
  608. case YMCommonFunctionsTypePrivateLetterChat:
  609. [dataDic setObject:@(model.userinfo.is_msg_refuse == 0 ? YES : NO) forKey:@"isOpen"];
  610. break;
  611. case YMCommonFunctionsTypePrivateLetterSound:
  612. [dataDic setObject:@([LCSaveData getIMMsgVoice] ? YES : NO) forKey:@"isOpen"];
  613. break;
  614. default:
  615. break;
  616. }
  617. return dataDic;
  618. }].array;
  619. if (commonFunctionsTwoListDataArr && commonFunctionsTwoListDataArr.count > 0) {
  620. self.commonFunctionsTwoListDataArray = commonFunctionsTwoListDataArr;
  621. } else {
  622. self.commonFunctionsTwoListDataArray = @[];
  623. }
  624. NSArray *commonFunctionsThreeGridDataArr = [self.commonFunctionsThreeDicDataArray.rac_sequence map:^(NSDictionary * _Nullable commonFunctionsThreeDic) {
  625. YMCommonFunctionsType type = [commonFunctionsThreeDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePersonalPage];
  626. YMMineCommonFunctionsViewModel *viewModel = [[YMMineCommonFunctionsViewModel alloc]init];
  627. viewModel.imageName = [commonFunctionsThreeDic stringValueForKey:@"icon" defaultValue:@""];
  628. viewModel.titleString = [commonFunctionsThreeDic stringValueForKey:@"title" defaultValue:@""];
  629. viewModel.functionsType = type;
  630. return viewModel;
  631. }].array;
  632. if (commonFunctionsThreeGridDataArr && commonFunctionsThreeGridDataArr.count > 0) {
  633. self.commonFunctionsThreeGridDataArray = commonFunctionsThreeGridDataArr;
  634. } else {
  635. self.commonFunctionsThreeGridDataArray = @[];
  636. }
  637. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  638. }
  639. } failure:^(NSError *error) {
  640. [ZCHUDHelper showTitle:error.localizedDescription];
  641. }];
  642. [LCHttpHelper requestWithURLString:WalletInit parameters:nil needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  643. NSDictionary* dict = (NSDictionary*)responseObject;
  644. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  645. if (code == 0) {
  646. YMWealthModel *model = [YMWealthModel yy_modelWithJSON:[dict dictionaryValueForKey:@"data" defaultValue:@{}]];
  647. self.userBalance = model.account.coin;
  648. self.userEarnings = stringFormat(@"%ld",model.account.income_coin);
  649. }else{
  650. [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
  651. }
  652. } failure:^(NSError *error) {
  653. [ZCHUDHelper showTitle:error.localizedDescription];
  654. }];
  655. }
  656. - (void)videoDoNotDisturbStatus{
  657. //0不接视频 1可以接视频
  658. NSInteger status = [LCSaveData getVideoOpenStatu] ? 0 : 1;
  659. [LCHttpHelper requestWithURLString:BigCastSetVideoStatus parameters:@{
  660. @"status":@(status)
  661. } needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  662. NSDictionary* dict = (NSDictionary*)responseObject;
  663. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  664. if (code == 0) {
  665. if (status == 0) {
  666. [ZCHUDHelper showTitle:@"关闭视频开关"];
  667. [LCSaveData saveVideoOpenStatu:NO];
  668. }else{
  669. [ZCHUDHelper showTitle:@"打开视频开关"];
  670. [LCSaveData saveVideoOpenStatu:YES];
  671. }
  672. self.commonFunctionsTwoListDataArray = [[self.commonFunctionsTwoListDataArray.rac_sequence filter:^BOOL(NSDictionary * _Nullable commonFunctionsTwoDic) {
  673. // YMCommonFunctionsType type = [commonFunctionsTwoDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat];
  674. // 是否是女性
  675. // if (self.userGender != 1) {
  676. // if (type == YMCommonFunctionsTypeVideoDoNotDisturb) {
  677. // return NO;
  678. // } else {
  679. // return YES;
  680. // }
  681. // }else{
  682. // return YES;
  683. // }
  684. return YES;
  685. }] map:^(NSDictionary * _Nullable commonFunctionsTwoDic) {
  686. NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithDictionary:commonFunctionsTwoDic];
  687. YMCommonFunctionsType type = [dataDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat];
  688. switch (type) {
  689. case YMCommonFunctionsTypeVideoDoNotDisturb:
  690. if (status == 0) {
  691. [dataDic setObject:@(NO) forKey:@"isOpen"];
  692. }else{
  693. [dataDic setObject:@(YES) forKey:@"isOpen"];
  694. }
  695. break;
  696. default:
  697. break;
  698. }
  699. return dataDic;
  700. }].array;
  701. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  702. } else {
  703. [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
  704. }
  705. } failure:^(NSError *error) {
  706. }];
  707. }
  708. - (void)privateLetterChatStatus{
  709. NSInteger status = [LCSaveData getProfileWuraoStatus] ? 1 : 0;
  710. [LCHttpHelper requestWithURLString:SetWuRaoStatus parameters:@{
  711. @"is_msg_refuse":@(status)
  712. } needToken:YES type:HttpRequestTypePost success:^(id responseObject) {
  713. NSDictionary* dict = (NSDictionary*)responseObject;
  714. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  715. if (code == 0) {
  716. if (status == 1) {
  717. [ZCHUDHelper showTitle:@"关闭私信聊天"];
  718. [LCSaveData saveProfileWuraoStatus:NO];
  719. }else{
  720. [ZCHUDHelper showTitle:@"打开私信聊天"];
  721. [LCSaveData saveProfileWuraoStatus:YES];
  722. }
  723. self.commonFunctionsTwoListDataArray = [[self.commonFunctionsTwoListDataArray.rac_sequence filter:^BOOL(NSDictionary * _Nullable commonFunctionsTwoDic) {
  724. // YMCommonFunctionsType type = [commonFunctionsTwoDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat];
  725. // 是否是女性
  726. // if (self.userGender != 1) {
  727. // if (type == YMCommonFunctionsTypeVideoDoNotDisturb) {
  728. // return NO;
  729. // } else {
  730. // return YES;
  731. // }
  732. // }else{
  733. // return YES;
  734. // }
  735. return YES;
  736. }] map:^(NSDictionary * _Nullable commonFunctionsTwoDic) {
  737. NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithDictionary:commonFunctionsTwoDic];
  738. YMCommonFunctionsType type = [dataDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat];
  739. switch (type) {
  740. case YMCommonFunctionsTypePrivateLetterChat:
  741. if (status == 1) {
  742. [dataDic setObject:@(NO) forKey:@"isOpen"];
  743. }else{
  744. [dataDic setObject:@(YES) forKey:@"isOpen"];
  745. }
  746. break;
  747. default:
  748. break;
  749. }
  750. return dataDic;
  751. }].array;
  752. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  753. }else{
  754. [ZCHUDHelper showTitle:[dict stringValueForKey:@"message" defaultValue:@""]];
  755. }
  756. } failure:^(NSError *error) {
  757. }];
  758. }
  759. - (void)privateLetterSoundStatus{
  760. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  761. if ([LCSaveData getIMMsgVoice]) {
  762. [LCSaveData saveIMMsgVoice:NO];
  763. }else{
  764. [LCSaveData saveIMMsgVoice:YES];
  765. }
  766. dispatch_async(dispatch_get_main_queue(), ^{
  767. self.commonFunctionsTwoListDataArray = [[self.commonFunctionsTwoListDataArray.rac_sequence filter:^BOOL(NSDictionary * _Nullable commonFunctionsTwoDic) {
  768. // YMCommonFunctionsType type = [commonFunctionsTwoDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat];
  769. // 是否是女性
  770. // if (self.userGender != 1) {
  771. // if (type == YMCommonFunctionsTypeVideoDoNotDisturb) {
  772. // return NO;
  773. // } else {
  774. // return YES;
  775. // }
  776. // }else{
  777. // return YES;
  778. // }
  779. return YES;
  780. }] map:^(NSDictionary * _Nullable commonFunctionsTwoDic) {
  781. NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithDictionary:commonFunctionsTwoDic];
  782. YMCommonFunctionsType type = [dataDic integerValueForKey:ParamsCategoryType defaultValue:YMCommonFunctionsTypePrivateLetterChat];
  783. switch (type) {
  784. case YMCommonFunctionsTypePrivateLetterSound:
  785. if ([LCSaveData getIMMsgVoice]) {
  786. [dataDic setObject:@(YES) forKey:@"isOpen"];
  787. }else{
  788. [dataDic setObject:@(NO) forKey:@"isOpen"];
  789. }
  790. break;
  791. default:
  792. break;
  793. }
  794. return dataDic;
  795. }].array;
  796. [self.refreshUISubject sendNext:@(YMRefreshUI)];
  797. });
  798. });
  799. }
  800. - (void)copyUserId{
  801. UIPasteboard *pab = [UIPasteboard generalPasteboard];
  802. pab.string = self.userCode?:@"";
  803. if (pab == nil) {
  804. [ZCHUDHelper showTitle:@"复制失败"];
  805. }else{
  806. [ZCHUDHelper showTitle:@"已复制到剪切板"];
  807. }
  808. // MSYMineinfoEditVC *vc = [[MSYMineinfoEditVC alloc]init];
  809. // YOUPAILZUserShowVC *vc = [[YOUPAILZUserShowVC alloc]init];
  810. // vc.youpaipuserId = stringFormat(@"%ld",self.userId);
  811. // YOUPAILZProfitVC *vc = [[YOUPAILZProfitVC alloc]init];
  812. // [[YMGlobalUtils getCurrentVC].navigationController pushViewController:vc animated:YES];
  813. }
  814. /// 前往编辑资料
  815. - (void)gotoEditProfile{
  816. YMEditProfileViewModel *editProfileVM = [[YMEditProfileViewModel alloc]initWithParams:@{
  817. ParamsId:@(self.userId)
  818. }];
  819. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_EDIT_PROFILE) withUserInfo:@{
  820. RouterViewModel:editProfileVM
  821. } completion:nil];
  822. }
  823. - (void)gotoMemberCenter{
  824. YMMemberCenterViewModel *memberCenterVM = [[YMMemberCenterViewModel alloc]initWithParams:@{}];
  825. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_MEMBER_CENTER) withUserInfo:@{
  826. RouterViewModel:memberCenterVM
  827. } completion:nil];
  828. }
  829. - (void)gotoAccountBalance{
  830. YMAccountBalanceViewModel *accountBalanceVM = [[YMAccountBalanceViewModel alloc]initWithParams:@{
  831. ParamsId:@(self.userId)
  832. }];
  833. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_ACCOUNT_BALANCE) withUserInfo:@{
  834. RouterViewModel:accountBalanceVM
  835. } completion:nil];
  836. }
  837. - (void)gotoMyEarnings{
  838. YMMyEarningsViewModel *myEarningsVM = [[YMMyEarningsViewModel alloc]initWithParams:@{
  839. ParamsId:@(self.userId)
  840. }];
  841. [YMRouter openURL:stringFormat(@"%@%@",YM_ROUTER_URL_PREFIX,YM_ROUTER_MY_EARNINGS) withUserInfo:@{
  842. RouterViewModel:myEarningsVM
  843. } completion:nil];
  844. }
  845. - (RACSubject *)quantityInfoOperationSubject{
  846. if (!_quantityInfoOperationSubject) {
  847. _quantityInfoOperationSubject = [RACSubject subject];
  848. }
  849. return _quantityInfoOperationSubject;
  850. }
  851. - (RACSubject *)commonFunctionsOperationSubject{
  852. if (!_commonFunctionsOperationSubject) {
  853. _commonFunctionsOperationSubject = [RACSubject subject];
  854. }
  855. return _commonFunctionsOperationSubject;
  856. }
  857. @end