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
This commit is contained in:
edwinQQQ
2025-10-09 16:19:14 +08:00
commit a35a711be6
5582 changed files with 408913 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
//
// MyDressingDataModel.h
// YuMi
//
// Created by P on 2024/11/19.
//
#import "PIBaseModel.h"
#import "CarModel.h"
#import "NobleCardModel.h"
#import "NameplateModel.h"
#import "ChatBubbleModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface MyDressingDataModel : PIBaseModel
//dressId = 191;
//dressType = 0;
//effect = "https://image.pekolive.com/Vip1headdress.svga";
//effectType = 2;
//expireDays = 44;
//expireTime = 1735812327000;
//hasExpired = 0;
//name = "VIP1\U982d\U98fe";
//obtainWay = 1;
//pic = "https://image.pekolive.com/Vip1headdress.png";
//used = 0;
@property(nonatomic, assign) NSInteger id;
@property(nonatomic, copy) NSString *dressId;
@property(nonatomic, assign) NSInteger dressType;
@property(nonatomic, copy) NSString *effect;
@property(nonatomic, assign) NSInteger effectType;
@property(nonatomic, assign) NSInteger expireDays;
@property(nonatomic, assign) NSInteger expireTime;
@property(nonatomic, assign) BOOL hasExpired;
@property(nonatomic, copy) NSString *name;
@property(nonatomic, assign) NSInteger obtainWay; // "获得方式1-普通2-活动"
@property(nonatomic, copy) NSString *pic;
@property(nonatomic, assign) NSInteger used;
@property(nonatomic, strong) NSNumber *discount;
@property(nonatomic, assign) NSInteger dressDay;
@property(nonatomic, assign) CGFloat discountPrice;
@property(nonatomic, assign) NSInteger vipLevel;
@property(nonatomic, assign) NSInteger dressPrice;
@property(nonatomic, copy) NSString *dressShopId;
- (NSString *)expiredContent;
- (NSMutableAttributedString *)generateAttributedStringWithIncludeOriginalPrice:(BOOL)includeOriginalPrice;
+ (MyDressingDataModel *)modelFromVehicle:(CarModel *)model;
+ (MyDressingDataModel *)modelFromNameplate:(NameplateModel *)model;
+ (MyDressingDataModel *)modelFromNobelCard:(NobleCardModel *)model;
+ (MyDressingDataModel *)modelFromChatBubble:(ChatBubbleModel *)model;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,207 @@
//
// MyDressingDataModel.m
// YuMi
//
// Created by P on 2024/11/19.
//
#import "MyDressingDataModel.h"
@implementation MyDressingDataModel
// JSON
+ (NSDictionary *)mj_replacedKeyFromPropertyName {
return @{
@"dressShopId" : @"id"
};
}
////
//- (id)mj_newValueFromOldValue:(id)oldValue property:(MJProperty *)property {
// if ([property.name isEqualToString:@"dressShopId"]) {
// if ([oldValue isKindOfClass:[NSNumber class]]) {
// // NSNumber NSString
// return [oldValue stringValue];
// }
// }
// return oldValue;
//}
- (NSString *)expiredContent {
if (self.hasExpired) {
return YMLocalizedString(@"XPMineCarTableViewCell1");
} else {
NSString *content = @"";
if (self.expireDays < 1) {
content = YMLocalizedString(@"1.0.30_text_13");
} else {
content = [NSString stringWithFormat:YMLocalizedString(@"1.0.18_8"), @(self.expireDays)];
}
return content;
}
}
- (NSMutableAttributedString *)generateAttributedStringWithIncludeOriginalPrice:(BOOL)includeOriginalPrice {
// NSMutableAttributedString
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init];
// 1.
NSTextAttachment *coinAttachment = [[NSTextAttachment alloc] init];
coinAttachment.image = kImage(@"moli_money_icon"); //
coinAttachment.bounds = CGRectMake(0, -2, 18, 18); //
NSAttributedString *coinString = [NSAttributedString attributedStringWithAttachment:coinAttachment];
[attributedString appendAttributedString:coinString];
// 2.
NSAttributedString *spaceString = [[NSAttributedString alloc] initWithString:@" "];
[attributedString appendAttributedString:spaceString];
// 3. price #F8CE1F 25
NSDictionary *priceAttributes = @{
NSFontAttributeName: kFontSemibold(15),
NSForegroundColorAttributeName: UIColorFromRGB(0xF8CE1F)
};
NSString *formattedPriceString = [self formatPrice: self.vipLevel>0 ? self.discountPrice : self.dressPrice];
NSAttributedString *priceString = [[NSAttributedString alloc] initWithString:formattedPriceString attributes:priceAttributes];
[attributedString appendAttributedString:priceString];
// 4. day #F8CE1F 12
NSDictionary *dayAttributes = @{
NSFontAttributeName: kFontRegular(12),
NSForegroundColorAttributeName: UIColorFromRGB(0xF8CE1F)
};
NSString *formattedDayString = [NSString stringWithFormat:@"/%ldD ", (long)self.dressDay];
NSAttributedString *dayString = [[NSAttributedString alloc] initWithString:formattedDayString attributes:dayAttributes];
[attributedString appendAttributedString:dayString];
//
if (includeOriginalPrice && self.vipLevel > 0) {
NSDictionary *originalPriceAttributes = @{
NSFontAttributeName: kFontRegular(12),
NSForegroundColorAttributeName: UIColorRGBAlpha(0xD9E7F7, 0.5f),
NSStrikethroughStyleAttributeName: @(NSUnderlineStyleSingle), // 线
NSStrikethroughColorAttributeName: UIColorRGBAlpha(0xD9E7F7, 0.5f) // 线
};
NSString *originalPriceString = [NSString stringWithFormat:@"%@", [self formatPrice:self.dressPrice]];
NSAttributedString *originalPriceAttributedString = [[NSAttributedString alloc] initWithString:originalPriceString attributes:originalPriceAttributes];
[attributedString appendAttributedString:originalPriceAttributedString];
}
return attributedString;
}
// 0-2
- (NSString *)formatPrice:(CGFloat)price {
// if (fmod(price, 1.0) == 0.0) {
// //
// return [NSString stringWithFormat:@"%.0f", price];
// } else if (fmod(price * 10, 1.0) == 0.0) {
// // 1
// return [NSString stringWithFormat:@"%.1f", price];
// } else {
// // 2
// return [NSString stringWithFormat:@"%.2f", price];
// }
NSString *priceString = [NSString stringWithFormat:@"%.8f", price]; //
NSArray<NSString *> *components = [priceString componentsSeparatedByString:@"."]; //
NSString *integerPart = components[0];
NSString *decimalPart = components.count > 1 ? components[1] : @"";
if (decimalPart.length > 2) {
//
decimalPart = [decimalPart substringToIndex:2];
}
if ([decimalPart isEqualToString:@"00"]) {
// 00
return integerPart;
} else if ([decimalPart hasSuffix:@"0"]) {
// 0 1
decimalPart = [decimalPart substringToIndex:1];
}
//
return [NSString stringWithFormat:@"%@.%@", integerPart, decimalPart];
}
+ (MyDressingDataModel *)modelFromVehicle:(CarModel *)model {
MyDressingDataModel *myDressingVehicle = [[MyDressingDataModel alloc] init];
myDressingVehicle.dressId = model.dressShopId;
myDressingVehicle.id = model.carID.integerValue;
myDressingVehicle.pic = model.pic;
myDressingVehicle.name = model.name;
myDressingVehicle.used = model.using;
myDressingVehicle.expireDays = model.expireDate;
myDressingVehicle.hasExpired = (model.status != 3 || model.expireDate<0);
myDressingVehicle.dressType = 1;
myDressingVehicle.discount = model.discount;
myDressingVehicle.discountPrice = model.discountPrice;
myDressingVehicle.dressPrice = model.dressPrice;
myDressingVehicle.vipLevel = model.vipLevel;
myDressingVehicle.dressShopId = model.dressShopId;
myDressingVehicle.effect = model.effect;
return myDressingVehicle;
}
+ (MyDressingDataModel *)modelFromNameplate:(NameplateModel *)model {
MyDressingDataModel *myDressingNameplate = [[MyDressingDataModel alloc] init];
myDressingNameplate.pic = model.nameplateImage;
myDressingNameplate.name = model.nameplateName;
myDressingNameplate.used = model.isUsing;
myDressingNameplate.expireDays = model.expireDays;
myDressingNameplate.expireTime = model.expireTime;
myDressingNameplate.hasExpired = model.isExpired;
myDressingNameplate.id = model.nId.integerValue;
myDressingNameplate.dressId = model.dressShopId;// model.nameplateId;
myDressingNameplate.dressType = 2;
myDressingNameplate.discount = model.discount;
myDressingNameplate.dressDay = model.dressDay;
myDressingNameplate.discountPrice = model.discountPrice;
myDressingNameplate.vipLevel = model.vipLevel;
myDressingNameplate.dressPrice = model.dressPrice;
myDressingNameplate.dressShopId = model.dressShopId;
myDressingNameplate.effect = model.effect;
myDressingNameplate.effectType = model.effectType;
return myDressingNameplate;
}
+ (MyDressingDataModel *)modelFromNobelCard:(NobleCardModel *)model {
MyDressingDataModel *myDressingNobrlCard = [[MyDressingDataModel alloc] init];
myDressingNobrlCard.pic = model.pic;
myDressingNobrlCard.effect = model.effect;
myDressingNobrlCard.name = model.name;
myDressingNobrlCard.used = model.used;
myDressingNobrlCard.expireDays = model.expireDays;
myDressingNobrlCard.expireTime = model.expireTime.integerValue;
myDressingNobrlCard.hasExpired = model.hasExpired;
myDressingNobrlCard.dressId = model.cardId;
myDressingNobrlCard.dressType = 3;
myDressingNobrlCard.discount = model.discount;
myDressingNobrlCard.dressDay = model.dressDay;
myDressingNobrlCard.discountPrice = model.discountPrice;
myDressingNobrlCard.vipLevel = model.vipLevel;
myDressingNobrlCard.dressPrice = model.dressPrice;
myDressingNobrlCard.dressShopId = model.dressShopId;
myDressingNobrlCard.effectType = model.effectType;
return myDressingNobrlCard;
}
+ (MyDressingDataModel *)modelFromChatBubble:(ChatBubbleModel *)model {
MyDressingDataModel *myDressingBubble = [[MyDressingDataModel alloc] init];
myDressingBubble.pic = model.bubbleUrl;
myDressingBubble.dressId = model.bubbleId;
myDressingBubble.expireDays = model.expireDays;
myDressingBubble.name = model.name;
myDressingBubble.used = model.hasUsed;
myDressingBubble.hasExpired = model.hasExpired;
myDressingBubble.dressType = 4;
myDressingBubble.dressShopId = model.bubbleId;
myDressingBubble.effect = model.effect;
myDressingBubble.effectType = model.effectType;
return myDressingBubble;
}
@end

View File

@@ -0,0 +1,53 @@
//
// MyDressingDataPresent.h
// YuMi
//
// Created by P on 2024/11/19.
//
#import "BaseMvpPresenter.h"
#import "CarModel.h"
#import "UserInfoModel.h"
#import "NobleCardModel.h"
#import "HeadwearModel.h"
#import "NameplateModel.h"
#import "ChatBubbleModel.h"
#import "MyDressingDataModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface MyDressingDataPresent : BaseMvpPresenter
- (void)loadVehicles:(void(^)(NSArray <CarModel *>*array))success
failure:(void(^)(NSError *error))failure;
- (void)loadNameplate:(NSInteger)page
success:(void(^)(NSArray <NameplateModel *>*array))success
failure:(void(^)(NSError *error))failure;
- (void)loadRoomCard:(NSInteger)page
success:(void(^)(NSArray <NobleCardModel *>*array))success
failure:(void(^)(NSError *error))failure;
- (void)loadBubble:(NSInteger)page
success:(void(^)(NSArray <ChatBubbleModel *>*array))success
failure:(void(^)(NSError *error))failure;
- (void)loadMyDressingItems:(NSInteger)type
page:(NSInteger)page
success:(void(^)(NSArray <MyDressingDataModel *>*array, NSInteger type))success
failure:(void(^)(NSError *error))failure;
- (void)useDressBy:(NSInteger)type
dressID:(NSInteger)dressID
success:(void(^)(UserInfoModel *userInfo))success
failure:(void(^)(NSError *error))failure;
- (void)rebuyItem:(NSString *)itemID
success:(void(^)(id obj))success
failure:(void(^)(NSError *error))failure;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,170 @@
//
// MyDressingDataPresent.m
// YuMi
//
// Created by P on 2024/11/19.
//
#import "MyDressingDataPresent.h"
#import "Api+DressUp.h"
@implementation MyDressingDataPresent
- (void)loadHeadWears:(void(^)(NSArray <HeadwearModel *>*array))success
failure:(void(^)(NSError *error))failure {
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * ticket = [AccountInfoStorage instance].getTicket;
[Api headwearList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
NSArray * array = [HeadwearModel modelsWithArray:data.data];
if (success) {
success(array);
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
if (failure) {
failure([NSError errorWithDomain:[NSString isEmpty:msg] ? @"" : msg code:code userInfo:nil]);
}
} showLoading:NO errorToast:YES] ticket:ticket uid:uid];
}
- (void)loadVehicles:(void(^)(NSArray <CarModel *>*array))success
failure:(void(^)(NSError *error))failure {
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * ticket = [AccountInfoStorage instance].getTicket;
[Api carList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
NSArray * array = [CarModel modelsWithArray:data.data];
if (success) {
success(array);
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
if (failure) {
failure([NSError errorWithDomain:[NSString isEmpty:msg] ? @"" : msg code:code userInfo:nil]);
}
} showLoading:NO errorToast:YES] ticket:ticket uid:uid];
}
- (void)loadNameplate:(NSInteger)page
success:(void(^)(NSArray <NameplateModel *>*array))success
failure:(void(^)(NSError *error))failure {
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * ticket = [AccountInfoStorage instance].getTicket;
[Api nameplateList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
if (success) {
NSArray *array = [NameplateModel modelsWithArray:data.data[@"nameplateList"]];
success(array);
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
} showLoading:page != 1 errorToast:YES]
ticket:ticket
uid:uid
page:@(page).stringValue
pageSize:@"20"];
}
- (void)loadRoomCard:(NSInteger)page
success:(void(^)(NSArray <NobleCardModel *>*array))success
failure:(void(^)(NSError *error))failure {
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * ticket = [AccountInfoStorage instance].getTicket;
[Api nobleCardList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
if (success) {
NSArray * array = [NobleCardModel modelsWithArray:data.data];
success(array);
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
} showLoading:page != 1 errorToast:YES]
ticket:ticket
uid:uid
page:@(page).stringValue
pageSize:@"20"];
}
- (void)loadBubble:(NSInteger)page
success:(void(^)(NSArray <ChatBubbleModel *>*array))success
failure:(void(^)(NSError *error))failure {
[Api chatBubbleList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
if (success) {
NSArray *array = [ChatBubbleModel modelsWithArray:data.data];
success(array);
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
} showLoading:page != 1 errorToast:YES] page:@(page).stringValue pageSize:@"20"];
}
- (void)loadMyDressingItems:(NSInteger)type
page:(NSInteger)page
success:(void(^)(NSArray <MyDressingDataModel *>*array, NSInteger type))success
failure:(void(^)(NSError *error))failure {
[Api mineDressItems:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
if (success) {
NSArray *models = [MyDressingDataModel modelsWithArray:data.data];
success(models, type);
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
} showLoading:page != 1 errorToast:YES]
page:@(page).stringValue
pageSize:@"20"
dressType:@(type).stringValue];
}
- (void)useDressBy:(NSInteger)type
dressID:(NSInteger)dressID
success:(void(^)(UserInfoModel *userInfo))success
failure:(void(^)(NSError *error))failure {
@kWeakify(self);
[Api optDress:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
if (type == 0) {
[self reloadUserInfo:^(UserInfoModel *userInfo) {
if (success) {
success(userInfo);
}
} failure:nil];
} else {
if (success) {
success(nil);
}
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
if (failure) {
failure([NSError errorWithDomain:[NSString isEmpty:msg] ? @"" : msg code:code userInfo:nil]);
}
} showLoading:YES errorToast:YES]
dressType:@(type).stringValue
dressId:@(dressID).stringValue];
}
- (void)reloadUserInfo:(void(^)(UserInfoModel *userInfo))success
failure:(void(^)(NSError *error))failure {
NSString * uid = [[AccountInfoStorage instance] getUid];
if (uid.length == 0) {
return;
}
[Api getUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
if (success) {
UserInfoModel * infoModel = [UserInfoModel modelWithDictionary:data.data];
success(infoModel);
}
} fail:nil showLoading:NO errorToast:YES] uid:uid];
}
- (void)rebuyItem:(NSString *)itemID
success:(void(^)(id obj))success
failure:(void(^)(NSError *error))failure {
[Api requestDressUpShopBuy:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
if (success) {
success(data.data);
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
if (failure) {
failure([NSError errorWithDomain:[NSString isEmpty:msg] ? @"" : msg code:code userInfo:nil]);
}
} showLoading:YES errorToast:YES]
id:itemID];
}
@end

View File

@@ -0,0 +1,16 @@
//
// MyDressingViewController.h
// YuMi
//
// Created by P on 2024/11/13.
//
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface MyDressingViewController : MvpViewController
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,534 @@
//
// MyDressingViewController.m
// YuMi
//
// Created by P on 2024/11/13.
//
#import "MyDressingViewController.h"
#import <SVGA.h>
#import <QGVAPWrapView.h>
#import "UserInfoModel.h"
#import "MyDressingDataPresent.h"
#import "ShoppingMallItemPreview.h"
#import "XPSkillCardPlayerManager.h"
#import "XPRoomGiftAnimationParser.h"
#import "ShoppingMallCategoryListView.h"
static NSArray<NSDictionary<NSString *, NSNumber *> *> *MyDressUpOptions(void) {
return @[
@{YMLocalizedString(@"XPMineDressUpViewController2") : @1}, //
@{YMLocalizedString(@"XPMineDressUpViewController1") : @0}, //
@{YMLocalizedString(@"XPMineDressUpViewController3") : @2}, //
@{YMLocalizedString(@"XPMineDressUpViewController4") : @3}, //
@{YMLocalizedString(@"XPMineDressUpViewController5") : @4}, //
@{YMLocalizedString(@"1.0.30_text_9") : @5} //
];
}
@interface MyDressingViewController ()
@property(nonatomic, strong) UserInfoModel *userInfo;
@property(nonatomic, strong) NetImageView *avatarView;
@property(nonatomic, strong) NetImageView *avatarHeadViewImageView;
@property(nonatomic, strong) SVGAImageView *avatarHeadWearSVGA;
@property (nonatomic, strong) UIView *playEffectMask;
@property (nonatomic, strong) VAPView *mp4Effect;
@property(nonatomic, strong) XPRoomGiftAnimationParser *mp4Parser;
@property (nonatomic, strong) SVGAImageView *svgaEffect;
@property(nonatomic, strong) UIActivityIndicatorView *loading;
@property(nonatomic, strong) MyDressingDataModel *selectedModel;
@property(nonatomic, strong) ShoppingMallCategoryListView *listView;
@end
@implementation MyDressingViewController
- (MyDressingDataPresent *)createPresenter {
return [[MyDressingDataPresent alloc] init];
}
- (BOOL)isHiddenNavBar {
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.userInfo = [XPSkillCardPlayerManager shareInstance].userInfoModel;
[self setupUI];
[self updateAvatar];
}
- (void)setupUI {
[self setupBackground];
[self setupNavigationBar];
[self setupAvatar];
[self setupContentList];
}
- (void)setupBackground {
self.view.backgroundColor = UIColorFromRGB(0x02061D);
UIImageView *topBG = [[UIImageView alloc] initWithImage:kImage(@"mall_top_bg")];
[self.view addSubview:topBG];
[topBG mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.leading.trailing.mas_equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(200));
}];
}
- (void)setupNavigationBar {
UILabel *titleLabel = [self titleLabel];
UIButton *backButton = [self backButton];
[self.view addSubview:titleLabel];
[self.view addSubview:backButton];
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.top.mas_equalTo(self.view).offset(44 + 11);
make.height.mas_equalTo(22);
}];
[backButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.view).offset(16);
make.centerY.mas_equalTo(titleLabel);
make.size.mas_equalTo(CGSizeMake(22, 22));
}];
}
- (void)setupAvatar {
[self.view addSubview:self.avatarView];
[self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(100);
make.centerX.mas_equalTo(self.view);
make.size.mas_equalTo(CGSizeMake(kGetScaleWidth(73), kGetScaleWidth(73)));
}];
[self.view addSubview:self.avatarHeadViewImageView];
[self.avatarHeadViewImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.avatarView);
make.size.mas_equalTo(self.avatarView).multipliedBy(1.3);
}];
[self.view addSubview:self.avatarHeadWearSVGA];
[self.avatarHeadWearSVGA mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.avatarView);
make.size.mas_equalTo(self.avatarView).multipliedBy(1.3);
}];
}
- (void)setupContentList {
NSInteger bottom = kSafeAreaBottomHeight;
// 使 frame height
ShoppingMallCategoryListView *listView = [[ShoppingMallCategoryListView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight - 100 - 73)];
listView.isForMyDressingPage = YES;
listView.bottomSpace = bottom;
[self.view addSubview:listView];
[listView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.avatarView.mas_bottom).offset(16);
make.leading.trailing.bottom.mas_equalTo(self.view);
}];
@kWeakify(self);
listView.fetchDataForMyDressingPage = ^(NSInteger pageIndex, NSInteger pageNum, FetchDataForMyDressingCompletion _Nonnull completion) {
@kStrongify(self);
[self fetchDataForPage:pageIndex
pageNum:pageNum
completion:completion];
};
listView.didTapItemPlay = ^(NSString * _Nonnull resourcePath, NSInteger effectType, NSInteger type) {
@kStrongify(self);
CGSize size = CGSizeZero;
switch (type) {
case 0: //
size = CGSizeMake(kGetScaleWidth(183), kGetScaleWidth(183));
break;
case 5:
size = CGSizeMake(KScreenWidth - 20, KScreenWidth - 20);
break;
default:
size = CGSizeMake(KScreenWidth, KScreenHeight);
break;
}
[self playItemEffect:resourcePath effectType:effectType size:size];
};
listView.returnMyDressingSelectedModel = ^(MyDressingDataModel * _Nonnull model, NSInteger type, NSIndexPath *indexPath) {
@kStrongify(self);
[self handTapItem:model type:type indexPath:indexPath];
};
listView.items = MyDressUpOptions();
self.listView = listView;
}
- (void)updateAvatar {
self.avatarView.imageUrl = self.userInfo.avatar;
if ([NSString isEmpty:self.userInfo.headwearEffect]) {
[self.avatarHeadWearSVGA stopAnimation];
self.avatarHeadWearSVGA.hidden = YES;
} else {
if ([self.userInfo.headwearEffect.lowercaseString hasSuffix:@"svga"]) {
self.avatarHeadWearSVGA.hidden = NO;
self.avatarHeadViewImageView.hidden = YES;
SVGAParser *p = [[SVGAParser alloc] init];
[p parseWithURL:[NSURL URLWithString:self.userInfo.headwearEffect]
completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
self.avatarHeadWearSVGA.videoItem = videoItem;
[self.avatarHeadWearSVGA startAnimation];
self.avatarHeadWearSVGA.hidden = NO;
} failureBlock:^(NSError * _Nullable error) {}];
} else {
self.avatarHeadWearSVGA.hidden = YES;
self.avatarHeadViewImageView.hidden = NO;
self.avatarHeadViewImageView.imageUrl = self.userInfo.headwearEffect;
}
}
}
#pragma mark -
- (void)fetchDataForPage:(NSInteger)pageIndex
pageNum:(NSInteger)pageNum
completion:(FetchDataForMyDressingCompletion)completion {
switch (pageIndex) {
case 0: {
[self.presenter loadMyDressingItems:0
page:pageNum
success:^(NSArray <MyDressingDataModel *>* _Nonnull array, NSInteger type) {
if (completion) {
completion(array);
}
} failure:^(NSError * _Nonnull error) {
}];
}
break;
case 1: {
[self.presenter loadVehicles:^(NSArray <CarModel *>* _Nonnull array) {
if (completion) {
NSMutableArray *transArray = @[].mutableCopy;
for (CarModel *car in array) {
MyDressingDataModel *model = [MyDressingDataModel modelFromVehicle:car];
[transArray addObject:model];
}
completion(transArray);
}
} failure:^(NSError * _Nonnull error) { }];
}
break;
case 2: {
[self.presenter loadNameplate:pageNum
success:^(NSArray<NameplateModel *> * _Nonnull array) {
if (completion) {
NSMutableArray *transArray = @[].mutableCopy;
for (NameplateModel *nameplate in array) {
MyDressingDataModel *model = [MyDressingDataModel modelFromNameplate:nameplate];
[transArray addObject:model];
}
completion(transArray);
}
} failure:^(NSError * _Nonnull error) {
}];
}
break;
case 3: {
[self.presenter loadRoomCard:pageNum
success:^(NSArray<NobleCardModel *> * _Nonnull array) {
if (completion) {
NSMutableArray *transArray = @[].mutableCopy;
for (NobleCardModel *nobleCard in array) {
MyDressingDataModel *model = [MyDressingDataModel modelFromNobelCard:nobleCard];
[transArray addObject:model];
}
completion(transArray);
}
} failure:^(NSError * _Nonnull error) {
}];
}
break;
case 4: {
[self.presenter loadBubble:pageNum
success:^(NSArray<ChatBubbleModel *> * _Nonnull array) {
if (completion) {
NSMutableArray *transArray = @[].mutableCopy;
for (ChatBubbleModel *bubble in array) {
MyDressingDataModel *model = [MyDressingDataModel modelFromChatBubble:bubble];
[transArray addObject:model];
}
completion(transArray);
}
} failure:^(NSError * _Nonnull error) {
}];
}
break;
case 5: {
[self.presenter loadMyDressingItems:5
page:pageNum
success:^(NSArray <MyDressingDataModel *>* _Nonnull array, NSInteger type) {
if (completion) {
completion(array);
}
} failure:^(NSError * _Nonnull error) {
}];
}
break;
default:
break;
}
}
- (void)handTapItem:(MyDressingDataModel *)model
type:(NSInteger)type
indexPath:(NSIndexPath *)indexPath {
if (model.hasExpired) {
//
BOOL isVaild = model.obtainWay<=1;
if (isVaild) {
isVaild = ![NSString isEmpty:model.dressShopId] && model.dressShopId.integerValue > 0;
}
ShoppingMallItemPreview *preview = [[ShoppingMallItemPreview alloc] initWithMyDress:model
isVaild:isVaild];
preview.frame = CGRectMake(0, 0, 284, 353);
[TTPopup popupView:preview style:TTPopupStyleAlert];
@kWeakify(self);
[preview setRebuyWith:^(MyDressingDataModel * _Nonnull model) {
@kStrongify(self);
@kWeakify(self)
[self.presenter rebuyItem:model.dressShopId
success:^(id _Nonnull obj) {
@kStrongify(self);
[TTPopup dismiss];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self showSuccessToast:YMLocalizedString(@"XPDressUpShopListViewController0")];
[self.listView updateSelectedItem:indexPath];
});
} failure:^(NSError * _Nonnull error) {
@kStrongify(self);
[self showErrorToast:error.localizedDescription];
}];
}];
} else {
// 使
NSInteger dressID = 0;
if (model) {
if (type == 1 || type == 2) {
dressID = model.id;
} else {
dressID = model.dressId.integerValue;
}
}
@kWeakify(self);
[self.presenter useDressBy:type
dressID:dressID
success:^(UserInfoModel *userInfo){
@kStrongify(self);
if (userInfo) {
self.userInfo = userInfo;
[XPSkillCardPlayerManager shareInstance].userInfoModel = userInfo;
[self updateAvatar];
}
[self.listView updateSelectedItem:indexPath];
} failure:^(NSError * _Nonnull error) {
// NSLog(@"%@", error);
}];
}
}
#pragma mark -
- (void)didTapBack {
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark -
- (void)playItemEffect:(NSString *)path
effectType:(NSInteger)effectType
size:(CGSize)size {
if (!_playEffectMask) {
[self.view addSubview:self.playEffectMask];
[self.playEffectMask mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
}];
[self.playEffectMask addSubview:self.svgaEffect];
[self.playEffectMask addSubview:self.mp4Effect];
}
[self.svgaEffect mas_updateConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.playEffectMask);
make.size.mas_equalTo(size);
}];
[self.mp4Effect mas_updateConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.playEffectMask);
make.size.mas_equalTo(size);
}];
self.playEffectMask.hidden = NO;
[self.loading startAnimating];
if ([path.lowercaseString hasSuffix:@"mp4"] || effectType == 1) {
[self playMP4:path];
} else if ([path.lowercaseString hasSuffix:@"svga"] || effectType == 2) {
[self playSVGA:path];
} else {
[self playSVGA:path];
}
}
- (void)playMP4:(NSString *)path {
@kWeakify(self);
[self.mp4Parser parseWithURL:path
completionBlock:^(NSString * _Nullable videoUrl) {
@kStrongify(self);
[self.loading stopAnimating];
self.mp4Effect.hidden = NO;
[self.mp4Effect playHWDMP4:videoUrl repeatCount:-1 delegate:nil];
} failureBlock:^(NSError * _Nullable error) {
@kStrongify(self);
[self stopItemEffect];
}];
}
- (void)playSVGA:(NSString *)path {
@kWeakify(self);
SVGAParser *p = [[SVGAParser alloc] init];
[p parseWithURL:[NSURL URLWithString:path]
completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
@kStrongify(self);
[self.loading stopAnimating];
self.svgaEffect.hidden = NO;
self.svgaEffect.videoItem = videoItem;
[self.svgaEffect startAnimation];
} failureBlock:^(NSError * _Nullable error) {
@kStrongify(self);
[self stopItemEffect];
}];
}
- (void)stopItemEffect {
[self.loading stopAnimating];
[self.svgaEffect stopAnimation];
self.svgaEffect.hidden = YES;
[self.mp4Effect stopHWDMP4];
self.mp4Effect.hidden = YES;
self.playEffectMask.hidden = YES;
}
#pragma mark -
- (UIButton *)backButton {
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
[b setImage:[kImage(@"common_nav_back_white") ms_SetImageForRTL]
forState:UIControlStateNormal];
[b addTarget:self
action:@selector(didTapBack)
forControlEvents:UIControlEventTouchUpInside];
return b;
}
- (UILabel *)titleLabel {
UILabel *label = [[UILabel alloc] init];
label.textAlignment = NSTextAlignmentCenter;
label.font = kFontMedium(17);
label.text = YMLocalizedString(@"1.0.30_text_8");
label.textColor = UIColorFromRGB(0xD9E7F7);
return label;
}
- (UIView *)playEffectMask {
if (!_playEffectMask) {
_playEffectMask = [[UIView alloc] initWithFrame:self.view.bounds];
_playEffectMask.backgroundColor = [UIColor colorWithWhite:0 alpha:0.7f];
[_playEffectMask addSubview:self.loading];
[self.loading mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(_playEffectMask);
}];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(stopItemEffect)];
[_playEffectMask addGestureRecognizer:tap];
}
return _playEffectMask;
}
- (SVGAImageView *)svgaEffect {
if (!_svgaEffect) {
_svgaEffect = [[SVGAImageView alloc] init];
_svgaEffect.contentMode = UIViewContentModeScaleAspectFit;
_svgaEffect.autoPlay = YES;
_svgaEffect.loops = 0;
_svgaEffect.clearsAfterStop = YES;
_svgaEffect.hidden = YES;
_svgaEffect.userInteractionEnabled = YES;
}
return _svgaEffect;
}
- (VAPView *)mp4Effect {
if (!_mp4Effect) {
_mp4Effect = [[VAPView alloc] init];
_mp4Effect.contentMode = UIViewContentModeScaleAspectFit;
}
return _mp4Effect;
}
- (XPRoomGiftAnimationParser *)mp4Parser {
if (!_mp4Parser) {
_mp4Parser = [[XPRoomGiftAnimationParser alloc] init];
}
return _mp4Parser;
}
- (UIActivityIndicatorView *)loading {
if (!_loading) {
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
indicator.translatesAutoresizingMaskIntoConstraints = NO;
indicator.hidesWhenStopped = YES;
_loading = indicator;
}
return _loading;
}
- (NetImageView *)avatarHeadViewImageView {
if (!_avatarHeadViewImageView) {
_avatarHeadViewImageView = [[NetImageView alloc] init];
_avatarHeadViewImageView.contentMode = UIViewContentModeScaleAspectFit;
}
return _avatarHeadViewImageView;
}
- (NetImageView *)avatarView {
if (!_avatarView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.imageType = ImageTypeUserIcon;
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_avatarView = [[NetImageView alloc] initWithConfig:config];
[_avatarView setCornerRadius:kGetScaleWidth(73)/2
corners:kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner | kCALayerMinXMaxYCorner | kCALayerMaxXMaxYCorner
borderWidth:2
borderColor:UIColorFromRGB(0xFBD99A)];
}
return _avatarView;
}
- (SVGAImageView *)avatarHeadWearSVGA {
if (!_avatarHeadWearSVGA) {
_avatarHeadWearSVGA = [[SVGAImageView alloc] init];
_avatarHeadWearSVGA.contentMode = UIViewContentModeScaleAspectFit;
_avatarHeadWearSVGA.autoPlay = YES;
_avatarHeadWearSVGA.loops = 0;
_avatarHeadWearSVGA.clearsAfterStop = YES;
}
return _avatarHeadWearSVGA;
}
@end

View File

@@ -0,0 +1,39 @@
//
// ShoppingMallCategoryListView.h
// YuMi
//
// Created by P on 2024/11/13.
//
#import <UIKit/UIKit.h>
#import "DressUpShopModel.h"
#import "MyDressingDataModel.h"
NS_ASSUME_NONNULL_BEGIN
typedef void (^DidTapPlay)(NSString *resourcePath, NSInteger effectType, NSInteger type);
typedef void (^FetchDataCompletion)(NSArray <DressUpShopModel *>* modelList);
typedef void (^FetchDataForPage)(NSInteger pageIndex, FetchDataCompletion completion);
typedef void (^FetchDataForMyDressingCompletion)(NSArray <MyDressingDataModel *>* modelList);
typedef void (^FetchDataForMyDressingPage)(NSInteger pageIndex, NSInteger pageNum, FetchDataForMyDressingCompletion completion);
@interface ShoppingMallCategoryListView : UIView
@property(nonatomic, assign) CGFloat bottomSpace;
@property(nonatomic, assign) CGFloat isForMyDressingPage;
/// 每个 category 的定义,{名称:类型}
@property (nonatomic, copy) NSArray<NSDictionary<NSString *, NSNumber *> *> *items;
@property (nonatomic, copy) FetchDataForPage fetchDataForPage;
@property(nonatomic, copy) FetchDataForMyDressingPage fetchDataForMyDressingPage;
@property (nonatomic, copy) DidTapPlay didTapItemPlay;
@property(nonatomic, copy) void(^returnSelectedModel)(DressUpShopModel * _Nullable model);
@property(nonatomic, copy) void(^returnMyDressingSelectedModel)(MyDressingDataModel * _Nullable model, NSInteger type, NSIndexPath *indexPath);
- (void)updateSelectedItem:(NSIndexPath *)indexPath;
@end
NS_ASSUME_NONNULL_END

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,26 @@
//
// ShoppingMallDataPresent.h
// YuMi
//
// Created by P on 2024/11/13.
//
#import "BaseMvpPresenter.h"
#import "DressUpShopModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface ShoppingMallDataPresent : BaseMvpPresenter
/// 获取装扮商城列表
/// @param type 类型 0铭牌1头饰2座驾3资料卡4聊天气泡
- (void)loadCategoryItems:(NSInteger)type
success:(void(^)(NSArray <DressUpShopModel *>* array))success
failure:(void(^)(NSError *error))failure;
- (void)buyItem:(NSString *)itemID
success:(void(^)(id obj))success
failure:(void(^)(NSError *error))failure;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,45 @@
//
// ShoppingMallDataPresent.m
// YuMi
//
// Created by P on 2024/11/13.
//
#import "ShoppingMallDataPresent.h"
#import "Api+DressUp.h"
@implementation ShoppingMallDataPresent
- (void)loadCategoryItems:(NSInteger)type
success:(nonnull void (^)(NSArray <DressUpShopModel *>* array))success
failure:(nonnull void (^)(NSError * _Nonnull))failure{
[Api requestDressUpShopList:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
if (success) {
NSArray *array = [DressUpShopModel modelsWithArray:data.data];
success(array);
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
if (failure) {
failure([NSError errorWithDomain:[NSString isEmpty:msg] ? @"" : msg code:code userInfo:nil]);
}
} showLoading:NO errorToast:YES]
dressType:@(type).stringValue];
}
- (void)buyItem:(NSString *)itemID
success:(void(^)(id obj))success
failure:(void(^)(NSError *error))failure {
[Api requestDressUpShopBuy:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
if (success) {
success(data.data);
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
if (failure) {
failure([NSError errorWithDomain:[NSString isEmpty:msg] ? @"" : msg code:code userInfo:nil]);
}
} showLoading:YES errorToast:YES]
id:itemID];
}
@end

View File

@@ -0,0 +1,26 @@
//
// ShoppingMallItemPreview.h
// YuMi
//
// Created by P on 2024/11/18.
//
#import <UIKit/UIKit.h>
@class DressUpShopModel, MyDressingDataModel;
NS_ASSUME_NONNULL_BEGIN
@interface ShoppingMallItemPreview : UIView
@property(nonatomic, copy) void(^buyWith)(DressUpShopModel *model);
@property(nonatomic, copy) void(^giveWith)(DressUpShopModel *model);
@property(nonatomic, copy) void(^rebuyWith)(MyDressingDataModel *model);
- (instancetype)initWith:(DressUpShopModel *)model isForGive:(BOOL)isForGive;
- (instancetype)initWithMyDress:(MyDressingDataModel *)model isVaild:(BOOL)isVaild;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,395 @@
//
// ShoppingMallItemPreview.m
// YuMi
//
// Created by P on 2024/11/18.
//
#import "ShoppingMallItemPreview.h"
#import "DressUpShopModel.h"
#import "MyDressingDataModel.h"
#import "XPSkillCardPlayerManager.h"
#import <SVGA.h>
#import <QGVAPWrapView.h>
#import "XPRoomGiftAnimationParser.h"
@interface ShoppingMallItemPreview ()
@property(nonatomic, assign) BOOL isForGive;
@property(nonatomic, assign) BOOL isVaild;
@property(nonatomic, strong) DressUpShopModel *model;
@property(nonatomic, strong) MyDressingDataModel *myDressingModel;
@property(nonatomic, strong) NetImageView *itemImageView;
@property(nonatomic, strong) UIView *itemImageBGView;
@property(nonatomic, strong) VAPView *mp4View;
@property(nonatomic, strong) XPRoomGiftAnimationParser *mp4Parser;
@property(nonatomic, strong) SVGAImageView *svgaView;
@property(nonatomic, strong) UILabel *nameLabel;
@property(nonatomic, strong) UILabel *pricePerDayLabel;
@property(nonatomic, strong) UIButton *cancelButton;
@property(nonatomic, strong) UIButton *buyButton;
@property(nonatomic, strong) UIButton *giveButton;
@property(nonatomic, strong) UserInfoModel *userModel;
@end
@implementation ShoppingMallItemPreview
- (instancetype)init {
if (self = [super init]) {
}
return self;
}
- (instancetype)initWith:(DressUpShopModel *)model isForGive:(BOOL)isForGive {
if (self = [super init]) {
[self setupUI];
self.isForGive = isForGive;
self.userModel = [[XPSkillCardPlayerManager shareInstance] userInfoModel];
self.model = model;
}
return self;
}
- (instancetype)initWithMyDress:(MyDressingDataModel *)model isVaild:(BOOL)isVaild {
if (self = [super init]) {
[self setupUI];
self.isVaild = isVaild;
self.userModel = [[XPSkillCardPlayerManager shareInstance] userInfoModel];
self.myDressingModel = model;
}
return self;
}
- (void)setModel:(DressUpShopModel *)model {
_model = model;
self.itemImageView.imageUrl = model.pic;
self.nameLabel.text = model.name;
if (model.dressType == 4) {
[self.itemImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.itemImageBGView);
make.width.mas_equalTo(kGetScaleWidth(90));
make.height.mas_equalTo(kGetScaleWidth(46));
}];
}
if (model.vipLimit > self.userModel.userVipInfoVO.vipLevel) {
self.buyButton.hidden = YES;
self.giveButton.hidden = YES;
[self.cancelButton setAttributedTitle:[[NSAttributedString alloc] initWithString:YMLocalizedString(@"TTAlertConfig0")
attributes:@{NSFontAttributeName: kFontMedium(14),
NSForegroundColorAttributeName: [UIColor whiteColor]}]
forState:UIControlStateNormal];
[self.cancelButton mas_remakeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.bottom.mas_equalTo(-38);
make.size.mas_equalTo(CGSizeMake(90, 32));
}];
self.pricePerDayLabel.text = [NSString stringWithFormat:YMLocalizedString(@"1.0.30_text_3"), @(model.vipLimit)];
} else {
self.pricePerDayLabel.attributedText = [model mallItemPricePerDay:YES isFullDisplay:YES];
if (model.dressType == 3) {
switch (model.effectType) {
case 1:{
[self addSubview:self.mp4View];
[self.mp4View mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.itemImageView);
}];
self.mp4Parser = [[XPRoomGiftAnimationParser alloc] init];
@kWeakify(self);
[self.mp4Parser parseWithURL:model.effect
completionBlock:^(NSString * _Nullable videoUrl) {
@kStrongify(self);
if (![NSString isEmpty:videoUrl]) {
[self.mp4View playHWDMP4:videoUrl repeatCount:-1 delegate:nil];
}
} failureBlock:^(NSError * _Nullable error) { }];
}
self.itemImageView.hidden = YES;
break;
case 0:
case 2:
default:
break;
}
}
}
}
- (void)setMyDressingModel:(MyDressingDataModel *)myDressingModel {
_myDressingModel = myDressingModel;
if (myDressingModel.dressType == 4) {
[self.itemImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.itemImageBGView);
make.width.mas_equalTo(kGetScaleWidth(90));
make.height.mas_equalTo(kGetScaleWidth(46));
}];
}
self.itemImageView.imageUrl = myDressingModel.pic;
self.nameLabel.text = myDressingModel.name;
if (myDressingModel.dressType == 3) {
switch (myDressingModel.effectType) {
case 1:{
[self addSubview:self.mp4View];
[self.mp4View mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.itemImageView);
}];
self.mp4Parser = [[XPRoomGiftAnimationParser alloc] init];
NSString *url = [NSString isEmpty:myDressingModel.effect] ? myDressingModel.pic : myDressingModel.effect;
@kWeakify(self);
[self.mp4Parser parseWithURL:url
completionBlock:^(NSString * _Nullable videoUrl) {
@kStrongify(self);
if (![NSString isEmpty:videoUrl]) {
[self.mp4View playHWDMP4:videoUrl repeatCount:-1 delegate:nil];
}
} failureBlock:^(NSError * _Nullable error) { }];
}
self.itemImageView.hidden = YES;
break;
case 0:
case 2:
default:
break;
}
}
if (self.isVaild) {
self.buyButton.hidden = NO;
self.pricePerDayLabel.attributedText = [myDressingModel generateAttributedStringWithIncludeOriginalPrice:YES];
} else {
self.buyButton.hidden = YES;
self.giveButton.hidden = YES;
[self.cancelButton setAttributedTitle:[[NSAttributedString alloc] initWithString:YMLocalizedString(@"TTAlertConfig0")
attributes:@{NSFontAttributeName: kFontMedium(14),
NSForegroundColorAttributeName: [UIColor whiteColor]}]
forState:UIControlStateNormal];
[self.cancelButton mas_remakeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.bottom.mas_equalTo(-38);
make.size.mas_equalTo(CGSizeMake(90, 32));
}];
self.pricePerDayLabel.text = YMLocalizedString(@"1.0.30_text_2");
}
}
- (void)setupUI {
UIImageView *bg = [self backgroundImageView];
[self addSubview:bg];
[bg mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
[self addSubview:self.itemImageBGView];
[self.itemImageBGView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(32);
make.size.mas_equalTo(CGSizeMake(155, 155));
}];
[self addSubview:self.itemImageView];
[self.itemImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(32);
make.size.mas_equalTo(CGSizeMake(155, 155));
}];
[self addSubview:self.nameLabel];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.mas_equalTo(self).inset(6);
make.top.mas_equalTo(self.itemImageBGView.mas_bottom).offset(4);
make.height.mas_equalTo(22);
}];
[self addSubview:self.pricePerDayLabel];
[self.pricePerDayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(10);
make.height.mas_equalTo(22);
}];
UIImageView *line = [self line];
[self addSubview:line];
[line mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.mas_equalTo(self).offset(22);
make.height.mas_equalTo(1.5);
make.top.mas_equalTo(self.pricePerDayLabel.mas_bottom).offset(18);
}];
[self addSubview:self.cancelButton];
[self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(line.mas_bottom).offset(20);
make.leading.mas_equalTo(46);
make.size.mas_equalTo(CGSizeMake(90, 32));
}];
[self addSubview:self.buyButton];
[self.buyButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(line.mas_bottom).offset(20);
make.trailing.mas_equalTo(-46);
make.size.mas_equalTo(CGSizeMake(90, 32));
}];
[self addSubview:self.giveButton];
[self.giveButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(line.mas_bottom).offset(20);
make.trailing.mas_equalTo(-46);
make.size.mas_equalTo(CGSizeMake(90, 32));
}];
}
#pragma mark -
- (void)setIsForGive:(BOOL)isForGive {
_isForGive = isForGive;
self.buyButton.hidden = isForGive;
self.giveButton.hidden = !isForGive;
}
- (void)didTapCancel {
[TTPopup dismiss];
}
- (void)didTapBuy {
if (self.buyWith) {
self.buyWith(self.model);
} else if (self.rebuyWith) {
self.rebuyWith(self.myDressingModel);
}
}
- (void)didTapGive {
if (self.giveWith) {
self.giveWith(self.model);
}
}
#pragma mark -
- (UIImageView *)backgroundImageView {
UIImageView *bgImageView = [[UIImageView alloc] initWithImage:kImage(@"mall_item_preview_bg")];
bgImageView.contentMode = UIViewContentModeScaleAspectFill;
return bgImageView;
}
- (UIView *)itemImageBGView {
if (!_itemImageBGView) {
_itemImageBGView = [[UIView alloc] init];
}
return _itemImageBGView;
}
- (NetImageView *)itemImageView {
if (!_itemImageView) {
_itemImageView = [[NetImageView alloc] init];
_itemImageView.contentMode = UIViewContentModeScaleAspectFit;
}
return _itemImageView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [UILabel labelInitWithText:@"" font:kFontMedium(14) textColor:UIColorFromRGB(0xd9e7f7)];
_nameLabel.textAlignment = NSTextAlignmentCenter;
}
return _nameLabel;
}
- (UILabel *)pricePerDayLabel {
if (!_pricePerDayLabel) {
_pricePerDayLabel = [UILabel labelInitWithText:@""
font:kFontRegular(14)
textColor:UIColorRGBAlpha(0xD9E7F7, 0.8)];
_pricePerDayLabel.textAlignment = NSTextAlignmentCenter;
}
return _pricePerDayLabel;
}
- (UIImageView *)line {
UIImageView *line = [[UIImageView alloc] initWithImage:kImage(@"mall_item_preview_line")];
line.contentMode = UIViewContentModeScaleAspectFill;
return line;
}
- (UIButton *)cancelButton {
if (!_cancelButton) {
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
[b setBackgroundColor:[UIColor colorWithWhite:0 alpha:0.3]];
[b setAttributedTitle:[[NSAttributedString alloc] initWithString:YMLocalizedString(@"XPShareView7")
attributes:@{NSFontAttributeName: kFontMedium(14),
NSForegroundColorAttributeName: [UIColor whiteColor]}]
forState:UIControlStateNormal];
[b addTarget:self action:@selector(didTapCancel) forControlEvents:UIControlEventTouchUpInside];
[b setCornerRadius:16];
_cancelButton = b;
}
return _cancelButton;
}
- (UIButton *)buyButton {
if (!_buyButton) {
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
[b addGradientBackgroundWithColors:@[UIColorFromRGB(0xFFE3B2), UIColorFromRGB(0xE9A71D)]
startPoint:CGPointMake(0.0, 0.5)
endPoint:CGPointMake(1.0, 0.5)
cornerRadius:16];
[b setAttributedTitle:[[NSAttributedString alloc] initWithString:YMLocalizedString(@"XPDressUpShopCardTableViewCell2")
attributes:@{NSFontAttributeName: kFontMedium(14),
NSForegroundColorAttributeName: UIColorFromRGB(0x51281b)}]
forState:UIControlStateNormal];
[b addTarget:self action:@selector(didTapBuy) forControlEvents:UIControlEventTouchUpInside];
[b setCornerRadius:16];
b.hidden = YES;
_buyButton = b;
}
return _buyButton;
}
- (UIButton *)giveButton {
if (!_giveButton) {
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
[b addGradientBackgroundWithColors:@[UIColorFromRGB(0xB2FCFF), UIColorFromRGB(0x4DA2EA)]
startPoint:CGPointMake(0.0, 0.5)
endPoint:CGPointMake(1.0, 0.5)
cornerRadius:16];
[b setAttributedTitle:[[NSAttributedString alloc] initWithString:YMLocalizedString(@"1.0.30_text_6")
attributes:@{NSFontAttributeName: kFontMedium(14),
NSForegroundColorAttributeName: UIColorFromRGB(0x172055)}]
forState:UIControlStateNormal];
[b addTarget:self action:@selector(didTapGive) forControlEvents:UIControlEventTouchUpInside];
[b setCornerRadius:16];
b.hidden = YES;
_giveButton = b;
}
return _giveButton;
}
- (VAPView *)mp4View {
if (!_mp4View) {
_mp4View = [[VAPView alloc] init];
_mp4View.contentMode = UIViewContentModeScaleAspectFit;
}
return _mp4View;
}
- (SVGAImageView *)svgaView {
if (!_svgaView) {
_svgaView = [[SVGAImageView alloc] init];
_svgaView.contentMode = UIViewContentModeScaleAspectFit;
}
return _svgaView;
}
@end

View File

@@ -0,0 +1,27 @@
//
// ShoppingMallTagView.h
// YuMi
//
// Created by P on 2024/11/18.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ShoppingMallTagView : UIView
@property(nonatomic, copy) NSString *text;
- (instancetype)initWithBackgroundColors:(NSArray <UIColor *>*)colors
font:(UIFont *)font
textColor:(UIColor *)textColor;
- (void)updateBackgroundColors:(NSArray <UIColor *>*)colors
textColor:(UIColor *)textColor;
- (CGFloat)textWidth;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,104 @@
//
// ShoppingMallTagView.m
// YuMi
//
// Created by P on 2024/11/18.
//
#import "ShoppingMallTagView.h"
@interface ShoppingMallTagView ()
@property (nonatomic, strong) CAGradientLayer *gradientLayer;
@property(nonatomic, strong) UILabel *label;
@end
@implementation ShoppingMallTagView
- (instancetype)initWithBackgroundColors:(NSArray <UIColor *>*)colors
font:(UIFont *)font
textColor:(UIColor *)textColor {
if (self = [super init]) {
if (isMSRTL()) {
[self setCornerRadius:10
cornerMask:kCALayerMaxXMinYCorner | kCALayerMinXMaxYCorner];
} else {
[self setCornerRadius:10
cornerMask:kCALayerMinXMinYCorner | kCALayerMaxXMaxYCorner];
}
self.clipsToBounds = YES;
if (colors.count>1) {
[self addGradientBackgroundWithColors:colors
startPoint:isMSRTL() ? CGPointMake(0.0, 0.0) : CGPointMake(1.0, 0.0)
endPoint:isMSRTL() ? CGPointMake(1.0, 0.0) : CGPointMake(0.0, 0.0)
cornerRadius:0];
} else if (colors.count == 1){
self.backgroundColor = colors.firstObject;
}
[self addSubview:self.label];
[self.label mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
self.label.font = font;
self.label.textColor = textColor;
}
return self;
}
- (void)updateBackgroundColors:(NSArray <UIColor *>*)colors
textColor:(UIColor *)textColor {
if (colors.count>1) {
[self addGradientBackgroundWithColors:colors //@[UIColorFromRGB(0xE29030), UIColorFromRGB(0xFCC074)]
startPoint:isMSRTL() ? CGPointMake(0.0, 0.0) : CGPointMake(1.0, 0.0)
endPoint:isMSRTL() ? CGPointMake(1.0, 0.0) : CGPointMake(0.0, 0.0)
cornerRadius:0];
} else if (colors.count == 1){
self.backgroundColor = colors.firstObject;
}
self.label.textColor = textColor;
}
- (instancetype)init {
if (self = [super init]) {
if (isMSRTL()) {
[self setCornerRadius:10
cornerMask:kCALayerMaxXMinYCorner | kCALayerMinXMaxYCorner];
} else {
[self setCornerRadius:10
cornerMask:kCALayerMinXMinYCorner | kCALayerMaxXMaxYCorner];
}
self.clipsToBounds = YES;
[self addSubview:self.label];
[self.label mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
}
return self;
}
- (void)setText:(NSString *)text {
_text = text;
self.label.text = text;
}
- (CGFloat)textWidth {
return [self.text boundingRectWithSize:CGSizeMake(KScreenWidth/3, self.label.font.lineHeight)
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
attributes:@{NSFontAttributeName: kFontMedium(12)}
context:nil].size.width + 20;
}
- (UILabel *)label {
if (!_label) {
_label = [UILabel labelInitWithText:@"" font:kFontMedium(12) textColor:UIColorFromRGB(0x51281B)];
_label.textAlignment = NSTextAlignmentCenter;
}
return _label;
}
@end

View File

@@ -0,0 +1,16 @@
//
// ShoppingMallViewController.h
// YuMi
//
// Created by P on 2024/11/13.
//
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface ShoppingMallViewController : MvpViewController
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,506 @@
//
// ShoppingMallViewController.m
// YuMi
//
// Created by P on 2024/11/13.
//
#import "ShoppingMallViewController.h"
#import <SVGA.h>
#import <QGVAPWrapView.h>
#import "XPRoomGiftAnimationParser.h"
#import "MyDressingViewController.h"
#import "XPDressSearchViewController.h"
#import "ShoppingMallItemPreview.h"
#import "ShoppingMallDataPresent.h"
#import "ShoppingMallCategoryListView.h"
static NSArray<NSDictionary<NSString *, NSNumber *> *> *DressUpOptions(void) {
return @[
@{YMLocalizedString(@"XPMineDressUpViewController2") : @1}, //
@{YMLocalizedString(@"XPMineDressUpViewController1") : @0}, //
@{YMLocalizedString(@"XPMineDressUpViewController3") : @2}, //
@{YMLocalizedString(@"XPMineDressUpViewController4") : @3}, //
@{YMLocalizedString(@"XPMineDressUpViewController5") : @4}, //
@{YMLocalizedString(@"1.0.30_text_9") : @5} //
];
}
@interface ShoppingMallViewController ()
@property(nonatomic, strong) ShoppingMallCategoryListView *listView;
@property (nonatomic, strong) UIView *playEffectMask;
@property (nonatomic, strong) VAPView *mp4Effect;
@property(nonatomic, strong) XPRoomGiftAnimationParser *mp4Parser;
@property (nonatomic, strong) SVGAImageView *svgaEffect;
@property(nonatomic, strong) UIView *bottomControlArea;
@property(nonatomic, strong) UILabel *bottomControlPriceLabel;
@property(nonatomic, strong) UIButton *bottomControlBuyButton;
@property(nonatomic, strong) UIButton *bottomControlGiveButton;
@property(nonatomic, strong) DressUpShopModel *selectedModel;
@property(nonatomic, strong) UIActivityIndicatorView *loading;
@end
@implementation ShoppingMallViewController
- (ShoppingMallDataPresent *)createPresenter {
return [[ShoppingMallDataPresent alloc] init];
}
- (BOOL)isHiddenNavBar {
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self setupUI];
}
- (void)setupUI {
[self setupBackground];
[self setupNavigationBar];
[self setupBottomControlBar];
[self setupContentList];
// [self hideBottomControlArea];
}
- (void)setupBackground {
self.view.backgroundColor = UIColorFromRGB(0x02061D);
UIImageView *topBG = [[UIImageView alloc] initWithImage:kImage(@"mall_top_bg")];
[self.view addSubview:topBG];
[topBG mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.leading.trailing.mas_equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(200));
}];
}
- (void)setupNavigationBar {
UILabel *titleLabel = [self titleLabel];
UIButton *backButton = [self backButton];
UIButton *myDressButton = [self myDressButton];
[self.view addSubview:titleLabel];
[self.view addSubview:backButton];
[self.view addSubview:myDressButton];
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.top.mas_equalTo(self.view).offset(kStatusBarHeight);
make.height.mas_equalTo(22);
}];
[backButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.view).offset(16);
make.centerY.mas_equalTo(titleLabel);
make.size.mas_equalTo(CGSizeMake(22, 22));
}];
[myDressButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(self.view).offset(-16);
make.centerY.mas_equalTo(titleLabel);
make.height.mas_equalTo(22);
make.width.mas_greaterThanOrEqualTo(84);
}];
}
- (void)setupBottomControlBar {
[self.view addSubview:self.bottomControlArea];
[self.bottomControlArea mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(-200);
make.leading.trailing.mas_equalTo(self.view);
make.height.mas_equalTo(80);
}];
}
- (void)setupContentList {
NSInteger top = kNavigationHeight;
NSInteger bottom = 80 + kSafeAreaBottomHeight;
ShoppingMallCategoryListView *listView = [[ShoppingMallCategoryListView alloc] initWithFrame:CGRectMake(0, top, KScreenWidth, KScreenHeight - top)];
listView.bottomSpace = bottom;
[self.view insertSubview:listView belowSubview:self.bottomControlArea];
self.listView = listView;
@kWeakify(self);
listView.fetchDataForPage = ^(NSInteger pageIndex, FetchDataCompletion completion) {
@kStrongify(self);
[self fetchDataForPage:pageIndex
completion:completion];
};
listView.didTapItemPlay = ^(NSString * _Nonnull resourcePath, NSInteger effectType, NSInteger type) {
@kStrongify(self);
CGSize size = CGSizeZero;
switch (type) {
case 0: //
size = CGSizeMake(kGetScaleWidth(183), kGetScaleWidth(183));
break;
case 5:
size = CGSizeMake(KScreenWidth - 20, KScreenWidth - 20);
break;
default:
size = CGSizeMake(KScreenWidth, KScreenHeight);
break;
}
[self playItemEffect:resourcePath effectType:effectType size:size];
};
listView.returnSelectedModel = ^(DressUpShopModel * _Nonnull model) {
@kStrongify(self);
self.selectedModel = model;
[self updateBottomControlArea];
};
listView.items = DressUpOptions();
}
#pragma mark -
- (void)fetchDataForPage:(NSInteger)pageIndex
completion:(FetchDataCompletion)completion {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.presenter loadCategoryItems:pageIndex success:^(NSArray <DressUpShopModel *>* array) {
if (completion) {
completion(array);
}
} failure:^(NSError * _Nonnull error) {}];
});
}
- (void)updateBottomControlArea {
if (self.selectedModel) {
if (self.selectedModel.obtainWay > 1) {
self.bottomControlPriceLabel.text = @"";
} else {
self.bottomControlPriceLabel.attributedText = [self.selectedModel mallItemPricePerDay:NO isFullDisplay:YES];
}
} else {
self.bottomControlPriceLabel.text = @"";
}
if ([NSString isEmpty:self.bottomControlPriceLabel.text]) {
[self hideBottomControlArea];
} else {
[self showBottomControlArea];
}
}
- (void)showBottomControlArea {
if (self.bottomControlArea.hidden) {
self.bottomControlArea.hidden = NO;
}
[UIView animateWithDuration:0.25 animations:^{
[self.bottomControlArea mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(0);
}];
[self.bottomControlArea layoutIfNeeded];
} completion:^(BOOL finished) {
}];
}
- (void)hideBottomControlArea {
[self.bottomControlArea mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(80 + kSafeAreaBottomHeight);
}];
[self.bottomControlArea layoutIfNeeded];
}
- (void)didTapBuy:(id)sender {
if (!self.selectedModel) {
return;
}
ShoppingMallItemPreview *preview = [[ShoppingMallItemPreview alloc] initWith:self.selectedModel isForGive:NO];
preview.frame = CGRectMake(0, 0, 284, 353);
[TTPopup popupView:preview style:TTPopupStyleAlert];
@kWeakify(self);
[preview setBuyWith:^(DressUpShopModel * _Nonnull model) {
@kStrongify(self);
@kWeakify(self);
[self.presenter buyItem:model.dressUpId
success:^(id _Nonnull obj) {
@kStrongify(self);
[TTPopup dismiss];
[self showSuccessToast:YMLocalizedString(@"XPDressUpShopListViewController0")];
} failure:^(NSError * _Nonnull error) {
// @kStrongify(self);
// [self showErrorToast:error.localizedDescription];
}];
}];
}
- (void)didTapGive:(id)sender {
if (!self.selectedModel) {
return;
}
XPDressSearchViewController *vc = [[XPDressSearchViewController alloc] init];
vc.selectedModel = self.selectedModel;
[self.navigationController pushViewController:vc animated:YES];
}
- (void)didTapBack {
[self.navigationController popViewControllerAnimated:YES];
}
- (void)didTapMyDress {
MyDressingViewController *myDressVC = [[MyDressingViewController alloc] init];
[self.navigationController pushViewController:myDressVC animated:YES];
}
#pragma mark -
- (void)playItemEffect:(NSString *)path
effectType:(NSInteger)effectType
size:(CGSize)size {
if (!_playEffectMask) {
[self.view addSubview:self.playEffectMask];
[self.playEffectMask mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.view);
}];
[self.playEffectMask addSubview:self.svgaEffect];
[self.playEffectMask addSubview:self.mp4Effect];
}
[self.svgaEffect mas_updateConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.playEffectMask);
make.size.mas_equalTo(size);
}];
[self.mp4Effect mas_updateConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.playEffectMask);
make.size.mas_equalTo(size);
}];
[self.loading startAnimating];
self.playEffectMask.hidden = NO;
if ([path.lowercaseString hasSuffix:@"mp4"] || effectType == 1) {
[self playMP4:path];
} else if ([path.lowercaseString hasSuffix:@"svga"] || effectType == 2) {
[self playSVGA:path];
} else {
[self playSVGA:path];
}
}
- (void)playMP4:(NSString *)path {
@kWeakify(self);
[self.mp4Parser parseWithURL:path
completionBlock:^(NSString * _Nullable videoUrl) {
@kStrongify(self);
[self.loading stopAnimating];
self.mp4Effect.hidden = NO;
[self.mp4Effect playHWDMP4:videoUrl repeatCount:-1 delegate:nil];
} failureBlock:^(NSError * _Nullable error) {
@kStrongify(self);
[self stopItemEffect];
}];
}
- (void)playSVGA:(NSString *)path {
@kWeakify(self);
SVGAParser *p = [[SVGAParser alloc] init];
[p parseWithURL:[NSURL URLWithString:path]
completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
@kStrongify(self);
[self.loading stopAnimating];
self.svgaEffect.hidden = NO;
self.svgaEffect.videoItem = videoItem;
[self.svgaEffect startAnimation];
} failureBlock:^(NSError * _Nullable error) {
@kStrongify(self);
[self stopItemEffect];
}];
}
- (void)stopItemEffect {
[self.loading stopAnimating];
[self.svgaEffect stopAnimation];
self.svgaEffect.hidden = YES;
[self.mp4Effect stopHWDMP4];
self.mp4Effect.hidden = YES;
self.playEffectMask.hidden = YES;
}
#pragma mark -
- (UIView *)playEffectMask {
if (!_playEffectMask) {
_playEffectMask = [[UIView alloc] initWithFrame:self.view.bounds];
_playEffectMask.backgroundColor = [UIColor colorWithWhite:0 alpha:0.7f];
[_playEffectMask addSubview:self.loading];
[self.loading mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(_playEffectMask);
}];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(stopItemEffect)];
[_playEffectMask addGestureRecognizer:tap];
}
return _playEffectMask;
}
- (SVGAImageView *)svgaEffect {
if (!_svgaEffect) {
_svgaEffect = [[SVGAImageView alloc] init];
_svgaEffect.contentMode = UIViewContentModeScaleAspectFit;
_svgaEffect.autoPlay = YES;
_svgaEffect.loops = 0;
_svgaEffect.clearsAfterStop = YES;
_svgaEffect.hidden = YES;
_svgaEffect.userInteractionEnabled = YES;
}
return _svgaEffect;
}
- (VAPView *)mp4Effect {
if (!_mp4Effect) {
_mp4Effect = [[VAPView alloc] init];
_mp4Effect.contentMode = UIViewContentModeScaleAspectFit;
}
return _mp4Effect;
}
- (XPRoomGiftAnimationParser *)mp4Parser {
if (!_mp4Parser) {
_mp4Parser = [[XPRoomGiftAnimationParser alloc] init];
}
return _mp4Parser;
}
- (UIView *)bottomControlArea {
if (!_bottomControlArea) {
_bottomControlArea = [[UIView alloc] init];
_bottomControlArea.hidden = YES;
[_bottomControlArea addGradientBackgroundWithColors:@[UIColorFromRGB(0x012E4D), UIColorFromRGB(0x0F1435)]
startPoint:CGPointMake(0.5, 0)
endPoint:CGPointMake(0.5, 1)
cornerRadius:0];
[_bottomControlArea addSubview:self.bottomControlGiveButton];
[self.bottomControlGiveButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(14);
make.trailing.mas_equalTo(-16);
make.size.mas_equalTo(CGSizeMake(74, 32));
}];
[_bottomControlArea addSubview:self.bottomControlBuyButton];
[self.bottomControlBuyButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(14);
make.trailing.mas_equalTo(self.bottomControlGiveButton.mas_leading).offset(-8);
make.size.mas_equalTo(CGSizeMake(74, 32));
}];
[_bottomControlArea addSubview:self.bottomControlPriceLabel];
[self.bottomControlPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.bottomControlGiveButton);
make.leading.top.mas_equalTo(16);
}];
}
return _bottomControlArea;
}
- (UILabel *)bottomControlPriceLabel {
if (!_bottomControlPriceLabel) {
_bottomControlPriceLabel = [[UILabel alloc] init];
}
return _bottomControlPriceLabel;
}
- (UIButton *)bottomControlBuyButton {
if (!_bottomControlBuyButton) {
_bottomControlBuyButton = [UIButton buttonWithType:UIButtonTypeCustom];
_bottomControlBuyButton.titleLabel.font = kFontMedium(14);
[_bottomControlBuyButton setTitle:YMLocalizedString(@"1.0.30_text_5") forState:UIControlStateNormal];
[_bottomControlBuyButton setTitleColor:UIColorFromRGB(0x51281B) forState:UIControlStateNormal];
[_bottomControlBuyButton addGradientBackgroundWithColors:@[UIColorFromRGB(0xFFE3B2), UIColorFromRGB(0xE9A71D)]
startPoint:CGPointMake(0.0, 0.5)
endPoint:CGPointMake(1.0, 0.5)
cornerRadius:16];
[_bottomControlBuyButton addTarget:self
action:@selector(didTapBuy:)
forControlEvents:UIControlEventTouchUpInside];
}
return _bottomControlBuyButton;
}
- (UIButton *)bottomControlGiveButton {
if (!_bottomControlGiveButton) {
_bottomControlGiveButton = [UIButton buttonWithType:UIButtonTypeCustom];
_bottomControlGiveButton.titleLabel.font = kFontMedium(14);
[_bottomControlGiveButton setTitle:YMLocalizedString(@"1.0.30_text_6") forState:UIControlStateNormal];
[_bottomControlGiveButton setTitleColor:UIColorFromRGB(0x172055) forState:UIControlStateNormal];
[_bottomControlGiveButton addGradientBackgroundWithColors:@[UIColorFromRGB(0xB2FCFF), UIColorFromRGB(0x4DA2EA)]
startPoint:CGPointMake(0.0, 0.5)
endPoint:CGPointMake(1.0, 0.5)
cornerRadius:16];
[_bottomControlGiveButton addTarget:self
action:@selector(didTapGive:)
forControlEvents:UIControlEventTouchUpInside];
}
return _bottomControlGiveButton;
}
- (UIButton *)backButton {
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
[b setImage:[kImage(@"common_nav_back_white") ms_SetImageForRTL]
forState:UIControlStateNormal];
[b addTarget:self
action:@selector(didTapBack)
forControlEvents:UIControlEventTouchUpInside];
return b;
}
- (UILabel *)titleLabel {
UILabel *label = [[UILabel alloc] init];
label.textAlignment = NSTextAlignmentCenter;
label.font = kFontMedium(17);
label.text = YMLocalizedString(@"XPDressUpShopViewController1");
label.textColor = UIColorFromRGB(0xD9E7F7);
return label;
}
- (UIButton *)myDressButton {
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
[b addGradientBackgroundWithColors:@[UIColorFromRGB(0x004A4F), UIColorFromRGB(0x11215B)]
startPoint:CGPointMake(0.5, 0.0)
endPoint:CGPointMake(0.5, 1.0)
cornerRadius:11];
[b setCornerRadius:11
corners:kCALayerMaxXMaxYCorner | kCALayerMaxXMinYCorner | kCALayerMinXMaxYCorner | kCALayerMinXMinYCorner
borderWidth:1
borderColor:UIColorFromRGB(0x75B4DF)];
NSTextAttachment *iconAttachment = [[NSTextAttachment alloc] init];
iconAttachment.image = kImage(@"mall_my_icon");
iconAttachment.bounds = CGRectMake(8, -2, 14, 14);
NSAttributedString *iconString = [NSAttributedString attributedStringWithAttachment:iconAttachment];
NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithAttributedString:iconString];
[title insertAttributedString:[[NSAttributedString alloc] initWithString:YMLocalizedString(@"1.0.30_text_8")
attributes:@{NSFontAttributeName: kFontMedium(12),
NSForegroundColorAttributeName: UIColorFromRGB(0xd9e7f7)}]
atIndex:0];
[b setAttributedTitle:title
forState:UIControlStateNormal];
CGFloat spacing = 8.0;
b.contentEdgeInsets = UIEdgeInsetsMake(0, spacing, 4, spacing);
[b addTarget:self action:@selector(didTapMyDress) forControlEvents:UIControlEventTouchUpInside];
return b;
}
- (UIActivityIndicatorView *)loading {
if (!_loading) {
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
indicator.translatesAutoresizingMaskIntoConstraints = NO;
indicator.hidesWhenStopped = YES;
_loading = indicator;
}
return _loading;
}
@end

View File

@@ -0,0 +1,117 @@
//
// Api+Login.h
// YUMI
//
// Created by zu on 2021/9/6.
//
#import "Api.h"
NS_ASSUME_NONNULL_BEGIN
@interface Api (Login)
+ (void)phoneQuickLogin:(HttpRequestHelperCompletion)completion
accessToken:(NSString *)accessToken
token:(NSString *)token;
/// 手机验证码登录
/// @param completion 完成
/// @param phone 手机号
/// @param code 验证码
+ (void)loginWithCode:(HttpRequestHelperCompletion)completion
phone:(NSString *)phone
code:(NSString *)code
client_secret:(NSString *)client_secret
version:(NSString *)version
client_id:(NSString *)client_id
grant_type:(NSString *)grant_type
phoneAreaCode:(NSString *)phoneAreaCode;
/// 手机密码登录
/// @param completion 完成
/// @param phone 手机号
/// @param password 验证码
+ (void)loginWithPassword:(HttpRequestHelperCompletion)completion
phone:(NSString *)phone
password:(NSString *)password
client_secret:(NSString *)client_secret
version:(NSString *)version
client_id:(NSString *)client_id
grant_type:(NSString *)grant_type;
/// 充值密码 没有登录的时候
/// @param complction 完成
/// @param phone 手机号
/// @param newPwd 新的密码
/// @param smsCode 验证码
+ (void)resetPasswordWithPhone:(HttpRequestHelperCompletion)complction
phone:(NSString *)phone
newPwd:(NSString *)newPwd
smsCode:(NSString *)smsCode phoneAreaCode:(NSString *)phoneAreaCode;
/// 第三方登录
/// @param complction 完成
/// @param openid 唯一标识符
/// @param unionid unionid
/// @param access_token access_token
/// @param type 第三方登录的类型
+ (void)loginWithThirdPart:(HttpRequestHelperCompletion)complction
openid:(NSString *)openid
unionid:(NSString *)unionid
access_token:(NSString *)access_token
type:(NSString *)type;
/// 随机获取一个昵称
/// @param completion 完成
+ (void)randomNick:(HttpRequestHelperCompletion)completion;
/// 绑定手机号码
/// @param complection 完成
/// @param phone 手机号
/// @param code 验证码
/// @param ticket ticket
+ (void)bindMoblieCode:(HttpRequestHelperCompletion)complection
phone:(NSString *)phone
code:(NSString *)code
ticket:(NSString *)ticket phoneAreaCode:(NSString *)phoneAreaCode;
+(void)getPhoneAreaCodeList:(HttpRequestHelperCompletion)complection;
/// 绑定授权码
/// @param complection 完成
+(void)bindAuthorizationCode:(HttpRequestHelperCompletion)complection authCode:(NSString *)authCode;
///反馈
+ (void)loadFeedbackConfig:(HttpRequestHelperCompletion)completion;
+ (void)commitFeedback:(HttpRequestHelperCompletion)completion
type:(NSString *)type
desc:(NSString *)desc
screenUrl:(NSString *)screenUrl
contact:(NSString *)contact;
+ (void)emailGetCode:(HttpRequestHelperCompletion)completion emailAddress:(NSString *)emailAddress type:(NSNumber *)type;
+ (void)emailVerify:(HttpRequestHelperCompletion)completion emailAddress:(NSString *)emailAddress code:(NSString *)code;
+ (void)loginWithCode:(HttpRequestHelperCompletion)completion
email:(NSString *)email
code:(NSString *)code
client_secret:(NSString *)client_secret
version:(NSString *)version
client_id:(NSString *)client_id
grant_type:(NSString *)grant_type;
+ (void)userBoundEmail:(HttpRequestHelperCompletion)completion
email:(NSString *)email
code:(NSString *)code;
+ (void)userBoundPhone:(HttpRequestHelperCompletion)completion
phone:(NSString *)email
code:(NSString *)code
phoneAreaCode:(NSString *)phoneAreaCode;
+ (void)resetPasswordWithEmail:(HttpRequestHelperCompletion)completion email:(NSString *)email newPwd:(NSString *)newPwd code:(NSString *)code;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,149 @@
//
// Api+Login.m
// YUMI
//
// Created by zu on 2021/9/6.
//
#import "Api+Login.h"
#import <Base64/MF_Base64Additions.h>
@implementation Api (Login)
+ (void)phoneQuickLogin:(HttpRequestHelperCompletion)completion accessToken:(NSString *)accessToken token:(NSString *)token {
NSString * fang = [NSString stringFromBase64String:@"YWNjL29uZWNsaWNrL2xvZ2lu"];///acc/oneclick/login
[self makeRequest:fang method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, accessToken, token, nil];
}
///
/// @param completion
/// @param phone
/// @param code
+ (void)loginWithCode:(HttpRequestHelperCompletion)completion phone:(NSString *)phone code:(NSString *)code client_secret:(NSString *)client_secret version:(NSString *)version client_id:(NSString *)client_id grant_type:(NSString *)grant_type phoneAreaCode:(NSString *)phoneAreaCode{
NSString * fang = [NSString stringFromBase64String:@"b2F1dGgvdG9rZW4="];///oauth/token
[self makeRequest:fang method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__,phone,code,client_secret,version, client_id, grant_type,phoneAreaCode, nil];
}
///
/// @param completion
/// @param phone
/// @param password
+ (void)loginWithPassword:(HttpRequestHelperCompletion)completion phone:(NSString *)phone password:(NSString *)password client_secret:(NSString *)client_secret version:(NSString *)version client_id:(NSString *)client_id grant_type:(NSString *)grant_type {
NSString * fang = [NSString stringFromBase64String:@"b2F1dGgvdG9rZW4="];///oauth/token
[self makeRequest:fang method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__,phone,password,client_secret,version, client_id, grant_type, nil];
}
///
/// @param completion
/// @param phone
/// @param newPwd
/// @param smsCode
+ (void)resetPasswordWithPhone:(HttpRequestHelperCompletion)completion phone:(NSString *)phone newPwd:(NSString *)newPwd smsCode:(NSString *)smsCode phoneAreaCode:(NSString *)phoneAreaCode{
NSString * fang = [NSString stringFromBase64String:@"YWNjL3B3ZC9yZXNldA=="];/// acc/pwd/reset
[self makeRequest:fang method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, phone, newPwd, smsCode,phoneAreaCode, nil];
}
+ (void)resetPasswordWithEmail:(HttpRequestHelperCompletion)completion email:(NSString *)email newPwd:(NSString *)newPwd code:(NSString *)code{
[self makeRequest:@"acc/pwd/resetByEmail" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, email, newPwd, code, nil];
}
///
/// @param completion
/// @param openid
/// @param unionid unionid
/// @param access_token access_token
/// @param type
+ (void)loginWithThirdPart:(HttpRequestHelperCompletion)completion openid:(NSString *)openid unionid:(NSString *)unionid access_token:(NSString *)access_token type:(NSString *)type {
NSString * fang = [NSString stringFromBase64String:@"YWNjL3RoaXJkL2xvZ2lu"];///acc/third/login
[self makeRequest:fang method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, openid, unionid, access_token, type, nil];
}
///
/// @param completion
+ (void)randomNick:(HttpRequestHelperCompletion)completion {
NSString * fang = [NSString stringFromBase64String:@"cmFuZG9tL25pY2svZ2V0"];///random/nick/get
[self makeRequest:fang method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, nil];
}
///
/// @param complection
/// @param phone
/// @param code
/// @param ticket ticket
+ (void)bindMoblieCode:(HttpRequestHelperCompletion)complection
phone:(NSString *)phone
code:(NSString *)code
ticket:(NSString *)ticket phoneAreaCode:(NSString *)phoneAreaCode{
NSString * fang = [NSString stringFromBase64String:@"d2l0aERyYXcvcGhvbmU="];///withDraw/phone
[self makeRequest:fang method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__, phone, code, ticket,phoneAreaCode, nil];
}
+(void)getPhoneAreaCodeList:(HttpRequestHelperCompletion)complection{
NSString * fang = [NSString stringFromBase64String:@"YXJlYUluZm8vbGlzdA=="];///areaInfo/list
[self makeRequest:fang method:HttpRequestHelperMethodGET completion:complection, __FUNCTION__,nil];
}
///
/// @param complection
+(void)bindAuthorizationCode:(HttpRequestHelperCompletion)complection authCode:(NSString *)authCode{
[self makeRequest:@"phone/auth/bound" method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__,authCode, nil];
}
///
+ (void)loadFeedbackConfig:(HttpRequestHelperCompletion)completion {
[self makeRequest:@"feedback/getConfig" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, nil];
}
+ (void)commitFeedback:(HttpRequestHelperCompletion)completion
type:(NSString *)type
desc:(NSString *)desc
screenUrl:(NSString *)screenUrl
contact:(NSString *)contact {
[self makeRequest:@"feedback/commit"
method:HttpRequestHelperMethodPOST
completion:completion, __FUNCTION__, type, desc, screenUrl, contact, nil];
}
+ (void)emailGetCode:(HttpRequestHelperCompletion)completion emailAddress:(NSString *)emailAddress type:(NSNumber *)type {
[self makeRequest:@"email/getCode"
method:HttpRequestHelperMethodPOST
completion:completion, __FUNCTION__, emailAddress, type, nil];
}
+ (void)emailVerify:(HttpRequestHelperCompletion)completion emailAddress:(NSString *)emailAddress code:(NSString *)code {
[self makeRequest:@"email/verify"
method:HttpRequestHelperMethodPOST
completion:completion, __FUNCTION__, emailAddress, code, nil];
}
+ (void)loginWithCode:(HttpRequestHelperCompletion)completion
email:(NSString *)email
code:(NSString *)code
client_secret:(NSString *)client_secret
version:(NSString *)version
client_id:(NSString *)client_id
grant_type:(NSString *)grant_type {
NSString * fang = [NSString stringFromBase64String:@"b2F1dGgvdG9rZW4="];///oauth/token
[self makeRequest:fang method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__,email,code,client_secret,version, client_id, grant_type, nil];
}
+ (void)userBoundEmail:(HttpRequestHelperCompletion)completion
email:(NSString *)email
code:(NSString *)code {
[self makeRequest:@"user/boundEmail"
method:HttpRequestHelperMethodPOST
completion:completion, __FUNCTION__, email, code, nil];
}
+ (void)userBoundPhone:(HttpRequestHelperCompletion)completion
phone:(NSString *)email
code:(NSString *)code
phoneAreaCode:(NSString *)phoneAreaCode {
[self makeRequest:@"user/boundPhone"
method:HttpRequestHelperMethodPOST
completion:completion, __FUNCTION__, email, code, nil];
}
@end

View File

@@ -0,0 +1,20 @@
//
// PILoginManager.h
// YuMi
//
// Created by duoban on 2023/10/7.
//
#import <Foundation/Foundation.h>
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface PILoginManager : NSObject
///登录是否手机isLoginPhone
+(void)loginWithVC:(MvpViewController *)VC isLoginPhone:(BOOL)isLoginPhone;
///登录成功,回到首页
+(void)jumpToHomeVCWithInviteCode:(NSString *)inviteCode;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,105 @@
//
// PILoginManager.m
// YuMi
//
// Created by duoban on 2023/10/7.
//
#import "PILoginManager.h"
///api
#import "Api+Main.h"
///vc
#import "LoginFullInfoViewController.h"
#import "TabbarViewController.h"
#import "BaseNavigationController.h"
#import "LoginVerifCodeViewController.h"
///Model
#import "ThirdUserInfo.h"
#import "AccountModel.h"
#import "UserInfoModel.h"
#import "XPLoginAuthCodeVC.h"
///Manager
#import "TurboModeStateManager.h"
#import "FirstRechargeManager.h"
#import "PublicRoomManager.h"
///Tool
#import "XNDJTDDLoadingTool.h"
#import "AccountInfoStorage.h"
@implementation PILoginManager
+(void)loginWithVC:(MvpViewController *)VC isLoginPhone:(BOOL)isLoginPhone{
[XNDJTDDLoadingTool showLoading];
AccountModel *accountModel = [[AccountInfoStorage instance] getCurrentAccountInfo];
HomeUserModel *homeUserModel = [HomeUserModel new];
if (accountModel == nil || accountModel.uid == nil || accountModel.access_token == nil) {
[XNDJTDDLoadingTool hideOnlyView:VC.view];
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"LoginPresenter1")];
return;
}
__block UserInfoModel *userInfo;
dispatch_group_t group = dispatch_group_create();
dispatch_queue_t queue =dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0);
dispatch_group_enter(group);
dispatch_async(queue, ^{
[Api requestTicket:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if(code == 200){
NSArray *tickets = [data.data valueForKey:@"tickets"];
NSString *ticket = [tickets[0] valueForKey:@"ticket"];
homeUserModel.ticket = ticket;
[[AccountInfoStorage instance] saveTicket:ticket];
[Api getUserInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if(code == 200){
userInfo = [UserInfoModel modelWithDictionary:data.data];
[AccountInfoStorage instance].name = userInfo.nick;
homeUserModel.nick = userInfo.nick;
homeUserModel.avatar = userInfo.avatar;
homeUserModel.isBindPhone = userInfo.isBindPhone;
}
dispatch_group_leave(group);
} uid:accountModel.uid];
return;
}
dispatch_group_leave(group);
} access_token:accountModel.access_token issue_type:@"multi"];
});
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
[XNDJTDDLoadingTool hideOnlyView:VC.view];
if ([[AccountInfoStorage instance] getTicket].length <= 0 || userInfo == nil) {
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"LoginPresenter1")];
return;
}
[[AccountInfoStorage instance]saveHomeUserInfo:homeUserModel];
if (userInfo.nick == nil || userInfo.avatar == nil) {
LoginFullInfoViewController * FullVC = [[LoginFullInfoViewController alloc] init];
[VC.navigationController pushViewController:FullVC animated:YES];
return;
}
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"PKIDLoginViewController0")];
[PILoginManager jumpToHomeVCWithInviteCode:@""];
});
}
+(void)jumpToHomeVCWithInviteCode:(NSString *)inviteCode{
TabbarViewController *vc = [[TabbarViewController alloc] init];
vc.isFormLogin = YES;
vc.inviteCode = inviteCode;
BaseNavigationController *bnc = [[BaseNavigationController alloc] initWithRootViewController:vc];
kWindow.rootViewController = bnc;
//
[[FirstRechargeManager sharedManager] startMonitoring];
//
[[PublicRoomManager sharedManager] initialize];
// 🔧 TurboModeStateManager
NSString *userId = [[AccountInfoStorage instance] getUid];
if (userId) {
[[TurboModeStateManager sharedManager] startupWithCurrentUser:userId];
}
}
@end

View File

@@ -0,0 +1,23 @@
//
// FeedBackConfigModel.h
// YuMi
//
// Created by P on 2024/7/3.
//
#import "PIBaseModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface FeedBackTypeModel : PIBaseModel
@property (nonatomic, copy) NSString *desc;
@property (nonatomic, copy) NSString *type;
@end
@interface FeedBackConfigModel : PIBaseModel
@property (nonatomic, copy) NSDictionary *customContactMap;
@property (nonatomic, copy) NSArray <FeedBackTypeModel *>*typeEnumList;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,20 @@
//
// FeedBackConfigModel.m
// YuMi
//
// Created by P on 2024/7/3.
//
#import "FeedBackConfigModel.h"
@implementation FeedBackTypeModel
@end
@implementation FeedBackConfigModel
+ (NSDictionary *)objectClassInArray{
return @{
@"typeEnumList":FeedBackTypeModel.class
};
}
@end

View File

@@ -0,0 +1,25 @@
//
// LoginAreaModel.h
// YuMi
//
// Created by YuMi on 2023/6/25.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface LoginAreaModel : PIBaseModel
@property (nonatomic,copy) NSString *codeId;
@property (nonatomic,copy) NSString *name;
@property (nonatomic,copy) NSString *abbr;
@property (nonatomic,copy) NSString *code;
@property (nonatomic,copy) NSString *seq;
@property (nonatomic,copy) NSString *status;
@property (nonatomic,copy) NSString *region;
@property (nonatomic,copy) NSString *create_time;
@property (nonatomic,copy) NSString *update_time;
@property (nonatomic,copy) NSString * mcc;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// LoginAreaModel.m
// YuMi
//
// Created by YuMi on 2023/6/25.
//
#import "LoginAreaModel.h"
@implementation LoginAreaModel
@end

View File

@@ -0,0 +1,26 @@
//
// RegionListInfo.h
// YuMi
//
// Created by P on 2024/12/17.
//
#import "PIBaseModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface RegionListInfo : PIBaseModel
@property(nonatomic, assign) BOOL checked;
@property(nonatomic, copy) NSString *code;
@property(nonatomic, copy) NSString *icon;
@property(nonatomic, copy) NSString *id;
@property(nonatomic, copy) NSString *name;
@property(nonatomic, copy) NSString *partitionDesc;
@property(nonatomic, assign) NSInteger partitionId;
@property(nonatomic, copy) NSString *regionDesc;
@property(nonatomic, assign) NSInteger seq;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// RegionListInfo.m
// YuMi
//
// Created by P on 2024/12/17.
//
#import "RegionListInfo.h"
@implementation RegionListInfo
@end

View File

@@ -0,0 +1,24 @@
//
// ThirdUserInfo.h
// YUMI
//
// Created by YUMI on 2021/9/13.
//
#import "NSObject+MJExtension.h"
NS_ASSUME_NONNULL_BEGIN
@interface ThirdUserInfo : PIBaseModel
///用户名
@property (nonatomic,copy) NSString *userName;
///头像的地址
@property (nonatomic,copy) NSString *avatarUrl;
@property (nonatomic,copy) NSString * openid;
@property (nonatomic,copy) NSString * access_token;
@property (nonatomic,copy) NSString * unionid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// ThirdUserInfo.m
// YUMI
//
// Created by YUMI on 2021/9/13.
//
#import "ThirdUserInfo.h"
@implementation ThirdUserInfo
@end

View File

@@ -0,0 +1,16 @@
//
// LoginBindPhonePresent.h
// YUMI
//
// Created by YUMI on 2021/9/15.
//
#import "BaseMvpPresenter.h"
NS_ASSUME_NONNULL_BEGIN
@interface LoginBindPhonePresent : BaseMvpPresenter
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,17 @@
//
// LoginBindPhonePresent.m
// YUMI
//
// Created by YUMI on 2021/9/15.
//
#import "LoginBindPhonePresent.h"
#import "BaseMvpProtocol.h"
@implementation LoginBindPhonePresent
- (id<BaseMvpProtocol>)getView {
return ((id<BaseMvpProtocol>) [super getView]);
}
@end

View File

@@ -0,0 +1,25 @@
//
// LoginForgetPasswordPresent.h
// YUMI
//
// Created by YUMI on 2021/9/10.
//
#import "BaseMvpPresenter.h"
#import "YUMINNNN.h"
NS_ASSUME_NONNULL_BEGIN
@interface LoginForgetPasswordPresent : BaseMvpPresenter
/// 获取手机的验证码
/// @param phone 手机号
/// @param type 类型
- (void)phoneSmsCode:(NSString *)phone type:(GetSmsType)type phoneAreaCode:(NSString *)phoneAreaCode;
/// 没有登录的时候 重置密码
/// @param phone 手机号
/// @param newPwd 新的密码
/// @param smsCode 验证码
- (void)resetPassword:(NSString *)phone newPwd:(NSString *)newPwd smsCode:(NSString *)smsCode phoneAreaCode:(NSString *)phoneAreaCode;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,49 @@
//
// LoginForgetPasswordPresent.m
// YUMI
//
// Created by YUMI on 2021/9/10.
//
#import "LoginForgetPasswordPresent.h"
///Tool
#import "AccountInfoStorage.h"
#import "DESEncrypt.h"
#import "YUMIConstant.h"
///Api
#import "Api+Login.h"
///Presenter
#import "LoginForgetPasswordPresent.h"
///Protocol
#import "LoginForgetPasswordProtocol.h"
@implementation LoginForgetPasswordPresent
- (id<LoginForgetPasswordProtocol>)getView {
return ((id<LoginForgetPasswordProtocol>) [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 newPwd
/// @param smsCode
- (void)resetPassword:(NSString *)phone newPwd:(NSString *)newPwd smsCode:(NSString *)smsCode phoneAreaCode:(NSString *)phoneAreaCode{
NSString * desPassword = [DESEncrypt encryptUseDES:newPwd key:KeyWithType(KeyType_PasswordEncode)];
NSString * desPhone = [DESEncrypt encryptUseDES:phone key:KeyWithType(KeyType_PasswordEncode)];
[Api resetPasswordWithPhone:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] resetPasswrodSuccess];
} showLoading:YES] phone:desPhone newPwd:desPassword smsCode:smsCode phoneAreaCode:phoneAreaCode];
}
@end

View File

@@ -0,0 +1,41 @@
//
// LoginFullInfoPresenter.h
// YUMI
//
// Created by YUMI on 2021/9/14.
//
#import "BaseMvpPresenter.h"
NS_ASSUME_NONNULL_BEGIN
@class ThirdUserInfo, RegionListInfo;
@interface LoginFullInfoPresenter : BaseMvpPresenter
/// 获取保存的第三方的数据模型
- (ThirdUserInfo *)getThirdUserInfo;
/// 随机获取昵称
- (void)randomRequestNick;
/// 补全资料
/// @param avatar 头像
/// @param gender 性别
/// @param nick 昵称
/// @param inviteCode 邀请码
/// @param roomUid 邀请的那个房间的uid
/// @param shareUid 邀请人的uid
/// @param shareChannel 邀请的渠道
- (void)complectionInfoWithAvatar:(NSString *)avatar
gender:(NSString *)gender
nick:(NSString *)nick
inviteCode:(NSString * __nullable)inviteCode
roomUid:(NSString * __nullable)roomUid
shareUid:(NSString * __nullable)shareUid
shareChannel:(NSString * __nullable)shareChannel
regionId:(NSString *)regionId;
- (void)loadAllRegionInfo:(void(^)(NSArray <RegionListInfo *>*array))success failure:(void(^)(NSError *error))failure;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,106 @@
//
// LoginFullInfoPresenter.m
// YUMI
//
// Created by YUMI on 2021/9/14.
//
#import "LoginFullInfoPresenter.h"
///Api
#import "Api+Login.h"
#import "LoginFullInfoProtocol.h"
#import "NSMutableDictionary+Saft.h"
///Tool
#import "AccountInfoStorage.h"
///Model
#import "ThirdUserInfo.h"
#import "RegionListInfo.h"
@implementation LoginFullInfoPresenter
- (id<LoginFullInfoProtocol>)getView {
return ((id<LoginFullInfoProtocol>) [super getView]);
}
///
- (ThirdUserInfo *)getThirdUserInfo {
if ([AccountInfoStorage instance].thirdUserInfo) {
return [AccountInfoStorage instance].thirdUserInfo;
}
return nil;
}
///
- (void)randomRequestNick {
[Api randomNick:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] requestRandomNickSuccess:data.data];
}]];
}
///
/// @param avatar
/// @param gender
/// @param nick
/// @param inviteCode
/// @param roomUid uid
/// @param shareUid uid
/// @param shareChannel
- (void)complectionInfoWithAvatar:(NSString *)avatar
gender:(NSString *)gender
nick:(NSString *)nick
inviteCode:(NSString * __nullable)inviteCode
roomUid:(NSString * __nullable)roomUid
shareUid:(NSString * __nullable)shareUid
shareChannel:(NSString * __nullable)shareChannel
regionId:(NSString *)regionId{
NSString * uid = [[AccountInfoStorage instance] getUid];
NSString * ticket = [[AccountInfoStorage instance] getTicket];
NSMutableDictionary * params = [NSMutableDictionary dictionary];
[params safeSetObject:avatar forKey:@"avatar"];
[params safeSetObject:gender forKey:@"gender"];
[params safeSetObject:nick forKey:@"nick"];
[params safeSetObject:uid forKey:@"uid"];
[params safeSetObject:ticket forKey:@"ticket"];
if (regionId.length > 0) {
[params safeSetObject:regionId forKey:@"regionId"];
}
if (inviteCode.length > 0) {
[params safeSetObject:inviteCode forKey:@"inviteCode"];
}
if (roomUid.length > 0) {
[params safeSetObject:roomUid forKey:@"roomUid"];
}
if (shareUid.length > 0) {
[params safeSetObject:shareUid forKey:@"shareUid"];
}
if (shareChannel.length > 0) {
[params safeSetObject:shareChannel forKey:@"shareChannel"];
}
[Api completeUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] complementInfoSuccess];
}fail:^(NSInteger code, NSString * _Nullable msg) {
[[self getView] complementInfoFail];
} errorToast:YES] userInfo:params];
}
- (void)loadAllRegionInfo:(void(^)(NSArray <RegionListInfo *>*array))success failure:(void(^)(NSError *error))failure {
[Api requestAllRegionInfoCompletion:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
if (data.code == 200) {
NSArray *array = [RegionListInfo modelsWithArray:data.data];
if (success) {
success(array);
}
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
if (failure) {
failure([NSError errorWithDomain:[NSString isEmpty:msg] ? @"" : msg code:code userInfo:nil]);
}
} showLoading:YES errorToast:YES]];
}
@end

View File

@@ -0,0 +1,19 @@
//
// LoginPasswordPresent.h
// YUMI
//
// Created by YUMI on 2021/9/9.
//
#import "BaseMvpPresenter.h"
NS_ASSUME_NONNULL_BEGIN
@interface LoginPasswordPresent : BaseMvpPresenter
/// 使用手机号和密码登录
/// @param phone 手机号
/// @param password 验证码
- (void)loginWithPhone:(NSString *)phone password:(NSString *)password;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,42 @@
//
// LoginPasswordPresent.m
// YUMI
//
// Created by YUMI on 2021/9/9.
//
#import "LoginPasswordPresent.h"
///Http
#import "Api+Login.h"
///Tool
#import "AccountInfoStorage.h"
#import "DESEncrypt.h"
#import "YUMIConstant.h"
///Model
#import "AccountModel.h"
///Protocol
#import "LoginPasswordProtocol.h"
@implementation LoginPasswordPresent
- (id<LoginPasswordProtocol>)getView {
return ((id<LoginPasswordProtocol>) [super getView]);
}
/// 使
/// @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] phoneAndPasswordLoginSuccess];
} showLoading:YES errorToast:YES] phone:desPhone password:desPassword client_secret:@"uyzjdhds" version:@"1" client_id:@"erban-client" grant_type:@"password"];
}
@end

View File

@@ -0,0 +1,72 @@
//
// LoginPresenter.h
// YUMI
//
// Created by zu on 2021/9/1.
//
#import "BaseMvpPresenter.h"
#import "YUMINNNN.h"
#import <GoogleSignIn/GoogleSignIn.h>
#import <GoogleSignIn/GIDGoogleUser.h>
#import <GoogleSignIn/GoogleSignIn-umbrella.h>
@class FeedBackConfigModel;
NS_ASSUME_NONNULL_BEGIN
@interface LoginPresenter : BaseMvpPresenter
- (void)phoneQuickLogin:(NSString *)accessToken token:(NSString*) token;
/// 第三方登录
/// @param type 登录的类型
- (void)thirdLoginWithType:(ThirdLoginType)type;
///第三方登录,谷歌登录
-(void)thirdLoginByGoogleWithPresentingViewController:(UIViewController *)presentingViewController configuration:(GIDConfiguration *)configuration;
///第三方登录fb登录
-(void)thirdLoginByFBWithPresentingViewController:(UIViewController *)presentingViewController;
///第三方登录line登录
-(void)thirdLoginByLine:(UIViewController *)presentingViewController;
/// 获取手机的验证码
/// @param phone 手机号
/// @param type 类型
- (void)phoneSmsCode:(NSString *)phone type:(GetSmsType)type phoneAreaCode:(NSString *)phoneAreaCode;
/// 使用手机号和验证码登录
/// @param phone 手机号
/// @param code 验证码
- (void)loginWithPhone:(NSString *)phone code:(NSString *)code phoneAreaCode:(NSString *)phoneAreaCode;
/// 使用手机号和密码登录
/// @param phone 手机号
/// @param password 验证码
- (void)loginWithPhone:(NSString *)phone password:(NSString *)password;
///反馈
- (void)loadFeedbackConfig:(void(^)(FeedBackConfigModel *model))success
failure:(void(^)(NSString *errorMessage))failure;
- (void)submitFeedback:(void(^)(void))success
failure:(void(^)(NSString *errorMessage))failure
type:(NSString *)type
desc:(NSString *)desc
photoURLString:(nullable NSString *)photoURLString
contact:(nullable NSString *)contact;
- (void)sendMailVerificationCode:(NSString *)emailAddress type:(NSInteger)type;
- (void)loginWithEmail:(NSString *)email code:(NSString *)code;
- (void)bindingNewEmail:(NSString *)email code:(NSString *)code;
- (void)bindingNewPhone:(NSString *)phone code:(NSString *)code areaCode:(NSString *)areaCode;
- (void)resetEmailPassword:(NSString *)email code:(NSString *)code newPassword:(NSString *)newPwd;
- (void)resetPhonePassword:(NSString *)phone code:(NSString *)code newPassword:(NSString *)newPwd areaCode:(NSString *)areaCode;
- (void)checkEmailCode:(NSString *)email code:(NSString *)code;
- (void)checkPhoneCode:(NSString *)phone code:(NSString *)code areaCode:(NSString *)areaCode;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,439 @@
//
// LoginPresenter.m
// YUMI
//
// Created by zu on 2021/9/1.
//
#import "LoginPresenter.h"
///Third
#import <ReactiveObjC/ReactiveObjC.h>
#import <ShareSDK/ShareSDK.h>
///APi
#import "Api+Login.h"
///Tool
#import "AccountInfoStorage.h"
#import "XNDJTDDLoadingTool.h"
#import "YUMIMacroUitls.h"
///P
#import "LoginProtocol.h"
///Model
#import "ThirdUserInfo.h"
#import "AccountModel.h"
#import "DESEncrypt.h"
#import "YuMi-swift.h"
#import "FeedBackConfigModel.h"
static NSString *clinet_s = @"uyzjdhds";
@implementation LoginPresenter
- (void)dealloc{
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
- (instancetype)init{
self = [super init];
if(self){
}
return self;
}
- (id<LoginProtocol>)getView {
return ((id<LoginProtocol>) [super getView]);
}
- (void)phoneQuickLogin:(NSString *)accessToken
token:(NSString *)token {
@kWeakify(self);
[Api phoneQuickLogin:[self createHttpCompletion:^(BaseModel *data) {
@kStrongify(self);
[[AccountInfoStorage instance] saveAccountInfo:[AccountModel modelWithDictionary:data.data]];
[[self getView] loginSuccess];
} showLoading:YES] accessToken:accessToken token:token];
}
///
/// @param type
- (void)thirdLoginWithType:(ThirdLoginType)type{
SSDKPlatformType platformType;
switch (type) {
case ThirdLoginType_FB:
platformType = SSDKPlatformTypeFacebook;
break;
case ThirdLoginType_Line:
platformType = SSDKPlatformTypeLine;
break;
case ThirdLoginType_Apple:
platformType = SSDKPlatformTypeAppleAccount;
break;
case ThirdLoginType_Gmail:
platformType = SSDKPlatformTypeGooglePlus;
break;
default:
platformType = SSDKPlatformTypeAppleAccount;
break;
}
NSDictionary * settings;
if (type == SSDKPlatformTypeFacebook) {
settings = @{@"isBrowser":@(YES)};
}
@kWeakify(self);
[ShareSDK cancelAuthorize:platformType result:nil];
[ShareSDK authorize:platformType
settings:settings
onStateChanged:^(SSDKResponseState state, SSDKUser *user, NSError *error) {
@kStrongify(self);
if (state == SSDKResponseStateSuccess) {///
ThirdUserInfo * userInfo = [[ThirdUserInfo alloc] init];
NSString * openid = @"";
NSString * access_token = user.credential.token.length > 0 ? user.credential.token : @"";
NSString * unionid = @"";
if (platformType == SSDKPlatformTypeLine) {
openid = user.credential.uid.length > 0 ? user.credential.uid : user.uid;
unionid = user.credential.uid.length > 0 ? user.credential.uid : user.uid;
userInfo.userName = user.nickname;
userInfo.avatarUrl = user.icon;
} else if (platformType == SSDKPlatformTypeFacebook) { //
openid = user.credential.uid.length > 0 ? user.credential.uid : user.uid;;
unionid = user.credential.uid.length > 0 ? user.credential.uid : user.uid;;
userInfo.userName = user.nickname;
userInfo.avatarUrl = user.icon;
} else if (platformType == SSDKPlatformTypeAppleAccount) { //
// openid = user.credential.token;
unionid = [user.credential rawData][@"user"];
NSString * familyName = [user.credential rawData][@"fullName"][@"familyName"];
NSString * givenName = [user.credential rawData][@"fullName"][@"givenName"];
if (familyName.length > 0 && givenName.length> 0) {
userInfo.userName = [NSString stringWithFormat:@"%@%@", familyName, givenName];
}
}
if (unionid == nil) {
unionid = @"";
}
openid = unionid;
userInfo.openid = openid;
userInfo.access_token = access_token;
userInfo.unionid = unionid;
///
[AccountInfoStorage instance].thirdUserInfo = userInfo;
[self loginWithThirdPartWithType:type];
} else if(state == SSDKResponseStateCancel) {///
[[self getView] showErrorToast:YMLocalizedString(@"LoginPresenter0")];
} else if (state == SSDKResponseStateFail) {///
[[self getView] showErrorToast:YMLocalizedString(@"LoginPresenter1")];
}
}];
}
-(void)loginWithThirdPartWithType:(ThirdLoginType)type{
[XNDJTDDLoadingTool showOnlyView:kWindow];
NSString * openid = [AccountInfoStorage instance].thirdUserInfo.openid;
NSString * access_token = [AccountInfoStorage instance].thirdUserInfo.access_token;
NSString * unionid = [AccountInfoStorage instance].thirdUserInfo.unionid;
@kWeakify(self);
[Api loginWithThirdPart:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
AccountModel * model = [AccountModel modelWithDictionary:data.data];
if (model != nil) {
[[AccountInfoStorage instance] saveAccountInfo:model];
[XNDJTDDLoadingTool hideOnlyView:kWindow];
[[self getView] loginThirdPartSuccess];
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
[XNDJTDDLoadingTool hideOnlyView:kWindow];
if (msg.length == 0) {
[[self getView] showErrorToast:YMLocalizedString(@"LoginPresenter1")];
}
} showLoading:YES errorToast:YES]
openid:openid
unionid:unionid
access_token:access_token
type:[NSString stringWithFormat:@"%lu", (unsigned long)type]];
}
-(void)thirdLoginByLine:(UIViewController *)presentingViewController {
}
-(void)thirdLoginByFBWithPresentingViewController:(UIViewController *)presentingViewController {
}
-(void)thirdLoginByGoogleWithPresentingViewController:(UIViewController *)presentingViewController configuration:(GIDConfiguration *)configuration{
@kWeakify(self);
[GIDSignIn sharedInstance].configuration = configuration;
[GIDSignIn.sharedInstance signInWithPresentingViewController:presentingViewController
completion:^(GIDSignInResult * _Nullable signInResult, NSError * _Nullable error) {
@kStrongify(self);
if (error) {
if (error.code == kGIDSignInErrorCodeCanceled){
[[self getView] showErrorToast:YMLocalizedString(@"LoginPresenter0")];
}else{
[[self getView] showErrorToast:YMLocalizedString(@"LoginPresenter1")];
}
} else {
ThirdUserInfo * userInfo = [[ThirdUserInfo alloc] init];
NSString * openid = signInResult.user.userID;
NSString * access_token = signInResult.user.idToken.tokenString.length > 0 ? signInResult.user.idToken.tokenString : @"";
NSString * unionid = signInResult.user.userID;
userInfo.userName = signInResult.user.profile.name;
userInfo.avatarUrl = [[signInResult.user.profile imageURLWithDimension:60] absoluteString];
userInfo.openid = openid;
userInfo.access_token = access_token;
userInfo.unionid = unionid;
///
[AccountInfoStorage instance].thirdUserInfo = userInfo;
[self loginWithThirdGoogle];
}
}];
}
-(void)loginWithThirdGoogle{
[XNDJTDDLoadingTool showOnlyView:kWindow];
NSString * openid = [AccountInfoStorage instance].thirdUserInfo.openid;
NSString * access_token = [AccountInfoStorage instance].thirdUserInfo.access_token;
NSString * unionid = [AccountInfoStorage instance].thirdUserInfo.unionid;
@kWeakify(self);
[Api loginWithThirdPart:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
[XNDJTDDLoadingTool hideOnlyView:kWindow];
AccountModel * model = [AccountModel modelWithDictionary:data.data];
if (model != nil) {
[[AccountInfoStorage instance] saveAccountInfo:model];
[[self getView] loginThirdPartSuccess];
}
}fail:^(NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
[XNDJTDDLoadingTool hideOnlyView:kWindow];
if (msg.length == 0) {
[[self getView] showErrorToast:YMLocalizedString(@"LoginPresenter1")];
}
} showLoading:YES errorToast:YES]
openid:openid
unionid:unionid
access_token:access_token
type:[NSString stringWithFormat:@"%lu", (unsigned long)ThirdLoginType_Gmail]];
}
///
/// @param phone
/// @param type
- (void)phoneSmsCode:(NSString *)phone type:(GetSmsType)type phoneAreaCode:(NSString *)phoneAreaCode {
NSString * desPhone = [DESEncrypt encryptUseDES:phone key:KeyWithType(KeyType_PasswordEncode)];
@kWeakify(self);
[Api phoneSmsCode:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
if ([[self getView] respondsToSelector:@selector(phoneSmsCodeSuccess:type:)]) {
NSString *message = data.message;
[[self getView] phoneSmsCodeSuccess:message type:type];
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
if ([[self getView] respondsToSelector:@selector(phoneSmsCodeFailure)]) {
[[self getView] phoneSmsCodeFailure];
}
} showLoading:YES errorToast:YES] 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)];
@kWeakify(self);
[Api loginWithCode:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
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) {
@kStrongify(self);
[[self getView] loginFailWithMsg:msg];
} errorToast:NO] phone:desPhone code:code client_secret:clinet_s 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)];
@kWeakify(self);
[Api loginWithPassword:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
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) {
@kStrongify(self);
[[self getView] loginFailWithMsg:msg];
} showLoading:YES errorToast:YES] phone:desPhone password:desPassword client_secret:clinet_s version:@"1" client_id:@"erban-client" grant_type:@"password"];
}
///
- (void)loadFeedbackConfig:(void(^)(FeedBackConfigModel *model))success
failure:(void(^)(NSString *errorMessage))failure {
[Api loadFeedbackConfig:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
FeedBackConfigModel *model =[FeedBackConfigModel modelWithDictionary:data.data];
if (success) {
success(model);
}
} else {
if (failure) {
failure(msg);
}
}
}];
}
- (void)submitFeedback:(void(^)(void))success
failure:(void(^)(NSString *errorMessage))failure
type:(NSString *)type
desc:(NSString *)desc
photoURLString:(nullable NSString *)photoURLString
contact:(nullable NSString *)contact {
[Api commitFeedback:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
if (success) {
success();
}
} else {
if (failure) {
failure(msg);
}
}
}
type:type
desc:desc
screenUrl:photoURLString ? photoURLString : @""
contact:contact ? contact : @""];
}
- (void)sendMailVerificationCode:(NSString *)emailAddress type:(NSInteger)type {
NSString * desEmail = [DESEncrypt encryptUseDES:emailAddress key:KeyWithType(KeyType_PasswordEncode)];
@kWeakify(self);
[Api emailGetCode:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
if ([[self getView] respondsToSelector:@selector(emailCodeSucess:type:)]) {
[[self getView] emailCodeSucess:@"" type:type];
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
if ([[self getView] respondsToSelector:@selector(emailCodeFailure)]) {
[[self getView] emailCodeFailure];
}
} showLoading:YES errorToast:YES]
emailAddress:desEmail type:@(type)];
}
- (void)loginWithEmail:(NSString *)email code:(NSString *)code {
NSString * desMail = [DESEncrypt encryptUseDES:email key:KeyWithType(KeyType_PasswordEncode)];
@kWeakify(self);
[Api loginWithCode:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
AccountModel * accountModel = [AccountModel modelWithDictionary:data.data];
if (accountModel && accountModel.access_token.length > 0) {
[[AccountInfoStorage instance] saveAccountInfo:accountModel];
}
if ([[self getView] respondsToSelector:@selector(loginSuccess)]) {
[[self getView] loginSuccess];
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
[[self getView] loginFailWithMsg:msg];
} errorToast:NO]
email:desMail
code:code
client_secret:clinet_s
version:@"1"
client_id:@"erban-client"
grant_type:@"email"];
}
- (void)bindingNewEmail:(NSString *)email code:(NSString *)code {
NSString *desMail = [DESEncrypt encryptUseDES:email key:KeyWithType(KeyType_PasswordEncode)];
@kWeakify(self);
[Api userBoundEmail:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
if ([[self getView] respondsToSelector:@selector(bindingNewEmailSuccess:)]) {
[[self getView] bindingNewEmailSuccess:@""];
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
if ([[self getView] respondsToSelector:@selector(bindingNewEmailFailure:)]) {
[[self getView] bindingNewEmailFailure:msg];
}
} showLoading:YES errorToast:NO] email:desMail code:code];
}
- (void)bindingNewPhone:(NSString *)phone code:(NSString *)code areaCode:(NSString *)areaCode {
NSString * desPhone = [DESEncrypt encryptUseDES:phone key:KeyWithType(KeyType_PasswordEncode)];
@kWeakify(self);
[Api userBoundPhone:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
if ([[self getView] respondsToSelector:@selector(bindingNewPhoneSuccess:)]) {
[[self getView] bindingNewPhoneSuccess:@""];
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
if ([[self getView] respondsToSelector:@selector(bindingNewPhoneFailure:)]) {
[[self getView] bindingNewPhoneFailure:msg];
}
} showLoading:YES errorToast:YES] phone:desPhone code:code phoneAreaCode:areaCode];
}
- (void)resetEmailPassword:(NSString *)email code:(NSString *)code newPassword:(NSString *)newPwd {
NSString *desMail = [DESEncrypt encryptUseDES:email key:KeyWithType(KeyType_PasswordEncode)];
NSString *desPassword = [DESEncrypt encryptUseDES:newPwd key:KeyWithType(KeyType_PasswordEncode)];
@kWeakify(self);
[Api resetPasswordWithEmail:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
if ([[self getView] respondsToSelector:@selector(resetEmailPasswordSuccess)]) {
[[self getView] resetEmailPasswordSuccess];
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
} showLoading:YES errorToast:YES] email:desMail newPwd:desPassword code:code];
}
- (void)resetPhonePassword:(NSString *)phone code:(NSString *)code newPassword:(NSString *)newPwd areaCode:(NSString *)areaCode {
NSString * desPhone = [DESEncrypt encryptUseDES:phone key:KeyWithType(KeyType_PasswordEncode)];
NSString *desPassword = [DESEncrypt encryptUseDES:newPwd key:KeyWithType(KeyType_PasswordEncode)];
@kWeakify(self);
[Api resetPasswordWithPhone:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
@kStrongify(self);
if ([[self getView] respondsToSelector:@selector(resetPhonePasswordSuccess)]) {
[[self getView] resetPhonePasswordSuccess];
}
} fail:^(NSInteger code, NSString * _Nullable msg) {
} showLoading:YES errorToast:YES] phone:desPhone newPwd:desPassword smsCode:code phoneAreaCode:areaCode];
}
- (void)checkEmailCode:(NSString *)email code:(NSString *)code {
NSString *desMail = [DESEncrypt encryptUseDES:email key:KeyWithType(KeyType_PasswordEncode)];
[Api emailVerify:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] checkEmailSuccess];
} fail:^(NSInteger code, NSString * _Nullable msg) {
} showLoading:YES errorToast:YES] emailAddress:desMail code:code];
}
- (void)checkPhoneCode:(NSString *)phone code:(NSString *)code areaCode:(NSString *)areaCode {
NSString * desPhone = [DESEncrypt encryptUseDES:phone key:KeyWithType(KeyType_PasswordEncode)];
NSString * uid = [[AccountInfoStorage instance] getUid];
NSString * ticket = [[AccountInfoStorage instance] getTicket];
[Api checkMoblieCode:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] checkPhoneSuccess];
} fail:^(NSInteger code, NSString * _Nullable msg) {
} showLoading:YES errorToast:YES] mobile:desPhone code:desPhone uid:uid ticket:ticket phoneAreaCode:areaCode];
}
@end

View File

@@ -0,0 +1,35 @@
//
// LoginVerifCodePresent.h
// YUMI
//
// Created by YUMI on 2021/9/9.
//
#import "BaseMvpPresenter.h"
#import "YUMINNNN.h"
NS_ASSUME_NONNULL_BEGIN
@interface LoginVerifCodePresent : BaseMvpPresenter
/// 获取手机的验证码
/// @param phone 手机号
/// @param type 类型
- (void)phoneSmsCode:(NSString *)phone type:(GetSmsType)type phoneAreaCode:(NSString *)phoneAreaCode;
/// 使用手机号和验证码登录
/// @param phone 手机号
/// @param code 验证码
- (void)loginWithPhone:(NSString *)phone code:(NSString *)code phoneAreaCode:(NSString *)phoneAreaCode;
/// 使用手机号和密码登录
/// @param phone 手机号
/// @param password 验证码
- (void)loginWithPhone:(NSString *)phone password:(NSString *)password;
/// 绑定手机号
/// @param phone 手机号
/// @param code 验证码
- (void)bindWithPhone:(NSString *)phone code:(NSString *)code phoneAreaCode:(NSString *)phoneAreaCode;
///绑定授权码
-(void)bindAuthorizationCodeWithAuthCode:(NSString *)authCode;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,89 @@
//
// 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

View File

@@ -0,0 +1,30 @@
//
// YMLoginVerifBindPhonePresenter.h
// YUMI
//
// Created by YUMI on 2021/9/18.
//
#import "MainPresenter.h"
#import "YUMINNNN.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPLoginVerifBindPhonePresenter : MainPresenter
/// 获取手机的验证码
/// @param phone 手机号
/// @param type 类型
- (void)phoneSmsCode:(NSString *)phone type:(GetSmsType)type phoneAreaCode:(NSString *)phoneAreaCode;
/// 校验手机验证码接口
/// @param moblieNum 手机号码
/// @param code 验证码
- (void)checkMoblieCodeWithMoblie:(NSString *)moblieNum code:(NSString *)code phoneAreaCode:(NSString *)phoneAreaCode;
/// 绑定手机验证码接口
/// @param moblieNum 手机号码
/// @param code 验证码
- (void)bindkMoblieCodeWithMoblie:(NSString *)moblieNum code:(NSString *)code phoneAreaCode:(NSString *)phoneAreaCode;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,53 @@
//
// YMLoginVerifBindPhonePresenter.m
// YUMI
//
// Created by YUMI on 2021/9/18.
//
#import "XPLoginVerifBindPhonePresenter.h"
#import "Api+Login.h"
///Tool
#import "AccountInfoStorage.h"
#import "DESEncrypt.h"
#import "YUMIConstant.h"
///P
#import "XPLoginVerifBindPhoneProtocol.h"
@implementation XPLoginVerifBindPhonePresenter
///
/// @param phone
/// @param type
- (void)phoneSmsCode:(NSString *)phone type:(GetSmsType)type phoneAreaCode:(NSString *)phoneAreaCode{
NSString * typeStr = [NSString stringWithFormat:@"%lu", (unsigned long)type];
NSString * desPhone = [DESEncrypt encryptUseDES:phone key:KeyWithType(KeyType_PasswordEncode)];
[Api phoneSmsCode:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] phoneSmsCodeSuccess];
}] mobile:desPhone type:typeStr phoneAreaCode:phoneAreaCode];
}
///
/// @param moblieNum
/// @param code
- (void)checkMoblieCodeWithMoblie:(NSString *)moblieNum code:(NSString *)code phoneAreaCode:(NSString *)phoneAreaCode{
NSString * uid = [[AccountInfoStorage instance] getUid];
NSString * ticket = [[AccountInfoStorage instance] getTicket];
NSString * desPhone = [DESEncrypt encryptUseDES:moblieNum key:KeyWithType(KeyType_PasswordEncode)];
[Api checkMoblieCode:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] checkMoblieCodeWithMoblieSuccess];
}] mobile:desPhone code:code uid:uid ticket:ticket phoneAreaCode:phoneAreaCode];
}
///
/// @param moblieNum
/// @param code
- (void)bindkMoblieCodeWithMoblie:(NSString *)moblieNum code:(NSString *)code phoneAreaCode:(NSString *)phoneAreaCode{
NSString * ticket = [[AccountInfoStorage instance] getTicket];
NSString * desPhone = [DESEncrypt encryptUseDES:moblieNum key:KeyWithType(KeyType_PasswordEncode)];
[Api bindMoblieCode:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
[[self getView] bindMoblieCodeWithMoblieSuccess];
}] phone:desPhone code:code ticket:ticket phoneAreaCode:phoneAreaCode];
}
@end

View File

@@ -0,0 +1,19 @@
//
// LoginForgetPasswordProtocol.h
// YUMI
//
// Created by YUMI on 2021/9/10.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol LoginForgetPasswordProtocol <NSObject>
///请求手机号的验证码成功
- (void)phoneSmsCodeSuccess;
///重置密码成功
- (void)resetPasswrodSuccess;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,21 @@
//
// LoginFullInfoProtocol.h
// YUMI
//
// Created by YUMI on 2021/9/14.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol LoginFullInfoProtocol <NSObject>
///随机请求一个昵称
- (void)requestRandomNickSuccess:(NSString *)nick;
///补全资料成功
- (void)complementInfoSuccess;
///补全资料失败
- (void)complementInfoFail;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,17 @@
//
// LoginPasswordProtocol.h
// YUMI
//
// Created by YUMI on 2021/9/9.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol LoginPasswordProtocol <NSObject>
///手机号密码登录成功
- (void)phoneAndPasswordLoginSuccess;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,42 @@
//
// LoginProtocol.h
// YUMI
//
// Created by zu on 2021/9/1.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol LoginProtocol <NSObject>
@optional
- (void)loginThirdPartSuccess;
- (void)loginSuccess;
- (void)emailCodeSucess:(NSString *)message type:(GetSmsType)type;
- (void)emailCodeFailure;
///请求手机号的验证码成功
- (void)phoneSmsCodeSuccess:(NSString *)message type:(GetSmsType)type;
- (void)phoneSmsCodeFailure;
///手机号登录成功
- (void)loginWithPhoenSuccess;
- (void)loginWithEmailSuccess;
///登录失败
- (void)loginFailWithMsg:(NSString *)msg;
- (void)bindingNewEmailSuccess:(NSString *)message;
- (void)bindingNewEmailFailure:(NSString *)message;
- (void)bindingNewPhoneSuccess:(NSString *)message;
- (void)bindingNewPhoneFailure:(NSString *)message;
- (void)resetEmailPasswordSuccess;
- (void)resetPhonePasswordSuccess;
- (void)checkEmailSuccess;
- (void)checkPhoneSuccess;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,29 @@
//
// LoginVerifCodeProtocol.h
// YUMI
//
// Created by YUMI on 2021/9/9.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol LoginVerifCodeProtocol <NSObject>
///请求手机号的验证码成功
- (void)phoneSmsCodeSuccess;
///手机号登录成功
- (void)loginWithPhoenSuccess;
///登录成功
- (void)loginSuccess;
///登录失败
- (void)loginFailWithMsg:(NSString *)msg;
///绑定手机号成功
- (void)bindPhoneSuccess;
///绑定授权码成功
-(void)bindAuthorizationCodeSuccess;
///绑定授权码失败
-(void)bindAuthorizationCodeFail;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,21 @@
//
// YMLoginVerifBindPhoneProtocol.h
// YUMI
//
// Created by YUMI on 2021/9/18.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol XPLoginVerifBindPhoneProtocol <NSObject>
///请求手机号的验证码成功
- (void)phoneSmsCodeSuccess;
///绑定手机号成功
- (void)bindMoblieCodeWithMoblieSuccess;
///验证绑定手机成功
- (void)checkMoblieCodeWithMoblieSuccess;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,27 @@
//
// AccountBindingViewController.h
// YuMi
//
// Created by P on 2025/3/14.
//
#import "MvpViewController.h"
@class UserInfoModel;
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, BindingDisplayType) {
BindingDisplayType_email,
BindingDisplayType_phoneNum,
};
@interface AccountBindingViewController : MvpViewController
- (instancetype)initWithType:(BindingDisplayType)type
currentBindingAccount:(NSString *)account
areaCode:(NSString *)areaCode
userInfo:(UserInfoModel *)userInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,444 @@
//
// AccountBindingViewController.m
// YuMi
//
// Created by P on 2025/3/14.
//
#import "AccountBindingViewController.h"
#import "LoginProtocol.h"
#import "LoginPresenter.h"
#import "LoginInputItemView.h"
#import "XPLoginAraeViewController.h"
#import "XPLoginVerifBindPhonePresenter.h"
#import "UserInfoModel.h"
#import "XPMineSettingViewController.h"
#import "XPWebViewController.h"
@interface AccountBindingViewController () <XPLoginAraeViewControllerDelegate, LoginProtocol, XPLoginAraeViewControllerDelegate>
@property(nonatomic, assign) BindingDisplayType type;
@property(nonatomic, copy) NSString *currentAccount;
@property(nonatomic, copy) NSString *currentAreaCode;
@property(nonatomic, strong) UILabel *currentAccountLabel;
@property(nonatomic, strong) UIStackView *stackView;
@property(nonatomic, strong) LoginInputItemView *firstLineInputView;
@property(nonatomic, strong) LoginInputItemView *secondLineInputView;
@property(nonatomic, strong) UIButton *bottomActionButton;
@property(nonatomic, strong) UserInfoModel *userInfo;
@property(nonatomic, strong) XPWebViewController *webVC;
@end
@implementation AccountBindingViewController
- (LoginPresenter *)createPresenter {
return [[LoginPresenter alloc] init];
}
- (instancetype)initWithType:(BindingDisplayType)type
currentBindingAccount:(NSString *)account
areaCode:(NSString *)areaCode
userInfo:(UserInfoModel *)userInfo {
if (self = [super init]) {
self.type = type;
self.currentAccount = account;
self.currentAreaCode = areaCode;
self.userInfo = userInfo;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self setupUI];
}
- (void)setupUI {
[self setupDefaultUI];
if ([NSString isEmpty:self.currentAccount]) {
[self setupNewBindingUI];
} else {
[self setupUpdateBindingUI];
}
}
- (void)setupDefaultUI {
self.view.backgroundColor = [UIColor whiteColor];
self.title = [self displayTitle];
}
- (void)setupNewBindingUI {
[self displayInputArea:25
topView:self.view
isBottom:NO];
}
- (void)setupUpdateBindingUI {
UIImageView *topImageView = [self topImageView];
[self.view addSubview:topImageView];
[topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view).offset(16);
make.centerX.mas_equalTo(self.view);
make.size.mas_equalTo(CGSizeMake(170, 170));
}];
UILabel *descLabel = [self descriptionLabel];
[self.view addSubview:descLabel];
[descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(topImageView.mas_bottom).offset(14);
make.leading.trailing.mas_equalTo(self.view).inset(40);
}];
[self.view addSubview:self.currentAccountLabel];
[self.currentAccountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(descLabel.mas_bottom).offset(9);
make.centerX.mas_equalTo(self.view);
}];
self.currentAccountLabel.text = self.currentAccount;
[self displayInputArea:25
topView:self.currentAccountLabel
isBottom:YES];
}
#pragma mark -
- (NSString *)displayTitle {
if ([NSString isEmpty:self.currentAccount]) {
if (self.type == BindingDisplayType_email) {
return YMLocalizedString(@"20.20.51_text_13");
} else {
return YMLocalizedString(@"20.20.51_text_14");
}
} else {
return YMLocalizedString(@"20.20.51_text_15");
}
}
- (void)displayInputArea:(NSInteger)topSpace
topView:(UIView *)topView
isBottom:(BOOL)isBottom {
[self.view addSubview:self.stackView];
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
if (isBottom) {
make.top.mas_equalTo(topView.mas_bottom).offset(topSpace);
} else {
make.top.mas_equalTo(topView).offset(topSpace);
}
make.leading.trailing.mas_equalTo(self.view).inset(40);
}];
@kWeakify(self);
if ([NSString isEmpty:self.currentAccount]) {
if (self.type == BindingDisplayType_email) {
self.firstLineInputView = [[LoginInputItemView alloc] initWithType:LoginInputType_email];
} else {
self.firstLineInputView = [[LoginInputItemView alloc] initWithType:LoginInputType_phoneNum];
}
[self.firstLineInputView updateBGColor:UIColorFromRGB(0xf2f3f7)];
[self.firstLineInputView setHandleItemAction:^(LoginInputType inputType) {
@kStrongify(self);
if (inputType == LoginInputType_phoneNum) {
[self handleTapAreaCode];
}
}];
[self.firstLineInputView setHandleFirstInputContentUpdate:^(NSString *inputContent) {
@kStrongify(self);
[self checkActionButtonStatus];
}];
[self.stackView addArrangedSubview:self.firstLineInputView];
}
self.secondLineInputView = [[LoginInputItemView alloc] initWithType:LoginInputType_verificationCode];
[self.secondLineInputView updateBGColor:UIColorFromRGB(0xf2f3f7)];
[self.secondLineInputView setHandleItemAction:^(LoginInputType inputType) {
@kStrongify(self);
if (inputType == LoginInputType_verificationCode) {
if (self.type == BindingDisplayType_phoneNum) {
[self handleTapGetPhoneVerificationCode];
} else if (self.type == BindingDisplayType_email) {
[self handleTapGetMailVerificationCode];
}
}
}];
[self.secondLineInputView setHandleSecondInputContentUpdate:^(NSString *inputContent) {
@kStrongify(self);
[self checkActionButtonStatus];
}];
[self.stackView addArrangedSubview:self.secondLineInputView];
[self.stackView addArrangedSubview:self.bottomActionButton];
[self.firstLineInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(46);
}];
[self.secondLineInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(46);
}];
[self.bottomActionButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(46);
}];
}
#pragma mark -
- (void)handleTapGetPhoneVerificationCode {
NSString *phone = @"";
NSString *areaCode = @"";
if ([NSString isEmpty:self.currentAccount]) {
phone = [self.firstLineInputView inputContent];
areaCode = [self.firstLineInputView loadAreaCode];
} else {
phone = self.currentAccount;
areaCode = self.currentAreaCode;
}
if (phone.length == 0 ) {
[self showErrorToast:YMLocalizedString(@"XPLoginPhoneViewController0")];
[self.secondLineInputView endVerificationCountDown];
return;
}
@kWeakify(self);
[self loadCaptchaWebView:^{
@kStrongify(self);
[self.presenter phoneSmsCode:[NSString stringWithFormat:@"%@%@", areaCode,phone]
type:[NSString isEmpty:self.currentAccount] ? GetSmsType_Regist : GetSmsType_Unbind_Phone
phoneAreaCode:areaCode];
}];
}
- (void)handleTapGetMailVerificationCode {
NSString *email = @"";
if (![NSString isEmpty:self.currentAccount]) {
email = self.currentAccount;
} else {
email = [self.firstLineInputView inputContent];
}
if (email.length == 0 ) {
// [self showErrorToast:YMLocalizedString(@"20.20.51_text_12")];
[self.secondLineInputView endVerificationCountDown];
return;
}
[self.presenter sendMailVerificationCode:email
type:[NSString isEmpty:self.currentAccount] ? GetSmsType_Regist : GetSmsType_Unbind_Phone];
}
#pragma mark -
- (void)didTapActionButton {
[self.view endEditing:true];
if (self.type == BindingDisplayType_email) {
if ([NSString isEmpty:self.currentAccount]) {
[self.presenter bindingNewEmail:[self.firstLineInputView inputContent]
code:[self.secondLineInputView inputContent]];
} else {
[self.presenter checkEmailCode:self.currentAccount
code:[self.secondLineInputView inputContent]];
}
} else {
if ([NSString isEmpty:self.currentAccount]) {
[self.presenter bindingNewPhone:[self.firstLineInputView inputContent]
code:[self.secondLineInputView inputContent]
areaCode:[self.firstLineInputView loadAreaCode]];
} else {
[self.presenter checkPhoneCode:self.currentAccount
code:[self.secondLineInputView inputContent]
areaCode:self.userInfo.phoneAreaCode];
}
}
}
- (void)handleTapAreaCode {
XPLoginAraeViewController *codeVC = [XPLoginAraeViewController new];
codeVC.delegate = self;
[self.navigationController pushViewController:codeVC animated:YES];
}
- (void)checkActionButtonStatus {
NSString *accountString = [self.firstLineInputView inputContent];
NSString *codeString = [self.secondLineInputView inputContent];
if ([NSString isEmpty:self.currentAccount]) {
if (![NSString isEmpty:accountString] && ![NSString isEmpty:codeString]) {
self.bottomActionButton.enabled = YES;
} else {
self.bottomActionButton.enabled = NO;
}
} else {
if (![NSString isEmpty:codeString]) {
self.bottomActionButton.enabled = YES;
} else {
self.bottomActionButton.enabled = NO;
}
}
}
- (void)loadCaptchaWebView:(void(^)(void))finishBlock {
if ([ClientConfig.shareConfig shouldDisplayCaptcha]) {
[self.view endEditing:YES];
XPWebViewController * webVC =[[XPWebViewController alloc] initWithRoomUID:nil];
webVC.view.frame = CGRectMake(0, 0, KScreenWidth*0.8, KScreenWidth*1.2);
webVC.view.backgroundColor = [UIColor clearColor];
[webVC.view setCornerRadius:12];
webVC.isLoginStatus = NO;
webVC.isPush = NO;
[webVC hideNavigationBar];
webVC.url = URLWithType(kCaptchaSwitchPath);
[webVC setVerifyCaptcha:^(BOOL result) {
if (result == NO) {
return;
}
if (result && finishBlock) {
[TTPopup dismiss];
finishBlock();
}
}];
[TTPopup popupView:webVC.view style:TTPopupStyleAlert];
self.webVC = webVC;
}
}
#pragma mark - API presenter Delegate
- (void)phoneSmsCodeSuccess:(NSString *)message type:(GetSmsType)type{
if (type == GetSmsType_Unbind_Phone) {
XPLoginVerifBindPhonePresenter *presenter = [[XPLoginVerifBindPhonePresenter alloc] init];
[presenter checkMoblieCodeWithMoblie:self.currentAccount
code:[self.secondLineInputView inputContent]
phoneAreaCode:self.userInfo.phoneAreaCode];
} else {
[self showSuccessToast:YMLocalizedString(@"XPLoginPhoneViewController2")];
[self.secondLineInputView startVerificationCountDown];
[self.secondLineInputView displayKeyboard];
}
}
- (void)phoneSmsCodeFailure {
[self.secondLineInputView endVerificationCountDown];
}
- (void)emailCodeSucess:(NSString *)message type:(GetSmsType)type{
[self showSuccessToast:YMLocalizedString(@"XPLoginPhoneViewController2")];
[self.secondLineInputView startVerificationCountDown];
[self.secondLineInputView displayKeyboard];
}
- (void)emailCodeFailure {
[self.secondLineInputView endVerificationCountDown];
[self.navigationController popViewControllerAnimated:YES];
}
- (void)bindingNewEmailSuccess:(NSString *)message {
[self showSuccessToast:YMLocalizedString(@"XPLoginBindSuccessView0")];
for (UIViewController *VC in self.navigationController.viewControllers) {
if ([VC isKindOfClass:[XPMineSettingViewController class]]) {
[self.navigationController popToViewController:VC animated:YES];
return;
}
}
}
- (void)bindingNewEmailFailure:(NSString *)message {
[self showSuccessToast:message];
}
- (void)chooseAreaCodeSuccess:(NSString *)code {
[self.firstLineInputView updateAreaCode:code];
}
- (void)checkEmailSuccess {
AccountBindingViewController *vc = [[AccountBindingViewController alloc] initWithType:self.type
currentBindingAccount:@""
areaCode:@""
userInfo:self.userInfo];
[self.navigationController pushViewController:vc animated:YES];
}
- (void)checkPhoneSuccess {
AccountBindingViewController *vc = [[AccountBindingViewController alloc] initWithType:self.type
currentBindingAccount:@""
areaCode:@""
userInfo:self.userInfo];
[self.navigationController pushViewController:vc animated:YES];
}
- (void)bindingNewPhoneSuccess:(NSString *)message {
[self showSuccessToast:YMLocalizedString(@"XPLoginBindSuccessView0")];
for (UIViewController *VC in self.navigationController.viewControllers) {
if ([VC isKindOfClass:[XPMineSettingViewController class]]) {
[self.navigationController popToViewController:VC animated:YES];
return;
}
}
}
- (void)bindingNewPhoneFailure:(NSString *)message {
[self showSuccessToast:message];
}
#pragma mark -
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisVertical;
_stackView.spacing = 24;
_stackView.distribution = UIStackViewDistributionFillEqually;
}
return _stackView;
}
- (UIButton *)bottomActionButton {
if (!_bottomActionButton) {
_bottomActionButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_bottomActionButton setCornerRadius:23];
[_bottomActionButton setTitle:YMLocalizedString(@"XPAnchorAudienceUpMicView2") forState:UIControlStateNormal];
[_bottomActionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
UIImage *normalBG = [UIImage gradientColorImageFromColors:@[
UIColorFromRGB(0xe29030),
UIColorFromRGB(0xfcc074)
]
gradientType:GradientTypeLeftToRight
imgSize:CGSizeMake(KScreenWidth-84, 46)] ;
UIImage *disableBG = [UIImage gradientColorImageFromColors:@[
[UIColor colorWithRed:245/255.0 green:199/255.0 blue:129/255.0 alpha:1],
[UIColor colorWithRed:253/255.0 green:217/255.0 blue:154/255.0 alpha:1],
]
gradientType:GradientTypeLeftToRight
imgSize:CGSizeMake(KScreenWidth-84, 46)] ;
[_bottomActionButton setBackgroundImage:normalBG forState:UIControlStateNormal];
[_bottomActionButton setBackgroundImage:disableBG forState:UIControlStateDisabled];
[_bottomActionButton addTarget:self
action:@selector(didTapActionButton)
forControlEvents:UIControlEventTouchUpInside];
_bottomActionButton.enabled = NO;
}
return _bottomActionButton;
}
- (UIImageView *)topImageView {
UIImageView *imageView = [[UIImageView alloc] initWithImage:kImage(@"binding_page_top")];
imageView.contentMode = UIViewContentModeScaleAspectFit;
return imageView;
}
- (UILabel *)descriptionLabel {
UILabel *label = [UILabel labelInitWithText:YMLocalizedString(@"20.20.51_text_16")
font:kFontRegular(14)
textColor:UIColorFromRGB(0xafb1b3)];
label.textAlignment = NSTextAlignmentCenter;
label.numberOfLines = 0;
return label;
}
- (UILabel *)currentAccountLabel {
if (!_currentAccountLabel) {
_currentAccountLabel = [UILabel labelInitWithText:@""
font:kFontMedium(16)
textColor:UIColorFromRGB(0x313131)];
_currentAccountLabel.textAlignment = NSTextAlignmentCenter;
}
return _currentAccountLabel;
}
@end

View File

@@ -0,0 +1,36 @@
//
// LoginForgetEditView.h
// xplan-ios
//
// Created by 冯硕 on 2021/9/10.
//
#import <UIKit/UIKit.h>
#import "XPTextField.h"
NS_ASSUME_NONNULL_BEGIN
typedef enum : NSUInteger {
LoginForgetEditViewTypeNormal, // 普通类型
LoginForgetEditViewTypeSms, // 短信验证码类型
LoginForgetEditViewTypePassword, ///密码
} LoginForgetEditViewType;
@interface LoginForgetEditView : UIView
/** textField */
@property (nonatomic, strong, readonly) XPTextField *textField;
/** rightButton */
@property (nonatomic, strong, readonly) UIButton *rightButton;
/** 验证码 */
@property (nonatomic, strong, readonly) UIButton *authCodeButton;
///选择区号
@property (nonatomic,strong,readonly) UILabel *codeView;
///倒计时
@property (nonatomic, strong, readonly) UILabel *cutdownLabel;
///类型
@property (nonatomic, assign) LoginForgetEditViewType type;
///展位图
@property (nonatomic,copy) NSString *placeholder;
@property (nonatomic,copy) NSString *areaCode;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,207 @@
//
// LoginForgetEditView.m
// xplan-ios
//
// Created by on 2021/9/10.
//
#import "LoginForgetEditView.h"
///
#import <Masonry/Masonry.h>
///Tool
@interface LoginForgetEditView()
///
@property (nonatomic,strong) UIStackView *stackView;
///
@property (nonatomic, strong) UILabel *cutdownLabel;
///
@property (nonatomic,strong) UILabel *codeView;
/** textField */
@property (nonatomic, strong) XPTextField *textField;
/** rightButton */
@property (nonatomic, strong) UIButton *rightButton;
/** */
@property (nonatomic, strong) UIButton *authCodeButton;
@end
@implementation LoginForgetEditView
#pragma mark - life cycle
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self initView];
[self initConstrations];
}
return self;
}
#pragma mark - private method
- (void)initView {
self.backgroundColor = UIColorFromRGB(0xF0F5F6);
self.layer.masksToBounds = YES;
self.layer.cornerRadius = kGetScaleWidth(24);
[self addSubview:self.stackView];
[self.stackView addArrangedSubview:self.codeView];
[self.stackView addArrangedSubview:self.textField];
[self.stackView addArrangedSubview:self.rightButton];
[self.stackView addArrangedSubview:self.cutdownLabel];
[self.stackView addArrangedSubview:self.authCodeButton];
}
- (void)initConstrations {
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(kGetScaleWidth(20));
make.trailing.mas_equalTo(-kGetScaleWidth(20));
make.top.bottom.equalTo(self);
}];
[self.codeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_lessThanOrEqualTo(kGetScaleWidth(70));
}];
[self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.equalTo(self.codeView.mas_trailing).mas_offset(10);
}];
[self.authCodeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_lessThanOrEqualTo(kGetScaleWidth(120));
}];
[self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(24));
}];
[self.cutdownLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_lessThanOrEqualTo(kGetScaleWidth(120));
}];
}
#pragma mark - getters and setters
- (void)setType:(LoginForgetEditViewType)type {
switch (type) {
case LoginForgetEditViewTypeNormal:
self.codeView.hidden = NO;
self.rightButton.hidden = YES;
self.authCodeButton.hidden = YES;
self.cutdownLabel.hidden = YES;
self.textField.isValidation = YES;
break;
case LoginForgetEditViewTypeSms:
self.authCodeButton.hidden = NO;
self.rightButton.hidden = YES;
self.cutdownLabel.hidden = YES;
self.codeView.hidden = YES;
self.textField.isValidation = YES;
break;
case LoginForgetEditViewTypePassword:
self.authCodeButton.hidden = YES;
self.cutdownLabel.hidden = YES;
self.codeView.hidden = YES;
self.rightButton.hidden = NO;
self.textField.isValidation = NO;
break;
default:
break;
}
}
-(NSMutableAttributedString *)getChooseCodeText:(NSString *)code{
NSMutableAttributedString *codeAtt = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@ ",code] attributes:@{NSFontAttributeName:kFontSemibold(15),NSForegroundColorAttributeName:[DJDKMIMOMColor inputTextColor]}];
NSTextAttachment * attachment = [[NSTextAttachment alloc] init];
UIImage *iconImage = [UIImage imageNamed:@"login_arrow"];;
attachment.bounds = CGRectMake(0, roundf(self.codeView.font.capHeight - iconImage.size.height)/2.f, iconImage.size.width, iconImage.size.height);
attachment.image = iconImage;
[codeAtt appendAttributedString:[NSMutableAttributedString attributedStringWithAttachment:attachment]];
return codeAtt;
}
-(void)setAreaCode:(NSString *)areaCode{
_areaCode = areaCode;
_codeView.attributedText = [self getChooseCodeText:_areaCode];
}
- (void)setPlaceholder:(NSString *)placeholder {
_placeholder = placeholder;
if (_placeholder) {
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
NSDictionary *dic = @{
NSParagraphStyleAttributeName:style,
NSFontAttributeName:kFontRegular(15),
NSForegroundColorAttributeName:[DJDKMIMOMColor disableButtonTextColor]};
if (placeholder == nil || placeholder.length == 0) {
placeholder = @"";
}
self.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholder attributes:dic];
}
}
#pragma mark -
- (UILabel *)codeView{
if (!_codeView){
_codeView = [UILabel new];
_codeView.userInteractionEnabled = YES;
NSString *code = [NSString getCountryCode];
_codeView.attributedText = [self getChooseCodeText: code];
}
return _codeView;
}
- (XPTextField *)textField {
if (!_textField) {
_textField = [[XPTextField alloc]initWithFrame:CGRectZero];
_textField.font = kFontRegular(15);
_textField.textColor = [DJDKMIMOMColor inputTextColor];
_textField.adjustsFontSizeToFitWidth = YES;
}
return _textField;
}
- (UIButton *)rightButton {
if (!_rightButton) {
_rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_rightButton setImage:[UIImage imageNamed:@"login_forget_password_hidden"] forState:UIControlStateNormal];
[_rightButton setImage:[UIImage imageNamed:@"login_forget_password_show"] forState:UIControlStateSelected];
}
return _rightButton;
}
- (UILabel *)cutdownLabel {
if (!_cutdownLabel) {
_cutdownLabel = [[UILabel alloc] init];
_cutdownLabel.textAlignment = NSTextAlignmentRight;
_cutdownLabel.font = kFontRegular(15);
_cutdownLabel.textColor = UIColorFromRGB(0x9168FA);
_cutdownLabel.hidden = NO;
}
return _cutdownLabel;
}
- (UIButton *)authCodeButton {
if (!_authCodeButton) {
_authCodeButton = [UIButton buttonWithType:UIButtonTypeCustom];
_authCodeButton.titleLabel.font = kFontRegular(15);
[_authCodeButton setTitle:YMLocalizedString(@"LoginForgetEditView0") forState:UIControlStateNormal];
_authCodeButton.titleLabel.numberOfLines = 0;
_authCodeButton.titleLabel.adjustsFontSizeToFitWidth = YES;
[_authCodeButton setTitleColor:[DJDKMIMOMColor inputTextColor] forState:UIControlStateNormal];
}
return _authCodeButton;
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisHorizontal;
_stackView.distribution = UIStackViewDistributionFill;
_stackView.alignment = UIStackViewAlignmentFill;
_stackView.spacing = 10;
}
return _stackView;
}
@end

View File

@@ -0,0 +1,48 @@
//
// LoginInputItemView.h
// YuMi
//
// Created by P on 2025/3/14.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, LoginInputType) {
LoginInputType_id,
LoginInputType_email,
LoginInputType_phoneNum,
LoginInputType_password,
LoginInputType_createPassword,
LoginInputType_verificationCode,
LoginInputType_confirmPassword,
LoginInputType_forgetPassword,
LoginInputType_login,
LoginInputType_confirm,
LoginInputType_none
};
@interface LoginInputItemView : UIView
@property(nonatomic, copy) void(^handleItemAction)(LoginInputType inputType);
@property(nonatomic, copy) void(^handleFirstInputContentUpdate)(NSString *inputContent);
@property(nonatomic, copy) void(^handleSecondInputContentUpdate)(NSString *inputContent);
@property(nonatomic, copy) void(^handleThirdInputContentUpdate)(NSString *inputContent);
- (instancetype)initWithType:(LoginInputType)type;
- (NSString *)inputContent;
- (void)updateAreaCode:(NSString *)code;
- (NSString *)loadAreaCode;
- (void)startVerificationCountDown;
- (void)endVerificationCountDown;
- (void)updateBGColor:(UIColor *)color;
- (void)displayKeyboard;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,386 @@
//
// LoginInputItemView.m
// YuMi
//
// Created by P on 2025/3/14.
//
#import "LoginInputItemView.h"
static NSString *const kAreaCodePrefix = @"+";
@interface LoginInputItemView() <UITextFieldDelegate>
@property(nonatomic, copy) NSString *placeholderText;
@property(nonatomic, assign) LoginInputType inputType;
@property(nonatomic, strong) UITextField *inputTextField;
@property(nonatomic, strong) UIButton *rightActionButton;
@property(nonatomic, strong) UIButton *areaCodeButton;
@property(nonatomic, strong) UILabel *areaLabel;
@property(nonatomic, strong) UIButton *verificationCodeButton;
@property(nonatomic, assign) NSInteger verificationCountDown;
@property(nonatomic, strong) NSTimer *verificationTimer;
@end
@implementation LoginInputItemView
- (void)deallo {
_verificationTimer = nil;
}
- (instancetype)initWithType:(LoginInputType)type {
if (self = [super init]) {
self.backgroundColor = [UIColor whiteColor];
[self setCornerRadius:23];
[self addSubview:self.inputTextField];
self.inputType = type;
}
return self;
}
- (void)setInputType:(LoginInputType)inputType {
_inputType = inputType;
switch (inputType) {
case LoginInputType_id: {
[self updatePlaceholder:YMLocalizedString(@"20.20.51_text_3")];
self.inputTextField.keyboardType = UIKeyboardTypeNumberPad;
}
break;
case LoginInputType_email: {
[self updatePlaceholder:YMLocalizedString(@"20.20.51_text_4")];
self.inputTextField.keyboardType = UIKeyboardTypeEmailAddress;
}
break;
case LoginInputType_phoneNum: {
[self updatePlaceholder:YMLocalizedString(@"XPMineResetLoginPwdViewController1")];
self.inputTextField.keyboardType = UIKeyboardTypePhonePad;
}
break;
case LoginInputType_password: {
[self updatePlaceholder:YMLocalizedString(@"XPLoginPwdViewController3")];
self.inputTextField.keyboardType = UIKeyboardTypeDefault;
self.inputTextField.secureTextEntry = YES;
}
break;
case LoginInputType_createPassword:
[self updatePlaceholder:YMLocalizedString(@"20.20.51_text_11")];
self.inputTextField.keyboardType = UIKeyboardTypeDefault;
self.inputTextField.secureTextEntry = YES;
break;
case LoginInputType_verificationCode: {
[self updatePlaceholder:YMLocalizedString(@"20.20.51_text_7")];
self.inputTextField.keyboardType = UIKeyboardTypeDefault;
}
break;
case LoginInputType_confirmPassword: {
[self updatePlaceholder:YMLocalizedString(@"20.20.51_text_11")];
self.inputTextField.keyboardType = UIKeyboardTypeDefault;
}
break;
default:
break;
}
[self updateInputLayout];
}
- (void)updatePlaceholder:(NSString *)placeholder {
self.inputTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholder attributes:@{
NSFontAttributeName: kFontRegular(14),
NSForegroundColorAttributeName: UIColorFromRGB(0xafb1b3)
}];
}
- (void)updateInputLayout {
switch (self.inputType) {
case LoginInputType_id:
case LoginInputType_email:
case LoginInputType_createPassword:
case LoginInputType_confirmPassword:
{
[self.inputTextField mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self).insets(UIEdgeInsetsMake(12, 20, 12, 20));
}];
}
break;
case LoginInputType_password: {
[self insertRightActionButton];
[self.inputTextField mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self).offset(20);
make.bottom.top.mas_equalTo(self).inset(12);
make.trailing
.mas_equalTo(self.rightActionButton.mas_leading)
.offset(-20);
}];
}
break;
case LoginInputType_phoneNum: {
[self insertAreaCodeButton];
[self.inputTextField mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.areaCodeButton.mas_trailing).offset(8);
make.bottom.top.mas_equalTo(self).inset(12);
make.trailing.mas_equalTo(self).offset(-12);
}];
}
break;
case LoginInputType_verificationCode: {
[self insertVerificationCodeButton];
[self.inputTextField mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self).offset(20);
make.bottom.top.mas_equalTo(self).inset(12);
make.trailing
.mas_equalTo(self.verificationCodeButton.mas_leading)
.offset(-20);
}];
}
break;
default:
break;
}
}
- (void)insertAreaCodeButton {
[self addSubview:self.areaCodeButton];
[self.areaCodeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self);
make.leading.mas_equalTo(13);
make.height.mas_equalTo(20);
make.width.mas_equalTo(60);
}];
UIImageView *image = [[UIImageView alloc] initWithImage:kImage(@"login_page_area_arrow")];
image.contentMode = UIViewContentModeScaleAspectFit;
[self.areaCodeButton addSubview:image];
[self.areaCodeButton addSubview:self.areaLabel];
[self.areaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.areaCodeButton);
make.leading.mas_equalTo(self.areaCodeButton);
make.height.mas_equalTo(20);
}];
[image mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.areaCodeButton);
make.leading.mas_equalTo(self.areaLabel.mas_trailing).offset(4);
make.size.mas_equalTo(CGSizeMake(10, 5));
}];
}
- (void)insertVerificationCodeButton {
[self addSubview:self.verificationCodeButton];
[self.verificationCodeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self);
make.trailing.mas_equalTo(-23);
make.height.mas_equalTo(20);
if (isMSRTL()) {
make.width.mas_equalTo(80);
} else {
make.width.mas_equalTo(60);
}
}];
}
- (void)insertRightActionButton {
[self addSubview:self.rightActionButton];
[self.rightActionButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self);
make.trailing.mas_equalTo(-20);
make.height.mas_equalTo(24);
make.width.mas_equalTo(24);
}];
}
- (NSString *)inputContent {
return self.inputTextField.text;
}
- (void)updateAreaCode:(NSString *)code {
self.areaLabel.text = [NSString stringWithFormat:@"%@%@", kAreaCodePrefix, code];
// if (_areaCodeButton) {
// [self.areaCodeButton setTitle:[NSString stringWithFormat:@"%@%@", kAreaCodePrefix, code]
// forState:UIControlStateNormal];
// }
}
- (NSString *)loadAreaCode {
NSString *code = [self.areaLabel text];
if ([code hasPrefix:kAreaCodePrefix]) {
[code stringByReplacingOccurrencesOfString:kAreaCodePrefix
withString:@""];
}
return code;
}
- (void)startVerificationCountDown {
self.verificationCountDown = 60;
@kWeakify(self);
self.verificationTimer = [NSTimer scheduledTimerWithTimeInterval:1
repeats:YES
block:^(NSTimer * _Nonnull timer) {
@kStrongify(self);
[self updateVerificationCountDown];
}];
}
- (void)endVerificationCountDown {
if (_verificationTimer) {
[self.verificationTimer invalidate];
}
self.verificationCodeButton.enabled = YES;
}
- (void)updateBGColor:(UIColor *)color {
self.backgroundColor = color;
}
- (void)displayKeyboard {
[self.inputTextField becomeFirstResponder];
}
#pragma mark -
- (void)handleVerificationCountDown {
if (_handleItemAction) {
self.handleItemAction(self.inputType);
}
}
- (void)updateVerificationCountDown {
[self.verificationCodeButton setTitle:[NSString stringWithFormat:YMLocalizedString(@"20.20.51_text_9"), @(self.verificationCountDown)]
forState:UIControlStateDisabled];
self.verificationCodeButton.enabled = NO;
self.verificationCountDown -= 1;
if (self.verificationCountDown < 0) {
[self endVerificationCountDown];
}
}
#pragma mark -
- (void)didTapAreaButton {
if (_handleItemAction) {
self.handleItemAction(self.inputType);
}
}
- (void)didTapVerificationButton {
if (_handleItemAction) {
self.handleItemAction(self.inputType);
}
}
- (void)didTapRightActionButton {
self.rightActionButton.selected = !self.rightActionButton.isSelected;
self.inputTextField.secureTextEntry = !self.rightActionButton.selected;
}
#pragma mark - UITextFieldDelegate
- (void)textFieldDidChange:(UITextField *)textField {
// NSLog(@"%@", textField.text);
switch (self.inputType) {
case LoginInputType_id:
case LoginInputType_email:
case LoginInputType_phoneNum:
if (self.handleFirstInputContentUpdate) {
self.handleFirstInputContentUpdate(textField.text);
}
break;
case LoginInputType_password:
case LoginInputType_verificationCode:
if (self.handleSecondInputContentUpdate) {
self.handleSecondInputContentUpdate(textField.text);
}
break;
case LoginInputType_confirmPassword:
if (self.handleThirdInputContentUpdate) {
self.handleThirdInputContentUpdate(textField.text);
}
break;
default:
break;
}
}
//- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// NSString *updatedText = [textField.text stringByReplacingCharactersInRange:range withString:string];
// switch (self.inputType) {
// case LoginInputType_id:
// case LoginInputType_email:
// case LoginInputType_phoneNum:
// if (self.handleFirstInputContentUpdate) {
// self.handleFirstInputContentUpdate(updatedText);
// }
// break;
// case LoginInputType_password:
// case LoginInputType_verificationCode:
// if (self.handleSecondInputContentUpdate) {
// self.handleSecondInputContentUpdate(updatedText);
// }
// break;
// case LoginInputType_confirmPassword:
// if (self.handleThirdInputContentUpdate) {
// self.handleThirdInputContentUpdate(updatedText);
// }
// break;
// default:
// break;
// }
// });
// return YES;
//}
#pragma mark -
- (UITextField *)inputTextField {
if (!_inputTextField) {
_inputTextField = [[UITextField alloc] init];
_inputTextField.font = kFontMedium(14);
_inputTextField.textColor = UIColorFromRGB(0x313131);
// _inputTextField.delegate = self;
[_inputTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
}
return _inputTextField;
}
- (UILabel *)areaLabel {
if (!_areaLabel) {
_areaLabel = [UILabel labelInitWithText:[NSString getCountryCode] font:kFontMedium(14) textColor:UIColorFromRGB(0x313131)];
}
return _areaLabel;
}
- (UIButton *)areaCodeButton {
if (!_areaCodeButton) {
_areaCodeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_areaCodeButton addTarget:self
action:@selector(didTapAreaButton)
forControlEvents:UIControlEventTouchUpInside];
}
return _areaCodeButton;
}
- (UIButton *)verificationCodeButton {
if (!_verificationCodeButton) {
_verificationCodeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_verificationCodeButton.titleLabel setFont:kFontMedium(14)];
[_verificationCodeButton setTitle:YMLocalizedString(@"20.20.51_text_8") forState:UIControlStateNormal];
[_verificationCodeButton setTitleColor:UIColorFromRGB(0xff8c03) forState:UIControlStateNormal];
[_verificationCodeButton setTitleColor:UIColorFromRGB(0xafb1b3) forState:UIControlStateDisabled];
[_verificationCodeButton addTarget:self
action:@selector(didTapVerificationButton)
forControlEvents:UIControlEventTouchUpInside];
}
return _verificationCodeButton;
}
- (UIButton *)rightActionButton {
if (!_rightActionButton) {
_rightActionButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_rightActionButton setBackgroundImage:kImage(@"login_page_kaigan") forState:UIControlStateNormal];
[_rightActionButton setBackgroundImage:kImage(@"login_page_eye_close") forState:UIControlStateSelected];
[_rightActionButton addTarget:self
action:@selector(didTapRightActionButton)
forControlEvents:UIControlEventTouchUpInside];
}
return _rightActionButton;
}
@end

View File

@@ -0,0 +1,24 @@
//
// LoginVerifCodeView.h
// YUMI
//
// Created by YUMI on 2021/9/8.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface LoginVerifCodeView : UIView
///输入的验证码 有几位
@property (nonatomic,assign) int number;
///输入的字符串的
@property (nonatomic,copy) void(^textFieldChangeBlock)(NSString *);
///是否密文输入
@property (nonatomic, assign) BOOL shouldBeSecurity;
///类型
@property (nonatomic,assign) int type;//1.转赠钻石
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,195 @@
//
// LoginVerifCodeView.m
// YUMI
//
// Created by YUMI on 2021/9/8.
//
#import "LoginVerifCodeView.h"
///
#import <Masonry/Masonry.h>
#import <ReactiveObjC/ReactiveObjC.h>
///Tool
#import "DJDKMIMOMColor.h"
@interface LoginVerifCodeView ()
///
@property (nonatomic,strong) MSBaseTextField *textField;
///label
@property (nonatomic,strong) NSMutableArray<UILabel *> *labelArray;
@end
@implementation LoginVerifCodeView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
[self initEvents];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.textField];
}
- (void)initSubViewConstraints {
[self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
}
- (void)initEvents {
@weakify(self);
[[self.textField rac_signalForControlEvents:UIControlEventEditingChanged] subscribeNext:^(__kindof UITextField *textField) {
@strongify(self);
[self updateLablesWithText:textField];
}];
}
- (void)updateLablesWithText:(UITextField *)textField {
if (textField.text.length > self.labelArray.count) {
textField.text = [textField.text substringToIndex:self.labelArray.count];
}
if (textField.text.length >= self.number) {
[textField resignFirstResponder];
if (_textFieldChangeBlock) {
_textFieldChangeBlock(textField.text);
}
}
if (self.type == 1) {
@kWeakify(self);
[self.labelArray enumerateObjectsUsingBlock:^(UILabel *obj, NSUInteger idx, BOOL *stop) {
@kStrongify(self);
[self normalStyle:obj];
}];
}
NSInteger index = -1;
for (UILabel *pwLab in self.labelArray) {
if (pwLab.tag < (100 + textField.text.length)) {
if (self.shouldBeSecurity) {
pwLab.text = @"●";
index += 1;
} else {
NSRange range = NSMakeRange(pwLab.tag-100, 1);
pwLab.text = [textField.text substringWithRange:range];
}
}else{
pwLab.text = @"";
}
}
if (self.type == 1) {
UILabel *label = [self.labelArray xpSafeObjectAtIndex:index];
if (label) {
[self lastInputStyle:label];
}
}
}
- (void)configLabelArray {
CGFloat itemWidth = 45;
CGFloat itemHeight = 45;
CGFloat itemSpace = 11;
for (int i = 0; i < _number; i++) {
UILabel * label = [[UILabel alloc] init];
label.textColor = [DJDKMIMOMColor mainTextColor];
label.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
label.textAlignment = NSTextAlignmentCenter;
label.backgroundColor = UIColorFromRGB(0xf4f4f4);
[label setCornerRadius:10];
label.tag = 100 + i;
[self addSubview:label];
[label mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemWidth, itemHeight));
make.centerY.mas_equalTo(self);
make.leading.mas_equalTo(self).offset((itemWidth + itemSpace)* i);
}];
[self.labelArray addObject:label];
}
UILabel * label = [self.labelArray lastObject];
if (label) {
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(label.mas_trailing);
make.height.mas_equalTo(itemHeight);
}];
}
}
- (void)configLabelArrayOfGiveDiamond {
CGFloat itemWidth = kGetScaleWidth(50);
CGFloat itemHeight = kGetScaleWidth(50);
CGFloat itemSpace = kGetScaleWidth(9);
for (int i = 0; i < _number; i++) {
UILabel * label = [[UILabel alloc] init];
label.textColor = [DJDKMIMOMColor mainTextColor];
label.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
label.textAlignment = NSTextAlignmentCenter;
label.backgroundColor = UIColorFromRGB(0xF0F5F6);
label.layer.masksToBounds = YES;
label.layer.cornerRadius = kGetScaleWidth(4);
label.tag = 100 + i;
[self addSubview:label];
[label mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemWidth, itemHeight));
make.centerY.mas_equalTo(self);
make.leading.mas_equalTo(self).offset((itemWidth + itemSpace)* i);
}];
[self.labelArray addObject:label];
}
}
- (void)normalStyle:(UILabel *)label {
label.backgroundColor = UIColorFromRGB(0xF0F5F6);
[label setCornerRadius:10
corners:kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner | kCALayerMinXMaxYCorner | kCALayerMaxXMaxYCorner
borderWidth:1
borderColor:UIColorFromRGB(0xF0F5F6)];
}
- (void)lastInputStyle:(UILabel *)label {
label.backgroundColor = UIColorFromRGB(0xFFF6EB);
[label setCornerRadius:10
corners:kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner | kCALayerMinXMaxYCorner | kCALayerMaxXMaxYCorner
borderWidth:1
borderColor:UIColorFromRGB(0xFF8C03)];
}
#pragma mark - Getters And Setters
- (void)setNumber:(int)number {
_number = number;
if(self.type == 1 && _number > 0){
[self configLabelArrayOfGiveDiamond];
return;
}
if (_number > 0) {
[self configLabelArray];
}
}
- (MSBaseTextField *)textField {
if (!_textField) {
_textField = [[MSBaseTextField alloc] init];
_textField.tintColor = [UIColor clearColor];
_textField.textColor = [UIColor clearColor];
_textField.keyboardType = UIKeyboardTypeNumberPad;
[_textField becomeFirstResponder];
}
return _textField;
}
- (NSMutableArray<UILabel *> *)labelArray {
if (!_labelArray) {
_labelArray = [NSMutableArray array];
}
return _labelArray;
}
@end

View File

@@ -0,0 +1,17 @@
//
// UserPrivacyView.h
// YUMI
//
// Created by YUMI on 2021/11/1.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface UserPrivacyView : UIView
///
@property (nonatomic,strong) UIViewController * controller;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,210 @@
//
// UserPrivacyView.m
// YUMI
//
// Created by YUMI on 2021/11/1.
//
#import "UserPrivacyView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "YUMIConstant.h"
#import "DJDKMIMOMColor.h"
#import "YUMIMacroUitls.h"
#import "YUMIHtmlUrl.h"
#import "TTPopup.h"
#import "UIImage+Utils.h"
///VC
#import "XPWebViewController.h"
NSString * const kYouMiNumberCountKey = @"kYouMinumbernnagna";
@interface UserPrivacyView ()
///title
@property (nonatomic, strong) UILabel *titleLabel;
///
@property (nonatomic, strong) YYTextView *contentLabel;
///
@property (nonatomic,strong) UIStackView *stackView;
///
@property (nonatomic, strong) UIButton *confirmButton;
///退
@property (nonatomic, strong) UIButton *exitButton;
@end
@implementation UserPrivacyView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Response
- (void)onAgreementButtonClick:(UIButton *)sender {
if (sender == self.confirmButton) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:@"isShow" forKey:kYouMiNumberCountKey];
[defaults synchronize];
[TTPopup dismiss];
}
}
- (void)exitButtonClick:(UIButton *)sender {
[self exitApplication];
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor whiteColor];
self.layer.masksToBounds = YES;
self.layer.cornerRadius = 10;
[self addSubview:self.titleLabel];
[self addSubview:self.contentLabel];
[self addSubview:self.stackView];
[self.stackView addArrangedSubview:self.exitButton];
[self.stackView addArrangedSubview:self.confirmButton];
}
- (void)initSubViewConstraints {
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(KScreenWidth - 38 * 2);
make.height.mas_equalTo(424);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(18);
make.centerX.mas_equalTo(self);
}];
[self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(55);
make.leading.mas_equalTo(28);
make.trailing.mas_equalTo(-28);
make.bottom.mas_equalTo(-68);
}];
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(-20);
make.leading.trailing.mas_equalTo(self).inset(15);
make.height.mas_equalTo(36);
}];
}
///退app
- (void)exitApplication {
[TTPopup dismiss];
[UIView beginAnimations:@"exitApplication" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self cache:NO];
[UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];
[UIView commitAnimations];
}
- (void)animationFinished:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
if ([animationID compare:@"exitApplication"] == 0) {
exit(0);
}
}
#pragma mark - getters and setters
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:16.f weight:UIFontWeightMedium];
_titleLabel.textColor = [DJDKMIMOMColor alertTitleColor];
_titleLabel.text = [NSString stringWithFormat:YMLocalizedString(@"UserPrivacyView0"), AppName];
}
return _titleLabel;
}
- (YYTextView *)contentLabel {
if (!_contentLabel) {
_contentLabel = [[YYTextView alloc]init];
_contentLabel.editable = NO;
_contentLabel.showsVerticalScrollIndicator = NO;
_contentLabel.showsHorizontalScrollIndicator = NO;
NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
paragraphStyle.lineSpacing = 4;
NSString * agreement = [NSString stringWithFormat:YMLocalizedString(@"UserPrivacyView1"), AppName];
NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] init];
NSAttributedString *att1 = [[NSAttributedString alloc] initWithString:agreement attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14], NSForegroundColorAttributeName : [DJDKMIMOMColor textThirdColor], NSParagraphStyleAttributeName : paragraphStyle, NSKernAttributeName : @(1.0)}];
NSMutableAttributedString *att2 = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"UserPrivacyView2") attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14 weight:UIFontWeightMedium], NSForegroundColorAttributeName : [DJDKMIMOMColor textThirdColor], NSParagraphStyleAttributeName : paragraphStyle, NSKernAttributeName : @(1.0)}];
@kWeakify(self);
[att2 yy_setTextHighlightRange:NSMakeRange(8, 6) color:[DJDKMIMOMColor appMainColor] backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
@kStrongify(self);
[TTPopup dismiss];
XPWebViewController *web = [[XPWebViewController alloc] initWithRoomUID:nil];
web.url = URLWithType(kPrivacyURL);
[self.controller.navigationController pushViewController:web animated:YES];
}];
[att2 yy_setTextHighlightRange:NSMakeRange(15, 6) color:[DJDKMIMOMColor appMainColor] backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
@kStrongify(self);
[TTPopup dismiss];
XPWebViewController *web = [[XPWebViewController alloc] initWithRoomUID:nil];
web.url = URLWithType(kUserProtocalURL);
[self.controller.navigationController pushViewController:web animated:YES];
}];
[attStr appendAttributedString:att1];
[attStr appendAttributedString:att2];
_contentLabel.attributedText = attStr;
}
return _contentLabel;
}
- (UIButton *)confirmButton {
if (!_confirmButton) {
_confirmButton = [[UIButton alloc]init];
[_confirmButton setTitle:YMLocalizedString(@"UserPrivacyView3") forState:UIControlStateNormal];
_confirmButton.titleLabel.font = [UIFont systemFontOfSize:15];
[_confirmButton setTitleColor:[DJDKMIMOMColor mainTextColor] forState:UIControlStateNormal];
UIImage *image = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor],[DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
[_confirmButton setBackgroundImage:image forState:UIControlStateNormal];
_confirmButton.layer.cornerRadius = 18;
_confirmButton.layer.masksToBounds = YES;
[_confirmButton addTarget:self action:@selector(onAgreementButtonClick:) forControlEvents:UIControlEventTouchUpInside];
}
return _confirmButton;
}
- (UIButton *)exitButton {
if (!_exitButton) {
_exitButton = [[UIButton alloc]init];
[_exitButton setTitle:YMLocalizedString(@"UserPrivacyView4") forState:UIControlStateNormal];
_exitButton.titleLabel.font = [UIFont systemFontOfSize:15];
[_exitButton setTitleColor:[DJDKMIMOMColor cancelButtonTextColor] forState:UIControlStateNormal];
UIImage *image = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor cancelButtonGradientStartColor],[DJDKMIMOMColor cancelButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
[_exitButton setBackgroundImage:image forState:UIControlStateNormal];
_exitButton.layer.cornerRadius = 18;
_exitButton.layer.masksToBounds = YES;
[_exitButton addTarget:self action:@selector(exitButtonClick:) forControlEvents:UIControlEventTouchUpInside];
}
return _exitButton;
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisHorizontal;
_stackView.distribution = UIStackViewDistributionFillEqually;
_stackView.alignment = UIStackViewAlignmentFill;
_stackView.spacing = 20;
}
return _stackView;
}
@end

View File

@@ -0,0 +1,17 @@
//
// YMLoginBindSuccessView.h
// YUMI
//
// Created by YUMI on 2021/9/18.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef void(^XPBindViewDismissHandler)(void);
@interface XPLoginBindSuccessView : UIView
@property (nonatomic, copy) XPBindViewDismissHandler dismissHandler;
+ (void)showBindSuccessViewWithHandler:(XPBindViewDismissHandler)handler;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,126 @@
//
// YMLoginBindSuccessView.m
// YUMI
//
// Created by YUMI on 2021/9/18.
//
#import "XPLoginBindSuccessView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "DJDKMIMOMColor.h"
#import "YUMIMacroUitls.h"
#import "TTPopup.h"
@interface XPLoginBindSuccessView ()
@property (nonatomic, strong) UIImageView *successImageView;
@property (nonatomic, strong) UILabel *textLabel;
@property (nonatomic, strong) UIButton *closeBtn;
@end
@implementation XPLoginBindSuccessView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self baseUI];
[self initViews];
[self initConstraints];
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
}
#pragma mark -
#pragma mark lifeCycle
- (void)baseUI {
self.layer.cornerRadius = 8.f;
self.layer.masksToBounds = YES;
self.backgroundColor = [UIColor whiteColor];
}
- (void)initViews {
[self addSubview:self.successImageView];
[self addSubview:self.textLabel];
[self addSubview:self.closeBtn];
}
- (void)initConstraints {
[self.successImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(18);
make.centerX.mas_equalTo(0);
make.size.mas_equalTo(CGSizeMake(76, 76));
}];
[self.textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(0);
make.top.mas_equalTo(self.successImageView.mas_bottom).offset(7);
}];
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(0);
make.top.mas_equalTo(self.textLabel.mas_bottom).offset(22);
make.height.mas_equalTo(38);
make.width.mas_equalTo(124);
}];
}
#pragma mark private methods
+ (void)showBindSuccessViewWithHandler:(XPBindViewDismissHandler)handler {
XPLoginBindSuccessView *bindSuccessView = [[XPLoginBindSuccessView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth - 64, 195)];
bindSuccessView.dismissHandler = handler;
[TTPopup popupView:bindSuccessView style:TTPopupStyleAlert];
}
#pragma mark -
#pragma mark button click events
- (void)closeBtnClickAction:(UIButton *)btn {
[TTPopup dismiss];
!_dismissHandler ? : _dismissHandler();
}
#pragma mark -
#pragma mark getter & setter
- (UIImageView *)successImageView
{
if (!_successImageView) {
_successImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"login_bind_phone_success"]];
}
return _successImageView;
}
- (UILabel *)textLabel
{
if (!_textLabel) {
_textLabel = [[UILabel alloc] init];
_textLabel.text = YMLocalizedString(@"XPLoginBindSuccessView0");
_textLabel.textColor = [DJDKMIMOMColor mainTextColor];
_textLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:17];
_textLabel.adjustsFontSizeToFitWidth = YES;
_textLabel.textAlignment = NSTextAlignmentCenter;
}
return _textLabel;
}
- (UIButton *)closeBtn {
if (!_closeBtn) {
_closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_closeBtn setTitle:YMLocalizedString(@"XPLoginBindSuccessView1") forState:UIControlStateNormal];
[_closeBtn setTitleColor:[DJDKMIMOMColor mainTextColor] forState:UIControlStateNormal];
[_closeBtn setBackgroundColor:[DJDKMIMOMColor appBackgroundColor]];
[_closeBtn.titleLabel setFont:[UIFont systemFontOfSize:15.f]];
_closeBtn.layer.masksToBounds = YES;
_closeBtn.layer.cornerRadius = 19;
[_closeBtn addTarget:self action:@selector(closeBtnClickAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _closeBtn;
}
@end

View File

@@ -0,0 +1,39 @@
//
// FeedBackViewController.h
// YuMi
//
// Created by P on 2024/7/2.
//
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface FeedBackViewController : MvpViewController
@property (nonatomic, strong) UIScrollView *scrollView;
@property (nonatomic, strong) UIView *scrollContentView;
@property (nonatomic, strong) UIButton *closeKeyboardButton;
@property (nonatomic, strong) UILabel *title_1;
@property (nonatomic, strong) UILabel *title_2;
@property (nonatomic, strong) UILabel *title_3;
@property (nonatomic, strong) UILabel *title_4;
@property (nonatomic, strong) UICollectionViewFlowLayout *typeCollectionLayout;
@property (nonatomic, strong) UICollectionView *typeCollectionView;
@property (nonatomic, strong) UITextView *feedbackTextView;
@property (nonatomic, strong) UILabel *feedbackPlaceholderLabel;
@property (nonatomic, strong) UILabel *feedbackCharCountLabel;
@property (nonatomic, strong) UILabel *feedbackCharLimitLabel;
@property (nonatomic, strong) UIButton *uploadImageButton;
@property (nonatomic, strong) UIImageView *uploadImageView;
@property (nonatomic, strong) UITextField *contactTextField;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,939 @@
//
// FeedBackViewController.m
// YuMi
//
// Created by P on 2024/7/2.
//
#import "FeedBackViewController.h"
#import "LoginPresenter.h"
#import "UploadFile.h"
#import "FeedBackConfigModel.h"
@interface FeedBackContactPopUpCell : UICollectionViewCell
@property (nonatomic, strong) UILabel *content;
@property (nonatomic, strong) UIImageView *icon;
//@
@end
@implementation FeedBackContactPopUpCell
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
_content = [UILabel labelInitWithText:@""
font:[UIFont systemFontOfSize:16 weight:UIFontWeightBold]
textColor:UIColorFromRGB(0x333333)];
_icon = [[UIImageView alloc] initWithImage:kImage(@"user_card_copy_id1")];
[self.contentView addSubview:_content];
[self.contentView addSubview:_icon];
[_content mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.leading.mas_equalTo(0);
}];
[_icon mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(12);
make.centerY.mas_equalTo(self.content);
make.leading.mas_equalTo(self.content.mas_trailing).offset(2);
}];
}
return self;
}
@end
@interface FeedBackContactPopUp : UIView<UICollectionViewDelegateFlowLayout, UICollectionViewDataSource>
@property (nonatomic, copy) NSArray *contactArray;
@property (nonatomic, strong) UICollectionView *collectionView;
@end
@implementation FeedBackContactPopUp
+ (CGFloat)popUpHeight:(NSDictionary *)dataSource {
return 32 + 75 + 14 * dataSource.count + 18 * dataSource.count;
}
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setup];
}
return self;
}
- (void)setup {
self.backgroundColor = [UIColor whiteColor];
self.layer.cornerRadius = 15.5;
self.clipsToBounds = YES;
self.layer.masksToBounds = YES;
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
b.layer.cornerRadius = 19;
b.layer.masksToBounds = YES;
[b setTitle:YMLocalizedString(@"XPRoomViewController16") forState:UIControlStateNormal];
[b setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x57e193),UIColorFromRGB(0x14d2a6)]
gradientType:GradientTypeLeftToRight
imgSize:CGSizeMake(120, 38)]
forState:UIControlStateNormal];
[b addTarget:self action:@selector(didTapButton) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:b];
[b mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.bottom.mas_equalTo(self).offset(-16);
make.height.mas_equalTo(38);
}];
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.backgroundColor = [UIColor clearColor];
_collectionView.scrollEnabled = NO;
_collectionView.delegate = self;
_collectionView.dataSource = self;
[_collectionView registerClass:[FeedBackContactPopUpCell class] forCellWithReuseIdentifier:@"cell"];
[self addSubview:_collectionView];
[_collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self).insets(UIEdgeInsetsMake(32, 0, 75, 0));
}];
}
- (void)setContactDic:(NSDictionary *)contactDic {
NSMutableArray *tempArr = @[].mutableCopy;
[contactDic enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL * _Nonnull stop) {
[tempArr addObject:@[key, obj]];
}];
_contactArray = tempArr;
[self.collectionView reloadData];
}
- (void)didTapButton {
[TTPopup dismiss];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.contactArray.count;
}
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout *)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
CGFloat padding = 24.0;
CGFloat totalPadding = padding * 2; // +
CGFloat availableWidth = collectionView.frame.size.width - totalPadding;
NSArray *subArray = [self.contactArray xpSafeObjectAtIndex:indexPath.row];
return CGSizeMake(availableWidth, subArray.count > 1 ? 14 : 0);
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
return 18.0;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
return 18.0;
}
// cell
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
FeedBackContactPopUpCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
NSArray *subArray = [self.contactArray xpSafeObjectAtIndex:indexPath.row];
if (subArray.count > 1) {
cell.content.text = [NSString stringWithFormat:@"%@: %@", [subArray firstObject], [subArray lastObject]];
}
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
NSArray *subArray = [self.contactArray xpSafeObjectAtIndex:indexPath.row];
if (subArray.count > 1) {
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
[pasteboard setString:[subArray lastObject]];
[XNDJTDDLoadingTool showSuccessWithMessage:YMLocalizedString(@"XPShareView0")];
}
}
@end
@interface TypeCollectionCell : UICollectionViewCell
@property (nonatomic, strong) UILabel *titleLabel;
@end
@implementation TypeCollectionCell
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.contentView.userInteractionEnabled = YES;
self.contentView.layer.cornerRadius = 15.5;
self.contentView.layer.masksToBounds = YES;
self.contentView.backgroundColor = UIColorFromRGB(0xf3f5fa);
_titleLabel = [UILabel labelInitWithText:@""
font:[UIFont systemFontOfSize:14 weight:UIFontWeightMedium] textColor:UIColorFromRGB(0x22252c)];
_titleLabel.textAlignment = NSTextAlignmentCenter;
_titleLabel.userInteractionEnabled = NO;
_titleLabel.numberOfLines = 1;
[self.contentView addSubview:_titleLabel];
[_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.contentView);
}];
}
return self;
}
- (void)setSelected:(BOOL)selected {
if (selected) {
self.contentView.backgroundColor = UIColorFromRGB(0x85f6d3);
} else {
self.contentView.backgroundColor = UIColorFromRGB(0xf3f5fa);
}
}
@end
@interface FeedBackViewController ()<UITextViewDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
@property (nonatomic, strong) UIButton *submitButton;
@property (nonatomic, strong) UIView *fakeTopBar;
@property (nonatomic, copy) NSString *uploadPhotoURLString;
@property (nonatomic, strong) UIImage *selectedImage;
@property (nonatomic, strong) FeedBackConfigModel *configModel;
@property (nonatomic, strong) FeedBackTypeModel *selectTypeModel;
@end
@implementation FeedBackViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self setup];
[self customLayout];
[self loadFeedbackConfig];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self addNavigationItemWithImageNames:@[@"login_custom_servise"]
isLeft:NO
target:self
action:@selector(rightButtonTapped) tags:nil];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (LoginPresenter *)createPresenter {
return [[LoginPresenter alloc] init];
}
- (BOOL)isHiddenNavBar {
return YES;
}
- (void)setup {
self.title = YMLocalizedString(@"XPMineFeedbackViewController0");
self.view.backgroundColor = [UIColor whiteColor];
[self setupFakeTopBar];
[self setupSubviews];
[self.closeKeyboardButton setTitle:@"" forState:UIControlStateNormal];
self.title_1.textColor = [UIColor blackColor];
self.title_2.textColor = [UIColor blackColor];
self.title_3.textColor = [UIColor blackColor];
self.title_4.textColor = [UIColor blackColor];
self.title_3.text = YMLocalizedString(@"FeedBackViewController2");
NSAttributedString *redMark = [[NSAttributedString alloc] initWithString:@"* "
attributes:@{NSForegroundColorAttributeName: UIColorFromRGB(0xeb5c2c),
NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightBold]}];
NSDictionary *defaultAttributes = @{NSForegroundColorAttributeName: UIColorFromRGB(0x000000),
NSFontAttributeName: [UIFont systemFontOfSize:16 weight:UIFontWeightBold]};
NSMutableAttributedString *attributedTitle_1 = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"FeedBackViewController0") attributes:defaultAttributes];
[attributedTitle_1 insertAttributedString:redMark atIndex:0];
NSMutableAttributedString *attributedTitle_2 = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"FeedBackViewController1") attributes:defaultAttributes];
[attributedTitle_2 insertAttributedString:redMark atIndex:0];
NSMutableAttributedString *attributedTitle_4 = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"FeedBackViewController3") attributes:defaultAttributes];
[attributedTitle_4 insertAttributedString:redMark atIndex:0];
self.title_1.attributedText = attributedTitle_1;
self.title_2.attributedText = attributedTitle_2;
self.title_4.attributedText = attributedTitle_4;
self.feedbackPlaceholderLabel.text = YMLocalizedString(@"FeedBackViewController4");
self.feedbackCharCountLabel.text = @"0";
if (isMSRTL()) {
self.feedbackCharCountLabel.textAlignment = NSTextAlignmentRight;
self.feedbackCharLimitLabel.textAlignment = NSTextAlignmentRight;
self.feedbackCharLimitLabel.text = @"300/";
self.typeCollectionView.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
} else {
self.feedbackCharCountLabel.textAlignment = NSTextAlignmentLeft;
self.feedbackCharLimitLabel.textAlignment = NSTextAlignmentLeft;
self.feedbackCharLimitLabel.text = @"/300";
}
UIColor *placeholderColor = UIColorFromRGB(0xacb0b7);
self.contactTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:YMLocalizedString(@"FeedBackViewController5")
attributes:@{NSForegroundColorAttributeName: placeholderColor}];
self.submitButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.submitButton addTarget:self action:@selector(didTapSubmitButton:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:self.submitButton];
[self.submitButton setTitle:YMLocalizedString(@"LoginForgetPasswordViewController6") forState:UIControlStateNormal];
[self.submitButton setTitle:YMLocalizedString(@"LoginForgetPasswordViewController6") forState:UIControlStateDisabled];
[self.submitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
UIImage *nextImage = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x57e193), UIColorFromRGB(0x14D2a6)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(KScreenWidth-36*2, 48)];
UIImage *disableImage = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xa5eec8), UIColorFromRGB(0xabf5e3)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(KScreenWidth-36*2, 48)];
[self.submitButton setBackgroundImage:nextImage forState:UIControlStateNormal];
[self.submitButton setBackgroundImage:disableImage forState:UIControlStateDisabled];
self.submitButton.layer.cornerRadius = 48/2;
self.submitButton.layer.masksToBounds = YES;
self.submitButton.enabled = NO;
}
- (void)setupSubviews {
//
[self.view addSubview:self.scrollView];
[self.scrollView addSubview:self.scrollContentView];
[self.scrollContentView addSubview:self.closeKeyboardButton];
//
[self.scrollContentView addSubview:self.title_1];
[self.scrollContentView addSubview:self.title_2];
[self.scrollContentView addSubview:self.title_3];
[self.scrollContentView addSubview:self.title_4];
//
[self.scrollContentView addSubview:self.typeCollectionView];
//
[self.scrollContentView addSubview:self.feedbackTextView];
[self.scrollContentView addSubview:self.feedbackPlaceholderLabel];
[self.scrollContentView addSubview:self.feedbackCharCountLabel];
[self.scrollContentView addSubview:self.feedbackCharLimitLabel];
//
[self.scrollContentView addSubview:self.uploadImageButton];
[self.scrollContentView addSubview:self.uploadImageView];
//
[self.scrollContentView addSubview:self.contactTextField];
}
- (void)setupFakeTopBar {
UIView *fakeTopBar = [[UIView alloc] init];
fakeTopBar.backgroundColor = UIColorFromRGB(0xebecf3);
[self.view addSubview:fakeTopBar];
_fakeTopBar = fakeTopBar;
CGFloat navigationBarHeight = self.navigationController.navigationBar.frame.size.height + [UIApplication sharedApplication].keyWindow.safeAreaInsets.top;
[fakeTopBar mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.view.mas_top);
make.leading.trailing.equalTo(self.view);
make.height.mas_equalTo(navigationBarHeight);
}];
UILabel *title = [UILabel labelInitWithText:YMLocalizedString(@"XPMineFeedbackViewController0")
font:[UIFont systemFontOfSize:17 weight:UIFontWeightMedium]
textColor:UIColorFromRGB(0x010101)];
[fakeTopBar addSubview:title];
[title mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(-16);
make.centerX.mas_equalTo(0);
}];
UIButton *back = [UIButton buttonWithType:UIButtonTypeCustom];
[back enlargeTouchArea:UIEdgeInsetsMake(10, 10, 10, 10)];
[back.imageView setContentMode:UIViewContentModeScaleAspectFill];
[back setImage:kImage(@"room_info_back") forState:UIControlStateNormal];
[back addTarget:self
action:@selector(didTapBackButton)
forControlEvents:UIControlEventTouchUpInside];
if (isMSRTL()) {
back.imageView.transform = CGAffineTransformMakeScale(-1.0, 1.0);
}
[fakeTopBar addSubview:back];
[back mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(title);
make.width.height.mas_equalTo(15);
make.leading.mas_equalTo(16);
}];
UIButton *cs = [UIButton buttonWithType:UIButtonTypeCustom];
[cs enlargeTouchArea:UIEdgeInsetsMake(10, 10, 10, 10)];
[cs setImage:kImage(@"login_custom_servise") forState:UIControlStateNormal];
[cs addTarget:self
action:@selector(rightButtonTapped)
forControlEvents:UIControlEventTouchUpInside];
[fakeTopBar addSubview:cs];
[cs mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(title);
make.width.height.mas_equalTo(18);
make.trailing.mas_equalTo(fakeTopBar).offset(-16);
}];
}
- (void)customLayout {
[self.submitButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.bottom.mas_equalTo(self.view).offset(-40);
make.leading.mas_equalTo(36);
make.trailing.mas_equalTo(-36);
make.height.mas_equalTo(48);
}];
[self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.fakeTopBar.mas_bottom).offset(0);
make.leading.trailing.mas_equalTo(self.view);
make.bottom.mas_equalTo(self.submitButton.mas_top).offset(-8);
}];
[self.scrollContentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.scrollView);
}];
[self.title_1 mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.scrollContentView).offset(30);
make.leading.mas_equalTo(self.scrollContentView).offset(16);
}];
[self.typeCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.title_1.mas_bottom).offset(18);
make.leading.mas_equalTo(self.scrollContentView).offset(16);
make.trailing.mas_equalTo(self.scrollContentView).offset(-16);
make.height.mas_greaterThanOrEqualTo(31);
make.width.mas_equalTo(KScreenWidth - 32);
}];
[self.closeKeyboardButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.typeCollectionView.mas_bottom);
make.bottom.leading.trailing.mas_equalTo(self.scrollContentView);
}];
[self.title_2 mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.typeCollectionView.mas_bottom).offset(31);
make.leading.mas_equalTo(self.scrollContentView).offset(16);
}];
[self.feedbackTextView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.title_2.mas_bottom).offset(18);
make.leading.mas_equalTo(self.scrollContentView).offset(16);
make.trailing.mas_equalTo(self.scrollContentView).offset(-16);
make.height.mas_equalTo(150);
}];
[self.feedbackPlaceholderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.feedbackTextView).offset(8);
make.leading.mas_equalTo(self.feedbackTextView).offset(12);
}];
[self.feedbackCharLimitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.feedbackTextView).offset(-8);
make.width.mas_equalTo(40);
make.trailing.mas_equalTo(self.feedbackTextView).offset(-4);
}];
[self.feedbackCharCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.feedbackTextView).offset(-8);
make.trailing.mas_equalTo(self.feedbackCharLimitLabel.mas_leading).offset(0);
}];
[self.title_3 mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.feedbackTextView.mas_bottom).offset(31);
make.leading.mas_equalTo(self.scrollContentView).offset(16);
}];
[self.uploadImageButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.title_3.mas_bottom).offset(18);
make.width.height.mas_equalTo(76);
make.leading.mas_equalTo(self.scrollContentView).offset(16);
}];
[self.uploadImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.uploadImageButton);
}];
[self.title_4 mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.uploadImageButton.mas_bottom).offset(31);
make.leading.mas_equalTo(self.scrollContentView).offset(16);
}];
[self.contactTextField mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.scrollContentView).offset(16);
make.trailing.mas_equalTo(self.scrollContentView).offset(-16);
make.top.mas_equalTo(self.title_4.mas_bottom).offset(17.5);
make.bottom.mas_equalTo(self.scrollContentView).offset (-30);
make.height.mas_equalTo(43.5);
}];
}
- (void)updateSubmitButtonStatus {
if (self.selectTypeModel == nil) {
self.submitButton.enabled = NO;
} else if(self.feedbackTextView.text.length == 0) {
self.submitButton.enabled = NO;
} else if(self.contactTextField.text.length == 0) {
self.submitButton.enabled = NO;
} else {
self.submitButton.enabled = YES;
}
}
- (void)showPhotoSelectionSheet {
@kWeakify(self);
TTActionSheetConfig *cameraConfig = [TTActionSheetConfig normalTitle:YMLocalizedString(@"XPMineUserInfoEditViewController1") clickAction:^{
[YYUtility checkCameraAvailable:^{
@kStrongify(self);
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker animated:YES completion:NULL];
} denied:^{
@kStrongify(self);
[self showNotPhoto:YMLocalizedString(@"XPMineUserInfoEditViewController2") content:YMLocalizedString(@"XPMineUserInfoEditViewController3")];
} restriction:^{
@kStrongify(self);
[self showNotPhoto:YMLocalizedString(@"XPMineUserInfoEditViewController4") content:YMLocalizedString(@"XPMineUserInfoEditViewController5")];
}];
}];
TTActionSheetConfig *photoLibrayConfig = [TTActionSheetConfig normalTitle:YMLocalizedString(@"XPMineUserInfoEditViewController6") clickAction:^{
[YYUtility checkAssetsLibrayAvailable:^{
@kStrongify(self);
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.modalPresentationCapturesStatusBarAppearance = YES;
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.allowsEditing = NO;
[self presentViewController:imagePicker animated:YES completion:NULL];
} denied:^{
@kStrongify(self);
[self showNotPhoto:YMLocalizedString(@"XPMineUserInfoEditViewController7") content:YMLocalizedString(@"XPMineUserInfoEditViewController8")];
} restriction:^{
@kStrongify(self);
[self showNotPhoto:YMLocalizedString(@"XPMineUserInfoEditViewController9") content:YMLocalizedString(@"XPMineUserInfoEditViewController10")];
}];
}];
[TTPopup actionSheetWithItems:@[cameraConfig, photoLibrayConfig]];
}
- (void)showNotPhoto:(NSString *)title content:(NSString *)content {
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.title = title;
config.message = content;
[TTPopup alertWithConfig:config confirmHandler:^{
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
}];
}
} cancelHandler:^{
}];
}
#pragma mark - UX Actions
- (void)didTapBackButton {
[self.navigationController popViewControllerAnimated:YES];
}
- (void)didTapUploadImageButton:(id)sender {
[self showPhotoSelectionSheet];
}
- (void)didTapSubmitButton:(id)sender {
[self uploadAvatar];
}
- (void)didTapCloseKeyboardButton:(id)sender {
[self.view endEditing:YES];
}
- (void)rightButtonTapped {
FeedBackContactPopUp *popUp = [[FeedBackContactPopUp alloc] initWithFrame:CGRectMake(0,
0,
290,
[FeedBackContactPopUp popUpHeight:self.configModel.customContactMap])];
[popUp setContactDic:self.configModel.customContactMap];
[TTPopup popupView:popUp style:TTPopupStyleAlert];
}
#pragma mark - API
- (void)loadFeedbackConfig {
[self showLoading];
@kWeakify(self);
[self.presenter loadFeedbackConfig:^(FeedBackConfigModel * _Nonnull model) {
@kStrongify(self);
[self hideHUD];
self.configModel = model;
[self.typeCollectionView reloadData];
[self updateCollectionViewHeight];
} failure:^(NSString * _Nonnull errorMessage) {
@kStrongify(self);
[self hideHUD];
if (errorMessage.length > 0) {
[TTPopup alertWithMessage:errorMessage confirmHandler:^{
} cancelHandler:^{
}];
}
}];
}
- (void)uploadAvatar {
[self showLoading];
if (self.selectedImage) {
@kWeakify(self);
NSData *data = UIImageJPEGRepresentation(self.selectedImage, 0.5);
NSString *format = [UIImage getImageTypeWithImageData:data];
NSString *name = [NSString stringWithFormat:@"image/%@.%@",[NSString createUUID],format];
[[UploadFile share]QCloudUploadImage:data named:name success:^(NSString * _Nonnull key, NSDictionary * _Nonnull resp) {
@kStrongify(self);
self.uploadPhotoURLString = key;
[self submitFeedBack];
} failure:^(NSNumber * _Nonnull resCode, NSString * _Nonnull message) {
@kStrongify(self);
[self showErrorToast:message];
}];
} else {
[self submitFeedBack];
}
}
- (void)submitFeedBack {
@kWeakify(self);
dispatch_async(dispatch_get_main_queue(), ^{
@kStrongify(self);
@kWeakify(self);
[self.presenter submitFeedback:^{
@kStrongify(self);
[self showSuccessToast:YMLocalizedString(@"FeedBackViewController6")];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.navigationController popViewControllerAnimated:YES];
});
} failure:^(NSString * _Nonnull errorMessage) {
@kStrongify(self);
[self showErrorToast:errorMessage];
}
type:self.selectTypeModel.type
desc:self.feedbackTextView.text
photoURLString:self.uploadPhotoURLString
contact:self.contactTextField.text];
});
}
- (void)contactDidChange:(UITextField *)sender {
[self updateSubmitButtonStatus];
}
#pragma mark - UICollectionView Delegate & DataSource
- (void)updateCollectionViewHeight {
[self.typeCollectionView layoutIfNeeded];
CGSize contentSize = self.typeCollectionView.collectionViewLayout.collectionViewContentSize;
[self.typeCollectionView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_greaterThanOrEqualTo(contentSize.height);
}];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.configModel.typeEnumList.count;
}
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout*)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
FeedBackTypeModel *model = [self.configModel.typeEnumList xpSafeObjectAtIndex:indexPath.row];
UILabel *label = [UILabel labelInitWithText:model.desc
font:[UIFont systemFontOfSize:14 weight:UIFontWeightMedium] textColor:UIColorFromRGB(0x22252c)];;
CGSize maxSize = CGSizeMake(CGFLOAT_MAX, 31);
CGSize requiredSize = [label sizeThatFits:maxSize];
return CGSizeMake(MAX(90, requiredSize.width + 20), 31);
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
return 14.0;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
return 14.0;
}
// cell
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
TypeCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
cell.contentView.layer.cornerRadius = 15.5;
cell.contentView.layer.masksToBounds = YES;
FeedBackTypeModel *model = [self.configModel.typeEnumList xpSafeObjectAtIndex:indexPath.row];
if (model) {
cell.titleLabel.text = model.desc;
}
return cell;
}
// cell
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
TypeCollectionCell *cell = (TypeCollectionCell *)[collectionView cellForItemAtIndexPath:indexPath];
[cell setSelected:YES];
// cell
for (NSIndexPath *visibleIndexPath in [collectionView indexPathsForVisibleItems]) {
if (![visibleIndexPath isEqual:indexPath]) {
[collectionView deselectItemAtIndexPath:visibleIndexPath animated:NO];
TypeCollectionCell *otherCell = (TypeCollectionCell *)[collectionView cellForItemAtIndexPath:visibleIndexPath];
[otherCell setSelected:NO];
}
}
FeedBackTypeModel *model = [self.configModel.typeEnumList xpSafeObjectAtIndex:indexPath.row];
if (model) {
self.selectTypeModel = model;
[self updateSubmitButtonStatus];
}
}
// cell
- (void)collectionView:(UICollectionView *)collectionView didDeselectItemAtIndexPath:(NSIndexPath *)indexPath {
TypeCollectionCell *cell = (TypeCollectionCell *)[collectionView cellForItemAtIndexPath:indexPath];
[cell setSelected:NO];
}
#pragma mark - UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *selectedPhoto = [info objectForKey:UIImagePickerControllerOriginalImage];
if (selectedPhoto) {
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
UIImageWriteToSavedPhotosAlbum(selectedPhoto, nil, nil, nil);
}
self.selectedImage = selectedPhoto;
self.uploadImageView.hidden = NO;
self.uploadImageView.image = selectedPhoto;
// [self.uploadImageButton setBackgroundImage:selectedPhoto forState:UIControlStateNormal];
// [self.uploadImageButton setImage:selectedPhoto forState:UIControlStateNormal];
}
[picker dismissViewControllerAnimated:YES
completion:^{}];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
[picker dismissViewControllerAnimated:YES
completion:^{}];
}
#pragma mark - UITextViewDelegate
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
NSString *newText = [textView.text stringByReplacingCharactersInRange:range withString:text];
self.feedbackCharCountLabel.text = [NSString stringWithFormat:@"%ld", (unsigned long)newText.length];
self.feedbackPlaceholderLabel.hidden = newText.length > 0;
self.feedbackCharCountLabel.textColor = newText.length > 0 ?
UIColorFromRGB(0x3fddac) : UIColorFromRGB(0xa7acb3);
[self updateSubmitButtonStatus];
if (newText.length >= 300) {
NSString *truncatedText = [newText substringToIndex:300];
self.feedbackCharCountLabel.text = [NSString stringWithFormat:@"%ld", (unsigned long)truncatedText.length];
self.feedbackPlaceholderLabel.hidden = truncatedText.length > 0;
self.feedbackCharCountLabel.textColor = truncatedText.length > 0 ? UIColorFromRGB(0x3fddac) : UIColorFromRGB(0xa7acb3);
textView.text = truncatedText;
return NO;
}
return YES;
}
#pragma mark - Lazy Loading
- (UIScrollView *)scrollView {
if (!_scrollView) {
_scrollView = [[UIScrollView alloc] init];
_scrollView.backgroundColor = [UIColor clearColor];
_scrollView.showsVerticalScrollIndicator = NO;
_scrollView.showsHorizontalScrollIndicator = NO;
}
return _scrollView;
}
- (UIView *)scrollContentView {
if (!_scrollContentView) {
_scrollContentView = [[UIView alloc] init];
_scrollContentView.backgroundColor = [UIColor clearColor];
}
return _scrollContentView;
}
- (UIButton *)closeKeyboardButton {
if (!_closeKeyboardButton) {
_closeKeyboardButton = [UIButton buttonWithType:UIButtonTypeCustom];
_closeKeyboardButton.backgroundColor = [UIColor clearColor];
[_closeKeyboardButton addTarget:self action:@selector(didTapCloseKeyboardButton:) forControlEvents:UIControlEventTouchUpInside];
}
return _closeKeyboardButton;
}
- (UILabel *)title_1 {
if (!_title_1) {
_title_1 = [UILabel labelInitWithText:@""
font:[UIFont systemFontOfSize:16 weight:UIFontWeightBold]
textColor:[UIColor blackColor]];
}
return _title_1;
}
- (UILabel *)title_2 {
if (!_title_2) {
_title_2 = [UILabel labelInitWithText:@""
font:[UIFont systemFontOfSize:16 weight:UIFontWeightBold]
textColor:[UIColor blackColor]];
}
return _title_2;
}
- (UILabel *)title_3 {
if (!_title_3) {
_title_3 = [UILabel labelInitWithText:@""
font:[UIFont systemFontOfSize:16 weight:UIFontWeightBold]
textColor:[UIColor blackColor]];
}
return _title_3;
}
- (UILabel *)title_4 {
if (!_title_4) {
_title_4 = [UILabel labelInitWithText:@""
font:[UIFont systemFontOfSize:16 weight:UIFontWeightBold]
textColor:[UIColor blackColor]];
}
return _title_4;
}
- (UICollectionViewFlowLayout *)typeCollectionLayout {
if (!_typeCollectionLayout) {
_typeCollectionLayout = [[UICollectionViewFlowLayout alloc] init];
_typeCollectionLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
}
return _typeCollectionLayout;
}
- (UICollectionView *)typeCollectionView {
if (!_typeCollectionView) {
_typeCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:self.typeCollectionLayout];
_typeCollectionView.backgroundColor = [UIColor clearColor];
_typeCollectionView.delegate = self;
_typeCollectionView.dataSource = self;
_typeCollectionView.allowsSelection = YES;
[_typeCollectionView registerClass:[TypeCollectionCell class] forCellWithReuseIdentifier:@"cell"];
}
return _typeCollectionView;
}
- (UITextView *)feedbackTextView {
if (!_feedbackTextView) {
_feedbackTextView = [[UITextView alloc] init];
_feedbackTextView.backgroundColor = UIColorFromRGB(0xf3f5fa);
_feedbackTextView.layer.cornerRadius = 8;
_feedbackTextView.layer.masksToBounds = YES;
_feedbackTextView.font = [UIFont systemFontOfSize:14];
_feedbackTextView.textColor = UIColorFromRGB(0x333333);
_feedbackTextView.delegate = self;
_feedbackTextView.textContainerInset = UIEdgeInsetsMake(8, 8, 20, 8);
}
return _feedbackTextView;
}
- (UILabel *)feedbackPlaceholderLabel {
if (!_feedbackPlaceholderLabel) {
_feedbackPlaceholderLabel = [UILabel labelInitWithText:@""
font:[UIFont systemFontOfSize:14]
textColor:UIColorFromRGB(0xacb0b7)];
_feedbackPlaceholderLabel.numberOfLines = 0;
}
return _feedbackPlaceholderLabel;
}
- (UILabel *)feedbackCharCountLabel {
if (!_feedbackCharCountLabel) {
_feedbackCharCountLabel = [UILabel labelInitWithText:@"0"
font:[UIFont systemFontOfSize:12]
textColor:UIColorFromRGB(0xa7acb3)];
}
return _feedbackCharCountLabel;
}
- (UILabel *)feedbackCharLimitLabel {
if (!_feedbackCharLimitLabel) {
_feedbackCharLimitLabel = [UILabel labelInitWithText:@"/300"
font:[UIFont systemFontOfSize:12]
textColor:UIColorFromRGB(0xa7acb3)];
}
return _feedbackCharLimitLabel;
}
- (UIButton *)uploadImageButton {
if (!_uploadImageButton) {
_uploadImageButton = [UIButton buttonWithType:UIButtonTypeCustom];
_uploadImageButton.backgroundColor = UIColorFromRGB(0xf3f5fa);
_uploadImageButton.layer.cornerRadius = 8;
_uploadImageButton.layer.masksToBounds = YES;
[_uploadImageButton setImage:kImage(@"feedback_upload_image") forState:UIControlStateNormal];
[_uploadImageButton addTarget:self action:@selector(didTapUploadImageButton:) forControlEvents:UIControlEventTouchUpInside];
}
return _uploadImageButton;
}
- (UIImageView *)uploadImageView {
if (!_uploadImageView) {
_uploadImageView = [[UIImageView alloc] init];
_uploadImageView.contentMode = UIViewContentModeScaleAspectFill;
_uploadImageView.layer.cornerRadius = 8;
_uploadImageView.layer.masksToBounds = YES;
_uploadImageView.hidden = YES;
}
return _uploadImageView;
}
- (UITextField *)contactTextField {
if (!_contactTextField) {
_contactTextField = [[UITextField alloc] init];
_contactTextField.backgroundColor = UIColorFromRGB(0xf3f5fa);
_contactTextField.layer.cornerRadius = 8;
_contactTextField.layer.masksToBounds = YES;
_contactTextField.font = [UIFont systemFontOfSize:14];
_contactTextField.textColor = UIColorFromRGB(0x333333);
_contactTextField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 16, 0)];
_contactTextField.leftViewMode = UITextFieldViewModeAlways;
_contactTextField.rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 16, 0)];
_contactTextField.rightViewMode = UITextFieldViewModeAlways;
[_contactTextField addTarget:self action:@selector(contactDidChange:) forControlEvents:UIControlEventEditingChanged];
}
return _contactTextField;
}
@end

View File

@@ -0,0 +1,16 @@
//
// LoginBindPhoneViewController.h
// YUMI
//
// Created by YUMI on 2021/9/14.
//
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface LoginBindPhoneViewController : MvpViewController
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,223 @@
//
// LoginBindPhoneViewController.m
// YUMI
//
// Created by YUMI on 2021/9/14.
//
#import "LoginBindPhoneViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <ReactiveObjC/ReactiveObjC.h>
///Tool
#import "YUMIMacroUitls.h"
#import "DJDKMIMOMColor.h"
#import "NSString+Utils.h"
#import "UIButton+EnlargeTouchArea.h"
///Tool
#import "LoginBindPhonePresent.h"
///VC
#import "LoginVerifCodeViewController.h"
@interface LoginBindPhoneViewController ()
///Label
@property (nonatomic, strong) UILabel *titleLabel;
///
@property (nonatomic, strong) UIView *bgView;
///86 Label
@property (nonatomic, strong) UILabel *countryLabel;
///
@property (nonatomic, strong) MSBaseTextField *phoneTextField;
///
@property (nonatomic, strong) UIButton *loginBtn;
/// 退
@property (nonatomic,strong) UIButton *backButton;
@end
@implementation LoginBindPhoneViewController
- (BOOL)isHiddenNavBar {
return YES;
}
#pragma mark - life cycle
- (LoginBindPhonePresent *)createPresenter {
return [[LoginBindPhonePresent alloc] init];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self setUpUI];
[self setEvents];
}
- (void)viewDidAppear:(BOOL)animated {
[self showErrorToast:YMLocalizedString(@"LoginBindPhoneViewController0")];
}
- (void)setUpUI {
[self.view addSubview:self.titleLabel];
[self.view addSubview:self.bgView];//
[self.bgView addSubview:self.countryLabel];
[self.bgView addSubview:self.phoneTextField];
[self.view addSubview:self.loginBtn]; //
[self.view addSubview:self.backButton];
}
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.top.mas_equalTo(self.view).offset(150);
}];
//
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(50);
make.width.mas_equalTo(280);
make.height.mas_equalTo(45);
}];
[self.countryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(10);
make.top.mas_equalTo(self.bgView).offset(5);
make.width.mas_equalTo(60);
make.height.mas_equalTo(35);
}];
[self.phoneTextField mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(70);
make.top.mas_equalTo(self.bgView).offset(5);
make.width.mas_equalTo(200);
make.height.mas_equalTo(35);
}];
//
[self.loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.top.mas_equalTo(self.bgView.mas_bottom).offset(50);
make.width.mas_equalTo(60);
make.height.mas_equalTo(60);
}];
[self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(15, 15));
make.leading.mas_equalTo(self.view).offset(14);
make.top.mas_equalTo(self.view).offset(36 + kSafeAreaTopHeight);
}];
}
- (void)setEvents {
@weakify(self)
//
[[RACSignal combineLatest:@[self.phoneTextField.rac_textSignal]
reduce:^id(NSString *phone){
BOOL enable = phone.length > 0;
return @(enable);
}] subscribeNext:^(NSNumber *enable) {
@strongify(self)
self.loginBtn.enabled = [enable boolValue];
}];
[[[[self.loginBtn rac_signalForControlEvents:UIControlEventTouchUpInside] doNext:^(id x) {
@strongify(self)
self.loginBtn.enabled = NO;
}] flattenMap:^id (id value) {
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
if (!self.phoneTextField.text.isPhoneNumber) {
[self showErrorToast:YMLocalizedString(@"LoginBindPhoneViewController1")];
[subscriber sendNext:@(NO)];
}else {
[subscriber sendNext:@(YES)];
}
[subscriber sendCompleted];
return nil;
}];
}] subscribeNext:^(NSNumber *signedIn) {
@strongify(self)
self.loginBtn.enabled = YES;
BOOL success = [signedIn boolValue];
if (success) {
//
LoginVerifCodeViewController *codeVC = [[LoginVerifCodeViewController alloc] init];
codeVC.phone = self.phoneTextField.text;
codeVC.type = VerifCodeType_BindPhone;
[self.navigationController pushViewController:codeVC animated:YES];
}
}];
}
#pragma mark - Event Response
- (void)backButtonAction:(UIButton *)sender {
///退
[self dismissViewControllerAnimated:NO completion:^{
[self.presenter logout];
}];
}
#pragma mark - Getters And Setters
- (UILabel *)titleLabel{
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
_titleLabel.text = YMLocalizedString(@"LoginBindPhoneViewController2");
_titleLabel.textColor = [DJDKMIMOMColor mainTextColor];
}
return _titleLabel;
}
- (UIView *)bgView {
if (!_bgView) {
_bgView = [[UIView alloc] init];
_bgView.backgroundColor = [DJDKMIMOMColor appCellBackgroundColor];
_bgView.layer.cornerRadius = 45/2;
_bgView.layer.masksToBounds = YES;
}
return _bgView;
}
- (UILabel *)countryLabel{
if (!_countryLabel) {
_countryLabel = [[UILabel alloc] init];
_countryLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:15];
NSString *code = [NSString getCountryCode];
_countryLabel.text = code;
_countryLabel.textColor = [DJDKMIMOMColor mainTextColor];
_countryLabel.backgroundColor = [UIColor clearColor];
_countryLabel.textAlignment = NSTextAlignmentCenter;
}
return _countryLabel;
}
- (MSBaseTextField *)phoneTextField {
if (!_phoneTextField) {
_phoneTextField = [[MSBaseTextField alloc] init];
_phoneTextField.keyboardType = UIKeyboardTypeNumberPad;
_phoneTextField.backgroundColor = [UIColor clearColor];
_phoneTextField.textColor = [DJDKMIMOMColor mainTextColor];
_phoneTextField.tintColor = [DJDKMIMOMColor appMainColor];
_phoneTextField.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:15];
_phoneTextField.textAlignment = NSTextAlignmentLeft;
}
return _phoneTextField;
}
- (UIButton *)loginBtn {
if (!_loginBtn) {
_loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_loginBtn.enabled = NO;
[_loginBtn setImage:[UIImage imageNamed:@"login_button"] forState:UIControlStateDisabled];
[_loginBtn setImage:[UIImage imageNamed:@"login_button_sel"] forState:UIControlStateNormal];
}
return _loginBtn;
}
- (UIButton *)backButton {
if (!_backButton) {
_backButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_backButton setImage:[[UIImage imageNamed:@"common_nav_back"]ms_SetImageForRTL] forState:UIControlStateNormal];
[_backButton setImage:[[UIImage imageNamed:@"common_nav_back"]ms_SetImageForRTL] forState:UIControlStateSelected];
[_backButton setEnlargeEdgeWithTop:15 right:15 bottom:15 left:15];
[_backButton addTarget:self action:@selector(backButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _backButton;
}
@end

View File

@@ -0,0 +1,17 @@
//
// LoginForgetPasswordViewController.h
// xplan-ios
//
// Created by 冯硕 on 2021/9/10.
//
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface LoginForgetPasswordViewController : MvpViewController
@property (nonatomic,copy) NSString *pi_phoneAreaCode;
@property (nonatomic,assign) BOOL isLogout;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,238 @@
//
// LoginForgetPasswordViewController.m
// xplan-ios
//
// Created by on 2021/9/10.
//
#import "LoginForgetPasswordViewController.h"
///
#import <Masonry/Masonry.h>
#import <ReactiveObjC/ReactiveObjC.h>
///Tool
#import "CountDownHelper.h"
#import "UIImage+Utils.h"
///Presenter
#import "LoginForgetPasswordPresent.h"
#import "LoginForgetPasswordProtocol.h"
///View
#import "LoginForgetEditView.h"
#import "XPLoginAraeViewController.h"
@interface LoginForgetPasswordViewController ()<XPLoginAraeViewControllerDelegate,LoginForgetPasswordProtocol, CountDownHelperDelegate>
///
@property (nonatomic,strong) UIStackView *stackView;
///
@property (nonatomic,strong) LoginForgetEditView *phoneView;
///
@property (nonatomic,strong) LoginForgetEditView *codeView;
///
@property (nonatomic,strong) LoginForgetEditView *passwordView;
///
@property (nonatomic,strong) UIButton *finishButton;
@end
@implementation LoginForgetPasswordViewController
- (void)dealloc {
[[CountDownHelper shareHelper] stopCountDown];
}
- (LoginForgetPasswordPresent *)createPresenter {
return [[LoginForgetPasswordPresent alloc] init];
}
- (void)viewDidLoad {
[super viewDidLoad];
NSString *code = [NSString getCountryCode];
self.pi_phoneAreaCode = [code stringByReplacingOccurrencesOfString:@"+" withString:@""];
[self initSubViews];
[self initSubViewConstraints];
[self initEvents];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self.view endEditing:NO];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[[CountDownHelper shareHelper] stopCountDown];
}
#pragma mark - Private Method
- (void)initSubViews {
self.title = YMLocalizedString(@"LoginForgetPasswordViewController0");
self.view.backgroundColor = [UIColor whiteColor];
[CountDownHelper shareHelper].delegate = self;
[self.view addSubview:self.stackView];
[self.view addSubview:self.finishButton];
[self.stackView addArrangedSubview:self.phoneView];
[self.stackView addArrangedSubview:self.codeView];
[self.stackView addArrangedSubview:self.passwordView];
}
- (void)initSubViewConstraints {
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view).mas_offset(kGetScaleWidth(30));
make.leading.trailing.equalTo(self.view).inset(kGetScaleWidth(15));
}];
[self.finishButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.mas_equalTo(self.view).inset(kGetScaleWidth(15));
make.height.mas_equalTo(45);
make.top.mas_equalTo(self.stackView.mas_bottom).offset(kGetScaleWidth(51));
}];
[self.phoneView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(kGetScaleWidth(48));
}];
[self.codeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(self.phoneView);
}];
[self.passwordView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(self.phoneView);
}];
}
- (void)initEvents {
@weakify(self);
RAC(self.finishButton, enabled) = [RACSignal combineLatest:@[self.phoneView.textField.rac_textSignal, self.codeView.textField.rac_textSignal, self.passwordView.textField.rac_textSignal] reduce:^id _Nonnull(NSString *phone, NSString *code, NSString *password){
return @(phone.length > 0 && code.length > 0 && password.length >= 6 && password.length <= 16);
}];
}
#pragma mark - XPChooseAreaCodeVCDelegate
-(void)chooseAreaCodeSuccess:(NSString *)code{
self.pi_phoneAreaCode = code;
self.phoneView.areaCode = [NSString stringWithFormat:@"+%@",code];
}
#pragma mark - LoginForgetPasswordProtocol
///
- (void)phoneSmsCodeSuccess {
[self hideHUD];
self.codeView.authCodeButton.enabled= NO;
[self showSuccessToast:YMLocalizedString(@"LoginForgetPasswordViewController1")];
[[CountDownHelper shareHelper] openCountdownWithTime:60];
}
///
- (void)resetPasswrodSuccess {
[[CountDownHelper shareHelper] stopCountDown];
[self showSuccessToast:YMLocalizedString(@"LoginForgetPasswordViewController2")];
if(self.isLogout == YES){
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self.presenter logout];
});
}else{
[self.navigationController popViewControllerAnimated:YES];
}
}
#pragma mark - CountDownHelperDelegate
///
- (void)onCountdownOpen:(int)time {
[self.codeView.authCodeButton setTitle:[NSString stringWithFormat:YMLocalizedString(@"LoginForgetPasswordViewController3"), time] forState:UIControlStateDisabled];
}
///
- (void)onCountdownFinish {
self.codeView.authCodeButton.enabled= YES;
[self.codeView.authCodeButton setTitle:YMLocalizedString(@"LoginForgetPasswordViewController4") forState:UIControlStateNormal];
}
#pragma mark - Event Response
- (void)finishButtonAction:(UIButton *)sender {
[self.view endEditing:YES];
[self.presenter resetPassword:[NSString stringWithFormat:@"%@%@",self.pi_phoneAreaCode,self.phoneView.textField.text] newPwd:self.passwordView.textField.text smsCode:self.codeView.textField.text phoneAreaCode:self.pi_phoneAreaCode];
}
- (void)authCodeButtonAction:(UIButton *)sender {
if(self.phoneView.textField.text.length == 0){
[self showErrorToast:YMLocalizedString(@"LoginForgetPasswordViewController7")];
return;
}
[self.view endEditing:YES];
[self showLoading];
[self.presenter phoneSmsCode:[NSString stringWithFormat:@"%@%@",self.pi_phoneAreaCode,self.phoneView.textField.text] type:GetSmsType_Reset_Password phoneAreaCode:self.pi_phoneAreaCode];
}
-(void)chooseAreaCodeAction{
XPLoginAraeViewController *codeVC = [XPLoginAraeViewController new];
codeVC.delegate = self;
[self.navigationController pushViewController:codeVC animated:YES];
}
-(void)hidePasswordAction{
self.passwordView.rightButton.selected = !self.passwordView.rightButton.selected;
self.passwordView.textField.secureTextEntry = !self.passwordView.rightButton.selected;
}
#pragma mark - Getters And Setters
- (UIButton *)finishButton{
if (!_finishButton) {
_finishButton = [UIButton buttonWithType:UIButtonTypeCustom];
_finishButton.layer.masksToBounds = YES;
_finishButton.layer.cornerRadius = kGetScaleWidth(24);
[_finishButton setTitle:YMLocalizedString(@"LoginForgetPasswordViewController6") forState:UIControlStateNormal];
_finishButton.titleLabel.font = kFontRegular(16);
[_finishButton setTitleColor:[DJDKMIMOMColor confirmButtonTextColor] forState:UIControlStateNormal];
_finishButton.enabled = NO;
UIImage *image = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor],[DJDKMIMOMColor confirmButtonGradientMiddleColor], [DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(kGetScaleWidth(345), kGetScaleWidth(46))];
[_finishButton setBackgroundImage:image forState:UIControlStateNormal];
[_finishButton addTarget:self action:@selector(finishButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _finishButton;
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisVertical;
_stackView.distribution = UIStackViewDistributionFill;
_stackView.alignment = UIStackViewAlignmentFill;
_stackView.spacing = kGetScaleWidth(25);
}
return _stackView;
}
- (LoginForgetEditView *)phoneView {
if (!_phoneView) {
_phoneView = [[LoginForgetEditView alloc] init];
// _phoneView.placeholder = YMLocalizedString(@"LoginForgetPasswordViewController7");
_phoneView.textField.keyboardType = UIKeyboardTypeNumberPad;
_phoneView.type = LoginForgetEditViewTypeNormal;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(chooseAreaCodeAction)];
[_phoneView.codeView addGestureRecognizer:tap];
}
return _phoneView;
}
- (LoginForgetEditView *)codeView {
if (!_codeView) {
_codeView = [[LoginForgetEditView alloc] init];
_codeView.placeholder = YMLocalizedString(@"LoginForgetPasswordViewController8");
_codeView.type = LoginForgetEditViewTypeSms;
_codeView.textField.keyboardType = UIKeyboardTypeNumberPad;
[_codeView.authCodeButton addTarget:self action:@selector(authCodeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _codeView;
}
- (LoginForgetEditView *)passwordView {
if (!_passwordView) {
_passwordView = [[LoginForgetEditView alloc] init];
_passwordView.textField.secureTextEntry = YES;
_passwordView.placeholder = YMLocalizedString(@"LoginForgetPasswordViewController9");
_passwordView.type = LoginForgetEditViewTypePassword;
_passwordView.textField.keyboardType = UIKeyboardTypeASCIICapable;
_passwordView.textField.clearButtonMode = UITextFieldViewModeAlways;
[_passwordView.rightButton addTarget:self action:@selector(hidePasswordAction) forControlEvents:UIControlEventTouchUpInside];
}
return _passwordView;
}
@end

View File

@@ -0,0 +1,16 @@
//
// LoginFullInfoViewController.h
// YUMI
//
// Created by YUMI on 2021/9/14.
//
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface LoginFullInfoViewController : MvpViewController
@property(nonatomic,copy) NSString *inviteCode;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,650 @@
//
// LoginFullInfoViewController.m
// YUMI
//
// Created by YUMI on 2021/9/14.
//
#import "LoginFullInfoViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <ReactiveObjC/ReactiveObjC.h>
///Tool
#import "YUMIMacroUitls.h"
#import "DJDKMIMOMColor.h"
#import "UIImage+Utils.h"
#import "UIButton+EnlargeTouchArea.h"
#import "AccountInfoStorage.h"
#import "TTPopup.h"
#import "PIUserSexView.h"
///Model
#import "ThirdUserInfo.h"
///P
#import "LoginFullInfoPresenter.h"
#import "LoginFullInfoProtocol.h"
#import "PILoginManager.h"
#import "ClientConfig.h"
#import "PublicRoomManager.h"
#import "RegionListViewController.h"
#import "RegionListInfo.h"
@interface LoginFullInfoViewController ()<LoginFullInfoProtocol, UIViewControllerTransitioningDelegate>
///
@property(nonatomic,strong) UIImageView *bgImageView;
///
@property(nonatomic,strong) UIView *bgView;
///
@property (nonatomic,strong) UILabel *titleLabel;
///
@property (nonatomic,strong) UILabel *remindLabel;
///
@property (nonatomic,strong) UIView * backView;
///
@property (nonatomic,strong) UILabel *nameLabel;
///
@property (nonatomic,strong) MSBaseTextField *textField;
///
@property (nonatomic,strong) UIButton *refreshButton;
///x
@property (nonatomic,strong) UIStackView *sexStackView;
///
@property (nonatomic,strong) PIUserSexView *maleView;
///
@property (nonatomic,strong) PIUserSexView*femaleView;
///
@property (nonatomic,strong) UIButton *nextButton;
@property(nonatomic, strong) UILabel *block18Tips;
///
@property (nonatomic,strong) UIView *codeContainView;
///
@property (nonatomic,strong) MSBaseTextField *codeTextField;
@property (nonatomic,strong) UIView *regionContainView;
@property(nonatomic, strong) UILabel *regionLabel;
@property(nonatomic, strong) NetImageView *regionFlagImageView;
///
@property (nonatomic,strong) ThirdUserInfo *thirdInfo;
///
@property (nonatomic,copy) NSString *sexString;
@property(nonatomic, copy) NSArray <RegionListInfo *> *regionInfoList;
@property(nonatomic, strong) RegionListInfo *selectedRegion;
@end
@implementation LoginFullInfoViewController
- (BOOL)isHiddenNavBar {
return YES;
}
- (LoginFullInfoPresenter *)createPresenter {
return [[LoginFullInfoPresenter alloc] init];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self initSubViews];
[self initSubViewConstraints];
[self initEvents];
[self loadAllRegions];
ClientConfig *config = [ClientConfig shareConfig];
if (config.inviteCode.length > 0){
self.inviteCode = config.inviteCode;
config.inviteCode = @"";
}
// loading
[XNDJTDDLoadingTool hideHUD];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self.view endEditing:YES];
}
- (void)loadAllRegions {
@kWeakify(self);
[self.presenter loadAllRegionInfo:^(NSArray<RegionListInfo *> * _Nonnull array) {
@kStrongify(self);
self.regionInfoList = array;
for (RegionListInfo *info in array) {
if (info.checked) {
[self updateRegion:info];
break;
}
}
} failure:^(NSError * _Nonnull error) {
}];
}
#pragma mark - Private Method
- (void)initSubViews {
self.view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.bgImageView];
[self.view addSubview:self.titleLabel];
[self.view addSubview:self.bgView];
[self.bgView addSubview:self.remindLabel];
[self.bgView addSubview:self.sexStackView];
[self.bgView addSubview:self.backView];
[self.view addSubview:self.codeContainView];
[self.view addSubview:self.regionContainView];
[self.view addSubview:self.nextButton];
[self.view addSubview:self.block18Tips];
[self.backView addSubview:self.textField];
[self.backView addSubview:self.refreshButton];
[self.backView addSubview:self.nameLabel];
[self.sexStackView addArrangedSubview:self.maleView];
[self.sexStackView addArrangedSubview:self.femaleView];
[self.codeContainView addSubview:self.codeTextField];
UIStackView *regionStack = [[UIStackView alloc] initWithArrangedSubviews:@[
self.regionFlagImageView,
self.regionLabel
]];
regionStack.spacing = 4;
[self.regionContainView addSubview:regionStack];
[regionStack mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(kGetScaleWidth(24));
make.centerY.mas_equalTo(self.regionContainView);
}];
[self.regionFlagImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(0, 18));
}];
if ([self.presenter getThirdUserInfo] && [self.presenter getThirdUserInfo].userName.length > 0) {
self.textField.text = [self.presenter getThirdUserInfo].userName;
} else {
[self.presenter randomRequestNick];
}
}
- (void)initSubViewConstraints {
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.top.equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(140));
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
if (iPhoneXSeries) {
make.top.mas_equalTo(kGetScaleWidth(128));
} else {
make.top.mas_equalTo(kGetScaleWidth(68));
}
make.leading.mas_equalTo(kGetScaleWidth(24));
make.height.mas_equalTo(kGetScaleWidth(40));
}];
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.bottom.equalTo(self.view);
if (iPhoneXSeries) {
make.top.mas_equalTo(kGetScaleWidth(192));
} else {
make.top.mas_equalTo(kGetScaleWidth(132));
}
}];
[self.remindLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.equalTo(self.bgView).inset(kGetScaleWidth(10));
make.top.mas_equalTo(kGetScaleWidth(48));
}];
[self.sexStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(kGetScaleWidth(38));
make.trailing.mas_equalTo(-kGetScaleWidth(38));
make.top.mas_equalTo(kGetScaleWidth(86));
}];
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(303));
make.height.mas_equalTo(kGetScaleWidth(52));
make.centerX.equalTo(self.bgView);
make.top.mas_equalTo(self.sexStackView.mas_bottom).offset(kGetScaleWidth(28));
}];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(-kGetScaleWidth(18));
make.centerY.equalTo(self.backView);
}];
[self.refreshButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(18));
make.centerY.equalTo(self.backView);
make.trailing.equalTo(self.nameLabel.mas_leading).mas_offset(-kGetScaleWidth(4));
}];
[self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(kGetScaleWidth(24));
make.top.bottom.equalTo(self.backView);
make.trailing.equalTo(self.refreshButton.mas_leading).mas_offset(-kGetScaleWidth(4));
}];
[self.maleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(132));
make.height.mas_equalTo(kGetScaleWidth(108));
}];
[self.femaleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(132));
make.height.mas_equalTo(kGetScaleWidth(108));
}];
[self.codeContainView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.height.mas_equalTo(self.backView);
make.top.mas_equalTo(self.backView.mas_bottom).offset(kGetScaleWidth(20));
}];
[self.codeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.codeContainView).offset(kGetScaleWidth(24));
make.top.bottom.mas_equalTo(self.codeContainView);
make.trailing.mas_equalTo(self.codeContainView).offset(-kGetScaleWidth(18));
}];
[self.regionContainView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.height.mas_equalTo(self.backView);
make.top.mas_equalTo(self.codeContainView.mas_bottom).offset(kGetScaleWidth(20));
}];
[self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(303));
make.centerX.equalTo(self.bgView);
make.height.mas_equalTo(kGetScaleWidth(48));
make.top.mas_equalTo(self.regionContainView.mas_bottom).offset(kGetScaleWidth(38));
}];
[self.block18Tips mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.nextButton);
make.top.mas_equalTo(self.nextButton.mas_bottom).offset(8);
}];
}
- (void)initEvents {
@weakify(self);
[[self.textField.rac_textSignal map:^id _Nullable(NSString * _Nullable value) {
if (value.length > 15) {
value = [value substringToIndex:15];
}
return value;
}] subscribeNext:^(id _Nullable x) {
@strongify(self);
self.textField.text = x;
[self updateNextButton];
}];
}
- (void)setInviteCode:(NSString *)inviteCode{
_inviteCode = inviteCode;
self.codeTextField.text = _inviteCode;
}
- (void)didTapRegionButton {
__block RegionListViewController *vc;
if (self.regionInfoList.count == 0) {
@kWeakify(self);
[self.presenter loadAllRegionInfo:^(NSArray<RegionListInfo *> * _Nonnull array) {
@kStrongify(self);
self.regionInfoList = array;
vc = [[RegionListViewController alloc] initForRegionList:array];
[self presentViewController:vc animated:YES completion:nil];
@kWeakify(self);
[vc setHandleTapRegionComfirm:^(RegionListInfo * _Nonnull regionInfo) {
@kStrongify(self);
[self updateRegion:regionInfo];
}];
} failure:^(NSError * _Nonnull error) {
}];
} else {
vc = [[RegionListViewController alloc] initForRegionList:self.regionInfoList];
[self presentViewController:vc animated:YES completion:nil];
@kWeakify(self);
[vc setHandleTapRegionComfirm:^(RegionListInfo * _Nonnull regionInfo) {
@kStrongify(self);
[self updateRegion:regionInfo];
}];
}
}
- (void)updateRegion:(RegionListInfo *)model {
self.selectedRegion = model;
self.regionLabel.text = model.name;
self.regionFlagImageView.imageUrl = model.icon;
self.regionLabel.textColor = UIColorFromRGB(0x313131);
[self.regionFlagImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(24, 18));
}];
[self.regionContainView layoutIfNeeded];
[self updateNextButton];
}
///
- (void)updateUserInfo {
[XNDJTDDLoadingTool showOnlyView:self.view];
[self.presenter complectionInfoWithAvatar:[self getAvatarUrl]
gender:self.maleView.selected ? @"1":@"2" nick:self.textField.text
inviteCode:self.codeTextField.text
roomUid:nil
shareUid:nil
shareChannel:nil
regionId:self.selectedRegion.id];
}
///
- (NSString *)getAvatarUrl {
NSString * avatar;
if ([self.presenter getThirdUserInfo] && [self.presenter getThirdUserInfo].avatarUrl.length > 0) {
avatar = [self.presenter getThirdUserInfo].avatarUrl;
} else {
avatar = @"https://image.hfighting.com/morentouxiang.png";
}
return avatar;
}
- (void)updateNextButton {
if (self.textField.text.length > 0 && self.sexString.length > 0 && self.selectedRegion) {
self.nextButton.enabled = YES;
} else {
self.nextButton.enabled = NO;
}
}
#pragma mark - LoginFullInfoProtocol
- (void)requestRandomNickSuccess:(NSString *)nick {
self.textField.text = nick;
}
- (void)complementInfoSuccess {
/// ticket tabbaritem
[[AccountInfoStorage instance] saveTicket:nil];
//
[[PublicRoomManager sharedManager] initialize];
NSString * inviteCode = self.codeTextField.text.length > 0 ? self.codeTextField.text : @"";
[PILoginManager jumpToHomeVCWithInviteCode:inviteCode];
}
-(void)complementInfoFail{
[XNDJTDDLoadingTool hideOnlyView:self.view];
};
#pragma mark - Event Response
- (void)nextButtonAction:(UIButton *)sender {
if (self.codeTextField.text.length <= 0) {
TTAlertConfig * config = [[TTAlertConfig alloc] init];
config.title = YMLocalizedString(@"LoginFullInfoViewController10");
config.message = YMLocalizedString(@"LoginFullInfoViewController0");
[TTPopup alertWithConfig:config confirmHandler:^{
[self updateUserInfo];
} cancelHandler:^{
}];
} else {
[self updateUserInfo];
}
}
- (void)refreshButtonAction {
CAKeyframeAnimation *lAni = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
lAni.duration = 1;
lAni.values=@[@0,@(M_PI*2)];
//使
lAni.removedOnCompletion = NO;
lAni.fillMode = kCAFillModeForwards;
[self.refreshButton.layer addAnimation:lAni forKey:nil];
[self.presenter randomRequestNick];
}
- (void)maleButtonAction:(UITapGestureRecognizer *)tap {
PIUserSexView * view = (PIUserSexView *)tap.view;
self.femaleView.selected = NO;
view.selected = YES;
self.sexString = @"1";
}
- (void)femaleButtonAction:(UITapGestureRecognizer *)tap {
PIUserSexView * view = (PIUserSexView *)tap.view;
view.selected = YES;
self.maleView.selected = NO;
self.sexString = @"2";
}
#pragma mark - Getters And Setters
- (void)setSexString:(NSString *)sexString {
_sexString = sexString;
[self updateNextButton];
}
- (UIImageView *)bgImageView{
if(!_bgImageView){
_bgImageView = [[UIImageView alloc]init];
_bgImageView.image = kImage(@"home_top_bg");
_bgImageView.contentMode = UIViewContentModeScaleAspectFill;
}
return _bgImageView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.text = YMLocalizedString(@"LoginFullInfoViewController1");
_titleLabel.font = kFontBold(28);
_titleLabel.textColor = UIColorFromRGB(0x1F1B4F);
}
return _titleLabel;
}
- (UILabel *)remindLabel {
if (!_remindLabel) {
_remindLabel = [[UILabel alloc] init];
NSMutableAttributedString *textAtt = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"%@%@",YMLocalizedString(@"LoginFullInfoViewController8"),YMLocalizedString(@"LoginFullInfoViewController2")] attributes:@{NSFontAttributeName:kFontMedium(16),NSForegroundColorAttributeName:UIColorFromRGB(0x1F1B4F)}];
[textAtt addAttributes:@{NSFontAttributeName:kFontRegular(12),NSForegroundColorAttributeName:UIColorFromRGB(0x6D6B89)} range:[textAtt.string rangeOfString:[NSString stringWithFormat:@"%@",YMLocalizedString(@"LoginFullInfoViewController2")]]];
_remindLabel.attributedText = textAtt;
_remindLabel.numberOfLines = 2;
_remindLabel.textAlignment = NSTextAlignmentCenter;
}
return _remindLabel;
}
- (UIView *)backView {
if (!_backView) {
_backView = [[UIView alloc] init];
_backView.backgroundColor = UIColorFromRGB(0xF5F6FA);
_backView.layer.masksToBounds = YES;
_backView.layer.cornerRadius = kGetScaleWidth(52)/2;
}
return _backView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.text = YMLocalizedString(@"LoginFullInfoViewController9");
_nameLabel.font = kFontRegular(14);
_nameLabel.textColor = UIColorFromRGB(0x1F1B4F);
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(refreshButtonAction)];
_nameLabel.userInteractionEnabled = YES;
[_nameLabel addGestureRecognizer:tap];
[_nameLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
[_nameLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
}
return _nameLabel;
}
- (MSBaseTextField *)textField {
if (!_textField) {
_textField = [[MSBaseTextField alloc] init];
_textField.textColor = UIColorFromRGB(0x1F1B4F);
_textField.font = kFontMedium(16);
_textField.placeholder = YMLocalizedString(@"LoginFullInfoViewController3");
_textField.borderStyle = UITextBorderStyleNone;
_textField.tintColor = [DJDKMIMOMColor appMainColor];
_textField.backgroundColor = [UIColor clearColor];
}
return _textField;
}
- (UIButton *)refreshButton {
if (!_refreshButton) {
_refreshButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_refreshButton setImage:[UIImage imageNamed:@"login_full_info_refresh"] forState:UIControlStateNormal];
[_refreshButton setImage:[UIImage imageNamed:@"login_full_info_refresh"] forState:UIControlStateSelected];
[_refreshButton setEnlargeEdgeWithTop:0 right:0 bottom:0 left:10];
[_refreshButton setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
[_refreshButton setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
[_refreshButton addTarget:self action:@selector(refreshButtonAction) forControlEvents:UIControlEventTouchUpInside];
}
return _refreshButton;
}
- (UIStackView *)sexStackView {
if (!_sexStackView) {
_sexStackView = [[UIStackView alloc] init];
_sexStackView.axis = UILayoutConstraintAxisHorizontal;
_sexStackView.distribution = UIStackViewDistributionFill;
_sexStackView.alignment = UIStackViewAlignmentCenter;
_sexStackView.spacing = kGetScaleWidth(35);
}
return _sexStackView;
}
- (PIUserSexView *)maleView {
if (!_maleView) {
_maleView = [[PIUserSexView alloc] init];
_maleView.gender = GenderType_Male;
_maleView.selected = NO;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(maleButtonAction:)];
[_maleView addGestureRecognizer:tap];
}
return _maleView;
}
- (PIUserSexView *)femaleView {
if (!_femaleView) {
_femaleView = [[PIUserSexView alloc] init];
_femaleView.gender = GenderType_Female;
_femaleView.selected = NO;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(femaleButtonAction:)];
[_femaleView addGestureRecognizer:tap];
}
return _femaleView;
}
- (UIView *)codeContainView {
if (!_codeContainView) {
_codeContainView = [[UIView alloc] init];
_codeContainView.backgroundColor = UIColorFromRGB(0xF5F6FA);
_codeContainView.layer.masksToBounds= YES;
_codeContainView.layer.cornerRadius = kGetScaleWidth(52)/2;
}
return _codeContainView;
}
- (MSBaseTextField *)codeTextField {
if (!_codeTextField) {
_codeTextField = [[MSBaseTextField alloc] init];
_codeTextField.textColor = UIColorFromRGB(0x1F1B4F);
_codeTextField.font = kFontMedium(14);
_codeTextField.borderStyle = UITextBorderStyleNone;
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc]initWithString:YMLocalizedString(@"LoginFullInfoViewController5") attributes:@{NSFontAttributeName:kFontRegular(14),NSForegroundColorAttributeName:UIColorFromRGB(0xB3B3C3)}];
_codeTextField.attributedPlaceholder = placeholder;
_codeTextField.textAlignment = NSTextAlignmentLeft;
_codeTextField.backgroundColor = [UIColor clearColor];
}
return _codeTextField;
}
- (UIButton *)nextButton{
if (!_nextButton) {
_nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
_nextButton.layer.masksToBounds = YES;
_nextButton.layer.cornerRadius = kGetScaleWidth(48)/2.f;
[_nextButton setTitle:YMLocalizedString(@"LoginFullInfoViewController6") forState:UIControlStateNormal];
_nextButton.titleLabel.font = kFontMedium(16);
[_nextButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
_nextButton.enabled = NO;
UIImage *image = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor], [DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
[_nextButton setBackgroundImage:image forState:UIControlStateNormal];
[_nextButton addTarget:self action:@selector(nextButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _nextButton;
}
- (UILabel *)block18Tips {
if (!_block18Tips) {
_block18Tips = [UILabel labelInitWithText:YMLocalizedString(@"1.0.30_text_25")
font:kFontRegular(11)
textColor:UIColorFromRGB(0xAFB1B3)];
}
return _block18Tips;
}
- (UIView *)bgView{
if(!_bgView){
UIView *bgView = [UIView new];
bgView.backgroundColor = [UIColor whiteColor];
bgView.layer.cornerRadius = kGetScaleWidth(20);
bgView.layer.masksToBounds = YES;
_bgView = bgView;
}
return _bgView;
}
- (UIView *)regionContainView {
if (!_regionContainView) {
_regionContainView = [[UIView alloc] init];
_regionContainView.backgroundColor = UIColorFromRGB(0xF5F6FA);
[_regionContainView setCornerRadius:kGetScaleWidth(52)/2];
UIImageView *arrow = [[UIImageView alloc] initWithImage:[kImage(@"grey_arrow") ms_SetImageForRTL]];
// arrow.layer.contentsRect = CGRectMake(0.1, 0.1, 0.8, 0.8);
arrow.contentMode = UIViewContentModeScaleAspectFit;
[_regionContainView addSubview:arrow];
[arrow mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(_regionContainView);
make.trailing.mas_equalTo(-20);
make.width.height.mas_equalTo(20);
}];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapRegionButton)];
[_regionContainView addGestureRecognizer:tap];
}
return _regionContainView;
}
- (UILabel *)regionLabel {
if (!_regionLabel) {
_regionLabel = [UILabel labelInitWithText:YMLocalizedString(@"1.0.31_text_0")
font:kFontMedium(12)
textColor:UIColorFromRGB(0xb3b3c1)];
_regionLabel.userInteractionEnabled = YES;
}
return _regionLabel;
}
- (NetImageView *)regionFlagImageView {
if (!_regionFlagImageView) {
_regionFlagImageView = [[NetImageView alloc] init];
_regionFlagImageView.contentMode = UIViewContentModeScaleAspectFit;
_regionFlagImageView.userInteractionEnabled = YES;
}
return _regionFlagImageView;
}
@end

View File

@@ -0,0 +1,30 @@
//
// LoginTypesViewController.h
// YuMi
//
// Created by P on 2025/3/11.
//
#import "MvpViewController.h"
#import "LoginInputItemView.h"
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, LoginDisplayType) {
LoginDisplayType_id,
LoginDisplayType_email,
LoginDisplayType_phoneNum,
LoginDisplayType_email_forgetPassword,
LoginDisplayType_phoneNum_forgetPassword,
};
@interface LoginTypesViewController : MvpViewController
@property(nonatomic, assign) BOOL isLogoutAfterRestPassword;
- (void)updateLoginType:(LoginDisplayType)type;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,542 @@
//
// LoginTypesViewController.m
// YuMi
//
// Created by P on 2025/3/11.
//
#import "LoginTypesViewController.h"
#import "LoginPresenter.h"
#import "XPLoginAraeViewController.h"
#import "LoginProtocol.h"
#import "PILoginManager.h"
#import "XPWebViewController.h"
@interface LoginTypesViewController () <XPLoginAraeViewControllerDelegate, LoginProtocol>
@property(nonatomic, assign) LoginDisplayType type;
@property(nonatomic, strong) UILabel *titleLabel;
@property(nonatomic, strong) LoginInputItemView *firstLineInputView;
@property(nonatomic, strong) LoginInputItemView *secondLineInputView;
@property(nonatomic, strong) LoginInputItemView *thirdLineInputView;
@property(nonatomic, strong) UIButton *bottomActionButton;
@property(nonatomic, strong) UIButton *forgotPasswordButton;
@property(nonatomic, strong) UIStackView *stackView;
@property(nonatomic, strong) XPWebViewController *webVC;
@property(nonatomic, strong) UIButton *switchForgotType;
@end
@implementation LoginTypesViewController
- (void)dealloc {
[self.secondLineInputView endVerificationCountDown];
}
- (BOOL)isHiddenNavBar {
return YES;
}
- (LoginPresenter *)createPresenter {
return [[LoginPresenter alloc] init];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self setupUI];
}
- (void)updateLoginType:(LoginDisplayType)type {
self.type = type;
[self setupInputArea];
}
- (void)setupUI {
[self setupDefaultUI];
[self setupNavigationBar];
}
- (void)handleTap {
[self.view endEditing:YES];
}
- (void)setupDefaultUI {
UIImageView *backagroundImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
backagroundImageView.userInteractionEnabled = YES;
if (isMSRTL()) {
backagroundImageView.image = kImage(@"login_page_backage_ar");
} else {
backagroundImageView.image = kImage(@"login_page_backage");
}
[self.view addSubview:backagroundImageView];
UIImageView *hiImageView = [[UIImageView alloc] initWithImage:kImage(@"login_page_mail_HI")];
[self.view addSubview:hiImageView];
[hiImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(45);
make.top.mas_equalTo(111);
make.size.mas_equalTo(CGSizeMake(88, 45));
}];
[self.view addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(45);
make.top.mas_equalTo(190);
}];
[self.view addSubview:self.stackView];
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(22);
make.leading.trailing.mas_equalTo(self.view).inset(40);
}];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
[tap addTarget:self action:@selector(handleTap)];
[backagroundImageView addGestureRecognizer:tap];
}
- (void)setupNavigationBar {
UIButton *backButton = [self backButton];
[self.view addSubview:backButton];
[backButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.view).offset(16);
make.top.mas_equalTo(self.view).offset(kStatusBarHeight);
make.size.mas_equalTo(CGSizeMake(22, 22));
}];
}
- (void)setupInputArea {
switch (self.type) {
case LoginDisplayType_id:
[self setupIDInputArea];
break;
case LoginDisplayType_email:
[self setupEmailInputArea];
break;
case LoginDisplayType_phoneNum:
[self setupPhoneInputArea];
break;
case LoginDisplayType_email_forgetPassword:
case LoginDisplayType_phoneNum_forgetPassword:
[self.firstLineInputView removeFromSuperview];
[self.secondLineInputView removeFromSuperview];
[self.thirdLineInputView removeFromSuperview];
[self.bottomActionButton removeFromSuperview];
[self.switchForgotType removeFromSuperview];
[self setupForgotPasswordArea];
break;
default:
break;
}
}
- (void)setupIDInputArea {
[self setupInpuArea:LoginInputType_id
second:LoginInputType_password
third:LoginInputType_none
action:LoginInputType_login
showForgetPassword:YES];
}
- (void)setupEmailInputArea {
[self setupInpuArea:LoginInputType_email
second:LoginInputType_verificationCode
third:LoginInputType_none
action:LoginInputType_login
showForgetPassword:NO];
}
- (void)setupPhoneInputArea {
[self setupInpuArea:LoginInputType_phoneNum
second:LoginInputType_verificationCode
third:LoginInputType_none
action:LoginInputType_login
showForgetPassword:NO];
}
- (void)setupForgotPasswordArea {
[self setupInpuArea:self.type==LoginDisplayType_email_forgetPassword ? LoginInputType_email : LoginInputType_phoneNum
second:LoginInputType_verificationCode
third:LoginInputType_confirmPassword
action:LoginInputType_confirm
showForgetPassword:NO];
}
- (void)setupInpuArea:(LoginInputType)first
second:(LoginInputType)second
third:(LoginInputType)third
action:(LoginInputType)action
showForgetPassword:(BOOL)showForgetPassword {
@kWeakify(self);
_firstLineInputView = [[LoginInputItemView alloc] initWithType:first];
[self.firstLineInputView setHandleItemAction:^(LoginInputType inputType) {
@kStrongify(self);
if (inputType == LoginInputType_phoneNum) {
[self handleTapAreaCode];
}
}];
[self.firstLineInputView setHandleFirstInputContentUpdate:^(NSString *inputContent) {
@kStrongify(self);
[self checkActionButtonStatus];
}];
[self.stackView addArrangedSubview:self.firstLineInputView];
[self.firstLineInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(46);
}];
_secondLineInputView = [[LoginInputItemView alloc] initWithType:second];
[self.secondLineInputView setHandleItemAction:^(LoginInputType inputType) {
@kStrongify(self);
if (inputType == LoginInputType_verificationCode) {
if (self.type == LoginDisplayType_phoneNum || self.type == LoginDisplayType_phoneNum_forgetPassword) {
[self handleTapGetPhoneVerificationCode];
} else if (self.type == LoginDisplayType_email || self.type == LoginDisplayType_email_forgetPassword) {
[self handleTapGetMailVerificationCode];
}
}
}];
[self.secondLineInputView setHandleSecondInputContentUpdate:^(NSString *inputContent) {
@kStrongify(self);
[self checkActionButtonStatus];
}];
[self.stackView addArrangedSubview:self.secondLineInputView];
[self.secondLineInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(46);
}];
if (third != LoginInputType_none) {
_thirdLineInputView = [[LoginInputItemView alloc] initWithType:third];
[self.thirdLineInputView setHandleThirdInputContentUpdate:^(NSString *inputContent) {
@kStrongify(self);
[self checkActionButtonStatus];
}];
[self.stackView addArrangedSubview:self.thirdLineInputView];
[self.thirdLineInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(46);
}];
[self.view addSubview:self.switchForgotType];
[self.switchForgotType mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.bottom.mas_equalTo(self.view).offset(-kSafeAreaBottomHeight - 43);
}];
[self.switchForgotType setTitle: self.type == LoginDisplayType_email_forgetPassword ? YMLocalizedString(@"20.20.51_text_19") : YMLocalizedString(@"20.20.51_text_18")
forState:UIControlStateNormal];
self.titleLabel.text = YMLocalizedString(@"20.20.51_text_20");
}
if (showForgetPassword) {
[self.stackView setCustomSpacing:8 afterView:self.secondLineInputView];
[self.stackView addArrangedSubview:self.forgotPasswordButton];
[self.forgotPasswordButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(30);
}];
[self.stackView setCustomSpacing:8 afterView:self.forgotPasswordButton];
}
if (action != LoginInputType_none) {
if (action == LoginInputType_login) {
[self.bottomActionButton setTitle:YMLocalizedString(@"XPLoginPhoneViewController8") forState:UIControlStateNormal];
[self.bottomActionButton setTitle:YMLocalizedString(@"XPLoginPhoneViewController8") forState:UIControlStateDisabled];
} else if (action == LoginInputType_confirm) {
[self.bottomActionButton setTitle:YMLocalizedString(@"XPAnchorAudienceUpMicView2") forState:UIControlStateNormal];
[self.bottomActionButton setTitle:YMLocalizedString(@"XPAnchorAudienceUpMicView2") forState:UIControlStateDisabled];
}
[self.stackView addArrangedSubview:self.bottomActionButton];
[self.bottomActionButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(46);
}];
}
}
#pragma mark -
- (void)didTapBack {
[self.navigationController popViewControllerAnimated:YES];
}
- (void)didTapActionButton {
[self.view endEditing:true];
switch (self.type) {
case LoginDisplayType_id: {
[self.presenter loginWithPhone:[self.firstLineInputView inputContent]
password:[self.secondLineInputView inputContent]];
}
break;
case LoginDisplayType_phoneNum: {
[self.presenter loginWithPhone:[self.firstLineInputView inputContent]
code:[self.secondLineInputView inputContent]
phoneAreaCode:[self.firstLineInputView loadAreaCode]];
}
break;
case LoginDisplayType_email: {
[self.presenter loginWithEmail:[self.firstLineInputView inputContent]
code:[self.secondLineInputView inputContent]];
}
break;
case LoginDisplayType_email_forgetPassword: {
[self.presenter resetEmailPassword:[self.firstLineInputView inputContent]
code:[self.secondLineInputView inputContent]
newPassword:[self.thirdLineInputView inputContent]];
}
break;
case LoginDisplayType_phoneNum_forgetPassword: {
[self.presenter resetPhonePassword:[self.firstLineInputView inputContent]
code:[self.secondLineInputView inputContent]
newPassword:[self.thirdLineInputView inputContent]
areaCode:[self.firstLineInputView loadAreaCode]];
}
break;
default:
break;
}
}
- (void)didTapForgotPasswordButton {
LoginTypesViewController *vc = [[LoginTypesViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[vc updateLoginType:LoginDisplayType_email_forgetPassword];
}
- (void)didTapSwitchForgotType {
if (self.type == LoginDisplayType_email_forgetPassword) {
[self updateLoginType:LoginDisplayType_phoneNum_forgetPassword];
} else {
[self updateLoginType:LoginDisplayType_email_forgetPassword];
}
}
- (void)handleTapAreaCode {
XPLoginAraeViewController *codeVC = [XPLoginAraeViewController new];
codeVC.delegate = self;
[self.navigationController pushViewController:codeVC animated:YES];
}
- (void)handleTapGetPhoneVerificationCode {
NSString *phone = [self.firstLineInputView inputContent];
if (phone.length == 0 ) {
[self showErrorToast:YMLocalizedString(@"XPLoginPhoneViewController0")];
[self.secondLineInputView endVerificationCountDown];
return;
}
@kWeakify(self);
[self loadCaptchaWebView:^{
@kStrongify(self);
NSString *areaCode = [self.firstLineInputView loadAreaCode];
[self.presenter phoneSmsCode:[NSString stringWithFormat:@"%@%@", areaCode,phone]
type:GetSmsType_Regist
phoneAreaCode:areaCode];
}];
}
- (void)handleTapGetMailVerificationCode {
NSString *email = [self.firstLineInputView inputContent];
if (email.length == 0 ) {
// [self showErrorToast:YMLocalizedString(@"20.20.51_text_12")];
[self.secondLineInputView endVerificationCountDown];
return;
}
[self.presenter sendMailVerificationCode:email type:GetSmsType_Regist];
}
- (void)checkActionButtonStatus {
switch (self.type) {
case LoginDisplayType_id:
case LoginDisplayType_email:
case LoginDisplayType_phoneNum:{
NSString *accountString = [self.firstLineInputView inputContent];
NSString *codeString = [self.secondLineInputView inputContent];
if (![NSString isEmpty:accountString] && ![NSString isEmpty:codeString]) {
self.bottomActionButton.enabled = YES;
} else {
self.bottomActionButton.enabled = NO;
}
}
break;
case LoginDisplayType_email_forgetPassword:
case LoginDisplayType_phoneNum_forgetPassword: {
NSString *accountString = [self.firstLineInputView inputContent];
NSString *codeString = [self.secondLineInputView inputContent];
NSString *passwordString = [self.thirdLineInputView inputContent];
if (![NSString isEmpty:accountString] && ![NSString isEmpty:codeString] && ![NSString isEmpty:passwordString]) {
self.bottomActionButton.enabled = YES;
} else {
self.bottomActionButton.enabled = NO;
}
}
default:
break;
}
}
- (void)loadCaptchaWebView:(void(^)(void))finishBlock {
if ([ClientConfig.shareConfig shouldDisplayCaptcha]) {
[self.view endEditing:YES];
XPWebViewController * webVC =[[XPWebViewController alloc] initWithRoomUID:nil];
webVC.view.frame = CGRectMake(0, 0, KScreenWidth*0.8, KScreenWidth*1.2);
webVC.view.backgroundColor = [UIColor clearColor];
[webVC.view setCornerRadius:12];
webVC.isLoginStatus = NO;
webVC.isPush = NO;
[webVC hideNavigationBar];
webVC.url = URLWithType(kCaptchaSwitchPath);
[webVC setVerifyCaptcha:^(BOOL result) {
if (result == NO) {
return;
}
if (result && finishBlock) {
[TTPopup dismiss];
finishBlock();
}
}];
[TTPopup popupView:webVC.view style:TTPopupStyleAlert];
self.webVC = webVC;
}
}
#pragma mark - XPLoginAraeViewControllerDelegate
- (void)chooseAreaCodeSuccess:(NSString *)code {
[self.firstLineInputView updateAreaCode:code];
}
- (void)loginSuccess {
[self showSuccessToast:YMLocalizedString(@"XPLoginPhoneViewController1")];
[PILoginManager loginWithVC:self isLoginPhone:NO];
}
- (void)loginFailWithMsg:(NSString *)msg {
[self showSuccessToast:msg];
}
#pragma mark - API presenter Delegate
- (void)phoneSmsCodeSuccess:(NSString *)message type:(GetSmsType)type {
[self showSuccessToast:YMLocalizedString(@"XPLoginPhoneViewController2")];
[self.secondLineInputView startVerificationCountDown];
[self.secondLineInputView displayKeyboard];
}
- (void)phoneSmsCodeFailure {
[self.secondLineInputView endVerificationCountDown];
}
- (void)emailCodeSucess:(NSString *)message type:(GetSmsType)type{
[self showSuccessToast:YMLocalizedString(@"XPLoginPhoneViewController2")];
[self.secondLineInputView startVerificationCountDown];
[self.secondLineInputView displayKeyboard];
}
- (void)emailCodeFailure {
[self.secondLineInputView endVerificationCountDown];
}
- (void)resetEmailPasswordSuccess {
if (self.isLogoutAfterRestPassword) {
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self.presenter logout];
});
} else {
[self.navigationController popViewControllerAnimated:YES];
}
}
- (void)resetPhonePasswordSuccess {
if (self.isLogoutAfterRestPassword) {
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self.presenter logout];
});
} else {
[self.navigationController popViewControllerAnimated:YES];
}
}
#pragma mark -
- (UIButton *)backButton {
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
[b setImage:[kImage(@"common_nav_back") ms_SetImageForRTL]
forState:UIControlStateNormal];
[b addTarget:self
action:@selector(didTapBack)
forControlEvents:UIControlEventTouchUpInside];
return b;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [UILabel labelInitWithText:YMLocalizedString(@"20.20.51_text_2")
font:kFontSemibold(20)
textColor:UIColorFromRGB(0x663c22)];
}
return _titleLabel;
}
- (UIButton *)bottomActionButton {
if (!_bottomActionButton) {
_bottomActionButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_bottomActionButton setCornerRadius:23];
[_bottomActionButton setTitle:YMLocalizedString(@"XPLoginPhoneViewController8") forState:UIControlStateNormal];
[_bottomActionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
UIImage *normalBG = [UIImage gradientColorImageFromColors:@[
UIColorFromRGB(0xe29030),
UIColorFromRGB(0xfcc074)
]
gradientType:GradientTypeLeftToRight
imgSize:CGSizeMake(KScreenWidth-84, 46)] ;
UIImage *disableBG = [UIImage gradientColorImageFromColors:@[
[UIColor colorWithRed:245/255.0 green:199/255.0 blue:129/255.0 alpha:1],
[UIColor colorWithRed:253/255.0 green:217/255.0 blue:154/255.0 alpha:1],
]
gradientType:GradientTypeLeftToRight
imgSize:CGSizeMake(KScreenWidth-84, 46)] ;
[_bottomActionButton setBackgroundImage:normalBG forState:UIControlStateNormal];
[_bottomActionButton setBackgroundImage:disableBG forState:UIControlStateDisabled];
[_bottomActionButton addTarget:self
action:@selector(didTapActionButton)
forControlEvents:UIControlEventTouchUpInside];
_bottomActionButton.enabled = NO;
}
return _bottomActionButton;
}
- (UIButton *)forgotPasswordButton {
if (!_forgotPasswordButton) {
_forgotPasswordButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_forgotPasswordButton.titleLabel setFont:kFontRegular(12)];
[_forgotPasswordButton setTitleColor:UIColorFromRGB(0x313131) forState:UIControlStateNormal];
[_forgotPasswordButton setTitle:YMLocalizedString(@"XPForgetPwdViewController3") forState:UIControlStateNormal];
[_forgotPasswordButton setBackgroundColor:[UIColor clearColor]];
_forgotPasswordButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
[_forgotPasswordButton addTarget:self
action:@selector(didTapForgotPasswordButton)
forControlEvents:UIControlEventTouchUpInside];
}
return _forgotPasswordButton;
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisVertical;
_stackView.spacing = 24;
_stackView.distribution = UIStackViewDistributionFill;
}
return _stackView;
}
- (UIButton *)switchForgotType {
if (!_switchForgotType) {
_switchForgotType = [UIButton buttonWithType:UIButtonTypeCustom];
[_switchForgotType.titleLabel setFont:kFontRegular(12)];
[_switchForgotType setTitle:YMLocalizedString(@"20.20.51_text_19") forState:UIControlStateNormal];
[_switchForgotType setTitleColor:UIColorFromRGB(0x7b7b7d) forState:UIControlStateNormal];
[_switchForgotType addTarget:self action:@selector(didTapSwitchForgotType) forControlEvents:UIControlEventTouchUpInside];
}
return _switchForgotType;
}
@end

View File

@@ -0,0 +1,28 @@
//
// LoginVerifCodeViewController.h
// YUMI
//
// Created by YUMI on 2021/9/8.
//
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, VerifCodeType){
VerifCodeType_Regist, ///注册的时候
VerifCodeType_BindPhone,///绑定手机
VerifCodeType_Login,///手机登录
VerifCodeType_AreaCode,///区号
} ;
@interface LoginVerifCodeViewController : MvpViewController
///输入的手机号
@property (nonatomic,copy) NSString *phone;
@property (nonatomic,copy) NSString *pi_phoneAreaCode;
///类型
@property (nonatomic,assign) VerifCodeType type;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,362 @@
//
// LoginVerifCodeViewController.m
// YuMi
//
// Created by YuMi on 2021/9/8.
//
#import "LoginVerifCodeViewController.h"
///
#import <Masonry/Masonry.h>
#import <ReactiveObjC/ReactiveObjC.h>
///Tool
#import "DJDKMIMOMColor.h"
#import "CountDownHelper.h"
#import "YUMIMacroUitls.h"
#import "YUMIConstant.h"
#import "XNDJTDDLoadingTool.h"
#import "UIView+Corner.h"
#import "UIButton+EnlargeTouchArea.h"
///Presenter
#import "LoginVerifCodePresent.h"
///Protocole
#import "LoginVerifCodeProtocol.h"
///View
#import "LoginVerifCodeView.h"
#import "LoginFullInfoViewController.h"
#import "XPLoginPwdViewController.h"
@interface LoginVerifCodeViewController ()<LoginVerifCodeProtocol, CountDownHelperDelegate>
///
@property (nonatomic,strong) UIImageView *topBackImgView;
///
@property (nonatomic,strong) UIView *contentView;
///
@property (nonatomic,strong) UILabel *titleLabel;
//
@property (nonatomic,strong) UIView *bgCodeView;
///
@property (nonatomic,strong) UIStackView *codeStackView;
///
@property (nonatomic,strong) UILabel *cutdownLabel;
///
@property (nonatomic,strong) UIButton *retryCodeButton;
///
@property (nonatomic,strong) MSBaseTextField *textField;
///
@property (nonatomic,strong) UIButton *loginButton;
///
@property (nonatomic,strong) UIButton *backBtn;
///
@property (nonatomic,assign) BOOL isLoginSuccess;
///
@property (nonatomic,copy) NSString *code;
@end
@implementation LoginVerifCodeViewController
- (void)dealloc {
[[CountDownHelper shareHelper] stopCountDown];
}
- (BOOL)isHiddenNavBar {
return YES;
}
- (LoginVerifCodePresent *)createPresenter {
return [[LoginVerifCodePresent alloc] init];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self initSubViews];
[self initSubViewConstraints];
if(self.type != VerifCodeType_AreaCode){
self.retryCodeButton.hidden = YES;
self.cutdownLabel.hidden = NO;
[[CountDownHelper shareHelper] openCountdownWithTime:60];
}else{
self.textField.keyboardType = UIKeyboardTypeDefault;
}
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self.view endEditing:NO];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[[CountDownHelper shareHelper] stopCountDown];
}
#pragma mark - Private Method
- (void)initSubViews {
[self.view addSubview:self.topBackImgView];
[self.view addSubview:self.contentView];
if(self.type == VerifCodeType_AreaCode){
self.titleLabel.text = YMLocalizedString(@"LoginVerifCodeViewController5");
}else{
[self.topBackImgView addSubview:self.backBtn];
[CountDownHelper shareHelper].delegate = self;
}
[self.topBackImgView addSubview:self.titleLabel];
[self.contentView addSubview:self.bgCodeView];
[self.bgCodeView addSubview:self.codeStackView];
[self.codeStackView addArrangedSubview:self.textField];
[self.codeStackView addArrangedSubview:self.cutdownLabel];
[self.codeStackView addArrangedSubview:self.retryCodeButton];
[self.contentView addSubview:self.loginButton];
}
- (void)initSubViewConstraints {
[self.topBackImgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.top.mas_equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(333));
}];
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.bottom.mas_equalTo(self.view);
make.top.equalTo(self.topBackImgView.mas_bottom).mas_offset(-kGetScaleWidth(30));
}];
if(self.type != VerifCodeType_AreaCode){
[self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.topBackImgView.mas_top).offset(kSafeAreaTopHeight + kGetScaleWidth(52));
make.width.height.mas_equalTo(kGetScaleWidth(20));
make.leading.mas_equalTo(kGetScaleWidth(15));
}];
}
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.topBackImgView).offset(kGetScaleWidth(30));
make.top.mas_equalTo(self.topBackImgView.mas_top).offset(kSafeAreaTopHeight + kGetScaleWidth(96));
}];
[self.bgCodeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(30));
make.trailing.mas_equalTo(-kGetScaleWidth(33));
make.leading.mas_equalTo(kGetScaleWidth(33));
make.height.mas_equalTo(kGetScaleWidth(63));
}];
[self.codeStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(kGetScaleWidth(20));
make.trailing.mas_equalTo(-kGetScaleWidth(20));
make.top.bottom.equalTo(self.bgCodeView);
}];
[self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_greaterThanOrEqualTo(kGetScaleWidth(190));
}];
[self.loginButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.contentView);
make.height.mas_equalTo(kGetScaleWidth(63));
make.width.mas_equalTo(kGetScaleWidth(165));
make.top.equalTo(self.bgCodeView.mas_bottom).mas_offset(kGetScaleWidth(50));
}];
}
- (void)httpRequestPhoneSmsCode {
[self.presenter phoneSmsCode:[NSString stringWithFormat:@"%@%@",self.pi_phoneAreaCode,self.phone] type:GetSmsType_Regist phoneAreaCode:self.pi_phoneAreaCode];
}
-(void)loginButtonAction{
[self.view endEditing:YES];
self.loginButton.enabled = NO;
// if(self.type == VerifCodeType_AreaCode){
// [self showLoading];
//
// return;
// }
if(self.isLoginSuccess == YES && [self.code isEqualToString:self.textField.text]){
[XNDJTDDLoadingTool showLoadingInView:self.view];
[self loginSuccess];
return;
}
self.isLoginSuccess = NO;
[XNDJTDDLoadingTool showLoadingInView:self.view];
self.code = self.textField.text;
[self.presenter loginWithPhone:[NSString stringWithFormat:@"%@%@",self.pi_phoneAreaCode,self.phone] code:self.textField.text phoneAreaCode:self.pi_phoneAreaCode];
}
- (void)disMissVC {
[[CountDownHelper shareHelper] stopCountDown];
NSMutableArray *vcList = [NSMutableArray array];
for (id vc in self.navigationController.viewControllers) {
if(![vc isKindOfClass:[XPLoginPwdViewController class]]){
[vcList addObject:vc];
}
}
self.navigationController.viewControllers = vcList;
UIViewController *vc = self.presentingViewController;
while (vc.presentingViewController) {
vc = vc.presentingViewController;
}
[vc dismissViewControllerAnimated:YES completion:nil];
[self.navigationController popToRootViewControllerAnimated:NO];
}
#pragma mark - LoginVerifCodeProtocol
- (void)loginFail:(NSString *)reason{
self.loginButton.enabled = YES;
[XNDJTDDLoadingTool showLoadingInView:self.view];
}
- (void)loginSuccess {
self.isLoginSuccess = YES;
[[CountDownHelper shareHelper] stopCountDown];
[self disMissVC];
self.loginButton.enabled = YES;
}
///
- (void)bindPhoneSuccess {
[self disMissVC];
}
#pragma mark - LoginProtocol
- (void)phoneSmsCodeSuccess {
[self showSuccessToast:YMLocalizedString(@"PKIDLoginViewController11")];
self.retryCodeButton.hidden = YES;
self.cutdownLabel.hidden = NO;
[[CountDownHelper shareHelper] openCountdownWithTime:60];
}
#pragma mark - CountDownHelperDelegate
- (void)onCountdownFinish {
self.retryCodeButton.hidden = NO;
self.cutdownLabel.hidden = YES;
}
- (void)onCountdownOpen:(int)time {
self.cutdownLabel.text = [NSString stringWithFormat:@"%dS",time];
}
-(void)textFieldDidChange:(UITextField *)textField{
self.loginButton.enabled = textField.text > 0;
}
#pragma mark
-(void)retryCodeAction{
[self httpRequestPhoneSmsCode];
}
-(void)backAction{
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - Getters And Setters
- (UILabel *)titleLabel{
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:40];
_titleLabel.textColor = [DJDKMIMOMColor mainTextColor];
_titleLabel.text = YMLocalizedString(@"LoginVerifCodeViewController3");
}
return _titleLabel;
}
- (UILabel *)cutdownLabel {
if (!_cutdownLabel) {
_cutdownLabel = [[UILabel alloc] init];
_cutdownLabel.textAlignment = NSTextAlignmentRight;
_cutdownLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
_cutdownLabel.textColor = UIColorFromRGB(0x9168FA);
_cutdownLabel.hidden = NO;
}
return _cutdownLabel;
}
-(UIView *)bgCodeView{
if (!_bgCodeView){
_bgCodeView = [UIView new];
_bgCodeView.backgroundColor = UIColorFromRGB(0xF0F5F6);
[_bgCodeView setCornerWithLeftTopCorner:kGetScaleWidth(10) rightTopCorner:kGetScaleWidth(10) bottomLeftCorner:kGetScaleWidth(10) bottomRightCorner:kGetScaleWidth(10) size:CGSizeMake(kGetScaleWidth(308), kGetScaleWidth(63))];
}
return _bgCodeView;
}
- (UIButton *)retryCodeButton {
if (!_retryCodeButton) {
_retryCodeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_retryCodeButton setTitle:YMLocalizedString(@"LoginVerifCodeViewController4") forState:UIControlStateNormal];
[_retryCodeButton setTitleColor:[DJDKMIMOMColor colorWithHexString:@"#1F1A4E"] forState:UIControlStateNormal];
_retryCodeButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
_retryCodeButton.hidden = YES;
[_retryCodeButton addTarget:self action:@selector(retryCodeAction) forControlEvents:UIControlEventTouchUpInside];
}
return _retryCodeButton;
}
- (UIImageView *)topBackImgView {
if (!_topBackImgView) {
_topBackImgView = [[UIImageView alloc] init];
_topBackImgView.userInteractionEnabled = YES;
_topBackImgView.image = [UIImage imageNamed:@"login_top_bg"];
_topBackImgView.layer.masksToBounds = YES;
_topBackImgView.contentMode = UIViewContentModeScaleAspectFill;
}
return _topBackImgView;
}
-(MSBaseTextField *)textField{
if (!_textField){
_textField = [[MSBaseTextField alloc]init];
_textField.keyboardType = UIKeyboardTypeNumberPad;
_textField.textColor = [DJDKMIMOMColor colorWithHexString:@"#1F1A4E"];
_textField.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
[_textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
}
return _textField;
}
- (UIView *)contentView {
if (!_contentView) {
_contentView = [[UIView alloc] init];
_contentView.backgroundColor = [UIColor whiteColor];
[_contentView setCornerWithLeftTopCorner:kGetScaleWidth(25) rightTopCorner:kGetScaleWidth(25) bottomLeftCorner:0 bottomRightCorner:0 size:CGSizeMake(KScreenWidth, KScreenHeight - kGetScaleWidth(303))];
}
return _contentView;
}
- (UIButton *)loginButton {
if (!_loginButton) {
_loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_loginButton setImage:[UIImage imageNamed:@"login_finish"] forState:UIControlStateNormal];
[_loginButton addTarget:self action:@selector(loginButtonAction) forControlEvents:UIControlEventTouchUpInside];
_loginButton.enabled = NO;
}
return _loginButton;
}
- (UIStackView *)codeStackView{
if (!_codeStackView) {
_codeStackView = [[UIStackView alloc] init];
_codeStackView.axis = UILayoutConstraintAxisHorizontal;
_codeStackView.distribution = UIStackViewDistributionFillProportionally;
_codeStackView.alignment = UIStackViewAlignmentFill;
_codeStackView.spacing = 10;
}
return _codeStackView;
}
- (UIButton *)backBtn{
if (!_backBtn){
_backBtn = [UIButton new];
[_backBtn setBackgroundImage:[[UIImage imageNamed:@"common_nav_back"]ms_SetImageForRTL] forState:UIControlStateNormal];
[_backBtn setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
[_backBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
}
return _backBtn;
}
@end

View File

@@ -0,0 +1,16 @@
//
// LoginViewController.h
// YuMi
//
// Created by P on 2025/3/10.
//
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface LoginViewController : MvpViewController
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,509 @@
//
// LoginViewController.m
// YuMi
//
// Created by P on 2025/3/10.
//
#import "LoginViewController.h"
#import "XPWebViewController.h"
#import "LoginPresenter.h"
#import "AESUtils.h"
#import "LoginTypesViewController.h"
#import "LoginProtocol.h"
#import "PILoginManager.h"
#import "PISwitchingEnvironmentVC.h"
#import "FeedBackViewController.h"
#import "FirstRechargeManager.h"
NSString * const HadAgreePrivacy = @"HadAgreePrivacy";
typedef NS_ENUM(NSUInteger, LoginType) {
LoginType_ID = 101,
LoginType_Email = 102,
LoginType_Google = 103,
LoginType_Apple = 104
};
@interface LoginViewController () <LoginProtocol>
@property(nonatomic, strong) UIImageView *logoImageView;
@property(nonatomic, assign) BOOL lastPolicySelectedStatus;
@property(nonatomic, strong) UIButton *agreeButton;
@property(nonatomic, strong) YYLabel *policyLabel;
@property(nonatomic, strong) UIView *policyTips;
///
@property (nonatomic,strong) GIDConfiguration *configuration;
@end
@implementation LoginViewController
- (LoginPresenter *)createPresenter {
return [[LoginPresenter alloc] init];
}
- (BOOL)isHiddenNavBar {
return YES;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self loadPolicySelectedStatus];
[self setupUI];
//
[[FirstRechargeManager sharedManager] stopMonitoring];
}
- (void)setupUI {
[self setupBackground];
[self setupNavigationBar];
[self setupBottomPolicy];
[self setupSMSLoginEntrcy];
[self setupEntrcyButtons];
}
- (void)setupBackground {
[self.view addGradientBackgroundWithColors:@[
UIColorFromRGB(0xfcf4df),
UIColorFromRGB(0xffd374)
]
startPoint:CGPointMake(0.5, 0)
endPoint:CGPointMake(0.5, 1)
cornerRadius:0];
UIImageView *topImageView = [[UIImageView alloc] initWithImage:kImage(@"login_page_top")];
topImageView.contentMode = UIViewContentModeScaleAspectFit;
[self.view addSubview:topImageView];
[topImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.leading.trailing.mas_equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(326));
}];
[self.view addSubview:self.logoImageView];
if (iPhoneXSeries) {
[self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.centerY.mas_equalTo(topImageView.mas_bottom);
make.size.mas_equalTo(CGSizeMake(124, 48));
}];
} else {
[self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.top.mas_equalTo(160);
make.size.mas_equalTo(CGSizeMake(124, 48));
}];
}
}
- (void)setupNavigationBar {
#if DEBUG
UIButton *debugButton = [self debugButton];
[self.view addSubview:debugButton];
[debugButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.view).offset(16);
make.top.mas_equalTo(self.view).offset(kStatusBarHeight);
make.height.mas_equalTo(22);
make.width.mas_greaterThanOrEqualTo(84);
}];
#endif
UIButton *feedBackButton = [self feedBackButton];
[self.view addSubview:feedBackButton];
[feedBackButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(self.view).offset(-16);
make.top.mas_equalTo(self.view).offset(kStatusBarHeight);
make.height.mas_equalTo(22);
// make.width.mas_lessThanOrEqualTo(200); //
}];
[self.view setNeedsLayout];
}
- (void)setupBottomPolicy {
UIView *view_1 = [[UIView alloc] init];
UIView *view_2 = [[UIView alloc] init];
UIStackView *stackView = [[UIStackView alloc] initWithArrangedSubviews:@[
view_1,
self.agreeButton,
self.policyLabel,
view_2
]];
stackView.spacing = 8;
stackView.alignment = UIStackViewAlignmentCenter;
stackView.distribution = UIStackViewDistributionFill;
[self.view addSubview:stackView];
[stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.bottom.mas_equalTo(self.view).offset(-44);
make.width.mas_lessThanOrEqualTo(self.view).offset(-32);
// make.height.mas_equalTo(60);
}];
[self.agreeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(18,18));
}];
}
- (void)setupSMSLoginEntrcy {
UIButton *smsLogin = [UIButton buttonWithType:UIButtonTypeCustom];
[smsLogin setBackgroundImage:kImage(@"login_page_phone") forState:UIControlStateNormal];
[smsLogin addTarget:self action:@selector(didTapSMS) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:smsLogin];
[smsLogin mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.bottom.mas_equalTo(self.view).offset(-124);
make.size.mas_equalTo(CGSizeMake(48, 48));
}];
}
- (void)setupEntrcyButtons {
UIButton *idBUtton = [self entrcyButton:LoginType_ID tapSelector:@selector(didTapEntrcyButton:)];
UIStackView *stackView = [[UIStackView alloc] initWithArrangedSubviews:@[
idBUtton,
[self entrcyButton:LoginType_Email tapSelector:@selector(didTapEntrcyButton:)],
[self entrcyButton:LoginType_Google tapSelector:@selector(didTapEntrcyButton:)],
[self entrcyButton:LoginType_Apple tapSelector:@selector(didTapEntrcyButton:)],
]];
stackView.axis = UILayoutConstraintAxisVertical;
stackView.distribution = UIStackViewDistributionFillEqually;
stackView.spacing = 14;
[self.view addSubview:stackView];
[stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.top.mas_equalTo(self.logoImageView.mas_bottom).offset(34);
}];
[idBUtton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(294, 46));
}];
}
- (UIButton *)entrcyButton:(LoginType)type tapSelector:(SEL)selector {
UIImageView *icon = [[UIImageView alloc] init];
icon.contentMode = UIViewContentModeScaleAspectFill;
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 294, 46);
button.tag = type;
[button addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside];
[button setCornerRadius:23];
[button setBackgroundColor:[UIColor whiteColor]];
[button.titleLabel setFont:kFontSemibold(14)];
[button.titleLabel setAdjustsFontSizeToFitWidth:YES];
[button setTitleColor:UIColorFromRGB(0x313131) forState:UIControlStateNormal];
switch (type) {
case LoginType_ID:{
[button setTitle:YMLocalizedString(@"1.0.37_text_26") forState:UIControlStateNormal];
[icon setImage:kImage(@"login_page_id")];
}
break;
case LoginType_Email:{
[button setTitle:YMLocalizedString(@"20.20.51_text_1") forState:UIControlStateNormal];
[icon setImage:kImage(@"login_page_mail")];
}
break;
case LoginType_Google:{
[button setTitle:YMLocalizedString(@"XPLoginViewController13") forState:UIControlStateNormal];
[icon setImage:kImage(@"login_gmail")];
}
break;
case LoginType_Apple:{
[button setTitle:YMLocalizedString(@"XPLoginViewController12") forState:UIControlStateNormal];
[icon setImage:kImage(@"mine_noble_center_apple")];
}
break;
default:
break;
}
[button addSubview:icon];
[icon mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(button);
make.leading.mas_equalTo(15);
make.size.mas_equalTo(CGSizeMake(24, 24));
}];
return button;
}
#pragma mark -
- (void)didTapPolice:(NSString *)url {
XPWebViewController * webVC = [[XPWebViewController alloc] initWithRoomUID:nil];
webVC.url = url;
[self.navigationController pushViewController:webVC animated:YES];
}
- (void)didTapAgreeButton {
self.agreeButton.selected = !self.agreeButton.isSelected;
[self updatePolicySelectedStatus:self.agreeButton.isSelected];
[self hidePolicyTips];
}
- (void)didTapSMS {
if (self.lastPolicySelectedStatus == NO) {
[self displayPolicyTips];
return;
}
LoginTypesViewController *vc = [[LoginTypesViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[vc updateLoginType:LoginDisplayType_phoneNum];
}
- (void)didTapEntrcyButton:(UIButton *)sender {
if (self.lastPolicySelectedStatus == NO) {
[self displayPolicyTips];
return;
}
switch (sender.tag) {
case LoginType_ID:{
LoginTypesViewController *vc = [[LoginTypesViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[vc updateLoginType:LoginDisplayType_id];
}
break;
case LoginType_Email: {
LoginTypesViewController *vc = [[LoginTypesViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[vc updateLoginType:LoginDisplayType_email];
}
break;
case LoginType_Google:
[self.presenter thirdLoginByGoogleWithPresentingViewController:self
configuration:self.configuration];
break;
case LoginType_Apple:
[self.presenter thirdLoginWithType:ThirdLoginType_Apple];
break;
default:
break;
}
}
- (void)didTapFeedback {
FeedBackViewController *vc = [[FeedBackViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
}
#ifdef DEBUG
- (void)switchEnvironments {
PISwitchingEnvironmentVC *vc = [PISwitchingEnvironmentVC new];
[self.navigationController pushViewController:vc animated:YES];
}
#endif
#pragma mark - LoginProtocol
- (void)loginThirdPartSuccess {
[self showSuccessToast:YMLocalizedString(@"XPLoginViewController4")];
[PILoginManager loginWithVC:self isLoginPhone:NO];
//
[[FirstRechargeManager sharedManager] startMonitoring];
}
- (void)loginSuccess {
//
[[FirstRechargeManager sharedManager] startMonitoring];
}
#pragma mark - Polisy Status
- (void)loadPolicySelectedStatus {
// YES
[self updatePolicySelectedStatus:YES];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
self.lastPolicySelectedStatus = [defaults boolForKey:HadAgreePrivacy];
self.agreeButton.selected = self.lastPolicySelectedStatus;
}
- (void)updatePolicySelectedStatus:(BOOL)isSelected {
self.lastPolicySelectedStatus = isSelected;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:isSelected forKey:HadAgreePrivacy];
}
- (void)displayPolicyTips {
[self.view addSubview:self.policyTips];
[self.policyTips mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.view).offset(-82);
make.leading.trailing.mas_equalTo(self.view).inset(22);
make.height.mas_equalTo(64);
}];
}
- (void)hidePolicyTips {
[self.policyTips removeFromSuperview];
}
#pragma mark - Lazy init
- (UIButton *)agreeButton {
if(!_agreeButton) {
_agreeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_agreeButton setImage:[UIImage imageNamed:@"login_page_privacy_selected"] forState:UIControlStateSelected];
[_agreeButton setImage:[UIImage imageNamed:@"login_page_privacy_unselected"] forState:UIControlStateNormal];
[_agreeButton setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
[_agreeButton addTarget:self action:@selector(didTapAgreeButton) forControlEvents:UIControlEventTouchUpInside];
// NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// NSString *hadAgree = [defaults objectForKey:HadAgreePrivacy];
// if (hadAgree.length > 0) {
// _agreeBtn.selected = YES;
// }
_agreeButton.selected = YES;
}
return _agreeButton;
}
- (YYLabel *)policyLabel {
if (!_policyLabel) {
_policyLabel = [[YYLabel alloc] init];
_policyLabel.font = kFontRegular(12);
_policyLabel.numberOfLines = 0;
_policyLabel.preferredMaxLayoutWidth = KScreenWidth-40;
NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginViewController6")];
if ([[UIScreen mainScreen] bounds].size.width < 450 && (isMSPT() || isMSTR())) {
attString = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginViewController6.1")];
}
attString.yy_color = UIColorFromRGB(0x7B7B7D);
NSRange userRange = [attString.string rangeOfString:YMLocalizedString(@"XPLoginViewController7")];
[attString addAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x313131)} range:userRange];
@kWeakify(self);
[attString yy_setTextHighlightRange:userRange color:nil backgroundColor:nil userInfo:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
@kStrongify(self);
//
[self didTapPolice:URLWithType(kUserProtocalURL)];
} longPressAction:nil];
NSRange andRange = [attString.string rangeOfString:YMLocalizedString(@"XPLoginViewController8")];
[attString addAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x7B7B7D)} range:andRange];
NSRange protocolRange = [attString.string rangeOfString:YMLocalizedString(@"XPLoginViewController9")];
[attString addAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0x313131)} range:protocolRange];
[attString yy_setTextHighlightRange:protocolRange color:nil backgroundColor:nil userInfo:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
@kStrongify(self);
//
[self didTapPolice:URLWithType(kPrivacyURL)];
} longPressAction:nil];
_policyLabel.attributedText = attString;
}
return _policyLabel;
}
- (UIView *)policyTips {
if (!_policyTips) {
_policyTips = [[UIView alloc] init];
[_policyTips setCornerRadius:8];
[_policyTips setBackgroundColor:[UIColor colorWithWhite:0 alpha:0.5]];
UILabel *_policyTipsLabel = [[UILabel alloc] init];
_policyTipsLabel.text = YMLocalizedString(@"XPLoginViewController11");
_policyTipsLabel.font = kFontRegular(12);
_policyTipsLabel.textColor = UIColor.whiteColor;
_policyTipsLabel.numberOfLines = 0;
_policyTipsLabel.textAlignment = NSTextAlignmentCenter;
[_policyTips addSubview:_policyTipsLabel];
[_policyTipsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(_policyTips).insets(UIEdgeInsetsMake(8, 12, 8, 12));
}];
}
return _policyTips;
}
- (GIDConfiguration *)configuration{
if (!_configuration){
static dispatch_once_t onceToken;
static NSString *decryptedNumber;
dispatch_once(&onceToken, ^{
decryptedNumber = [AESUtils aesDecrypt:@"ScLBu7ctIiyGCKPro3Jj6XMdsdCCpNT9L4wyjHEF+bguqubkXNSayFBGMKmoDwe1hjfAc958XSaBdMyEaFXLO38Bwq3xURYVNpgEM4b14zg="];
});
_configuration = [[GIDConfiguration alloc] initWithClientID:decryptedNumber];
}
return _configuration;
}
- (UIImageView *)logoImageView {
if (!_logoImageView) {
_logoImageView = [[UIImageView alloc] initWithImage:kImage(@"login_page_logo")];
}
return _logoImageView;
}
- (UIButton *)feedBackButton {
UIButton *feedBackButton = [UIButton buttonWithType:UIButtonTypeCustom];
[feedBackButton setTitle:YMLocalizedString(@"XPMineFeedbackViewController0") forState:UIControlStateNormal];
[feedBackButton setTitleColor:UIColorFromRGB(0x313131) forState:UIControlStateNormal];
[feedBackButton setContentEdgeInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
feedBackButton.titleLabel.font = kFontRegular(12);
//
// feedBackButton.titleLabel.adjustsFontSizeToFitWidth = YES;
// feedBackButton.titleLabel.minimumScaleFactor = 0.8;
// feedBackButton.titleLabel.numberOfLines = 1;
[feedBackButton setBackgroundImage:[[UIImage imageWithColor:[UIColor whiteColor]] imageByApplyingAlpha:0.5]
forState:UIControlStateNormal];
[feedBackButton setCornerRadius:10.5];
[feedBackButton addTarget:self
action:@selector(didTapFeedback)
forControlEvents:UIControlEventTouchUpInside];
[feedBackButton sizeToFit];
// [feedBackButton enlargeTouchArea:UIEdgeInsetsMake(10, 10, 10, 10)];
return feedBackButton;
}
#if DEBUG
- (UIButton *)debugButton {
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
b.frame = CGRectMake(0, 0, 84, 22);
[b setTitle:@"切换环境" forState:UIControlStateNormal];
[b setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[self.view addSubview:b];
[b addTarget:self action:@selector(switchEnvironments) forControlEvents:UIControlEventTouchUpInside];
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.frame = b.bounds;
gradientLayer.colors = @[
(id)[UIColor redColor].CGColor,
(id)[UIColor blueColor].CGColor,
(id)[UIColor greenColor].CGColor
];
gradientLayer.startPoint = CGPointMake(0, 0.5);
gradientLayer.endPoint = CGPointMake(1, 0.5);
[b.layer addSublayer:gradientLayer];
@kWeakify(self);
[NSTimer scheduledTimerWithTimeInterval:0.1
repeats:YES
block:^(NSTimer * _Nonnull timer) {
@kStrongify(self);
if (!self) {
return;
}
NSArray *fromColors = gradientLayer.colors;
NSArray *toColors = [self shiftedColorsFromColors:fromColors];
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"colors"];
animation.fromValue = fromColors;
animation.toValue = toColors;
animation.duration = 0.1;
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
[gradientLayer addAnimation:animation forKey:@"colorChange"];
gradientLayer.colors = toColors;
}];
return b;
}
- (NSArray *)shiftedColorsFromColors:(NSArray *)colors {
NSMutableArray *mutableColors = [colors mutableCopy];
id firstColor = [mutableColors firstObject];
[mutableColors xpSafeRemoveObjectAtIndex:0];
[mutableColors addObject:firstColor];
return [mutableColors copy];
}
#endif
@end

View File

@@ -0,0 +1,17 @@
//
// PIUserSexView.h
// YuMi
//
// Created by duoban on 2023/8/14.
//
#import <UIKit/UIKit.h>
#import "YUMINNNN.h"
NS_ASSUME_NONNULL_BEGIN
@interface PIUserSexView : UIView
@property (nonatomic,assign) GenderType gender;
@property (nonatomic,assign) BOOL selected;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,137 @@
//
// PIUserSexView.m
// YuMi
//
// Created by duoban on 2023/8/14.
//
#import "PIUserSexView.h"
@interface PIUserSexView ()
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) UIImageView *logoImageView;
///
@property (nonatomic,strong) UIImageView *sexImageView;
///
@property (nonatomic,strong) UILabel *sexLb;
@end
@implementation PIUserSexView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
- (void)initSubViews {
[self addSubview:self.backImageView];
[self.backImageView addSubview:self.logoImageView];
[self.backImageView addSubview:self.sexLb];
[self.backImageView addSubview:self.sexImageView];
}
- (void)initSubViewConstraints {
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
[self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(kGetScaleWidth(66), kGetScaleWidth(66)));
make.centerX.mas_equalTo(self.backImageView);
make.top.mas_equalTo(self.backImageView).offset(kGetScaleWidth(8));
}];
[self.sexImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(kGetScaleWidth(16), kGetScaleWidth(16)));
make.trailing.mas_equalTo(self.backImageView.mas_centerX).offset(-1.5);
make.top.mas_equalTo(self.logoImageView.mas_bottom).offset(kGetScaleWidth(8));
}];
[self.sexLb mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.backImageView.mas_centerX).offset(1.5);
make.centerY.mas_equalTo(self.sexImageView);
}];
}
- (void)setGender:(GenderType)gender {
_gender = gender;
switch (_gender) {
case GenderType_Male:
{
self.logoImageView.image = [UIImage imageNamed:@"login_full_male_logo"];
self.sexLb.text = YMLocalizedString(@"PIUserSexView0");
self.sexImageView.image = [UIImage imageNamed:@"login_full_male"];
}
break;
case GenderType_Female:
{
self.logoImageView.image = [UIImage imageNamed:@"login_full_female_logo"];
self.sexLb.text = YMLocalizedString(@"PIUserSexView1");
self.sexImageView.image = [UIImage imageNamed:@"login_full_female"];
}
break;
default:
break;
}
}
- (void)setSelected:(BOOL)selected {
_selected = selected;
if (_selected) {
if (self.gender == GenderType_Male) {
self.backImageView.image = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor colorWithHexString:@"#EBF5FF"],[DJDKMIMOMColor colorWithHexString:@"#FFFFFF"]] gradientType:GradientTypeTopToBottom imgSize:CGSizeMake(10, 10)];
self.backImageView.layer.borderColor = [DJDKMIMOMColor colorWithHexString:@"#B8E5FF"].CGColor;
} else {
self.backImageView.image = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor colorWithHexString:@"#FFEBFA"],[DJDKMIMOMColor colorWithHexString:@"#FFFFFF"]] gradientType:GradientTypeTopToBottom imgSize:CGSizeMake(10, 10)];
self.backImageView.layer.borderColor = [DJDKMIMOMColor colorWithHexString:@"#FFB8E2"].CGColor;
}
} else {
self.backImageView.image = [UIImage imageWithColor:[UIColor clearColor]];
self.backImageView.layer.borderColor = [DJDKMIMOMColor colorWithHexString:@"#FAFBFC"].CGColor;
}
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
_backImageView.layer.masksToBounds = YES;
_backImageView.layer.borderWidth = 1;
_backImageView.layer.cornerRadius = kGetScaleWidth(18);
}
return _backImageView;
}
- (UIImageView *)logoImageView {
if (!_logoImageView) {
_logoImageView = [[UIImageView alloc] init];
_logoImageView.userInteractionEnabled = YES;
}
return _logoImageView;
}
- (UIImageView *)sexImageView {
if (!_sexImageView) {
_sexImageView = [[UIImageView alloc] init];
_sexImageView.userInteractionEnabled = YES;
}
return _sexImageView;
}
- (UILabel *)sexLb {
if (!_sexLb) {
_sexLb = [[UILabel alloc] init];
_sexLb.font = kFontMedium(14);
_sexLb.textColor = [DJDKMIMOMColor colorWithHexString:@"#1F1A4E"];
}
return _sexLb;
}
@end

View File

@@ -0,0 +1,16 @@
//
// YMForgetPwdViewController.h
// YUMI
//
// Created by XY on 2023/2/14.
//
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPForgetPwdViewController : MvpViewController
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,271 @@
//
// YMForgetPwdViewController.m
// YUMI
//
// Created by XY on 2023/2/14.
//
#import "XPForgetPwdViewController.h"
#import <Masonry.h>
#import "YUMIMacroUitls.h"
#import <ReactiveObjC.h>
#import "XPLoginInputView.h"
#import "LoginForgetPasswordPresent.h"
#import "LoginForgetPasswordProtocol.h"
#import "XPLoginAraeViewController.h"
@interface XPForgetPwdViewController ()<XPLoginInputViewDelegate, LoginForgetPasswordProtocol, XPLoginAraeViewControllerDelegate>
///
@property(nonatomic,strong) UIImageView *bgImageView;
///
@property(nonatomic,strong) UIButton *backBnt;
///
@property (nonatomic, strong) UILabel *titleLabel;
///
@property (nonatomic, strong) XPLoginInputView *phoneInputView;
///
@property (nonatomic, strong) XPLoginInputView *codeInputView;
///
@property (nonatomic, strong) XPLoginInputView *pwdInputView;
///
@property (nonatomic, strong) UIButton *sureBtn;
@property (nonatomic,copy) NSString *pi_phoneAreaCode;
@end
@implementation XPForgetPwdViewController
- (BOOL)isHiddenNavBar {
return YES;
}
- (LoginForgetPasswordPresent *)createPresenter {
return [[LoginForgetPasswordPresent alloc] init];
}
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.codeInputView cancelTimer];
}
- (void)viewDidLoad {
NSString *code = [NSString getCountryCode];
self.pi_phoneAreaCode = [code stringByReplacingOccurrencesOfString:@"+" withString:@""];
[super viewDidLoad];
[self createUI];
[self racBind];
}
- (void)createUI {
self.view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.bgImageView];
[self.view addSubview:self.backBnt];
[self.view addSubview:self.titleLabel];
UIView *bgView = [UIView new];
bgView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:bgView];
bgView.layer.cornerRadius = kGetScaleWidth(20);
bgView.layer.masksToBounds = YES;
[self.view addSubview:self.phoneInputView];
[self.view addSubview:self.codeInputView];
[self.view addSubview:self.pwdInputView];
[self.view addSubview:self.sureBtn];
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.top.equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(418));
}];
[self.backBnt mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(kGetScaleWidth(20));
make.width.mas_equalTo(kGetScaleWidth(28));
make.height.mas_equalTo(kGetScaleWidth(28));
make.top.mas_equalTo(kGetScaleWidth(52));
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.top.equalTo(self.backBnt.mas_bottom).mas_offset(kGetScaleWidth(48));
make.leading.mas_equalTo(kGetScaleWidth(24));
make.height.mas_equalTo(kGetScaleWidth(40));
}];
[bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.bottom.equalTo(self.view);
make.top.mas_equalTo(kGetScaleWidth(257));
}];
[self.phoneInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.width.mas_equalTo(kGetScaleWidth(303));
make.top.mas_equalTo(kGetScaleWidth(296));
make.height.mas_equalTo(kGetScaleWidth(52));
}];
[self.codeInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.width.mas_equalTo(kGetScaleWidth(303));
make.top.mas_equalTo(self.phoneInputView.mas_bottom).offset(kGetScaleWidth(20));
make.height.mas_equalTo(kGetScaleWidth(52));
}];
[self.pwdInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.width.mas_equalTo(kGetScaleWidth(303));
make.top.mas_equalTo(self.codeInputView.mas_bottom).offset(kGetScaleWidth(20));
make.height.mas_equalTo(kGetScaleWidth(52));
}];
[self.sureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.pwdInputView.mas_bottom).offset(kGetScaleWidth(48));
make.centerX.mas_equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(48));
make.width.mas_equalTo(kGetScaleWidth(303));
}];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[self.view endEditing:YES];
}
- (void)racBind {
RAC(self.sureBtn, enabled) = [[RACSignal combineLatest:@[self.phoneInputView.inputTextField.rac_textSignal, self.pwdInputView.inputTextField.rac_textSignal, self.pwdInputView.inputTextField.rac_textSignal] reduce:^id _Nonnull(NSString *phone, NSString* smsCode, NSString *password){
return @((phone.length > 0) && smsCode.length >= 5 && (password.length >= 6 && password.length <= 16));
}] takeUntil:self.rac_willDeallocSignal];
}
///
- (void)sureBtnClicked {
NSString *phone = self.phoneInputView.inputTextField.text;
NSString *smsCode = self.codeInputView.inputTextField.text;
NSString *password = self.pwdInputView.inputTextField.text;
[self.presenter resetPassword:[NSString stringWithFormat:@"%@%@",self.pi_phoneAreaCode,phone] newPwd:password smsCode:smsCode phoneAreaCode:self.pi_phoneAreaCode];
}
#pragma mark - XPLoginInputViewDelegate
- (void)smsCodeAction {
NSString *phone = self.phoneInputView.inputTextField.text;
if (phone.length <= 0) {
[self showErrorToast:YMLocalizedString(@"XPForgetPwdViewController0")];
return;
}
[self.presenter phoneSmsCode:[NSString stringWithFormat:@"%@%@",self.pi_phoneAreaCode,phone] type:GetSmsType_Reset_Password phoneAreaCode:self.pi_phoneAreaCode];
}
- (void)areaListAction {
XPLoginAraeViewController *codeVC = [XPLoginAraeViewController new];
codeVC.delegate = self;
[self.navigationController pushViewController:codeVC animated:YES];
}
- (void)chooseAreaCodeSuccess:(NSString *)code {
if (code.length > 0) {
self.pi_phoneAreaCode = code;
[self.phoneInputView.areaCodeBtn setTitle:[NSString stringWithFormat:@"+%@", code] forState:UIControlStateNormal];
}
}
#pragma mark - LoginForgetPasswordProtocol
///
- (void)phoneSmsCodeSuccess {
[self showSuccessToast:YMLocalizedString(@"XPForgetPwdViewController1")];
[self.codeInputView fireTimer];
}
///
- (void)resetPasswrodSuccess {
[self showSuccessToast:YMLocalizedString(@"XPForgetPwdViewController2")];
[self.navigationController popViewControllerAnimated:YES];
}
-(void)backViewAction1{
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark -
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = kFontBold(28);
_titleLabel.textColor = UIColorFromRGB(0x1F1B4F);
_titleLabel.text = YMLocalizedString(@"XPForgetPwdViewController3");
}
return _titleLabel;
}
- (XPLoginInputView *)phoneInputView {
if (!_phoneInputView) {
_phoneInputView = [[XPLoginInputView alloc] init];
_phoneInputView.areaStackView.hidden = NO;
_phoneInputView.delegate = self;
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPForgetPwdViewController4")];
[placeholder addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xB3B3C3) range:NSMakeRange(0, placeholder.length)];
_phoneInputView.inputTextField.attributedPlaceholder = placeholder;
_phoneInputView.inputTextField.keyboardType = UIKeyboardTypeNumberPad;
}
return _phoneInputView;
}
- (XPLoginInputView *)codeInputView {
if (!_codeInputView) {
_codeInputView = [[XPLoginInputView alloc] init];
_codeInputView.smsCodeBtn.hidden = NO;
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPForgetPwdViewController5")];
[placeholder addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xB3B3C3) range:NSMakeRange(0, placeholder.length)];
_codeInputView.inputTextField.attributedPlaceholder = placeholder;
_codeInputView.inputTextField.keyboardType = UIKeyboardTypeNumberPad;
_codeInputView.delegate = self;
}
return _codeInputView;
}
- (XPLoginInputView *)pwdInputView {
if (!_pwdInputView) {
_pwdInputView = [[XPLoginInputView alloc] init];
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPForgetPwdViewController6")];
[placeholder addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xB3B3C3) range:NSMakeRange(0, placeholder.length)];
_pwdInputView.inputTextField.attributedPlaceholder = placeholder;
_pwdInputView.inputTextField.keyboardType = UIKeyboardTypeAlphabet;
_pwdInputView.inputTextField.secureTextEntry = YES;
}
return _pwdInputView;
}
- (UIButton *)sureBtn {
if (!_sureBtn) {
_sureBtn = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *nextImage = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor],[DJDKMIMOMColor confirmButtonGradientMiddleColor],[DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(kGetScaleWidth(303), kGetScaleWidth(48))];
UIImage *disableImage = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xD1F9FF),UIColorFromRGB(0xDEE4FF),UIColorFromRGB(0xEEDCFF)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(kGetScaleWidth(303), kGetScaleWidth(48))];
[_sureBtn setImage:nextImage forState:UIControlStateNormal];
[_sureBtn setImage:disableImage forState:UIControlStateDisabled];
_sureBtn.layer.cornerRadius = kGetScaleWidth(48)/2;
_sureBtn.layer.masksToBounds = YES;
UILabel *titleView = [UILabel labelInitWithText:YMLocalizedString(@"XPLoginPhoneViewController8") font:kFontMedium(16) textColor:[UIColor whiteColor]];
titleView.textAlignment = NSTextAlignmentCenter;
[_sureBtn addSubview:titleView];
[titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.sureBtn);
}];
[_sureBtn addTarget:self action:@selector(sureBtnClicked) forControlEvents:UIControlEventTouchUpInside];
}
return _sureBtn;
}
- (UIImageView *)bgImageView{
if(!_bgImageView){
_bgImageView = [[UIImageView alloc]init];
_bgImageView.image = kImage(@"login_phone_pwd_bg");
_bgImageView.contentMode = 2;
}
return _bgImageView;
}
- (UIButton *)backBnt{
if(!_backBnt){
_backBnt = [UIButton new];
[_backBnt setImage:[kImage(@"common_nav_back")ms_SetImageForRTL] forState:UIControlStateNormal];
[_backBnt addTarget:self action:@selector(backViewAction1) forControlEvents:UIControlEventTouchUpInside];
[_backBnt setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
}
return _backBnt;
}
@end

View File

@@ -0,0 +1,21 @@
//
// XPLoginAraeViewController.h
// YuMi
//
// Created by YuMi on 2023/6/25.
//
#import "BaseViewController.h"
NS_ASSUME_NONNULL_BEGIN
@protocol XPLoginAraeViewControllerDelegate <NSObject>
-(void)chooseAreaCodeSuccess:(NSString *)code;
@end
@interface XPLoginAraeViewController : BaseViewController
///代理
@property (nonatomic,weak) id<XPLoginAraeViewControllerDelegate> delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,191 @@
//
// XPLoginAraeViewController.m
// YuMi
//
// Created by YuMi on 2023/6/25.
//
#import "XPLoginAraeViewController.h"
///view
#import "XPLoginAreaTableViewCell.h"
#import "LoginAreaModel.h"
#import "NSObject+MJExtension.h"
#import "YUMIMacroUitls.h"
#import "Api+Login.h"
///Third
#import <Masonry/Masonry.h>
@interface XPLoginAraeViewController ()<UITableViewDelegate,UITableViewDataSource,XPLoginAreaTableViewCellDelegate>
@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,strong) NSMutableArray *listData;
@property (nonatomic,strong) NSMutableArray *titleList;
@end
@implementation XPLoginAraeViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self initSubViews];
[self initSubViewConstraints];
[self getPhoneAreaCodeList];
}
#pragma mark - LoginVerifCodeProtocol
-(void)getPhoneAreaCodeList{
//
NSString *path = [[NSBundle mainBundle] pathForResource:@"pi_area_info" ofType:@"json"];
//
NSData *data = [[NSData alloc] initWithContentsOfFile:path];
// JSON
NSError *error = nil;
NSDictionary *codeData = [NSJSONSerialization JSONObjectWithData:data
options:NSJSONReadingMutableLeaves
error:&error];
if (error) {
// NSLog(@"JSON Parsing Error: %@", error.localizedDescription);
}
NSArray *codeList = [LoginAreaModel modelsWithArray:codeData[@"RECORDS"]];
[self getLocalPlistWithList:codeList];
}
-(void)getLocalPlistWithList:(NSArray *)list{
NSArray * letterList = @[@"",@"A",@"B",@"C",@"D",@"E",@"F",@"G",@"H",@"I",@"J",@"K",@"L",@"M",@"N",@"O",@"P",@"Q",@"R",@"S",@"T",@"U",@"V",@"W",@"X",@"Y",@"Z"];
NSMutableArray *otherList = [NSMutableArray array];
NSMutableArray *defaultList = [NSMutableArray array];
LoginAreaModel *TwModel;
LoginAreaModel *HKModel ;
LoginAreaModel *SPModel ;
LoginAreaModel *MYModel ;
LoginAreaModel *ChinsModel ;
[self.titleList addObject:@""];
for (NSString *letter in letterList) {
NSMutableArray *modelList = [NSMutableArray array];
for (LoginAreaModel *model in list) {
if([model.code isEqualToString:@"886"]){
TwModel = model;
}
if([model.code isEqualToString:@"852"]){
HKModel = model;
}
if([model.code isEqualToString:@"65"]){
SPModel = model;
}
if([model.code isEqualToString:@"60"]){
MYModel = model;
}
if([model.code isEqualToString:@"86"]){
ChinsModel = model;
}
NSString *fristLetter = [model.name substringWithRange:NSMakeRange(0, 1)];
if([letter isEqualToString:fristLetter]){
[modelList addObject:model];
}else{
if(![letterList containsObject:fristLetter] && ![otherList containsObject:model]){
[otherList addObject:model];
}
}
}
if(modelList.count > 0){
[self.titleList addObject:letter];
[self.listData addObject:modelList];
}
}
if(TwModel != nil){
[defaultList addObject:TwModel];
}
if(HKModel != nil){
[defaultList addObject:HKModel];
}
if(SPModel != nil){
[defaultList addObject:SPModel];
}
if(MYModel != nil){
[defaultList addObject:MYModel];
}
if(ChinsModel != nil){
[defaultList addObject:ChinsModel];
}
[self.listData insertObject:defaultList atIndex:0];
if(otherList.count > 0){
[self.listData addObject:otherList];
[self.titleList addObject:@"#"];
}
[self.tableView reloadData];
}
#pragma mark - UITableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return self.listData.count;
}
- (nullable NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
return self.titleList[section];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [self.listData[section] count];
}
- (NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView {
return self.titleList;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
XPLoginAreaTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPLoginAreaTableViewCell class]) forIndexPath:indexPath];
if(cell.delegate == nil){
cell.delegate = self;
}
if(indexPath.section < self.listData.count){
NSArray *listModel = self.listData[indexPath.section];
if(indexPath.row < listModel.count){
cell.areaModel =listModel[indexPath.row];
}
}
return cell;
}
#pragma mark - XPLoginAreaTableViewCellDelegate
- (void)didSelectModel:(LoginAreaModel *)model{
LoginAreaModel *codeModel = model;
if(self.delegate && [self.delegate respondsToSelector:@selector(chooseAreaCodeSuccess:)]){
[self.delegate chooseAreaCodeSuccess:codeModel.code];
}
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - Private Method
- (void)initSubViews {
self.title = YMLocalizedString(@"XPChooseRreaCodeVC0");
[self.view addSubview:self.tableView];
}
- (void)initSubViewConstraints {
[self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
}
#pragma mark - Getters And Setters
- (UITableView *)tableView {
if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.rowHeight = kGetScaleWidth(37);
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;;
_tableView.backgroundColor = [UIColor whiteColor];
[_tableView registerClass:[XPLoginAreaTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPLoginAreaTableViewCell class])];
}
return _tableView;
}
- (NSMutableArray *)titleList{
if (!_titleList){
_titleList = [NSMutableArray array];
}
return _titleList;
}
- (NSMutableArray *)listData{
if (!_listData){
_listData = [NSMutableArray array];
}
return _listData;
}
@end

View File

@@ -0,0 +1,24 @@
//
// XPLoginAreaTableViewCell.h
// YuMi
//
// Created by YuMi on 2023/6/25.
//
#import <UIKit/UIKit.h>
@class LoginAreaModel;
@protocol XPLoginAreaTableViewCellDelegate <NSObject>
-(void)didSelectModel:(LoginAreaModel *_Nullable)model;
@end
NS_ASSUME_NONNULL_BEGIN
@interface XPLoginAreaTableViewCell : UITableViewCell
@property (nonatomic,strong) LoginAreaModel *areaModel;
@property(nonatomic,weak) id<XPLoginAreaTableViewCellDelegate>delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,88 @@
//
// XPLoginAreaTableViewCell.m
// YuMi
//
// Created by YuMi on 2023/6/25.
//
#import "XPLoginAreaTableViewCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "DJDKMIMOMColor.h"
#import "LoginAreaModel.h"
@interface XPLoginAreaTableViewCell()
@property (nonatomic,strong) UILabel *areaVeiw;
@property (nonatomic,strong) UILabel *codeView;
@property(nonatomic,strong) UIButton *clickBtn;
@end
@implementation XPLoginAreaTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor whiteColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.areaVeiw];
[self.contentView addSubview:self.codeView];
[self.contentView addSubview:self.clickBtn];
}
- (void)initSubViewConstraints {
[self.areaVeiw mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(kGetScaleWidth(15));
make.centerY.equalTo(self.contentView);
}];
[self.codeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(-kGetScaleWidth(15));
make.centerY.equalTo(self.contentView);
}];
[self.clickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.leading.bottom.equalTo(self.contentView);
make.trailing.mas_equalTo(-kGetScaleWidth(20));
}];
}
-(void)didClickBtnAction{
if(self.delegate && [self.delegate respondsToSelector:@selector(didSelectModel:)]){
[self.delegate didSelectModel:self.areaModel];
}
}
- (void)setAreaModel:(LoginAreaModel *)areaModel{
_areaModel = areaModel;
_areaVeiw.text = _areaModel.name;
_codeView.text = _areaModel.code;
}
#pragma mark -
- (UILabel *)areaVeiw {
if (!_areaVeiw) {
_areaVeiw = [[UILabel alloc] init];
_areaVeiw.font = [UIFont systemFontOfSize:14];
_areaVeiw.textColor = [DJDKMIMOMColor colorWithHexString:@"#1F1A4E"];
}
return _areaVeiw;
}
- (UILabel *)codeView {
if (!_codeView) {
_codeView = [[UILabel alloc] init];
_codeView.font = [UIFont systemFontOfSize:14];
_codeView.textColor = [DJDKMIMOMColor colorWithHexString:@"#1F1A4E"];
}
return _codeView;
}
- (UIButton *)clickBtn{
if(!_clickBtn){
_clickBtn = [UIButton new];
[_clickBtn addTarget:self action:@selector(didClickBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
return _clickBtn;
}
@end

View File

@@ -0,0 +1,23 @@
//
// XPLoginAuthCodeVC.h
// YuMi
//
// Created by duoban on 2023/8/11.
//
#import "MvpViewController.h"
@protocol XPLoginAuthCodeVCDelegate <NSObject>
-(void)bindCodeSuccess;
@end
NS_ASSUME_NONNULL_BEGIN
@interface XPLoginAuthCodeVC : MvpViewController
@property(nonatomic,weak) id<XPLoginAuthCodeVCDelegate>delegate;
@property(nonatomic,assign) BOOL pi_isPush;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,165 @@
//
// XPLoginAuthCodeVC.m
// YuMi
//
// Created by duoban on 2023/8/11.
//
#import "XPLoginAuthCodeVC.h"
#import "XPLoginInputView.h"
#import <ReactiveObjC.h>
#import "LoginVerifCodePresent.h"
#import "LoginFullInfoViewController.h"
@interface XPLoginAuthCodeVC ()
///
@property(nonatomic,strong) UIImageView *bgImageView;
///
@property (nonatomic, strong) UILabel *titleLabel;
///
@property (nonatomic, strong) XPLoginInputView *codeInputView;
///
@property (nonatomic, strong) UIButton *loginBtn;
@end
@implementation XPLoginAuthCodeVC
- (BOOL)isHiddenNavBar {
return YES;
}
- (LoginVerifCodePresent *)createPresenter {
return [[LoginVerifCodePresent alloc] init];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self installUI];
[self installConstraints];
[self racBind];
}
-(void)installUI{
self.view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.bgImageView];
[self.view addSubview:self.titleLabel];
}
-(void)installConstraints{
UIView *bgView = [UIView new];
bgView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:bgView];
bgView.layer.cornerRadius = kGetScaleWidth(20);
bgView.layer.masksToBounds = YES;
[self.view addSubview:self.codeInputView];
[self.view addSubview:self.loginBtn];
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.top.equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(418));
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.top.mas_equalTo(kGetScaleWidth(128));
make.leading.mas_equalTo(kGetScaleWidth(24));
make.height.mas_equalTo(kGetScaleWidth(40));
}];
[bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.bottom.equalTo(self.view);
make.top.mas_equalTo(kGetScaleWidth(192));
}];
[self.codeInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.width.mas_equalTo(kGetScaleWidth(303));
make.top.mas_equalTo(kGetScaleWidth(260));
make.height.mas_equalTo(kGetScaleWidth(52));
}];
[self.loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.codeInputView.mas_bottom).offset(kGetScaleWidth(48));
make.centerX.mas_equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(48));
make.width.mas_equalTo(kGetScaleWidth(303));
}];
}
- (void)racBind {
RAC(self.loginBtn, enabled) = [[RACSignal combineLatest:@[self.codeInputView.inputTextField.rac_textSignal] reduce:^id _Nonnull(NSString *account){
return @(account.length > 0);
}] takeUntil:self.rac_willDeallocSignal];
}
-(void)loginBtnClicked{
[self showLoading];
[self.presenter bindAuthorizationCodeWithAuthCode:self.codeInputView.inputTextField.text];
}
#pragma mark - LoginVerifCodeProtocol
- (void)bindAuthorizationCodeSuccess{
[self hideHUD];
[self showSuccessToast:YMLocalizedString(@"XPLoginAuthCodeVC2")];
self.loginBtn.enabled = YES;
if(self.pi_isPush == YES){
LoginFullInfoViewController * FullVC = [[LoginFullInfoViewController alloc] init];
[self.navigationController pushViewController:FullVC animated:YES];
return;
}
[self dismissViewControllerAnimated:YES completion:nil];
if(self.delegate && [self.delegate respondsToSelector:@selector(bindCodeSuccess)]){
[self.delegate bindCodeSuccess];
}
}
-(void)bindAuthorizationCodeFail{
[self hideHUD];
self.loginBtn.enabled = YES;
}
#pragma mark -
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.text = YMLocalizedString(@"XPLoginAuthCodeVC0");
_titleLabel.font = kFontBold(28);
_titleLabel.textColor = UIColorFromRGB(0x1F1B4F);
}
return _titleLabel;
}
- (UIImageView *)bgImageView{
if(!_bgImageView){
_bgImageView = [[UIImageView alloc]init];
_bgImageView.image = kImage(@"login_phone_pwd_bg");
_bgImageView.contentMode = 2;
}
return _bgImageView;
}
- (XPLoginInputView *)codeInputView {
if (!_codeInputView) {
_codeInputView = [[XPLoginInputView alloc] init];
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginAuthCodeVC1")];
[placeholder addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xB3B3C3) range:NSMakeRange(0, placeholder.length)];
_codeInputView.inputTextField.attributedPlaceholder = placeholder;
_codeInputView.inputTextField.keyboardType = UIKeyboardTypeNumberPad;
}
return _codeInputView;
}
- (UIButton *)loginBtn {
if (!_loginBtn) {
_loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *nextImage = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor],[DJDKMIMOMColor confirmButtonGradientMiddleColor],[DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(kGetScaleWidth(303), kGetScaleWidth(48))];
UIImage *disableImage = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xD1F9FF),UIColorFromRGB(0xDEE4FF),UIColorFromRGB(0xEEDCFF)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(kGetScaleWidth(303), kGetScaleWidth(48))];
[_loginBtn setImage:nextImage forState:UIControlStateNormal];
[_loginBtn setImage:disableImage forState:UIControlStateDisabled];
_loginBtn.layer.cornerRadius = kGetScaleWidth(48)/2;
_loginBtn.layer.masksToBounds = YES;
UILabel *titleView = [UILabel labelInitWithText:YMLocalizedString(@"XPLoginAuthCodeVC3") font:kFontMedium(16) textColor:[UIColor whiteColor]];
titleView.textAlignment = NSTextAlignmentCenter;
[_loginBtn addSubview:titleView];
[titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.loginBtn);
}];
[_loginBtn addTarget:self action:@selector(loginBtnClicked) forControlEvents:UIControlEventTouchUpInside];
}
return _loginBtn;
}
@end

View File

@@ -0,0 +1,37 @@
//
// YMLoginInputView.h
// YUMI
//
// Created by XY on 2023/2/14.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol XPLoginInputViewDelegate <NSObject>
- (void)smsCodeAction;
- (void)areaListAction;
@end
@interface XPLoginInputView : UIView
///
@property (nonatomic,strong) UIStackView *areaStackView;
/// 区号
@property (nonatomic, strong) UIButton *areaCodeBtn;
/// 输入框
@property (nonatomic, strong) UITextField *inputTextField;
/// 验证码
@property (nonatomic, strong) UIButton *smsCodeBtn;
@property (nonatomic, weak) id<XPLoginInputViewDelegate> delegate;
//开启倒计时
- (void)fireTimer;
-(void)cancelTimer;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,168 @@
//
// YMLoginInputView.m
// YUMI
//
// Created by XY on 2023/2/14.
//
#import "XPLoginInputView.h"
#import "DJDKMIMOMColor.h"
#import <Masonry.h>
#import <ReactiveObjC.h>
#import "LoginAreaModel.h"
#import "MSBaseTextField.h"
@interface XPLoginInputView()
@property (nonatomic, strong) dispatch_source_t timer;
@property (nonatomic,strong) UIImageView *areaImageView;
@end
@implementation XPLoginInputView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = UIColorFromRGB(0xF3F5FA);
self.layer.cornerRadius = kGetScaleWidth(52)/2;
self.layer.masksToBounds = YES;
[self createUI];
}
return self;
}
- (void)createUI {
UIStackView *stackView = [[UIStackView alloc] init];
stackView.axis = UILayoutConstraintAxisHorizontal;
stackView.distribution = UIStackViewDistributionFill;
stackView.alignment = UIStackViewAlignmentCenter;
stackView.spacing = kGetScaleWidth(8);
[self addSubview:stackView];
UIImageView * areaImageView = [[UIImageView alloc] init];
areaImageView.userInteractionEnabled = YES;
areaImageView.image = [UIImage imageNamed:@"login_area_arrow"];
areaImageView.userInteractionEnabled = NO;
///
NSString *code = [NSString getCountryCode];
UIButton *areaCodeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[areaCodeBtn setTitle:code forState:UIControlStateNormal];
[areaCodeBtn setTitleColor:UIColorFromRGB(0x1F1B4F) forState:UIControlStateNormal];
areaCodeBtn.titleLabel.font = kFontMedium(16);
_areaCodeBtn = areaCodeBtn;
areaCodeBtn.userInteractionEnabled = NO;
UIStackView *areaStackView = [[UIStackView alloc] init];
areaStackView.axis = UILayoutConstraintAxisHorizontal;
areaStackView.distribution = UIStackViewDistributionFill;
areaStackView.alignment = UIStackViewAlignmentCenter;
areaStackView.spacing = kGetScaleWidth(8);
UIButton *areaBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[areaBtn addTarget:self action:@selector(areaChooseClicked) forControlEvents:UIControlEventTouchUpInside];
[areaStackView addSubview:areaBtn];
[areaStackView addArrangedSubview:areaCodeBtn];
[areaStackView addArrangedSubview:areaImageView];
[stackView addArrangedSubview:areaStackView];
self.areaStackView = areaStackView;
///
MSBaseTextField *inputTextField = [[MSBaseTextField alloc] init];
inputTextField.textColor = UIColorFromRGB(0x1F1B4F);
inputTextField.font = kFontRegular(14);
[stackView addArrangedSubview:inputTextField];
self.inputTextField = inputTextField;
///
UIButton *smsCodeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[smsCodeBtn setTitle:YMLocalizedString(@"XPLoginInputView0") forState:UIControlStateNormal];
[smsCodeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
smsCodeBtn.titleLabel.font = kFontMedium(12);
smsCodeBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
smsCodeBtn.titleLabel.numberOfLines = 2;
smsCodeBtn.layer.cornerRadius = kGetScaleWidth(38)/2;
smsCodeBtn.layer.masksToBounds = YES;
smsCodeBtn.backgroundColor = UIColorFromRGB(0x9168FA);
[smsCodeBtn addTarget:self action:@selector(smsCodeBtnClicked) forControlEvents:UIControlEventTouchUpInside];
[stackView addArrangedSubview:smsCodeBtn];
self.smsCodeBtn = smsCodeBtn;
[stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(kGetScaleWidth(24));
make.trailing.mas_equalTo(-kGetScaleWidth(24));
make.top.bottom.mas_equalTo(0);
}];
[areaImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(12));
make.height.mas_equalTo(kGetScaleWidth(8));
}];
[areaCodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_lessThanOrEqualTo(kGetScaleWidth(60));
make.height.mas_equalTo(stackView);
}];
[inputTextField mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(stackView);
}];
[smsCodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(102));
make.height.mas_equalTo(kGetScaleWidth(38));
}];
[areaBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(areaStackView);
}];
self.areaStackView.hidden = YES;
self.smsCodeBtn.hidden = YES;
}
- (void)smsCodeBtnClicked {
if (self.delegate && [self.delegate respondsToSelector:@selector(smsCodeAction)]) {
[self.delegate smsCodeAction];
}
}
- (void)areaChooseClicked {
if (self.delegate && [self.delegate respondsToSelector:@selector(areaListAction)]) {
[self.delegate areaListAction];
}
}
//
- (void)fireTimer {
__block NSInteger count = 60;
dispatch_queue_t queue = dispatch_get_main_queue();
dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
@weakify(self);
dispatch_source_set_event_handler(timer, ^{
@strongify(self);
count--;
if (count < 0) {
[self.smsCodeBtn setTitle:YMLocalizedString(@"XPLoginInputView1") forState:UIControlStateNormal];
self.smsCodeBtn.userInteractionEnabled = YES;
dispatch_cancel(self.timer);
self.timer = nil;
}else{
[self.smsCodeBtn setTitle:[NSString stringWithFormat:@"%lds",count] forState:UIControlStateNormal];
self.smsCodeBtn.userInteractionEnabled = NO;
}
});
dispatch_resume(timer);
self.timer = timer;
}
-(void)cancelTimer{
if (self.timer != nil){
dispatch_cancel(self.timer);
self.timer = nil;
}
}
@end

View File

@@ -0,0 +1,16 @@
//
// YMLoginPhoneViewController.h
// YUMI
//
// Created by XY on 2023/2/13.
//
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPLoginPhoneViewController : MvpViewController
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,430 @@
//
// YMLoginPhoneViewController.m
// YUMI
//
// Created by XY on 2023/2/13.
//
#import "XPLoginPhoneViewController.h"
#import <Masonry.h>
#import "YUMIMacroUitls.h"
#import <ReactiveObjC.h>
#import "XPLoginInputView.h"
#import "PILoginManager.h"
#import "XPLoginPwdViewController.h"
#import "XPLoginAraeViewController.h"
#import "LoginVerifCodePresent.h"
#import "LoginVerifCodeProtocol.h"
#import "XPForgetPwdViewController.h"
@interface XPLoginPhoneViewController ()<XPLoginInputViewDelegate, LoginVerifCodeProtocol, XPLoginAraeViewControllerDelegate>
///
@property(nonatomic,strong) UIImageView *bgImageView;
///
@property(nonatomic,strong) UIButton *backBnt;
///
@property (nonatomic, strong) UILabel *titleLabel;
///
@property (nonatomic, strong) UILabel *despLabel;
///
@property(nonatomic,strong) UIImageView *chooseTypeView;
///
@property(nonatomic,strong) UIButton *choosePhoneBtn;
///
@property(nonatomic,strong) UIButton *choosePsdBtn;
///
@property (nonatomic, strong) XPLoginInputView *phoneInputView;
///
@property (nonatomic, strong) XPLoginInputView *codeInputView;
/////
@property (nonatomic, strong) XPLoginInputView *accountView;
///
@property (nonatomic, strong) XPLoginInputView *accountPwdView;
///
@property (nonatomic, strong) UIButton *forgetBtn;
///
@property (nonatomic, strong) UIButton *loginBtn;
///
@property (nonatomic,copy) NSString *pi_phoneAreaCode;
///,01.
@property(nonatomic,assign) int selectType;
@end
@implementation XPLoginPhoneViewController
- (BOOL)isHiddenNavBar {
return YES;
}
- (LoginVerifCodePresent *)createPresenter {
return [[LoginVerifCodePresent alloc] init];
}
- (void)viewDidLoad {
self.selectType = 0;
NSString *code = [NSString getCountryCode];
self.pi_phoneAreaCode = [code stringByReplacingOccurrencesOfString:@"+" withString:@""];
[super viewDidLoad];
[self createUI];
[self racBind];
}
- (void)createUI {
self.view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.bgImageView];
[self.view addSubview:self.backBnt];
[self.view addSubview:self.titleLabel];
[self.view addSubview:self.chooseTypeView];
[self.chooseTypeView addSubview:self.choosePhoneBtn];
[self.chooseTypeView addSubview:self.choosePsdBtn];
UIView *bgView = [UIView new];
bgView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:bgView];
[self.view addSubview:self.phoneInputView];
[self.view addSubview:self.codeInputView];
[self.view addSubview:self.accountView];
[self.view addSubview:self.accountPwdView];
[self.view addSubview:self.forgetBtn];
[self.view addSubview:self.loginBtn];
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.top.equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(418));
}];
[self.backBnt mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(kGetScaleWidth(20));
make.width.mas_equalTo(kGetScaleWidth(28));
make.height.mas_equalTo(kGetScaleWidth(28));
make.top.mas_equalTo(kGetScaleWidth(52));
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.top.equalTo(self.backBnt.mas_bottom).mas_offset(kGetScaleWidth(48));
make.leading.mas_equalTo(kGetScaleWidth(24));
make.height.mas_equalTo(kGetScaleWidth(40));
}];
[self.chooseTypeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.titleLabel.mas_bottom).mas_offset(kGetScaleWidth(24));
make.leading.trailing.equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(65));
}];
[self.choosePsdBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(16));
make.height.mas_equalTo(kGetScaleWidth(22));
make.width.mas_equalTo(KScreenWidth/2);
make.leading.mas_equalTo(0);
}];
[self.choosePhoneBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(16));
make.height.mas_equalTo(kGetScaleWidth(22));
make.width.mas_equalTo(KScreenWidth/2);
make.trailing.mas_equalTo(0);
}];
[bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.bottom.equalTo(self.view);
make.top.equalTo(self.chooseTypeView.mas_bottom);
}];
[self.phoneInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.width.mas_equalTo(kGetScaleWidth(303));
make.top.mas_equalTo(self.chooseTypeView.mas_bottom).offset(kGetScaleWidth(39));
make.height.mas_equalTo(kGetScaleWidth(52));
}];
[self.codeInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.view);
make.width.mas_equalTo(kGetScaleWidth(303));
make.top.mas_equalTo(self.phoneInputView.mas_bottom).offset(kGetScaleWidth(20));
make.height.mas_equalTo(kGetScaleWidth(52));
}];
[self.accountView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.phoneInputView);
}];
[self.accountPwdView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.codeInputView);
}];
[self.forgetBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(-kGetScaleWidth(52));
make.height.mas_equalTo(kGetScaleWidth(17));
make.top.equalTo(self.accountPwdView.mas_bottom).mas_offset(kGetScaleWidth(8));
}];
[self.loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.codeInputView.mas_bottom).offset(kGetScaleWidth(48));
make.centerX.mas_equalTo(self.view);
make.height.mas_equalTo(kGetScaleWidth(48));
make.width.mas_equalTo(kGetScaleWidth(303));
}];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[self.view endEditing:YES];
}
- (void)racBind {
@weakify(self);
RAC(self.loginBtn, enabled) = [[RACSignal combineLatest:@[self.phoneInputView.inputTextField.rac_textSignal, self.codeInputView.inputTextField.rac_textSignal,self.accountView.inputTextField.rac_textSignal,self.accountPwdView.inputTextField.rac_textSignal] reduce:^id _Nonnull(NSString *phone, NSString* smsCode,NSString *account,NSString *accountPwd){
@strongify(self);
if(self.selectType == 0){
return @((account.length > 0) && accountPwd.length >= 6);
}
return @((phone.length > 0) && smsCode.length >= 5);
}] takeUntil:self.rac_willDeallocSignal];
}
///
- (void)loginBtnClicked {
[XNDJTDDLoadingTool showOnlyView:self.view];
if(self.selectType == 0){
NSString *phone = self.accountView.inputTextField.text;
NSString *password = self.accountPwdView.inputTextField.text;
[self.presenter loginWithPhone:phone password:password];
return;
}
NSString *phone = self.phoneInputView.inputTextField.text;
NSString *smsCode = self.codeInputView.inputTextField.text;
NSString * phoneStr = [NSString stringWithFormat:@"%@%@",self.pi_phoneAreaCode, phone];
[self.presenter loginWithPhone:phoneStr code:smsCode phoneAreaCode:self.pi_phoneAreaCode];
}
- (void)forgetBtnClicked {
XPForgetPwdViewController *forgetVC = [[XPForgetPwdViewController alloc] init];
[self.navigationController pushViewController:forgetVC animated:YES];
}
#pragma mark - XPLoginInputViewDelegate
- (void)smsCodeAction {
NSString *phone = self.phoneInputView.inputTextField.text;
if (phone.length == 0 ) {
[self showErrorToast:YMLocalizedString(@"XPLoginPhoneViewController0")];
return;
}
[self.presenter phoneSmsCode:[NSString stringWithFormat:@"%@%@",self.pi_phoneAreaCode,phone] type:GetSmsType_Regist phoneAreaCode:self.pi_phoneAreaCode];
}
- (void)areaListAction {
XPLoginAraeViewController *codeVC = [XPLoginAraeViewController new];
codeVC.delegate = self;
[self.navigationController pushViewController:codeVC animated:YES];
}
- (void)chooseAreaCodeSuccess:(NSString *)code {
if (code.length > 0) {
self.pi_phoneAreaCode = code;
[self.phoneInputView.areaCodeBtn setTitle:[NSString stringWithFormat:@"+%@", code] forState:UIControlStateNormal];
}
}
#pragma mark - LoginVerifCodeProtocol
- (void)loginWithPhoenSuccess{
[XNDJTDDLoadingTool hideOnlyView:self.view];
[self showSuccessToast:YMLocalizedString(@"XPLoginPhoneViewController1")];
[PILoginManager loginWithVC:self isLoginPhone:YES];
}
- (void)loginSuccess {
[XNDJTDDLoadingTool hideOnlyView:self.view];
[self showSuccessToast:YMLocalizedString(@"XPLoginPhoneViewController1")];
[PILoginManager loginWithVC:self isLoginPhone:NO];
}
- (void)loginFailWithMsg:(NSString *)msg{
[self showErrorToast:msg];
[XNDJTDDLoadingTool hideOnlyView:self.view];
}
-(void)backViewAction{
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - LoginProtocol
- (void)phoneSmsCodeSuccess {
[self showSuccessToast:YMLocalizedString(@"XPLoginPhoneViewController2")];
[self.codeInputView fireTimer];
}
-(void)setSelectType:(int)selectType{
_selectType = selectType;
_chooseTypeView.image = _selectType == 0 ? kImage(@"login_choose_phone_bg"): kImage(@"login_choose_pwd_bg");
_choosePhoneBtn.selected = _selectType != 0;
_choosePsdBtn.selected = _selectType == 0;
_forgetBtn.hidden = _selectType != 0;
_phoneInputView.hidden = _selectType == 0;
_codeInputView.hidden = _selectType == 0;
_accountView.hidden = _selectType != 0;
_accountPwdView.hidden = _selectType != 0;
}
-(void)choosePhoneAction{
self.selectType = 1;
}
-(void)choosePwdAction{
self.selectType = 0;
}
#pragma mark -
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.text = @"Welcome to MoliStar";
_titleLabel.font = kFontBold(28);
_titleLabel.textColor = UIColorFromRGB(0x1F1B4F);
}
return _titleLabel;
}
- (UILabel *)despLabel {
if (!_despLabel) {
_despLabel = [[UILabel alloc] init];
_despLabel.text = YMLocalizedString(@"XPLoginPhoneViewController4");
_despLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
_despLabel.textColor = [UIColor.whiteColor colorWithAlphaComponent:0.6];
}
return _despLabel;
}
- (XPLoginInputView *)phoneInputView {
if (!_phoneInputView) {
_phoneInputView = [[XPLoginInputView alloc] init];
_phoneInputView.areaStackView.hidden = NO;
_phoneInputView.delegate = self;
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginPhoneViewController5")];
[placeholder addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xB3B3C3) range:NSMakeRange(0, placeholder.length)];
_phoneInputView.inputTextField.attributedPlaceholder = placeholder;
_phoneInputView.inputTextField.keyboardType = UIKeyboardTypeNumberPad;
_phoneInputView.hidden = YES;
}
return _phoneInputView;
}
- (XPLoginInputView *)codeInputView {
if (!_codeInputView) {
_codeInputView = [[XPLoginInputView alloc] init];
_codeInputView.smsCodeBtn.hidden = NO;
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginPhoneViewController6")];
[placeholder addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xB3B3C3) range:NSMakeRange(0, placeholder.length)];
_codeInputView.inputTextField.attributedPlaceholder = placeholder;
_codeInputView.inputTextField.keyboardType = UIKeyboardTypeNumberPad;
_codeInputView.delegate = self;
_codeInputView.hidden = YES;
}
return _codeInputView;
}
- (UIButton *)loginBtn {
if (!_loginBtn) {
_loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *nextImage = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor],[DJDKMIMOMColor confirmButtonGradientMiddleColor],[DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(kGetScaleWidth(303), kGetScaleWidth(48))];
UIImage *disableImage = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xD1F9FF),UIColorFromRGB(0xDEE4FF),UIColorFromRGB(0xEEDCFF)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(kGetScaleWidth(303), kGetScaleWidth(48))];
[_loginBtn setImage:nextImage forState:UIControlStateNormal];
[_loginBtn setImage:disableImage forState:UIControlStateDisabled];
_loginBtn.layer.cornerRadius = kGetScaleWidth(48)/2;
_loginBtn.layer.masksToBounds = YES;
UILabel *titleView = [UILabel labelInitWithText:YMLocalizedString(@"XPLoginPhoneViewController8") font:kFontMedium(16) textColor:[UIColor whiteColor]];
titleView.textAlignment = NSTextAlignmentCenter;
[_loginBtn addSubview:titleView];
[titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.loginBtn);
}];
[_loginBtn addTarget:self action:@selector(loginBtnClicked) forControlEvents:UIControlEventTouchUpInside];
}
return _loginBtn;
}
- (UIImageView *)bgImageView{
if(!_bgImageView){
_bgImageView = [[UIImageView alloc]init];
_bgImageView.image = kImage(@"login_phone_pwd_bg");
_bgImageView.contentMode = 2;
}
return _bgImageView;
}
- (UIButton *)backBnt{
if(!_backBnt){
_backBnt = [UIButton new];
[_backBnt setImage:[kImage(@"common_nav_back")ms_SetImageForRTL] forState:UIControlStateNormal];
[_backBnt addTarget:self action:@selector(backViewAction) forControlEvents:UIControlEventTouchUpInside];
[_backBnt setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
}
return _backBnt;
}
- (UIImageView *)chooseTypeView{
if(!_chooseTypeView){
_chooseTypeView = [UIImageView new];
_chooseTypeView.userInteractionEnabled = YES;
[_chooseTypeView setImage:kImage(@"login_choose_phone_bg")];
}
return _chooseTypeView;
}
- (UIButton *)choosePhoneBtn{
if(!_choosePhoneBtn){
_choosePhoneBtn = [UIButton new];
[_choosePhoneBtn setTitle:YMLocalizedString(@"1.0.37_text_26") forState:UIControlStateNormal];
[_choosePhoneBtn setTitleColor:UIColorFromRGB(0x6D6B89) forState:UIControlStateNormal];
[_choosePhoneBtn setTitleColor:UIColorFromRGB(0x1F1B4F) forState:UIControlStateSelected];
_choosePhoneBtn.titleLabel.font = kFontSemibold(16);
[ _choosePhoneBtn setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
[_choosePhoneBtn addTarget:self action:@selector(choosePhoneAction) forControlEvents:UIControlEventTouchUpInside];
}
return _choosePhoneBtn;
}
- (UIButton *)choosePsdBtn{
if(!_choosePsdBtn){
_choosePsdBtn = [UIButton new];
[_choosePsdBtn setTitle:YMLocalizedString(@"1.0.37_text_27") forState:UIControlStateNormal];
[_choosePsdBtn setTitleColor:UIColorFromRGB(0x6D6B89) forState:UIControlStateNormal];
[_choosePsdBtn setTitleColor:UIColorFromRGB(0x1F1B4F) forState:UIControlStateSelected];
_choosePsdBtn.titleLabel.font = kFontSemibold(16);
[_choosePsdBtn setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
[_choosePsdBtn addTarget:self action:@selector(choosePwdAction) forControlEvents:UIControlEventTouchUpInside];
_choosePsdBtn.selected = YES;
}
return _choosePsdBtn;
}
- (XPLoginInputView *)accountView {
if (!_accountView) {
_accountView = [[XPLoginInputView alloc] init];
_accountView.areaStackView.hidden = YES;
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginPwdViewController6")];
[placeholder addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xB3B3C3) range:NSMakeRange(0, placeholder.length)];
_accountView.inputTextField.attributedPlaceholder = placeholder;
_accountView.inputTextField.keyboardType = UIKeyboardTypeNumberPad;
}
return _accountView;
}
- (XPLoginInputView *)accountPwdView {
if (!_accountPwdView) {
_accountPwdView = [[XPLoginInputView alloc] init];
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginPwdViewController3")];
[placeholder addAttribute:NSForegroundColorAttributeName value:UIColorFromRGB(0xB3B3C3) range:NSMakeRange(0, placeholder.length)];
_accountPwdView.inputTextField.attributedPlaceholder = placeholder;
_accountPwdView.inputTextField.keyboardType = UIKeyboardTypeAlphabet;
_accountPwdView.inputTextField.secureTextEntry = YES;
}
return _accountPwdView;
}
- (UIButton *)forgetBtn {
if (!_forgetBtn) {
_forgetBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_forgetBtn setTitle:YMLocalizedString(@"XPRoomRedPacketPwdView1") forState:UIControlStateNormal];
[_forgetBtn setTitleColor:UIColorFromRGB(0xB3B3C3) forState:UIControlStateNormal];
_forgetBtn.titleLabel.font = kFontRegular(12);
[_forgetBtn addTarget:self action:@selector(forgetBtnClicked) forControlEvents:UIControlEventTouchUpInside];
}
return _forgetBtn;
}
@end

View File

@@ -0,0 +1,16 @@
//
// YMLoginPwdViewController.h
// YUMI
//
// Created by XY on 2023/2/14.
//
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPLoginPwdViewController : MvpViewController
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,193 @@
//
// YMLoginPwdViewController.m
// YUMI
//
// Created by XY on 2023/2/14.
//
#import "XPLoginPwdViewController.h"
#import <Masonry.h>
#import "YUMIMacroUitls.h"
#import <ReactiveObjC.h>
#import "XPLoginInputView.h"
#import "XPLoginPwdViewController.h"
#import "XPForgetPwdViewController.h"
#import "LoginPasswordPresent.h"
#import "LoginPasswordProtocol.h"
@interface XPLoginPwdViewController ()<LoginPasswordProtocol>
///
@property (nonatomic, strong) UILabel *titleLabel;
///
@property (nonatomic, strong) XPLoginInputView *phoneInputView;
///
@property (nonatomic, strong) XPLoginInputView *pwdInputView;
///
@property (nonatomic, strong) UIButton *forgetBtn;
///
@property (nonatomic, strong) UIButton *loginBtn;
///
@property (nonatomic, strong) UIButton *phoneLoginBtn;
@end
@implementation XPLoginPwdViewController
- (LoginPasswordPresent *)createPresenter {
return [[LoginPasswordPresent alloc] init];
}
- (void)viewDidLoad {
[super viewDidLoad];
[self createUI];
[self racBind];
}
- (void)createUI {
[self.view addSubview:self.titleLabel];
[self.view addSubview:self.phoneInputView];
[self.view addSubview:self.pwdInputView];
[self.view addSubview:self.loginBtn];
[self.view addSubview:self.phoneLoginBtn];
[self.view addSubview:self.forgetBtn];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.view);
make.top.mas_equalTo(146.0/812.0*KScreenHeight);
}];
[self.phoneInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(38);
make.trailing.mas_equalTo(-38);
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(41);
make.height.mas_equalTo(66);
}];
[self.pwdInputView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.phoneInputView);
make.trailing.mas_equalTo(self.phoneInputView);
make.top.mas_equalTo(self.phoneInputView.mas_bottom).offset(16);
make.height.mas_equalTo(self.phoneInputView);
}];
[self.loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.pwdInputView.mas_bottom).offset(51);
make.centerX.mas_equalTo(self.view);
make.width.height.mas_equalTo(96);
}];
[self.phoneLoginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.loginBtn.mas_bottom).offset(24);
make.centerX.mas_equalTo(self.view);
}];
[self.forgetBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(self.pwdInputView);
make.top.mas_equalTo(self.pwdInputView.mas_bottom).offset(10);
}];
}
- (void)racBind {
RAC(self.loginBtn, enabled) = [[RACSignal combineLatest:@[self.phoneInputView.inputTextField.rac_textSignal, self.pwdInputView.inputTextField.rac_textSignal] reduce:^id _Nonnull(NSString *phone, NSString* password){
return @((phone.length > 0) && password.length >= 6);
}] takeUntil:self.rac_willDeallocSignal];
}
- (void)loginBtnClicked {
NSString *phone = self.phoneInputView.inputTextField.text;
NSString *password = self.pwdInputView.inputTextField.text;
[self.presenter loginWithPhone:phone password:password];
}
- (void)phoneLoginBtnClicked {
[self.navigationController popViewControllerAnimated:YES];
}
- (void)forgetBtnClicked {
XPForgetPwdViewController *forgetVC = [[XPForgetPwdViewController alloc] init];
[self.navigationController pushViewController:forgetVC animated:YES];
}
#pragma mark - LoginPasswordProtocol
- (void)phoneAndPasswordLoginSuccess {
[self showSuccessToast:YMLocalizedString(@"XPLoginPwdViewController0")];
UIViewController *vc = self.presentingViewController;
while (vc.presentingViewController) {
vc = vc.presentingViewController;
}
[vc dismissViewControllerAnimated:YES completion:nil];
[self.navigationController popToRootViewControllerAnimated:NO];
}
#pragma mark -
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.text = YMLocalizedString(@"XPLoginPwdViewController1");
_titleLabel.font = [UIFont systemFontOfSize:24 weight:UIFontWeightMedium];
_titleLabel.textColor = UIColor.whiteColor;
}
return _titleLabel;
}
- (XPLoginInputView *)phoneInputView {
if (!_phoneInputView) {
_phoneInputView = [[XPLoginInputView alloc] init];
_phoneInputView.areaStackView.hidden = YES;
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginPwdViewController2")];
[placeholder addAttribute:NSForegroundColorAttributeName value:UIColor.whiteColor range:NSMakeRange(0, placeholder.length)];
_phoneInputView.inputTextField.attributedPlaceholder = placeholder;
_phoneInputView.inputTextField.keyboardType = UIKeyboardTypeNumberPad;
}
return _phoneInputView;
}
- (XPLoginInputView *)pwdInputView {
if (!_pwdInputView) {
_pwdInputView = [[XPLoginInputView alloc] init];
NSMutableAttributedString *placeholder = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginPwdViewController3")];
[placeholder addAttribute:NSForegroundColorAttributeName value:UIColor.whiteColor range:NSMakeRange(0, placeholder.length)];
_pwdInputView.inputTextField.attributedPlaceholder = placeholder;
_pwdInputView.inputTextField.keyboardType = UIKeyboardTypeAlphabet;
_pwdInputView.inputTextField.secureTextEntry = YES;
}
return _pwdInputView;
}
- (UIButton *)forgetBtn {
if (!_forgetBtn) {
_forgetBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_forgetBtn setTitle:YMLocalizedString(@"XPRoomRedPacketPwdView1") forState:UIControlStateNormal];
[_forgetBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
_forgetBtn.titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
[_forgetBtn addTarget:self action:@selector(forgetBtnClicked) forControlEvents:UIControlEventTouchUpInside];
}
return _forgetBtn;
}
- (UIButton *)loginBtn {
if (!_loginBtn) {
_loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_loginBtn setImage:[UIImage imageNamed:@"login_next"] forState:UIControlStateNormal];
[_loginBtn setImage:[UIImage imageNamed:@"login_next_disable"] forState:UIControlStateDisabled];
[_loginBtn addTarget:self action:@selector(loginBtnClicked) forControlEvents:UIControlEventTouchUpInside];
}
return _loginBtn;
}
- (UIButton *)phoneLoginBtn {
if (!_phoneLoginBtn) {
_phoneLoginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPLoginPwdViewController4")];
[title addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, title.length)];
[_phoneLoginBtn setAttributedTitle:title forState:UIControlStateNormal];
[_phoneLoginBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
_phoneLoginBtn.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightRegular];
[_phoneLoginBtn addTarget:self action:@selector(phoneLoginBtnClicked) forControlEvents:UIControlEventTouchUpInside];
}
return _phoneLoginBtn;
}
@end

View File

@@ -0,0 +1,23 @@
//
// RegionListViewController.h
// YuMi
//
// Created by P on 2024/12/13.
//
#import "MvpViewController.h"
@class PIHomeCategoryTitleModel, RegionListInfo;
NS_ASSUME_NONNULL_BEGIN
@interface RegionListViewController : MvpViewController
@property(nonatomic, copy) void(^handleDismiss)(void);
@property(nonatomic, copy) void(^handleTapCategiryComfirm)(PIHomeCategoryTitleModel *tagModel);
@property(nonatomic, copy) void(^handleTapRegionComfirm)(RegionListInfo *regionInfo);
- (instancetype)initForRegionList:(NSArray <RegionListInfo *>*)regionInfoList;
- (instancetype)initForHomeTags:(NSArray <PIHomeCategoryTitleModel*>*)tags currentItem:(PIHomeCategoryTitleModel *)itemModel;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,521 @@
//
// RegionListViewController.m
// YuMi
//
// Created by P on 2024/12/13.
//
#import "RegionListViewController.h"
#import "PIHomeCategoryTitleModel.h"
#import "LoginFullInfoPresenter.h"
#import "RegionListInfo.h"
@interface RegionListCell : UICollectionViewCell
@property(nonatomic, strong) RegionListInfo *regionModel;
@property(nonatomic, strong) PIHomeCategoryTitleModel *tagModel;
@property(nonatomic, strong) UIView *selectedBG;
@property(nonatomic, strong) UIImageView *selectedMark;
@property(nonatomic, strong) NetImageView *flagImageView;
@property(nonatomic, strong) UILabel *titleLabel;
+ (void)registerTo:(UICollectionView *)collectionView;
+ (RegionListCell *)cellFor:(UICollectionView *)collectionView indexPath:(NSIndexPath *)indexPath;
@end
@implementation RegionListCell
+ (void)registerTo:(UICollectionView *)collectionView {
[collectionView registerClass:[self class] forCellWithReuseIdentifier:NSStringFromClass([self class])];
}
+ (RegionListCell *)cellFor:(UICollectionView *)collectionView
indexPath:(NSIndexPath *)indexPath {
RegionListCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([self class])
forIndexPath:indexPath];
// [cell.contentView setBackgroundColor:UIColorFromRGB(0xF7F7F7)];
// [cell setCornerRadius:19];
return cell;
}
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
[self.contentView addSubview:self.flagImageView];
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.selectedMark];
[self.flagImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(14);
make.centerY.mas_equalTo(self.contentView);
make.size.mas_equalTo(CGSizeMake(30, 22));
}];
[self.selectedMark mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(-14);
make.centerY.mas_equalTo(self.contentView);
make.size.mas_equalTo(CGSizeMake(20, 20));
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.flagImageView.mas_trailing).offset(6);
make.trailing.mas_equalTo(self.selectedMark.mas_leading).offset(-6);
make.centerY.mas_equalTo(self.contentView);
make.height.mas_equalTo(20);
}];
UIView *line = [[UIView alloc] init];
line.backgroundColor = UIColorFromRGB(0xe4e4e4);
[self.contentView addSubview:line];
[line mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.contentView);
make.trailing.mas_equalTo(self.selectedMark);
make.leading.mas_equalTo(self.flagImageView);
make.height.mas_equalTo(1);
}];
// [self.contentView addSubview:self.selectedBG];
// [self.selectedBG mas_makeConstraints:^(MASConstraintMaker *make) {
// make.edges.mas_equalTo(self.contentView);
// }];
}
return self;
}
- (void)setSelected:(BOOL)selected {
[super setSelected:selected];
// self.selectedBG.hidden = !selected;
self.selectedMark.hidden = !selected;
// if (selected) {
// [self.contentView setBackgroundColor:UIColorFromRGB(0xFFFAF5)];
// } else {
// [self.contentView setBackgroundColor:UIColorFromRGB(0xF7F7F7)];
// }
}
- (void)prepareForReuse {
[super prepareForReuse];
self.flagImageView.image = nil;
}
- (void)setTagModel:(PIHomeCategoryTitleModel *)tagModel {
_tagModel = tagModel;
self.flagImageView.imageUrl = tagModel.icon;
self.titleLabel.text = tagModel.name;
[self.flagImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(14);
make.centerY.mas_equalTo(self.contentView);
make.size.mas_equalTo(CGSizeMake(40, 30));
}];
}
- (void)setRegionModel:(RegionListInfo *)regionModel {
_regionModel = regionModel;
self.flagImageView.imageUrl = regionModel.icon;
self.titleLabel.text = regionModel.name;
}
#pragma mark -
- (UIView *)selectedBG {
if (!_selectedBG) {
_selectedBG = [[UIView alloc] init];
[_selectedBG setCornerRadius:19
corners:kCALayerMaxXMaxYCorner | kCALayerMaxXMinYCorner | kCALayerMinXMaxYCorner | kCALayerMinXMinYCorner
borderWidth:1
borderColor:UIColorFromRGB(0xFF8C03)];
_selectedBG.hidden = YES;
}
return _selectedBG;
}
- (NetImageView *)flagImageView {
if (!_flagImageView) {
_flagImageView = [[NetImageView alloc] init];
_flagImageView.contentMode = UIViewContentModeScaleAspectFit;
}
return _flagImageView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [UILabel labelInitWithText:@"" font:kFontMedium(15) textColor:UIColorFromRGB(0x313131)];
}
return _titleLabel;
}
- (UIImageView *)selectedMark {
if (!_selectedMark) {
_selectedMark = [[UIImageView alloc] initWithImage:kImage(@"region_list_selected")];
_selectedMark.hidden = YES;
}
return _selectedMark;
}
@end
@interface RegionListViewController () <UISearchBarDelegate, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource>
@property(nonatomic, assign) NSInteger type;
@property(nonatomic, assign) CGFloat displayHeight;
@property(nonatomic, strong) UILabel *titleLabel;
@property(nonatomic, strong) UISearchBar *searchBar;
@property(nonatomic, strong) UICollectionView *collectionView;
@property(nonatomic, strong) UIButton *comfirmButton;
@property(nonatomic, strong) UIView *bgView;
@property(nonatomic, strong) UIView *emptyView;
@property(nonatomic, copy) NSArray <PIHomeCategoryTitleModel*> *tagDataSource;
@property(nonatomic, strong) PIHomeCategoryTitleModel *selectedTag;
@property(nonatomic, copy) NSArray <RegionListInfo *> *regionList;
@property(nonatomic, strong) NSMutableArray <RegionListInfo *> *filteredRegionList;
@property(nonatomic, strong) RegionListInfo *selectedRegion;
@property(nonatomic, assign) NSInteger defaultIndex;
@end
@implementation RegionListViewController
- (LoginFullInfoPresenter *)createPresenter {
return [[LoginFullInfoPresenter alloc] init];
}
- (instancetype)initForRegionList:(NSArray <RegionListInfo *>*)regionInfoList {
if (self = [super init]) {
self.type = 1;
self.displayHeight = KScreenHeight/2;
self.regionList = regionInfoList;
self.filteredRegionList = [regionInfoList mutableCopy];
[self.collectionView reloadData];
}
return self;
}
- (instancetype)initForHomeTags:(NSArray <PIHomeCategoryTitleModel*>*)tags
currentItem:(nonnull PIHomeCategoryTitleModel *)itemModel {
if (self = [super init]) {
self.type = 2;
self.modalPresentationStyle = UIModalPresentationOverFullScreen;
self.displayHeight = KScreenHeight*2/3;
NSMutableArray *temp = @[].mutableCopy;
for (PIHomeCategoryTitleModel *model in tags) {
if (![NSString isEmpty:model.regionId]) {
[temp addObject:model];
}
}
self.defaultIndex = [temp indexOfObject:itemModel];
self.selectedTag = itemModel;
self.tagDataSource = temp;
[self.collectionView reloadData];
@kWeakify(self);
dispatch_async(dispatch_get_main_queue(), ^{
@kStrongify(self);
[self.collectionView selectItemAtIndexPath:[NSIndexPath indexPathForRow:self.defaultIndex inSection:0]
animated:NO
scrollPosition:UICollectionViewScrollPositionNone];
});
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.title = YMLocalizedString(@"1.0.31_text_1");
switch (self.type) {
case 1:
[self setupUIForFullDisplay];
break;
case 2:
[self setupUIForHalfScreen];
break;
default:
break;
}
}
- (void)setupUIForFullDisplay {
self.view.backgroundColor = [UIColor whiteColor];
// self.comfirmButton.frame = CGRectMake(0, 0, 48, 44);
// UIBarButtonItem *rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.comfirmButton];
// self.navigationItem.rightBarButtonItem = rightBarButtonItem;
[self.view addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(10);
make.centerX.mas_equalTo(self.view);
make.height.mas_equalTo(34);
}];
[self.view addSubview:self.comfirmButton];
[self.comfirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.titleLabel);
make.trailing.mas_equalTo(-15);
}];
[self.view addSubview:self.searchBar];
[self.searchBar mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10);
make.leading.trailing.mas_equalTo(self.view).inset(16);
make.height.mas_equalTo(34);
}];
[self.view addSubview:self.collectionView];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.searchBar.mas_bottom).offset(8);
make.bottom.leading.trailing.mas_equalTo(0);
}];
[self.view addSubview:self.emptyView];
[self.emptyView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.collectionView).offset(8);
make.centerX.mas_equalTo(self.collectionView);
make.size.mas_equalTo(CGSizeMake(120, 120));
}];
}
- (void)setupUIForHalfScreen {
self.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
[self.view addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(KScreenHeight - self.displayHeight);
make.centerX.mas_equalTo(self.view);
make.height.mas_equalTo(34);
}];
[self.view addSubview:self.comfirmButton];
[self.comfirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.titleLabel);
make.trailing.mas_equalTo(-15);
}];
[self.view addSubview:self.collectionView];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(8);
make.bottom.leading.trailing.mas_equalTo(0);
}];
[self.view insertSubview:self.bgView belowSubview:self.titleLabel];
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.titleLabel).offset(-10);
make.leading.bottom.trailing.mas_equalTo(self.view);
}];
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
[b addTarget:self action:@selector(didTapSpace) forControlEvents:UIControlEventTouchUpInside];
[self.view insertSubview:b atIndex:0];
[b mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.leading.trailing.mas_equalTo(self.view);
make.height.mas_equalTo(KScreenHeight/2);
}];
}
- (void)didTapComfirm {
if (self.type == 1) {
if (self.handleTapRegionComfirm) {
self.handleTapRegionComfirm(self.selectedRegion);
}
} else if (self.type == 2) {
if (self.handleTapCategiryComfirm) {
self.handleTapCategiryComfirm(self.selectedTag);
}
}
[self dismissViewControllerAnimated:YES completion:^{}];
}
- (void)didTapSpace {
@kWeakify(self);
[self dismissViewControllerAnimated:YES completion:^{
@kStrongify(self);
if (self.handleDismiss) {
self.handleDismiss();
}
}];
}
#pragma mark - UISearchBarDelegate
// "Search"
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
[searchBar resignFirstResponder]; //
}
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
if (searchText.length == 0) {
//
self.filteredRegionList = [self.regionList copy];
} else {
//
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name CONTAINS[cd] %@", searchText];
self.filteredRegionList = [[self.regionList filteredArrayUsingPredicate:predicate] mutableCopy];
}
[self.collectionView reloadData];
self.emptyView.hidden = self.filteredRegionList.count > 0;
}
//
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
[searchBar resignFirstResponder];
searchBar.text = @"";
self.filteredRegionList = [self.regionList mutableCopy];
[self.collectionView reloadData];
}
#pragma mark -
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
if (self.type == 1) {
return self.filteredRegionList.count;
} else if (self.type == 2) {
return self.tagDataSource.count;
}
return 0;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
RegionListCell *cell = [RegionListCell cellFor:collectionView indexPath:indexPath];
if (self.type == 1) {
cell.regionModel = [self.filteredRegionList xpSafeObjectAtIndex:indexPath.row];
} else if (self.type == 2) {
cell.tagModel = [self.tagDataSource xpSafeObjectAtIndex:indexPath.row];
}
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if (self.type == 1) {
self.selectedRegion = [self.filteredRegionList xpSafeObjectAtIndex:indexPath.row];
} else if (self.type == 2) {
self.selectedTag = [self.tagDataSource xpSafeObjectAtIndex:indexPath.row];
if (self.handleTapCategiryComfirm) {
self.handleTapCategiryComfirm(self.selectedTag);
}
}
}
#pragma mark -
- (UISearchBar *)searchBar {
if (!_searchBar) {
UIColor *bgColor = UIColorFromRGB(0xf4f4f4);
_searchBar = [[UISearchBar alloc] init];
_searchBar.delegate = self;
_searchBar.placeholder = YMLocalizedString(@"XPHomeSearchNavView1");
_searchBar.barTintColor = bgColor;
[_searchBar setCornerRadius:34/2];
if (@available(iOS 13.0, *)) {
_searchBar.searchTextField.backgroundColor = bgColor;
_searchBar.searchTextField.textColor = UIColorFromRGB(0x313131);
} else {
UITextField *searchField = [self findTextFieldInSearchBar:_searchBar];
if (searchField) {
searchField.backgroundColor = bgColor;
searchField.textColor = UIColorFromRGB(0x313131);
}
}
}
return _searchBar;
}
- (UICollectionView *)collectionView {
if (!_collectionView) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
// if (self.type == 1) {
layout.itemSize = CGSizeMake(KScreenWidth - 30, 48);
// } else if (self.type == 2) {
// layout.itemSize = CGSizeMake(kGetScaleWidth(166), 38);
// }
layout.sectionInset = UIEdgeInsetsMake(0, 16, kSafeAreaBottomHeight, 16);
layout.minimumLineSpacing = 0;
layout.minimumInteritemSpacing = 10;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 44, KScreenWidth, KScreenHeight-44)
collectionViewLayout:layout];
_collectionView.delegate = self;
_collectionView.dataSource = self;
_collectionView.backgroundColor = [UIColor whiteColor];
[RegionListCell registerTo:_collectionView];
}
return _collectionView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [UILabel labelInitWithText:YMLocalizedString(@"1.0.31_text_2")
font:kFontSemibold(16)
textColor:UIColorFromRGB(0x313131)];
}
return _titleLabel;
}
- (UIButton *)comfirmButton {
if (!_comfirmButton) {
_comfirmButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_comfirmButton setTitleColor:UIColorFromRGB(0xFF8C03) forState:UIControlStateNormal];
[_comfirmButton setTitle:YMLocalizedString(@"TTAlertConfig0") forState:UIControlStateNormal];
[_comfirmButton addTarget:self
action:@selector(didTapComfirm)
forControlEvents:UIControlEventTouchUpInside];
}
return _comfirmButton;
}
- (UITextField *)findTextFieldInSearchBar:(UISearchBar *)searchBar {
for (UIView *subview in searchBar.subviews) {
for (UIView *nestedSubview in subview.subviews) {
if ([nestedSubview isKindOfClass:[UITextField class]]) {
return (UITextField *)nestedSubview;
}
}
}
return nil;
}
- (UIView *)bgView {
if (!_bgView) {
UIView *bg = [[UIView alloc] init];
bg.backgroundColor = [UIColor whiteColor];
[bg setCornerRadius:16 cornerMask:kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner];
bg.userInteractionEnabled = NO;
_bgView = bg;
}
return _bgView;
}
- (UIView *)emptyView {
if (!_emptyView) {
_emptyView = [[UIView alloc] init];
UIImageView *icon = [[UIImageView alloc] initWithImage:[UIImageConstant defaultEmptyPlaceholder_UFO]];
[_emptyView addSubview:icon];
[icon mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.centerX.mas_equalTo(_emptyView);
make.size.mas_equalTo(CGSizeMake(80, 80));
}];
UILabel *emptyTitle = [UILabel labelInitWithText:YMLocalizedString(@"XPMomentsRecommendViewController0")
font:kFontRegular(14)
textColor:[UIColor colorWithWhite:0 alpha:0.4]];
emptyTitle.textAlignment = NSTextAlignmentCenter;
[_emptyView addSubview:emptyTitle];
[emptyTitle mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(_emptyView);
make.top.mas_equalTo(icon.mas_bottom).offset(6);
make.height.mas_equalTo(22);
}];
_emptyView.hidden = YES;
}
return _emptyView;
}
@end

View File

@@ -0,0 +1,16 @@
//
// YMLoginBindPhoneResultViewController.h
// YUMI
//
// Created by YUMI on 2021/9/17.
//
#import "BaseViewController.h"
NS_ASSUME_NONNULL_BEGIN
@class UserInfoModel;
@interface XPLoginBindPhoneResultViewController : BaseViewController
@property (nonatomic, strong) UserInfoModel *userInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,128 @@
//
// XPLoginBindPhoneResultViewController.m
// xplan-ios
//
// Created by on 2021/9/17.
//
#import "XPLoginBindPhoneResultViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <ReactiveObjC/ReactiveObjC.h>
///Tool
#import "UIImage+Utils.h"
///Model
#import "UserInfoModel.h"
///VC
#import "XPLoginVerifBindPhoneViewController.h"
@interface XPLoginBindPhoneResultViewController ()
@property (nonatomic, strong) UIView *containerView;
@property (nonatomic, strong) UIImageView *iconImageView;
@property (nonatomic, strong) UILabel *phoneLabel;
@property (nonatomic, strong) UIButton *changePhoneBtn;
@end
@implementation XPLoginBindPhoneResultViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self initViews];
[self setUpConstraints];
[self setConfigs];
}
#pragma mark - Private Method
- (void)initViews {
[self.view addSubview:self.containerView];
[self.containerView addSubview:self.iconImageView];
[self.containerView addSubview:self.phoneLabel];
[self.containerView addSubview:self.changePhoneBtn];
}
- (void)setConfigs {
self.title = YMLocalizedString(@"XPLoginBindPhoneResultViewController0");
NSMutableAttributedString *titleAtt = [[NSMutableAttributedString alloc]initWithString:YMLocalizedString(@"XPLoginBindPhoneResultViewController1") attributes:@{NSFontAttributeName:kFontSemibold(16),NSForegroundColorAttributeName:[DJDKMIMOMColor inputTextColor]}];
NSString *phone = self.userInfo.phone.length > 0 ? self.userInfo.phone : @"";
NSAttributedString *phoneAtt = [[NSAttributedString alloc]initWithString:[NSString stringWithFormat:@"\n%@ %@",self.userInfo.phoneAreaCode, phone] attributes:@{NSFontAttributeName:kFontSemibold(16),NSForegroundColorAttributeName:UIColorFromRGB(0x9168FA)}];
[titleAtt appendAttributedString:phoneAtt];
self.phoneLabel.attributedText = titleAtt;
}
- (void)setUpConstraints {
[self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(30));
make.centerX.mas_equalTo(0);
make.size.mas_equalTo(CGSizeMake(kGetScaleWidth(164), kGetScaleWidth(112)));
}];
[self.phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(184));
make.centerX.equalTo(self.containerView);
}];
[self.changePhoneBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.phoneLabel.mas_bottom).offset(kGetScaleWidth(47));
make.leading.trailing.mas_equalTo(0).inset(15);
make.centerX.mas_equalTo(0);
make.height.mas_equalTo(kGetScaleWidth(46));
}];
}
#pragma mark - Event Response
- (void)changePhoneBtnAction:(UIButton *)sender {
XPLoginVerifBindPhoneViewController *vc = [[XPLoginVerifBindPhoneViewController alloc] init];
vc.userInfo = self.userInfo;
vc.bindingPhoneNumType = XPBindingPhoneNumTypeConfirm;
[self.navigationController pushViewController:vc animated:YES];
}
#pragma mark - Getters And Setters
- (UIView *)containerView{
if (!_containerView) {
_containerView = [[UIView alloc] init];
_containerView.backgroundColor = [UIColor whiteColor];
}
return _containerView;
}
- (UIImageView *)iconImageView{
if (!_iconImageView) {
_iconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"login_bind_phone_bg"]];
}
return _iconImageView;
}
- (UILabel *)phoneLabel{
if (!_phoneLabel) {
_phoneLabel = [[UILabel alloc] init];
_phoneLabel.textAlignment = NSTextAlignmentCenter;
_phoneLabel.numberOfLines = 0;
}
return _phoneLabel;
}
- (UIButton *)changePhoneBtn {
if (!_changePhoneBtn) {
_changePhoneBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_changePhoneBtn setTitle:YMLocalizedString(@"XPLoginBindPhoneResultViewController2") forState:UIControlStateNormal];
[_changePhoneBtn setTitleColor:[DJDKMIMOMColor confirmButtonTextColor] forState:UIControlStateNormal];
[_changePhoneBtn.titleLabel setFont:kFontRegular(16)];
[_changePhoneBtn setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor], [DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
_changePhoneBtn.layer.masksToBounds = YES;
_changePhoneBtn.layer.cornerRadius = kGetScaleWidth(23);
[_changePhoneBtn addTarget:self action:@selector(changePhoneBtnAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _changePhoneBtn;
}
@end

View File

@@ -0,0 +1,30 @@
//
// XPLoginVerifBindPhoneViewController.h
// xplan-ios
//
// Created by 冯硕 on 2021/9/18.
//
#import "MvpViewController.h"
NS_ASSUME_NONNULL_BEGIN
/**
手机号绑定的类型
- TTBindingPhoneNumTypeNormal: 普通状态,首次绑定
- TTBindingPhoneNumTypeConfirm : 验证状态:验证已绑定的手机
*/
typedef NS_ENUM(NSUInteger, TTBindingPhoneNumType) {
XPBindingPhoneNumTypeNormal = 0,
XPBindingPhoneNumTypeEdit = 1,
XPBindingPhoneNumTypeConfirm = 2,
};
@class UserInfoModel;
@interface XPLoginVerifBindPhoneViewController : MvpViewController
@property (nonatomic, assign) TTBindingPhoneNumType bindingPhoneNumType;
@property(nonatomic,assign) BOOL isLogout;
///用户信息
@property (nonatomic, strong) UserInfoModel *userInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,289 @@
//
// XPLoginVerifBindPhoneViewController.m
// xplan-ios
//
// Created by on 2021/9/18.
//
#import "XPLoginVerifBindPhoneViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <ReactiveObjC/ReactiveObjC.h>
///Tool
#import "UIImage+Utils.h"
#import "CountDownHelper.h"
///Model
#import "UserInfoModel.h"
///P
#import "XPLoginVerifBindPhoneProtocol.h"
#import "XPLoginVerifBindPhonePresenter.h"
///VC
#import "LoginBindPhoneViewController.h"
#import "XPMineSettingViewController.h"
///View
#import "XPLoginBindSuccessView.h"
#import "LoginForgetEditView.h"
#import "XPLoginAraeViewController.h"
#import "XPMineLoginPasswordViewController.h"
@interface XPLoginVerifBindPhoneViewController ()<XPLoginAraeViewControllerDelegate,XPLoginVerifBindPhoneProtocol, CountDownHelperDelegate>
///
@property (nonatomic,strong) LoginForgetEditView *phoneView;
///
@property (nonatomic,strong) LoginForgetEditView *codeView;
///
@property (nonatomic,copy)NSString *pi_phoneAreaCode;
//
@property (nonatomic, strong) UIButton *confirmBtn;
//
@property (nonatomic, assign) BOOL isResetPhone;
@end
@implementation XPLoginVerifBindPhoneViewController
- (void)dealloc {
[[CountDownHelper shareHelper] stopCountDown];
}
- (XPLoginVerifBindPhonePresenter *)createPresenter {
return [[XPLoginVerifBindPhonePresenter alloc] init];
}
- (void)viewDidLoad {
[super viewDidLoad];
NSString *code = [NSString getCountryCode];
self.pi_phoneAreaCode = [code stringByReplacingOccurrencesOfString:@"+" withString:@""];
[self initSubViews];
[self initSubViewConstraints];
[self setConfigs];
[self setEvents];
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[[CountDownHelper shareHelper] stopCountDown];
self.codeView.authCodeButton.enabled= YES;
[self.codeView.authCodeButton setTitle:YMLocalizedString(@"XPLoginVerifBindPhoneViewController11") forState:UIControlStateNormal];
}
#pragma mark - Private Method
- (void)initSubViews {
[CountDownHelper shareHelper].delegate = self;
self.view.backgroundColor = [UIColor whiteColor];
[self.view addSubview:self.codeView];
[self.view addSubview:self.phoneView];
[self.view addSubview:self.confirmBtn];
}
- (void)initSubViewConstraints {
[self.phoneView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(30));
make.leading.trailing.equalTo(self.view).inset(kGetScaleWidth(15));
make.height.mas_equalTo(kGetScaleWidth(48));
}];
[self.codeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.height.equalTo(self.phoneView);
make.top.equalTo(self.phoneView.mas_bottom).mas_offset(kGetScaleWidth(25));
}];
[self.confirmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.equalTo(self.view).inset(kGetScaleWidth(15));
make.height.mas_equalTo(kGetScaleWidth(46));
make.top.mas_equalTo(kGetScaleWidth(275));
}];
}
#pragma mark -
- (void)setConfigs {
switch (self.bindingPhoneNumType) {
case XPBindingPhoneNumTypeEdit:{
self.navigationItem.title = YMLocalizedString(@"XPLoginVerifBindPhoneViewController0");
}
break;
case XPBindingPhoneNumTypeNormal:{
self.navigationItem.title = YMLocalizedString(@"XPLoginVerifBindPhoneViewController1");
}
break;
case XPBindingPhoneNumTypeConfirm:{
self.navigationItem.title = YMLocalizedString(@"XPLoginVerifBindPhoneViewController2");
[self.confirmBtn setTitle:YMLocalizedString(@"XPLoginVerifBindPhoneViewController3") forState:UIControlStateNormal];
if (self.userInfo.isBindPhone) {
// self.phoneNumTextField.enabled = NO;
// self.phoneNumTextField.text = self.userInfo.phone;
}
}
break;
default:
break;
}
RAC(self.confirmBtn,enabled) = [RACSignal combineLatest:@[self.phoneView.textField.rac_textSignal,self.codeView.textField.rac_textSignal] reduce:^(NSString *phone,NSString *code){
return @(phone.length > 0 && code.length == 5);
}];
}
#pragma mark - XPChooseAreaCodeVCDelegate
-(void)chooseAreaCodeSuccess:(NSString *)code{
self.pi_phoneAreaCode = code;
self.phoneView.areaCode = [NSString stringWithFormat:@"+%@",code];
}
-(void)chooseAreaCodeAction{
XPLoginAraeViewController *codeVC = [XPLoginAraeViewController new];
codeVC.delegate = self;
[self.navigationController pushViewController:codeVC animated:YES];
}
#pragma mark
- (void)setEvents {
@weakify(self)
//
[[[self.codeView.authCodeButton rac_signalForControlEvents:UIControlEventTouchUpInside] filter:^BOOL(__kindof UIControl * _Nullable value) {
//
if (self.phoneView.textField.text.length == 0) {
[self showErrorToast:YMLocalizedString(@"XPLoginVerifBindPhoneViewController4")];
return NO;
}
return YES;
}] subscribeNext:^(id _Nullable x) {
@strongify(self);
[self.presenter phoneSmsCode:[NSString stringWithFormat:@"%@%@",self.pi_phoneAreaCode,self.phoneView.textField.text] type:self.bindingPhoneNumType == XPBindingPhoneNumTypeConfirm ? GetSmsType_Unbind_Phone : GetSmsType_Bind_Phone phoneAreaCode:self.pi_phoneAreaCode];
}];
// //
[[[self.confirmBtn rac_signalForControlEvents:UIControlEventTouchUpInside] filter:^BOOL(__kindof UIControl * _Nullable value) {
@strongify(self)
//
if (self.phoneView.textField.text.length == 0) {
[self showErrorToast:YMLocalizedString(@"XPLoginVerifBindPhoneViewController6")];
return NO;
}else if (self.codeView.textField.text.length == 0) {
[self showErrorToast:YMLocalizedString(@"XPLoginVerifBindPhoneViewController7")];
return NO;
}else {
return YES;
}
}] subscribeNext:^(id _Nullable x) {
@strongify(self)
[self.view endEditing:YES];
if (self.bindingPhoneNumType == XPBindingPhoneNumTypeConfirm) {
[self.presenter checkMoblieCodeWithMoblie:[NSString stringWithFormat:@"%@%@",self.pi_phoneAreaCode,self.phoneView.textField.text] code:self.codeView.textField.text phoneAreaCode:self.pi_phoneAreaCode];
} else {
[self.presenter bindkMoblieCodeWithMoblie:[NSString stringWithFormat:@"%@%@",self.pi_phoneAreaCode,self.phoneView.textField.text] code:self.codeView.textField.text phoneAreaCode:self.pi_phoneAreaCode];
}
} error:^(NSError * _Nullable error) {
}];
}
#pragma mark - XPLoginVerifBindPhoneProtocol
- (void)phoneSmsCodeSuccess {
self.codeView.authCodeButton.enabled = NO;
[self showSuccessToast:YMLocalizedString(@"XPLoginVerifBindPhoneViewController8")];
[[CountDownHelper shareHelper] openCountdownWithTime:60];
}
- (void)checkMoblieCodeWithMoblieSuccess {
[self showSuccessToast:YMLocalizedString(@"XPLoginVerifBindPhoneViewController9")];
[[CountDownHelper shareHelper] stopCountDown];
XPLoginVerifBindPhoneViewController *vc = [[XPLoginVerifBindPhoneViewController alloc] init];
vc.bindingPhoneNumType = XPBindingPhoneNumTypeEdit;
vc.userInfo = self.userInfo;
[self.navigationController pushViewController:vc animated:YES];
}
- (void)bindMoblieCodeWithMoblieSuccess {
[[CountDownHelper shareHelper] stopCountDown];
//
if (self.bindingPhoneNumType == XPBindingPhoneNumTypeEdit) {
@weakify(self);
[XPLoginBindSuccessView showBindSuccessViewWithHandler:^{
@strongify(self);
//
__block __kindof UIViewController *vc;
[self.navigationController.childViewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if ([obj isKindOfClass:[XPMineSettingViewController class]]) {
vc = obj; // VC
}
}];
if ([self.navigationController.childViewControllers containsObject:vc]) {
[self.navigationController popToViewController:vc animated:YES];
} else {
[self.navigationController popViewControllerAnimated:YES];
}
}];
} else if (self.bindingPhoneNumType == XPBindingPhoneNumTypeNormal) {
@weakify(self);
if(self.isLogout == YES){
XPMineLoginPasswordViewController *vc = [[XPMineLoginPasswordViewController alloc] init];
vc.userInfo = self.userInfo;
vc.isModifiPwd = NO;
vc.isLogout = YES;
[self.navigationController pushViewController:vc animated:YES];
return;
}
[XPLoginBindSuccessView showBindSuccessViewWithHandler:^{
@strongify(self);
[self.navigationController popViewControllerAnimated:YES];
}];
}
self.confirmBtn.enabled = YES; //
}
#pragma mark - CountDownHelperDelegate
///
- (void)onCountdownOpen:(int)time {
[self.codeView.authCodeButton setTitle:[NSString stringWithFormat:YMLocalizedString(@"XPLoginVerifBindPhoneViewController10"), time] forState:UIControlStateDisabled];
}
///
- (void)onCountdownFinish {
self.codeView.authCodeButton.enabled= YES;
[self.codeView.authCodeButton setTitle:YMLocalizedString(@"XPLoginVerifBindPhoneViewController11") forState:UIControlStateNormal];
}
#pragma mark - Getters And Setters
- (UIButton *)confirmBtn {
if (!_confirmBtn) {
_confirmBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_confirmBtn setTitle:YMLocalizedString(@"XPLoginVerifBindPhoneViewController14") forState:UIControlStateNormal];
[_confirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_confirmBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateDisabled];
[_confirmBtn.titleLabel setFont:kFontRegular(16)];
_confirmBtn.layer.cornerRadius = kGetScaleWidth(23);
_confirmBtn.layer.masksToBounds = YES;
_confirmBtn.enabled = NO;
[_confirmBtn setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor], [DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
}
return _confirmBtn;
}
- (LoginForgetEditView *)phoneView {
if (!_phoneView) {
_phoneView = [[LoginForgetEditView alloc] init];
// _phoneView.placeholder = YMLocalizedString(@"LoginForgetPasswordViewController7");
_phoneView.type = LoginForgetEditViewTypeNormal;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(chooseAreaCodeAction)];
[_phoneView.codeView addGestureRecognizer:tap];
}
return _phoneView;
}
- (LoginForgetEditView *)codeView {
if (!_codeView) {
_codeView = [[LoginForgetEditView alloc] init];
_codeView.placeholder = YMLocalizedString(@"XPLoginVerifBindPhoneViewController17");
_codeView.type = LoginForgetEditViewTypeSms;
}
return _codeView;
}
@end

View File

@@ -0,0 +1,22 @@
//
// Api+Message.h
// YUMI
//
// Created by zu on 2021/12/8.
//
#import "Api.h"
NS_ASSUME_NONNULL_BEGIN
@interface Api (Message)
+ (void)getChatLimit:(HttpRequestHelperCompletion)completion receiverUid:(NSString *)receiverUid;
+ (void)checkLimit:(HttpRequestHelperCompletion)completion receiverUid:(NSString *)receiverUid;
+ (void)sendRoomImageMessage:(HttpRequestHelperCompletion)completion picUrl:(NSString *)picUrl roomUid:(NSInteger)roomUid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,26 @@
//
// Api+Message.m
// YUMI
//
// Created by zu on 2021/12/8.
//
#import "Api+Message.h"
#import <Base64/MF_Base64Additions.h>
@implementation Api (Message)
+ (void)getChatLimit:(HttpRequestHelperCompletion)completion receiverUid:(NSString *)receiverUid {
NSString * fang = [NSString stringFromBase64String:@"cHJpdmF0ZUNoYXQvbGltaXQ="];///privateChat/limit
[self makeRequest:fang method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, receiverUid,nil];
}
+ (void)checkLimit:(HttpRequestHelperCompletion)completion receiverUid:(NSString *)receiverUid {
[self makeRequest:@"privateChat/limitV2" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, receiverUid,nil];
}
+ (void)sendRoomImageMessage:(HttpRequestHelperCompletion)completion picUrl:(NSString *)picUrl roomUid:(NSInteger)roomUid {
[self makeRequest:@"roomScreen/sendPic" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, picUrl, @(roomUid), nil];
}
@end

View File

@@ -0,0 +1,821 @@
//
// AttachmentModel.h
// YUMI
//
// Created by YUMI on 2021/11/16.
//
#import <Foundation/Foundation.h>
#import <NIMSDK/NIMSDK.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, CustomMessageType) {
///房间提示
CustomMessageType_Room_Tip = 2,
///送礼物的接口
CustomMessageType_Gift = 3,
///账户更新
CustomMessageType_Account = 5,
///关注的主播上线
CustomMessageType_Member_Online = 6,
///队列操作
CustomMessageType_Queue = 8,
///表情
CustomMessageType_Face = 9,
///推文
CustomMessageType_Tweet = 10,
///全麦送
CustomMessageType_AllMicroSend = 12,
///座驾相關通知
CustomMessageType_Car_Notify = 15,
///踢出房间
CustomMessageType_Kick_User = 18,
///小秘书消息
CustomMessageType_Secretary = 19,
///房间信息更新
CustomMessageType_Update_RoomInfo = 20,
///应用内分享
CustomMessageType_Application_Share = 22,
///系统通知,自定义布局消息(带确认、取消)
CustomMessageType_Message_Handle = 23,
///用户升级
CustomMessageType_User_UpGrade = 24,
///糖果树
CustomMessageType_Candy_Tree = 26,
///排麦
CustomMessageType_Arrange_Mic = 30,
///房间内PK
CustomMessageType_Room_PK = 31,
///家族
CustomMessageType_Hall = 32,
///房间礼物值
CustomMessageType_Room_GiftValue = 42,
///版本升级
CustomMessageType_Version_Update = 49,
///公会超管
CustomMessageType_Hall_Super_Admin = 50,
///动态
CustomMessageType_Monents = 52,
///收藏
CustomMessageType_Collection_Room = 59,
///房间红包
CustomMessageType_RedPacket = 60,
///福袋消息
CustomMessageType_LuckyBag = 61,
///发现萌新
CustomMessageType_FindNew = 62,
///房间火箭
CustomMessageType_RoomBoom = 63,
/// CP 礼物
CustomMessageType_CP = 64,
/// 房间活动
CustomMessageType_Public_Event = 68,
///塔罗
CustomMessageType_Tarot = 71,
///相亲
CustomMessageType_RoomPlay_Dating = 72,
///私聊风险提醒
CustomMessageType_Chat_Risk_Alert = 75,
///首充奖励
CustomMessageType_First_Recharge_Reward = 76,
///访客记录
CustomMessageType_First_VisitorRecord = 78,
///航海
CustomMessageType_Room_Sailing = 81,
///跨房PK
CustomMessageType_Across_Room_PK = 83,
///VIPVIP
CustomMessageType_Noble_VIP = 85,
///个播房观众点击空坑位,房主收到请求上麦提示
CustomMessageType_AnchorRoom_AudienceUpMic = 86,
///技能卡
CustomMessageType_Skill_Card = 87,
///个播小时榜
CustomMessageType_Anchor_Hour_Rank = 89,
///个播粉丝团
CustomMessageType_Anchor_FansTeam = 90,
///牌照房小时榜
CustomMessageType_License_Hour_Rank = 91,
///任务完成通知
CustomMessageType_Task_Complete = 92,
///礼物合成
CustomMessageType_Gift_Compound = 93,
///涂鸦礼物
CustomMessageType_Graffiti_Gift = 94,
///免费礼物倒计时重置时间
CustomMessageType_Free_Gift_Star_Reset_Time = 96,
///精灵密藏
// CustomMessageType_Treasure_Fairy = 97,
///寻爱之旅
CustomMessageType_Look_Love = 98,
///联系客服
CustomMessageType_Service_Reply = 99,
///通用h5
CustomMessageType_Common_H5 = 100,
///房间相册
CustomMessageType_Room_Album = 101,
///守护星球
CustomMessageType_Guardian_Planet = 102,
///通用公屏信息
CustomMessageType_General_Public_Screen = 103,
///疯狂动物园飘屏
CustomMessageType_Graffiti_Star_Kitchen = 104,
///超级礼物
CustomMessageType_Super_Gift = 106,
///通用飘屏
CustomMessageType_General_Floating_Screen = 107,
///聊天大厅上头条
CustomMessageType_Chat_Hall_Headlines = 108,
///游戏
CustomMessageType_Chat_Room_Game = 109,
///家族新协议
CustomMessageType_New_Hall = 110,
///房间流水
CustomMessageType_MoneyFlow = 111,
///游戏陪玩开黑
CustomMessageType_Game_Order = 112,
///房間背景更新
CustomMessageType_Custom_Room_Background = 113,
///房间等级更新
CustomMessageType_RoomLevel_Update = 114,
/// 进房类型
CustomMessageType_User_Enter_Room = 115,
/// 新系統消息
CustomMessageType_System_message = 116,
/// 关系更新消息
CustomMessageType_CP_message = 117,
/// 客户端独立收发的消息, 从 1000 开始
ClientMessage_Type = 1000,
MicRelationship_Type = 1001,
};
typedef NS_ENUM(NSUInteger, ClientMessageType) {
ClientMessage_UpMic_Ask = 10001,
ClientMessage_UpMic_Agree = 10002,
ClientMessage_UpMic_Reject = 10003,
};
typedef NS_ENUM(NSUInteger, MicRelationshipType) {
MicRelationship_CP = 10011,
};
typedef NS_ENUM(NSUInteger, CustomMessageTypePublicEvent) {
Custom_Message_Sub_Public_Event_message = 681,
};
/// first = CustomMessageType_CP_message
typedef NS_ENUM(NSUInteger, CustomMessageTypeCPmessage) {
Custom_Message_Sub_CP_message_request = 1170,
Custom_Message_Sub_CP_message_result = 1171,
};
/// first = CustomMessageType_System_message
typedef NS_ENUM(NSUInteger, CustomMessageTypeSystemmessage) {
Custom_Message_Sub_System_message = 1160,
};
///first = CustomMessageType_User_Enter_Room
typedef NS_ENUM(NSUInteger, CustomMessageTypeUserEnterRoom) {
/// 图片消息
Custom_Message_Sub_Pic_Message = 1151,
/// 用户进房
Custom_Message_Sub_User_Enter_Room = 1152,
};
///first = CustomMessageType_Room_Tip
typedef NS_ENUM(NSUInteger, CustomMessageSubRoomTip) {
///分享房间
Custom_Message_Sub_Room_Tip_ShareRoom = 21,
///关注房主
Custom_Message_Sub_Room_Tip_Attention_Owner = 22,
};
///first = CustomMessageType_Gift
typedef NS_ENUM(NSUInteger, CustomMessageSubGift) {
///发送礼物
Custom_Message_Sub_Gift_Send = 31,
///全服发送礼物
Custom_Message_Sub_Gift_ChannelNotify = 32,
///发送 福袋 礼物
Custom_Message_Sub_Gift_LuckySend = 34,
///发送 嵌入式礼物
Custom_Message_Sub_Gift_EmbeddedStyle = 35,
};
///first = CustomMessageType_Account
typedef NS_ENUM(NSUInteger, CustomMessageSubAccount) {
//账户余额钻石变更
Custom_Message_Sub_Account_Changed = 51,
};
///first = CustomMessageType_Member_Online
typedef NS_ENUM(NSInteger, CustomMessageSubOnLine) {
///房主的主播上线了
Custom_Message_Type_Attention_Member_Online = 61
};
///first = CustomMessageType_Queue
typedef NS_ENUM(NSInteger, CustomMessageSubQueue) {
///邀请上麦
Custom_Message_Sub_Queue_Invite = 81,
///踢下麦
Custom_Message_Sub_Queue_Kick = 82,
};
//first = CustomMessageType_Face
typedef NS_ENUM(NSUInteger, CustomMessageSubFace) {
///发送
Custom_Message_Sub_Face_Send = 91,
};
///first == CustomMessageType_Tweet
typedef NS_ENUM(NSInteger, CustomMessageSubTweet) {
///推文的内容
Custom_Message_Sub_Tweet_News = 101,
};
///first = CustomMessageType_ALLMicroSend
typedef NS_ENUM(NSUInteger, CustomMessageSubAllMicroSend) {
///全麦送礼物
Custom_Message_Sub_AllMicroSend = 121,
///非全麦 多人送礼
Custom_Message_Sub_AllBatchSend = 123,
///非全麦 多人送福袋礼物
Custom_Message_Sub_AllBatchMicroLuckySend = 124,
///全麦送 福袋 礼物 122老版本占用了
Custom_Message_Sub_AllMicroLuckySend = 125,
};
///first == CustomMessageType_Car_Notify
typedef NS_ENUM(NSUInteger, CustomMessageSubCar) {
Custom_Message_Sub_Car_OutDate = 151,
Custom_Message_Sub_Car_EnterRoom = 159, //进房动画
};
///first = CustomMessageType_Kick_User
typedef NS_ENUM(NSUInteger, CustomNotificationSubKick) {
///拉黑
Custom_Message_Sub_Kick_BlackList = 182,
///踢出房间
Custom_Message_Sub_Kick_BeKicked = 181,
};
///first = CustomMessageType_Secretary
typedef NS_ENUM(NSUInteger, CustomNotificationSecretary) {
///跳转页面
Custom_Message_Sub_Secretary_Router = 191,
};
///first = CustomMessageType_Update_RoomInfo
typedef NS_ENUM(NSUInteger, CustomMessageSubUpdateRoomInfo) {
///动画开关状态更新
Custom_Message_Sub_Update_RoomInfo_AnimateEffect = 201,
///公屏开关更新
Custom_Message_Sub_Update_RoomInfo_MessageState = 203,
///通用公屏提示文案, 公屏纯文本展示消息 data[@"tip"]
Custom_Message_Sub_Update_RoomInfo_Notice = 204,
///红包开关通知
Custom_Message_Sub_Update_RoomInfo_RedPacket = 205,
///清空公屏
Custom_Message_Sub_Update_RoomInfo_CleanScreen = 206,
};
///first = CustomMessageType_Application_Share
typedef NS_ENUM(NSInteger, CustomMessageSubApplicationShare) {
///分享房间
Custom_Message_Sub_Application_Share_Room = 221,
};
///first = CustomMessageType_Applica
typedef NS_ENUM(NSInteger, CustomMessageSubMessageHandle) {
Custom_Message_Sub_Message_Handle_Content = 231, //文本
Custom_Message_Sub_Message_Handle_Bussiness = 232, //业务
};
///first = CustomMessageType_User_UpGrade
typedef NS_ENUM(NSInteger, CustomMessageSubUserUpgrade) {
///用户等级
Custom_Message_Sub_User_UpGrade_Exper = 241,
///魅力等级
Custom_Message_Sub_User_UpGrade_Charm = 242
};
///first = CustomMessageType_Candy_Tree
typedef NS_ENUM(NSUInteger, CustomMessageSubCandyTree) {
//.自己可见 一级礼物(最小)
Custom_Message_Sub_Candy_Tree_Me = 261,
///当前房间可见 二级礼物
Custom_Message_Sub_Candy_Tree_InRoom = 262,
///所有房间可见 三级礼物
Custom_Message_Sub_Candy_Tree_AllRoom = 263,
///所有房间可见+小秘书 四级礼物
Custom_Message_Sub_Candy_Tree_AllRoom_Notify = 264,
///五级礼物
Custom_Message_Sub_Candy_Tree_InRoom_NeedAllMicSend = 265,
//暴击的没用 不写了
};
///first = CustomMessageType_Arrange_Mic
typedef NS_ENUM(NSUInteger, CustomNotiHeaderArrangeMic) {
///队列从无人排麦到有人排麦
Custom_Message_Sub_Arrange_Mic_Non_Empty= 301,
///队列从有人排麦到无人排麦
Custom_Message_Sub_Arrange_Mic_Empty= 302,
///开启排麦
Custom_Message_Sub_Arrange_Mic_Mode_Open= 303,
///关闭排麦
Custom_Message_Sub_Arrange_Mic_Mode_Close= 304,
///将坑位设置成自由麦
Custom_Message_Sub_Arrange_Mic_Free_Mic_Open= 305,
///将坑位设置为排麦
Custom_Message_Sub_Arrange_Mic_Free_Mic_Close= 306,
};
///first =CustomMessageType_Room_PK
typedef NS_ENUM(NSUInteger, CustomMessageSubRoomPK){
///从无人报名pk排麦到有人报名pk排麦
Custom_Message_Sub_Room_PK_Non_Empty = 311,
///从有人报名pk排麦到无人报名pk排麦
Custom_Message_Sub_Room_PK_Empty = 312,
///创建了pk模式
Custom_Message_Sub_Room_PK_Mode_Open = 313,
///关闭pk模式
Custom_Message_Sub_Room_PK_Mode_Close = 314,
///pk开始
Custom_Message_Sub_Room_PK_Start = 315,
///pk结果
Custom_Message_Sub_Room_PK_Result = 316,
///重新开始
Custom_Message_Sub_Room_PK_Re_Start= 317,
///管理员邀请上麦(只用在客户端)
Custom_Message_Sub_Room_PK_Manager_Up_Mic = 318,
};
///first=CustomMessageType_Hall
typedef NS_ENUM(NSUInteger, Custom_Noti_Sub_HALL) {
///申请加入厅
Custom_Message_Sub_Hall_Apply_Join = 321,
///管理邀请入厅
Custom_Message_Sub_Hall_Manager_Invite = 322,
///申请退出厅
Custom_Message_Sub_Hall_Apply_Exit = 323,
///模厅普通通知
Custom_Message_Sub_Hall_Notice = 324,
///设置为模厅
Custom_Message_Sub_Hall_Become_Hall = 325,
};
///first = CustomMessageType_Room_GiftValue
typedef NS_ENUM(NSUInteger, CustomMessageSubRoomGiftValue) {
///礼物值同步
Custom_Message_Sub_Room_GiftValue_Sync = 421
};
///first = CustomMessageType_Version_Update)
typedef NS_ENUM(NSUInteger, CustomMessageVersionUpdateValue) {
///版本升级
Custom_Message_Version_Update_Value = 491
};
///first = CustomMessageType_Hall_Super_Admin
typedef NS_ENUM(NSInteger, CustomMessageSubHallSuperAdmin) {
///超管解除陪伴房的进房限制
Custom_Message_Sub_Hall_Super_Admin_Remove_CP_Room_Limit = 501,
///超管解除多人房的房间密码
Custom_Message_Sub_Hall_Super_Admin_Remove_Room_Pwd = 502,
///锁麦
Custom_Message_Sub_Hall_Super_Admin_Lock_Mic = 503,
///闭麦
Custom_Message_Sub_Hall_Super_Admin_Mute_Mic = 504,
///踢人下麦
Custom_Message_Sub_Hall_Super_Admin_Kick_Down_Mic = 505,
///拉黑
Custom_Message_Sub_Hall_Super_Admin_Mark_Black = 506,
///踢出房间
Custom_Message_Sub_Hall_Super_Admin_Kick_Out_Room = 507,
///踢管理员出房间
Custom_Message_Sub_Hall_Super_Admin_Kick_Manager_Out_Room = 508,
};
/// first == CustomMessageType_Monents
typedef NS_ENUM(NSUInteger, Custom_Noti_Sub_Dynamic) {
///未读更新
Custom_Message_Sub_Monents_Unread_Update = 521,
/// 违禁删除
Custom_Message_Sub_Monents_Ban_Delete = 522,
/// 动态审核通过
Custom_Message_Sub_Monents_Approved = 523,
/// app内分享动态
Custom_Message_Sub_Monents_Share = 524,
};
///first = CustomMessageType_RedPacket
typedef NS_ENUM(NSUInteger, CustomMessageSubRedPacket) {
Custom_Message_Sub_RoomGiftRedPacket = 601, //房间礼物红包
Custom_Message_Sub_RoomDiamandRedPacket = 602, //房间钻石红包
Custom_Message_Sub_AllGiftRedPacket = 603, //全服礼物红包
Custom_Message_Sub_AllDiamandRedPacket = 604, //全服钻石红包
Custom_Message_Sub_OpenRedPacketSuccess = 605,//抢红包成功
Custom_Message_Sub_NewRoomDiamandRedPacket = 606, //新版本房间钻石红包
Custom_Message_Sub_LuckyPackage = 607, // 最新版本房间红包推送
};
///first = CustomMessageType_Collection_Room
typedef NS_ENUM(NSUInteger, CustomMessageSubCollectRoom) {
/// 福袋礼物房间飘屏通知
Custom_Message_Sub_Room_Gift_LuckBag= 610,
/// 福袋礼物全服飘屏通知
Custom_Message_Sub_Room_Gift_LuckBag_Server = 611,
/// 福袋礼物全服飘屏通知
Custom_Message_Sub_Room_Gift_LuckBag_FullScree = 612,
};
///first == CustomMessageType_FindNew 发现萌新
typedef NS_ENUM(NSUInteger, CustomMessageFindNewUserGreet) {
/// 打招呼
Custom_Message_Find_New_Greet_New_User = 621,
};
///first == CustomMessageType_RoomBoom 房间火箭
typedef NS_ENUM(NSUInteger, CustomMessageRoomBoom) {
/// 经验值更新
Custom_Message_Room_Boom_EXP = 631,
/// 升级
Custom_Message_Room_Boom_LevelUp = 632,
/// 奖励
Custom_Message_Room_Boom_Award = 633,
};
///跳转类型
typedef NS_ENUM(NSUInteger, CustomMessageRouter) {
/// 跳转H5
Custom_Message_Router_H5 = 2,
};
///first = CustomMessageType_LuckyBag
typedef NS_ENUM(NSUInteger, CustomMessageSubLuckyBag) {
///收藏房间公屏提示消息
Custom_Message_Sub_Collect_Room_Tips = 591,
/// 提醒用户收藏房间
Custom_Message_Sub_Collect_Room_Remind_User = 592,
};
//first = CustomMessageType_Free_Gift_Star_Reset_Time
typedef NS_ENUM(NSUInteger, CustomMessageFreeGiftStarResetTime) {
///免费礼物倒计时重置时间
Custom_Message_Sub_Free_Gift_Star_Reset_Time = 960,
///更新礼物信息
Custom_Message_Sub_Update_Gift_Information = 961,
};
///CustomMessageType_Tarot
typedef NS_ENUM(NSUInteger, CustomMessageSubTarot) {
/// 塔罗中奖消息
///初级
Custom_Message_Sub_Tarot_Novice = 712,
///中初
Custom_Message_Sub_Tarot_Intermediate = 713,
///高级
Custom_Message_Sub_Tarot_Advanced = 714,
};
///CustomMessageType_RoomPlay_Dating
typedef NS_ENUM(NSUInteger, CustomMessageSubRoomPlayDating){
///选择心动用户
Custom_Message_Sub_Room_Play_Dating_Pick_Heart= 721,
///公布结果
Custom_Message_Sub_Room_Play_Dating_Public_Result = 722,
///选择了对象 但不是互选 客户端收到结果之后自动加到 公屏上
Custom_Message_Sub_Room_Play_Dating_Result_Not_Mutual = 723,
///互选的 客户端收到结果之后自动加到 公屏上
Custom_Message_Sub_Room_Play_Dating_Result_Mutual = 724,
};
///first = CustomMessageType_Chat_Risk_Alert
/// 访客记录
typedef NS_ENUM(NSUInteger, CustomMessageSubChatRiskAlert) {
/// 私聊风险提醒
Custom_Message_Sub_Chat_Risk_Alert= 751,
};
///first = CustomMessageType_First_Recharge_Reward
typedef NS_ENUM(NSUInteger, CustomMessageSubFirstRecharge) {
/// 首充完成
Custom_Message_Sub_Room_First_Recharge_Reward= 761,
/// 新用户专享优惠充值完成
Custom_Message_Sub_New_User_Recharge_Reward = 762,
};
/// 访客记录
typedef NS_ENUM(NSUInteger, CustomMessageSubVisitorRecord) {
/// 访客记录
Custom_Message_Sub_Visitor_Record = 781,
};
///first == CustomMessageType_Room_Sailing
typedef NS_ENUM(NSInteger, CustomMessageSubSailing) {
//自己可见 一级礼物(最小)
Custom_Message_Sub_Sailing_Me = 811,
//当前房间可见 二级礼物
Custom_Message_Sub_Sailing_InRoom = 812,
//所有房间可见 三级礼物
Custom_Message_Sub_Sailing_AllRoom = 813,
//所有房间可见+小秘书 四级礼物(最大)
Custom_Message_Sub_Sailing_AllRoom_Notify = 814,
//开箱子开到全麦送 (服务端发)
Custom_Message_Sub_Sailing_InRoom_NeedAllMicSend = 815,
};
///first = CustomMessageType_Across_Room_PK
typedef NS_ENUM(NSUInteger, CustomMessageSubAcrossRoomPK) {
/// 收到跨房PK邀请
Custom_Message_Sub_AcrossRoomPK_Invite = 831,
/// 拒绝跨房PK
Custom_Message_Sub_AcrossRoomPK_Reject = 832,
/// 接受跨房PK
Custom_Message_Sub_AcrossRoomPK_Accept = 833,
/// 面板消息
Custom_Message_Sub_AcrossRoomPK_Panel = 834,
/// 跨房PK结束通知
Custom_Message_Sub_AcrossRoomPK_End = 835,
/// 跨房PK结束飘屏
Custom_Message_Sub_AcrossRoomPK_Result = 836,
///收到个播PK邀请
Custom_Message_Sub_AnchorPK_Invite = 837,
///拒绝个播pk
Custom_Message_Sub_AnchorPK_Reject = 838,
///接收个播PK
Custom_Message_Sub_AnchorPK_Accept = 839,
///个播PK面板消息
Custom_Message_Sub_AnchorPK_Panel = 8310,
///个播PK结束通知收到后进入惩罚阶段)
Custom_Message_Sub_AnchorPK_End = 8311,
///个播PK结束飘屏
Custom_Message_Sub_AnchorPK_Result = 8312,
///个播PK完成
Custom_Message_Sub_AnchorPK_Finish = 8313,
///收到预约PK倒计时
Custom_Message_Sub_PK_BeginTime = 8314,
///匹配个播随机PK等待超时
Custom_Message_Sub_AnchorPK_Match_TimeOut = 8315,
///个播pk禁用对方麦克风
Custom_Message_Sub_AnchorPK_MuteOtherMic = 8316,
};
///first = CustomMessageType_Noble_VIP
typedef NS_ENUM(NSUInteger, CustomMessageSubNobleVIP) {
/// 开通VIP房内消息公屏显示
Custom_Message_Sub_Room_Open_Noble_VIP = 851,
/// 开通VIP成功通知消息
Custom_Message_Sub_Open_Noble_Success = 852,
/// VIP升级房内消息公屏显示
Custom_Message_Sub_Room_Noble_LevelUp = 853,
/// VIP升级用户通知消息弹窗
Custom_Message_Sub_Noble_LevelUp_User = 854,
/// VIP升级全服飘屏通知消息
Custom_Message_Sub_Room_Noble_LevelUp_Suspend = 855,
/// VIP升级全服房间公屏通知消息
Custom_Message_Sub_AllRoom_Noble_LevelUp_Suspend = 856,
/// VIP小喇叭房间消息
Custom_Message_Sub_Room_Trumpet = 857,
};
///first = CustomMessageType_Anchor_Hour_Rank
typedef NS_ENUM(NSUInteger, CustomMessageAnchorHourRank) {
///个播小时榜
Custom_Message_Sub_Anchor_Hour_Rank = 891,
};
///first = CustomMessageType_Anchor_FansTeam
typedef NS_ENUM(NSUInteger, CustomMessageAnchorFansTeam) {
///开通粉丝团成功
Custom_Message_Sub_FansTeam_Open_Success = 901,
///开通粉丝团失败
Custom_Message_Sub_FansTeam_Open_Fail = 902,
///用户加入粉丝团成功
Custom_Message_Sub_FansTeam_Join_Success = 903,
///用户退出粉丝团成功
Custom_Message_Sub_FansTeam_Out_Success = 904,
};
///first = CustomMessageType_Licnese_Hour_Rank
typedef NS_ENUM(NSUInteger, CustomMessageLicneseHourRank) {
///牌照房小时榜
Custom_Message_Sub_License_Hour_Rank = 911,
};
///first = CustomMessageType_Task_Complete
typedef NS_ENUM(NSUInteger, CustomMessageTaskComplete) {
///任务完成通知
Custom_Message_Sub_TaskComplete = 921,
};
///first = CustomMessageType_Gift_Compound
typedef NS_ENUM(NSUInteger, CustomMessageGiftCompound) {
///礼物合成通知
Custom_Message_Sub_Gift_Compound = 931,
};
///first = CustomMessageType_Graffiti_Gift
typedef NS_ENUM(NSUInteger, CustomMessageGraffitiGift) {
///涂鸦礼物
Custom_Message_Sub_Graffiti_Gift = 941,
};
//first = CustomMessageType_Graffiti_Star_Kitchen
typedef NS_ENUM(NSUInteger, CustomMessageGraffitiStarKitchen) {
/// 已删除相关代码
// 星级厨房礼物全服飘屏通知
Custom_Message_Sub_Star_Kitchen_Server = 1041,
// 星级厨房礼物全服飘屏通知
Custom_Message_Sub_Star_Kitchen_FullScreen = 1042,
};
///夺宝精灵 CustomMessageType_Treasure_Fairy = 97,
//typedef NS_ENUM(NSInteger, CustomMessageTreasureFairy) {
// ///精灵赠送
// Custom_Message_Sub_Treasure_Fairy_Send_Fairy = 9701,
// ///索要精灵
// Custom_Message_Sub_Treasure_Fairy_Ask_Fairy = 9702,
//
//
// ///抽奖礼物
// ///抽奖L1礼物
// Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L1 = 9711,
// ///抽奖L2礼物
// Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L2 = 9712,
// ///抽奖L3礼物
// Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L3 = 9713,
// ///抽奖L4礼物
// Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L4 = 9714,
// ///抽奖L5礼物
// Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5 = 9715,
//
// ///抽奖获得的精灵球的
// /// 抽奖L1精灵球
// Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L1 = 9721,
// /// 抽奖L2精灵球
// Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L2 = 9722,
// /// 抽奖L3精灵球
// Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L3 = 9723,
// ///精灵球召唤礼物
// ///召唤L1
// Custom_Message_Sub_Treasure_Fairy_Convert_L1 = 9731,
// ///召唤L2
// Custom_Message_Sub_Treasure_Fairy_Convert_L2 = 9732,
// ///召唤L3
// Custom_Message_Sub_Treasure_Fairy_Convert_L3 = 9733,
//};
///first = CustomMessageType_Candy_Tree
typedef NS_ENUM(NSUInteger, CustomMessageSubLookLove) {
//.自己可见 一级礼物(最小)
Custom_Message_Sub_Look_Love_Me = 981,
///当前房间可见 二级礼物
Custom_Message_Sub_Look_Love_InRoom = 982,
///所有房间可见 三级礼物
Custom_Message_Sub_Look_Love_AllRoom = 983,
///所有房间可见+小秘书 四级礼物
Custom_Message_Sub_Look_Love_AllRoom_Notify = 984,
///五级礼物
Custom_Message_Sub_Look_Love_InRoom_NeedAllMicSend = 985,
//暴击的没用 不写了
};
///通用h5
//CustomMessageType_Common_H5 = 100
typedef NS_ENUM(NSUInteger, CustomMessageTypeCommonH5) {
///所有房间
Custom_Message_Sub_Common_H5_Novice = 1101,
///全服
Custom_Message_Sub_Common_H5_Advanced = 1102,
};
///房间相册
//CustomMessageType_Room_Album = 101,
typedef NS_ENUM(NSUInteger, CustomMessageTypeRoomAlbum) {
///所有房间
Custom_Message_Sub_Room_Album = 1011,
};
//CustomMessageType_Guardian_Planet = 102,
typedef NS_ENUM(NSUInteger, CustomMessageTypeGuardianPlanet) {
///所有房间
Custom_Message_Sub_Guardian_Planet_One_Room = 1021,//单房间
Custom_Message_Sub_Guardian_Planet_All_Room = 1022,///全部房间
};
///通用公屏信息
//CustomMessageType_General_Public_Screen = 10000,
typedef NS_ENUM(NSUInteger, CustomMessageTypeGeneralPublicScreen) {
///所有房间
Custom_Message_Sub_General_Public_Screen_One_Room = 1031,//单房间
Custom_Message_Sub_General_Public_Screen_All_Room = 1032,///全部房间
};
///超级礼物
//CustomMessageType_Super_Gift = 106,
typedef NS_ENUM(NSUInteger, CustomMessageTypeSuperGift) {
///所有房间
Custom_Message_Sub_Super_Gift = 1061,
// 送礼者显示中奖内容
Custom_Message_Sub_Super_Gift_Winning_Coins = 1062,
// 全服显示中奖内容
Custom_Message_Sub_Super_Gift_Winning_Coins_ALL_Room = 1063,
Custom_Message_Sub_Super_Gift_Room_Message = 1064, // 公屏消息
Custom_Message_Sub_Super_Gift_UI_Rffect = 1065, // 金币动效 & 大奖提示
Custom_Message_Sub_Super_Gift_Banner = 1066, // 飘屏
};
///通用飘屏
//CustomMessageType_General_Floating_Screen = 107,
typedef NS_ENUM(NSUInteger, CustomMessageTypeGeneralFloatingScreen) {
///所有房间
Custom_Message_Sub_General_Floating_Screen_One_Room = 1071,//单房间
Custom_Message_Sub_General_Floating_Screen_All_Room = 1072,//全部房间
};
///聊天大厅上头条
//CustomMessageType_Chat_Hall_Headlines = 108,
typedef NS_ENUM(NSUInteger, CustomMessageTypeChatHallHeadlines) {
///所有房间
Custom_Message_Sub_Chat_Hall_Headlines = 1081,//单房间
};
//CustomMessageType_Chat_Room_Game = 109,
typedef NS_ENUM(NSUInteger, CustomMessageTypeRoomGame) {
Custom_Message_Sub_Room_Game_Match_Success = 1091,//匹配成功
Custom_Message_Sub_Room_Game_Match_Fail = 1092,//匹配失败
Custom_Message_Sub_Room_Game_Early_Exit = 1093,//提前退出游戏
};
///家族新协议
//CustomMessageType_New_Hall = 110,
typedef NS_ENUM(NSUInteger, CustomMessageTypeNewHall) {
///所有房间
Custom_Message_Sub_New_Hall_Invite = 1101,//邀请加入
Custom_Message_Sub_New_Hall_Deal_Invite = 1102,//邀请加入
Custom_Message_Sub_New_Hall_Apply = 1103,//申请加入
Custom_Message_Sub_New_Hall_Deal_Apply = 1104,//申请加入
Custom_Message_Sub_New_Hall_Set_Manager = 1105,//设置管理员
Custom_Message_Sub_New_Hall_Remove_Manager = 1106,//移除管理员
Custom_Message_Sub_New_Hall_Create = 1107,//加入成员
Custom_Message_Sub_New_Hall_Dismiss = 1108,//移除成员
};
///开黑邀请
typedef NS_ENUM(NSUInteger, CustomMessageTypeGameOrder) {
///所有房间
Custom_Message_Sub_Game_order = 1121,
};
/// 房间流水
typedef NS_ENUM(NSUInteger, CustomMessageTypeMoneyFlow) {
///所有房间
Custom_Message_Sub_Money_Flow = 1110,
};
typedef NS_ENUM(NSUInteger, CustomMessageTypeCPGift) {
Custom_Message_Sub_CP_Gift = 641, // 礼物聊屏
Custom_Message_Sub_CP_Upgrade = 642, // 升级
Custom_Message_Sub_CP_Binding = 643, // 绑定
};
///开黑邀请
typedef NS_ENUM(NSUInteger, CustomMessageTypeCustomRoomBackground) {
///所有房间
Custom_Message_Sub_Custom_Room_Background = 1131
};
///房间等级更新
typedef NS_ENUM(NSUInteger, CustomMessageTypeRoomLevelUpdate) {
///所有房间
Custom_Message_Sub_RoomLevel_Update = 1141
};
@interface AttachmentModel : PIBaseModel<NIMCustomAttachment>
@property (nonatomic, strong) id data; // Must be NSMutable Type
@property (nonatomic,assign) int first;
@property (nonatomic,assign) int second;
@property(nonatomic,assign) BOOL isBroadcast;
@property(nonatomic, assign) NSInteger seq; // 本地序号,用于将一条消息分解为多条有次序的消息
@property (nonatomic, assign) BOOL isFromPublic;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,81 @@
//
// AttachmentModel.m
// YUMI
//
// Created by YUMI on 2021/11/16.
//
#import "AttachmentModel.h"
#import "NSObject+MJExtension.h"
@implementation AttachmentModel
- (NSString *)encodeAttachment {
//#if DEBUG
// NSString *s = [self toJSONString];
// NSString *ss = [self compressJSONString:s];
// NSString *sss = [self convertModelToJSONString:self];
//#endif
return [self toJSONString];
}
//- (NSDictionary *)toDictionary {
// NSMutableDictionary *dict = [NSMutableDictionary dictionary];
//
// if (self.data) {
// dict[@"data"] = self.data;
// }
// dict[@"first"] = @(self.first);
// dict[@"second"] = @(self.second);
// dict[@"isBroadcast"] = @(self.isBroadcast);
//
// return [dict copy];
//}
//
//- (NSString *)convertModelToJSONString:(AttachmentModel *)model {
// if (!model) {
// return nil;
// }
//
// //
// NSDictionary *modelDict = [model toDictionary];
//
// // JSON
// NSError *error;
// NSData *jsonData = [NSJSONSerialization dataWithJSONObject:modelDict options:0 error:&error];
//
// if (error) {
// NSLog(@"JSON 序列化失败: %@", error.localizedDescription);
// return nil;
// }
//
// //
// return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
//}
//
//- (NSString *)compressJSONString:(NSString *)jsonString {
// if (!jsonString) return nil;
//
// // JSON
// NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
// NSError *error;
// id jsonObject = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
//
// if (error) {
// NSLog(@"JSON 解析错误: %@", error.localizedDescription);
// return nil;
// }
//
// // JSON
// NSData *compressedData = [NSJSONSerialization dataWithJSONObject:jsonObject options:0 error:&error];
//
// if (error) {
// NSLog(@"JSON 序列化错误: %@", error.localizedDescription);
// return nil;
// }
//
// //
// NSString *compressedString = [[NSString alloc] initWithData:compressedData encoding:NSUTF8StringEncoding];
// return compressedString;
//}
@end

Some files were not shown because too many files have changed in this diff Show More