Files
real-e-party-iOS/YuMi/Modules/YMLogin/Presenter/LoginVerifCodePresent.m
edwinQQQ a35a711be6 chore: Initial clean commit
- Removed YuMi/Library/ (138 MB, not tracked)
- Removed YuMi/Resources/ (23 MB, not tracked)
- Removed old version assets (566 files, not tracked)
- Excluded Pods/, xcuserdata/ and other build artifacts
- Clean repository optimized for company server deployment
2025-10-09 16:19:14 +08:00

90 lines
3.8 KiB
Objective-C

//
// LoginVerifCodePresent.m
// YUMI
//
// Created by YUMI on 2021/9/9.
//
#import "LoginVerifCodePresent.h"
///第三方
#import <ReactiveObjC/ReactiveObjC.h>
///Tool
#import "AccountInfoStorage.h"
#import "DESEncrypt.h"
#import "YUMIConstant.h"
///Api
#import "Api+Login.h"
///Presenter
#import "LoginVerifCodePresent.h"
///Protocol
#import "LoginVerifCodeProtocol.h"
///Model
#import "AccountModel.h"
@implementation LoginVerifCodePresent
- (id<LoginVerifCodeProtocol>)getView {
return ((id<LoginVerifCodeProtocol>) [super getView]);
}
/// 获取手机的验证码
/// @param phone 手机号
/// @param type 类型
- (void)phoneSmsCode:(NSString *)phone type:(GetSmsType)type phoneAreaCode:(NSString *)phoneAreaCode {
NSString * desPhone = [DESEncrypt encryptUseDES:phone key:KeyWithType(KeyType_PasswordEncode)];
[Api phoneSmsCode:[self createHttpCompletion:^(id _Nonnull data) {
[[self getView] phoneSmsCodeSuccess];
}] mobile:desPhone type:[NSString stringWithFormat:@"%lu", (unsigned long)type] phoneAreaCode:phoneAreaCode];
}
/// 使用手机号和验证码登录
/// @param phone 手机号
/// @param code 验证码
- (void)loginWithPhone:(NSString *)phone code:(NSString *)code phoneAreaCode:(NSString *)phoneAreaCode{
NSString * desPhone = [DESEncrypt encryptUseDES:phone key:KeyWithType(KeyType_PasswordEncode)];
[Api loginWithCode:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
AccountModel * accountModel = [AccountModel modelWithDictionary:data.data];
if (accountModel && accountModel.access_token.length > 0) {
[[AccountInfoStorage instance] saveAccountInfo:accountModel];
}
[[self getView] loginWithPhoenSuccess];
} fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView] loginFailWithMsg:msg];
} errorToast:YES] phone:desPhone code:code client_secret:@"uyzjdhds" version:@"1" client_id:@"erban-client" grant_type:@"password" phoneAreaCode:phoneAreaCode];
}
/// 使用手机号和密码登录
/// @param phone 手机号
/// @param password 验证码
- (void)loginWithPhone:(NSString *)phone password:(NSString *)password {
NSString * desPassword = [DESEncrypt encryptUseDES:password key:KeyWithType(KeyType_PasswordEncode)];
NSString * desPhone = [DESEncrypt encryptUseDES:phone key:KeyWithType(KeyType_PasswordEncode)];
[Api loginWithPassword:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
AccountModel * accountModel = [AccountModel modelWithDictionary:data.data];
if (accountModel && accountModel.access_token.length > 0) {
[[AccountInfoStorage instance] saveAccountInfo:accountModel];
}
[[self getView] loginSuccess];
} fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView] loginFailWithMsg:msg];
} errorToast:YES] phone:desPhone password:desPassword client_secret:@"uyzjdhds" version:@"1" client_id:@"erban-client" grant_type:@"password"];
}
/// 绑定手机号
/// @param phone 手机号
/// @param code 验证码
- (void)bindWithPhone:(NSString *)phone code:(NSString *)code phoneAreaCode:(NSString *)phoneAreaCode{
NSString * ticket = [[AccountInfoStorage instance] getTicket];
NSString * desPhone = [DESEncrypt encryptUseDES:phone key:KeyWithType(KeyType_PasswordEncode)];
[Api bindMoblieCode:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] bindPhoneSuccess];
} showLoading:YES] phone:desPhone code:code ticket:ticket phoneAreaCode:phoneAreaCode];
}
-(void)bindAuthorizationCodeWithAuthCode:(NSString *)authCode{
[Api bindAuthorizationCode:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] bindAuthorizationCodeSuccess];
}fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView]bindAuthorizationCodeFail];
} showLoading:YES errorToast:YES] authCode:authCode];
}
@end