50 lines
1.5 KiB
Objective-C
50 lines
1.5 KiB
Objective-C
//
|
|
// MainPresenter.m
|
|
// xplan-ios
|
|
//
|
|
// Created by apple on 2021/9/8.
|
|
//
|
|
|
|
#import "MainPresenter.h"
|
|
#import "AccountInfoStorage.h"
|
|
#import "AccountModel.h"
|
|
#import "Api+Main.h"
|
|
#import "MainProtocol.h"
|
|
#import "NSObject+JSONString.h"
|
|
|
|
@implementation MainPresenter
|
|
|
|
- (void)autoLogin {
|
|
AccountModel *accountModel = [[AccountInfoStorage instance] getCurrentAccountInfo];
|
|
if (accountModel == nil) {
|
|
[[self getView] tokenInvalid];
|
|
return;
|
|
}
|
|
if ([[AccountInfoStorage instance] getTicket].length > 0) {
|
|
return;
|
|
}
|
|
[Api requestTicket:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
NSArray *tickets = [data.data valueForKey:@"tickets"];
|
|
NSString *ticket = [tickets[0] valueForKey:@"ticket"];
|
|
[[AccountInfoStorage instance] saveTicket:ticket];
|
|
[[self getView] autoLoginSuccess];
|
|
}] access_token:accountModel.access_token issue_type:@"multi"];
|
|
}
|
|
|
|
- (void)getUserInfo {
|
|
[Api getUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
[[self getView] getUserInfoSuccess:[UserInfoModel modelWithDictionary:data.data]];
|
|
}] uid:[[AccountInfoStorage instance] getUid]];
|
|
}
|
|
|
|
/// 批量验证内购掉单
|
|
/// @param transcations 凭据的数组
|
|
- (void)checkTranscationIds:(NSArray *)transcations {
|
|
NSString * transcationIdStr = [transcations objectToJSONString];
|
|
[Api requestCheckTranscationIdsWithComplection:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
|
|
[[self getView] checkTranscationIdsSuccess];
|
|
}] transcationIdStr:transcationIdStr];
|
|
}
|
|
|
|
@end
|