选择区号修改

This commit is contained in:
liyuhua
2023-12-07 19:44:52 +08:00
parent 6e8ead27dd
commit 6a3201135b
12 changed files with 1333 additions and 64 deletions

View File

@@ -300,6 +300,7 @@
239141C92AE1358F00322CA9 /* PIInputEntireServerScrollingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 239141C82AE1358F00322CA9 /* PIInputEntireServerScrollingView.m */; };
239141CC2AE267EF00322CA9 /* PIReceiveRedPacketSuccessView.m in Sources */ = {isa = PBXBuildFile; fileRef = 239141CB2AE267EF00322CA9 /* PIReceiveRedPacketSuccessView.m */; };
23942E912A86424500D0ECC2 /* XPLoginAuthCodeVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 23942E902A86424500D0ECC2 /* XPLoginAuthCodeVC.m */; };
2396FCE22B21D34A0014021D /* pi_area_info.json in Resources */ = {isa = PBXBuildFile; fileRef = 2396FCE12B21D34A0014021D /* pi_area_info.json */; };
239BEEDB2AA1E058005CDA94 /* PIHoemCategoryTitleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 239BEEDA2AA1E058005CDA94 /* PIHoemCategoryTitleView.m */; };
23A439742AA1CF7C002E6039 /* XPNewHomeHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23A439732AA1CF7C002E6039 /* XPNewHomeHeadView.m */; };
23B2AEC12A64E9C200543D17 /* LoginForgetEditView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23B2AEC02A64E9C200543D17 /* LoginForgetEditView.m */; };
@@ -2063,6 +2064,7 @@
239141CB2AE267EF00322CA9 /* PIReceiveRedPacketSuccessView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIReceiveRedPacketSuccessView.m; sourceTree = "<group>"; };
23942E8F2A86424500D0ECC2 /* XPLoginAuthCodeVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPLoginAuthCodeVC.h; sourceTree = "<group>"; };
23942E902A86424500D0ECC2 /* XPLoginAuthCodeVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPLoginAuthCodeVC.m; sourceTree = "<group>"; };
2396FCE12B21D34A0014021D /* pi_area_info.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = pi_area_info.json; sourceTree = "<group>"; };
239BEED92AA1E058005CDA94 /* PIHoemCategoryTitleView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIHoemCategoryTitleView.h; sourceTree = "<group>"; };
239BEEDA2AA1E058005CDA94 /* PIHoemCategoryTitleView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIHoemCategoryTitleView.m; sourceTree = "<group>"; };
23A439722AA1CF7C002E6039 /* XPNewHomeHeadView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPNewHomeHeadView.h; sourceTree = "<group>"; };
@@ -4593,6 +4595,7 @@
E84A2EAC2A52F20900D6AF8A /* Launch Screen.storyboard */,
23E9EB322A85E97B00B792F2 /* pi_login_new_logo.png */,
23E9EB302A85E5D100B792F2 /* pi_app_logo_new_bg.png */,
2396FCE12B21D34A0014021D /* pi_area_info.json */,
189DD53D26DE255600AB55B1 /* Info.plist */,
E80E09AB2A40B70100CD2BE7 /* Localizable.strings */,
189DD53E26DE255600AB55B1 /* main.m */,
@@ -10749,6 +10752,7 @@
E80EC87628ACD84000D133C5 /* emoji_139@2x.png in Resources */,
23CEFC572AFB8FC100576D89 /* pay_off@2x.png in Resources */,
E80EC86328ACD84000D133C5 /* emoji_41@2x.png in Resources */,
2396FCE22B21D34A0014021D /* pi_area_info.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@@ -20,6 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
@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

@@ -144,7 +144,8 @@
if (!_codeView){
_codeView = [UILabel new];
_codeView.userInteractionEnabled = YES;
_codeView.attributedText = [self getChooseCodeText:@"+852"];
NSString *code = [NSString getCountryCode];
_codeView.attributedText = [self getChooseCodeText: code];
}
return _codeView;

View File

@@ -177,7 +177,8 @@
if (!_countryLabel) {
_countryLabel = [[UILabel alloc] init];
_countryLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:15];
_countryLabel.text = @"+852";
NSString *code = [NSString getCountryCode];
_countryLabel.text = code;
_countryLabel.textColor = [DJDKMIMOMColor mainTextColor];
_countryLabel.backgroundColor = [UIColor clearColor];
_countryLabel.textAlignment = NSTextAlignmentCenter;

View File

@@ -14,7 +14,7 @@
#import "Api+Login.h"
///Third
#import <Masonry/Masonry.h>
@interface XPLoginAraeViewController ()<UITableViewDelegate,UITableViewDataSource>
@interface XPLoginAraeViewController ()<UITableViewDelegate,UITableViewDataSource,XPLoginAreaTableViewCellDelegate>
@property (nonatomic,strong) UITableView *tableView;
@property (nonatomic,strong) NSMutableArray *listData;
@property (nonatomic,strong) NSMutableArray *titleList;
@@ -26,39 +26,49 @@
[super viewDidLoad];
[self initSubViews];
[self initSubViewConstraints];
[Api getPhoneAreaCodeList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
NSArray *list = [LoginAreaModel modelsWithArray:data.data];
[self.titleList removeAllObjects];
[self.listData removeAllObjects];
[self getLocalPlistWithList:list];
}
}];
[self getPhoneAreaCodeList];
}
#pragma mark - LoginVerifCodeProtocol
-(void)getPhoneAreaCodeListSuccess:(NSArray *)list{
[self hideHUD];
[self.titleList removeAllObjects];
[self.listData removeAllObjects];
[self getLocalPlistWithList:list];
}
-(void)getPhoneAreaCodeListFail{
[self hideHUD];
NSBundle *bundle = [NSBundle mainBundle];
NSString *file = [bundle pathForResource:@"district" ofType:@"plist"];
NSArray *dictArray = [NSArray arrayWithContentsOfFile:file];
NSArray *list = [LoginAreaModel modelsWithArray:dictArray];
[self getLocalPlistWithList:list];
-(void)getPhoneAreaCodeList{
//
NSString *path = [[NSBundle mainBundle] pathForResource:@"pi_area_info" ofType:@"json"];
//
NSData *data = [[NSData alloc] initWithContentsOfFile:path];
// JSON
NSDictionary *codeData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
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"];
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.phone_area_code isEqualToString:@"886"]){
TwModel = model;
}
if([model.phone_area_code isEqualToString:@"852"]){
HKModel = model;
}
if([model.phone_area_code isEqualToString:@"65"]){
SPModel = model;
}
if([model.phone_area_code isEqualToString:@"60"]){
MYModel = model;
}
if([model.phone_area_code isEqualToString:@"86"]){
ChinsModel = model;
}
NSString *fristLetter = [model.name substringWithRange:NSMakeRange(0, 1)];
if([letter isEqualToString:fristLetter]){
[modelList addObject:model];
@@ -74,6 +84,22 @@
[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];
[self.listData addObject:otherList];
[self.titleList addObject:@"#"];
[self.tableView reloadData];
@@ -96,6 +122,9 @@
-(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){
@@ -104,13 +133,15 @@
}
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
LoginAreaModel *codeModel = self.listData[indexPath.section][indexPath.row];
if(self.delegate && [self.delegate respondsToSelector:@selector(chooseAreaCodeSuccess:)]){
[self.delegate chooseAreaCodeSuccess:codeModel.pi_phoneAreaCode ?: codeModel.phone_area_code];
}
[self.navigationController popViewControllerAnimated:YES];
#pragma mark - XPLoginAreaTableViewCellDelegate
- (void)didSelectModel:(LoginAreaModel *)model{
LoginAreaModel *codeModel = model;
if(self.delegate && [self.delegate respondsToSelector:@selector(chooseAreaCodeSuccess:)]){
[self.delegate chooseAreaCodeSuccess:codeModel.pi_phoneAreaCode ?: codeModel.phone_area_code];
}
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - Private Method
- (void)initSubViews {

View File

@@ -6,13 +6,19 @@
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class LoginAreaModel;
@interface XPLoginAreaTableViewCell : UITableViewCell
@protocol XPLoginAreaTableViewCellDelegate <NSObject>
@property (nonatomic,strong) LoginAreaModel *areaModel;
-(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

@@ -14,6 +14,7 @@
@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 {
@@ -30,6 +31,7 @@
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) {
@@ -40,6 +42,15 @@
make.right.mas_equalTo(-kGetScaleWidth(15));
make.centerY.equalTo(self.contentView);
}];
[self.clickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.bottom.equalTo(self.contentView);
make.right.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;
@@ -70,5 +81,11 @@
}
return _codeView;
}
- (UIButton *)clickBtn{
if(!_clickBtn){
_clickBtn = [UIButton new];
[_clickBtn addTarget:self action:@selector(didClickBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
return _clickBtn;
}
@end

View File

@@ -9,6 +9,7 @@
#import "DJDKMIMOMColor.h"
#import <Masonry.h>
#import <ReactiveObjC.h>
#import "LoginAreaModel.h"
@interface XPLoginInputView()
@@ -46,12 +47,16 @@
areaImageView.userInteractionEnabled = NO;
///
NSString *code = [NSString getCountryCode];
UIButton *areaCodeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[areaCodeBtn setTitle:@"+852" forState:UIControlStateNormal];
[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;

View File

@@ -495,21 +495,26 @@
break;
case NIMChatroomEventTypeEnter:
{
///
RoomInfoModel * roomInfo =self.hostDelegate.getRoomInfo;
NSString * roomId = [NSString stringWithFormat:@"%ld", roomInfo.uid];
for (MicroQueueModel *sequence in self.micQueue.allValues) {
if ([AccountInfoStorage instance].getUid.integerValue == sequence.userInfo.uid) {
NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init];
request.key = @(sequence.microState.position).stringValue;
request.value = [sequence.userInfo toJSONString];
request.roomId = roomId;
request.transient = YES;
[[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) {
}];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
///
RoomInfoModel * roomInfo =self.hostDelegate.getRoomInfo;
NSString * roomId = [NSString stringWithFormat:@"%ld", roomInfo.uid];
for (MicroQueueModel *sequence in self.micQueue.allValues) {
if ([AccountInfoStorage instance].getUid.integerValue == sequence.userInfo.uid) {
NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init];
request.key = @(sequence.microState.position).stringValue;
request.value = [sequence.userInfo toJSONString];
request.roomId = roomId;
request.transient = YES;
[[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) {
}];
break;
}
}
});
}
break;
case NIMChatroomEventTypeExit:

View File

@@ -33,6 +33,9 @@ NS_ASSUME_NONNULL_BEGIN
+ (NSString *)getCalculateConstellationImageWithMonth:(long)time;
///得到年龄
+(NSString *)getAgeWithBirth:(long)birth;
///得到区号
+(NSString *)getCountryCode;
@end

View File

@@ -7,6 +7,7 @@
#import "NSString+Utils.h"
#import <CommonCrypto/CommonDigest.h>
#import "LoginAreaModel.h"
@implementation NSString (Utils)
@@ -23,12 +24,12 @@
unsigned char result[16];
CC_MD5(cstr, (CC_LONG)strlen(cstr), result);
return [NSString stringWithFormat:
@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
result[0], result[1], result[2], result[3],
result[4], result[5], result[6], result[7],
result[8], result[9], result[10], result[11],
result[12], result[13], result[14], result[15]
];
];
}
+ (BOOL)versionCompareOldStr:(NSString *)first andNewStr: (NSString *)second{
@@ -72,7 +73,7 @@
//
NSTimeInterval second = timeStamp.longLongValue / 1000;
NSDate *date = [NSDate dateWithTimeIntervalSince1970:second];
//NSdate
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
@@ -119,7 +120,7 @@
// E. yyyy-mm-dd
return [yearFormatter stringFromDate:date];
}
return result;
}
@@ -128,14 +129,14 @@
NSString *astroString = YMLocalizedString(@"XPMineHeadView0");
NSString *astroFormat = @"102123444543";
NSString *result;
NSInteger month = [NSString getMonth:time];
NSInteger day = [NSString getDay:time];
if (month<1 || month>12 || day<1 || day>31){
return YMLocalizedString(@"XPMineHeadView1");
}
if(month==2 && day>29)
{
return YMLocalizedString(@"XPMineHeadView2");
@@ -144,25 +145,25 @@
return YMLocalizedString(@"XPMineHeadView3");
}
}
result=[NSString stringWithFormat:@"%@",[astroString substringWithRange:NSMakeRange(month*2-(day < [[astroFormat substringWithRange:NSMakeRange((month-1), 1)] intValue] - (-19))*2,2)]];
return [NSString stringWithFormat:YMLocalizedString(@"XPMineHeadView6"),result];
}
///
+ (NSString *)getCalculateConstellationImageWithMonth:(long)time{
NSString *astroString = YMLocalizedString(@"XPMineHeadView0");
NSString *astroFormat = @"102123444543";
NSString *result;
NSInteger month = [self getMonth:time];
NSInteger day = [self getDay:time];
if (month<1 || month>12 || day<1 || day>31){
return @"";
}
if(month==2 && day>29)
{
return @"";
@@ -171,7 +172,7 @@
return @"";
}
}
result=[NSString stringWithFormat:@"%@",[astroString substringWithRange:NSMakeRange(month*2-(day < [[astroFormat substringWithRange:NSMakeRange((month-1), 1)] intValue] - (-19))*2,2)]];
NSDictionary *starDic = @{YMLocalizedString(@"XPMineHeadView9"):@"pi_capricorn",YMLocalizedString(@"XPMineHeadView10"):@"pi_water_bottle",YMLocalizedString(@"XPMineHeadView11"):@"pi_pisces",YMLocalizedString(@"XPMineHeadView12"):@"pi_aries",YMLocalizedString(@"XPMineHeadView13"):@"pi_taurus",YMLocalizedString(@"XPMineHeadView14"):@"pi_gemini",YMLocalizedString(@"XPMineHeadView15"):@"pi_cancer",YMLocalizedString(@"XPMineHeadView16"):@"pi_lion",YMLocalizedString(@"XPMineHeadView17"):@"pi_virgin",YMLocalizedString(@"XPMineHeadView18"):@"pi_libra",YMLocalizedString(@"XPMineHeadView19"):@"pi_scorpion",YMLocalizedString(@"XPMineHeadView20"):@"pi_shooter"};
return starDic[result];
@@ -208,4 +209,25 @@
}
return @(iAge).stringValue;
}
///
+(NSString *)getCountryCode{
//
NSString *path = [[NSBundle mainBundle] pathForResource:@"pi_area_info" ofType:@"json"];
//
NSData *data = [[NSData alloc] initWithContentsOfFile:path];
// JSON
NSDictionary *codeData = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
NSArray *codeList = [LoginAreaModel modelsWithArray:codeData[@"RECORDS"]];
NSString *mccCode = [YYUtility getMobileCountryCode];
NSString *countryCode = @"";
if([mccCode isEqualToString:@"65535"])return @"+886";
for (LoginAreaModel *obj in codeList) {
if([mccCode isEqualToString:obj.mcc]){
countryCode = obj.mcc;
break;
}
}
if(countryCode.length == 0)return @"+886";
return [NSString stringWithFormat:@"+%@",countryCode];
}
@end

1173
YuMi/pi_area_info.json Normal file

File diff suppressed because it is too large Load Diff