| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 | ////  ASUserInfoManager.m//  Asteria////  Created by iOS on 2023/11/27.//#import "ASUserInfoManager.h"#import "ASVipUrlTempModel.h"@interface ASUserInfoManager ()@end@implementation ASUserInfoManager+ (instancetype)shared {    static id sharedInstance = nil;    static dispatch_once_t onceToken;    dispatch_once(&onceToken, ^{        sharedInstance = [[self alloc] init];    });    return sharedInstance;}- (instancetype)init{    self = [super init];    if (self) {            }    return self;}- (void)getInfo {    [self baseInfoNet:^{            }];    [self vipInfoNet];    [self birthInfoNet];}- (void)baseInfoNet:(void(^)(void))comp {    [ASNetTools.shared getWithPath:userinfoUrl param:@{} success:^(id _Nonnull json) {        self.userInfo = [ASUserModel mj_objectWithKeyValues:json];        [NSNotificationCenter.defaultCenter postNotificationName:UserInfoUpdate object:nil];        NSLog(@"----userInfo:%@-----id:%@----issub:%u----address:%@----", self.userInfo, self.userInfo.Id, self.userInfo.is_subscribed, self.userInfo.addresses);        comp();    } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {        [Current_normalTool.currentNav.topViewController.view makeToast:msg];        comp();    }];}- (void)birthInfoNet {    [ASNetTools.shared getWithPath:userBirthUrl param:@{} success:^(id _Nonnull json) {        self.birthDay = [NSString stringWithFormat:@"%@", json[@"birthDay"]];        self.birthStatus = [NSString stringWithFormat:@"%@", json[@"status"]];        self.amount = [NSString stringWithFormat:@"%@", json[@"amount"]];        self.code = [NSString stringWithFormat:@"%@", json[@"code"]];        self.typeId = [NSString stringWithFormat:@"%@", json[@"typeid"]];            } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {        [Current_normalTool.currentNav.topViewController.view makeToast:msg];    }];}- (void)vipInfoNet {    [ASNetTools.shared getWithPath:vipInfoUrl param:@{} success:^(id _Nonnull json) {                ASVipUrlTempModel *tempModel = [ASVipUrlTempModel mj_objectWithKeyValues:json];        self.pointAmount = tempModel.amount;        self.userPoints = tempModel.balanceAmount;        NSMutableArray<ASVipModel *> *arr = [NSMutableArray array];        ASVipModel *cur = [ASVipModel new];        ASVipModel *next = [ASVipModel new];        if (tempModel != nil && tempModel.membergrade.count != 0) {            NSArray *keys = tempModel.membergrade.allKeys;            NSMutableArray *sortedArr = [NSMutableArray array];            for (NSString *key in keys) {                if (sortedArr.count == 0) {                    [sortedArr addObject:key];                    continue;                }                for (int i=0; i<sortedArr.count; i++) {                    NSString *this = sortedArr[i];                    if (sortedArr.count > i+1) {                        NSString *nx = sortedArr[i+1];                        if (key.intValue >= this.intValue && key.intValue < nx.intValue) {                            [sortedArr insertObject:key atIndex:i+1];                            break;                        }                    } else {                        if (sortedArr.count == 1 && key.intValue <= this.intValue) {                            [sortedArr insertObject:key atIndex:i];                        } else {                            [sortedArr addObject:key];                        }                        break;                    }                }                            }            for (int i=0; i<sortedArr.count; i++) {                ASVipModel *vipM = [ASVipModel mj_objectWithKeyValues: tempModel.membergrade[sortedArr[i]]];                if (i+1<sortedArr.count) {                    ASVipModel *tempNext = [ASVipModel mj_objectWithKeyValues: tempModel.membergrade[sortedArr[i+1]]];                    vipM.nextExppoints = tempNext.exppoints;                }                if (cur.level.intValue > 0 && next.level.intValue <= 0) {                    next = vipM;                }                if (vipM.is_cur) {                    cur = vipM;                }                if (cur.level.intValue > 0 && next.level.intValue <= 0 && i == sortedArr.count-1) {                    next = vipM;                }                [arr addObject:vipM];            }        }        self.curVipInfo = cur;        self.nextVipInfo = next;        self.vipInfoArr = arr;        [NSNotificationCenter.defaultCenter postNotificationName:UserInfoUpdate object:nil];            } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {        [Current_normalTool.currentNav.topViewController.view makeToast:msg];    }];}- (BOOL)isLogin {    NSString *token = [DataUtil loginToken];    return !(token == nil || [token isEqualToString:@""]);}@end
 |