MORefreshViewManage.m 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // MORefreshViewManage.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2024/1/4.
  6. //
  7. #import "MORefreshViewManage.h"
  8. @interface MORefreshViewManage ()
  9. @end
  10. static MORefreshViewManage *_manager;
  11. @implementation MORefreshViewManage
  12. ///单例
  13. + (MORefreshViewManage *)shareManager
  14. {
  15. static dispatch_once_t onceToken;
  16. dispatch_once(&onceToken, ^
  17. {
  18. _manager = [[MORefreshViewManage alloc] init];
  19. });
  20. return _manager;
  21. }
  22. - (void)resetAllProperty{
  23. [self.refreshDict enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
  24. obj = @(NO);
  25. }];
  26. }
  27. - (void)setNeedRefreshWithCode:(NSString *)codeStr{
  28. [self.refreshDict setObject:@(YES) forKey:codeStr];
  29. }
  30. - (BOOL)getRefreshTagWithCode:(NSString *)codeStr{
  31. BOOL result = [[MODataManager objectOrNilForKey:codeStr fromDictionary:self.refreshDict] boolValue];
  32. return result;
  33. }
  34. - (void)toUpdataTheUserInfo{
  35. WEAKSELF
  36. [kHttpManager toGetTheUserCurrentDiamondWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  37. if(kCode_Success){
  38. NSDictionary *backDict = data[@"data"];
  39. NSInteger currentDiamond = [[MODataManager objectOrNilForKey:@"result" fromDictionary:backDict] integerValue];
  40. if(currentDiamond < 0){
  41. return;
  42. }
  43. MOMeDataInfo *userInfoData = (MOMeDataInfo *)[[MODataCache sharedYYCache] objectForKey:kMineUserInfo];
  44. userInfoData.userWallet.diamond = currentDiamond;
  45. [[MODataCache sharedYYCache] setObject:userInfoData forKey:kMineUserInfo];
  46. }
  47. }];
  48. return;
  49. [kHttpManager getMeUserInfoWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  50. __strong typeof(weakSelf) self = weakSelf;
  51. if(kCode_Success){
  52. // MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  53. //更新个人信息偏好缓存
  54. [MODataManager saveUserInfo:data];
  55. }
  56. }];
  57. }
  58. - (NSMutableDictionary *)refreshDict{
  59. if(!_refreshDict){
  60. _refreshDict = [NSMutableDictionary dictionary];
  61. }
  62. return _refreshDict;
  63. }
  64. @end