12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319 |
- //
- // JXMainLoginVc.m
- // shiku_im
- //
- // Created by 123 on 2020/5/6.
- // Copyright © 2020 Reese. All rights reserved.
- //
- #import "JXMainLoginVc.h"
- #import <AVFoundation/AVFoundation.h>
- #import <AVKit/AVKit.h>
- #import "loginVC.h"
- #import "JXRegisterShowView.h"
- #import "JXLoginBtn.h"
- #import "JXLocation.h"
- #import "JLBubbleModel.h"
- #import "WXApi.h"
- #import <TencentOpenAPI/TencentOAuth.h>
- #import <TencentOpenAPI/QQApiInterface.h>
- #import "inputPhoneVC.h"
- #import "JXTelAreaListVC.h"
- #import "JXLoginTopView.h"
- @interface JXMainLoginVc ()<UITextFieldDelegate,JXLocationDelegate,JXLocationDelegate,WXApiDelegate,WXApiManagerDelegate,TencentSessionDelegate,TencentLoginDelegate>
- {
-
- NSString *_myToken;
- NSInteger setServerNum;
- BOOL _isFirstLocation;
- }
- //播放器ViewController
- @property(nonatomic, strong)AVPlayerViewController *AVPlayer;
-
- @property(nonatomic,strong)dispatch_source_t authTimer;
- @property(nonatomic,assign)NSInteger count;
- @property(nonatomic,strong)UIView *waitAuthView;
- @property (nonatomic, strong)TencentOAuth *oauth;
- @property (nonatomic,copy) NSString *phoneStr;
- @property (nonatomic,copy) NSString *pwdStr;
- @property (nonatomic,copy) NSString *phone3;
- @property (nonatomic,copy) NSString *areaCodeBtn;
- @property (nonatomic,weak) JXRegisterShowView *showLogView;
- @property (nonatomic,weak) UIImageView *backView;
- @property (nonatomic,weak) JXLoginTopView *loginTopView;
- @end
- @implementation JXMainLoginVc
-
- - (void)viewWillDisappear:(BOOL)animated{
-
- [super viewWillDisappear:animated];
- [_showLogView removeFromSuperview];
-
- }
- - (void)viewWillAppear:(BOOL)animated {
- [super viewWillAppear:animated];
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- //初始化AVPlayer
-
-
- UIImageView *backView = [[UIImageView alloc] init];
- backView.image=[UIImage imageNamed:@"new_login_bg"];
- backView.contentMode = UIViewContentModeScaleAspectFill;
- backView.frame=self.view.bounds;
- [self.view addSubview:backView];
- _backView = backView;
- [self setMoviePlayer:@""];
- [self loadDataWeb];
-
- //[self setMoviePlayer];
- long time = (long)[[NSDate date] timeIntervalSince1970];
- time = (time *1000 + g_server.timeDifference);
- NSString *salt = [NSString stringWithFormat:@"%ld", time];
-
- //视频地址
- [g_server getact_apiAppFileResourceall:salt toView:self];
-
-
- [g_server getact_UserdeviceLogsecurity:salt userId:g_server.myself.userId andToView:self];
- NSString *xieyiValue = [[NSUserDefaults standardUserDefaults] objectForKey:@"yonghuxieyi"];
- if (xieyiValue.length>0) {
-
- }else{
- [[NSUserDefaults standardUserDefaults] setObject:@"yonghuxieyi" forKey:@"yonghuxieyi"];
- [[NSUserDefaults standardUserDefaults] synchronize];
- [g_server act_UserfuwenBenLogin:salt type:@"1000" title:@"用户协议" andToView:self];
- }
-
-
- // 获取自己的用户信息
- [g_server getUser:MY_USER_ID toView:self];
-
- [self CreateTopBtnIMG];
- [self prepareForbackIMG];
-
-
-
-
- _user = [[JXUserObject alloc] init];
- self.heightFooter = 0;
- self.heightHeader = 0;
- if (_isThirdLogin) {
- self.title = Localized(@"JX_BindExistingAccount");
- }
- if (self.isSMSLogin) {
- self.title = Localized(@"JX_SMSLogin");
- self.isGotoBack = YES;
- }
- [g_server getAppResource:@"0" ToView:self];
- [g_server customerLinkList:self];
- // 获取所有气泡
- [g_server getAllBubbleFontListToView:self];
- // 获取所有等级
- [g_server getAllGradeListToView:self];
- g_server.isManualLogin = NO;
-
- self.isGotoBack = NO;
- _myToken = [g_default objectForKey:kMY_USER_TOKEN];
- [g_default setObject:nil forKey:kMyPayPrivateKey];
-
- g_server.isLogin = NO;
- g_navigation.lastVC = nil;
-
-
-
-
- // 微信登录回调
- [WXApiManager sharedManager].delegate = self;
- if ([g_default objectForKey:kMY_USER_NICKNAME])
- _user.userNickname = MY_USER_NAME;
-
- if ([g_default objectForKey:kMY_USER_ID])
- _user.userId = [g_default objectForKey:kMY_USER_ID];
-
- if ([g_default objectForKey:kMY_USER_COMPANY_ID])
- _user.companyId = [g_default objectForKey:kMY_USER_COMPANY_ID];
-
- if ([g_default objectForKey:kMY_USER_LoginName]) {
- _phoneStr=[g_default objectForKey:kMY_USER_LoginName];
- _user.telephone = _phoneStr;
- }
- if ([g_default objectForKey:kMY_USER_PASSWORD]) {
- // [_pwd setText:[g_default objectForKey:kMY_USER_PASSWORD]];
-
- _phoneStr=[g_default objectForKey:kMY_USER_PASSWORD];
- _user.password = _phoneStr;
-
- }
- if ([g_default objectForKey:kLocationLogin]) {
- NSDictionary *dict = [g_default objectForKey:kLocationLogin];
- g_server.longitude = [[dict objectForKey:@"longitude"] doubleValue];
- g_server.latitude = [[dict objectForKey:@"latitude"] doubleValue];
- }
-
-
- [g_notify addObserver:self selector:@selector(onRegistered:) name:kRegisterNotifaction object:nil];
- [g_notify addObserver:self selector:@selector(authRespNotification:) name:kWxSendAuthRespNotification object:nil];
- if(!self.isAutoLogin || IsStringNull(_myToken)) {
- _btn.userInteractionEnabled = YES;
- }else {
- _launchImageView = [[UIImageView alloc] init];
- _launchImageView.frame = self.view.bounds;
- _launchImageView.image = [UIImage imageNamed:[self getLaunchImageName]];
- [self.view addSubview:_launchImageView];
- }
-
- if(self.isAutoLogin && !IsStringNull(_myToken))
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- // [_wait start:Localized(@"JX_Logining")];
- [_wait startWithClearColor];
- });
- if (!_isThirdLogin) {
-
- [g_server getSetting:self];
-
- }
-
- }
-
- /**
- * 头部图片
- */
- - (void)CreateTopBtnIMG{
-
-
- UIImageView *logoIMG=[[UIImageView alloc]init];
- logoIMG.image=[UIImage imageNamed:@"jxlOGO"];
- [self.view addSubview:logoIMG];
- self.logoIMG=logoIMG;
- [logoIMG mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(JX_SCREEN_HEIGHT>=812?100:(SCREENSIZE_IS_PLUS?64:30));
- make.centerX.mas_equalTo(self.view.mas_centerX);
- make.width.mas_equalTo(150);
- make.height.mas_equalTo(40);
- }];
-
- UILabel *titleBt = [[UILabel alloc] init];
- titleBt.text=@"官方认证";
- titleBt.textAlignment=NSTextAlignmentCenter;
- titleBt.textColor=[UIColor whiteColor];
- titleBt.font=[UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
- [self.view addSubview:titleBt];
- [titleBt mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(logoIMG.mas_bottom).mas_offset(15);
- make.centerX.mas_equalTo(self.view.mas_centerX);
- }];
-
- UILabel *leftLine = [[UILabel alloc] init];
- leftLine.text=@"---------";
- leftLine.backgroundColor=[UIColor whiteColor];
- [self.view addSubview:leftLine];
- [leftLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(titleBt.mas_centerY).mas_offset(0);
- make.right.mas_equalTo(titleBt.mas_left).mas_offset(-20);
- make.height.mas_equalTo(1);
- }];
-
- UILabel *rightLine = [[UILabel alloc] init];
- rightLine.text=@"---------";
- rightLine.backgroundColor=[UIColor whiteColor];
- [self.view addSubview:rightLine];
- [rightLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.mas_equalTo(titleBt.mas_centerY).mas_offset(0);
- make.left.mas_equalTo(titleBt.mas_right).mas_offset(20);
- make.height.mas_equalTo(1);
- }];
-
- JXLoginTopView *loginTopView = [JXLoginTopView customView];
- [self.view addSubview:loginTopView];
- [loginTopView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(titleBt.mas_bottom).mas_offset(20);
- make.centerX.mas_equalTo(self.view.mas_centerX).mas_offset(0);
- make.height.mas_equalTo(180);
- make.width.mas_equalTo(220);
- }];
-
- _loginTopView = loginTopView;
- // CGFloat btnW=(JX_SCREEN_WIDTH-100)/5;
- // NSArray *titles=@[@"菲律宾政府PAGCOR",@"英国曼岛博彩监督委员会",@"马其他在线博彩委员会",@"直布罗陀博彩委员会"];
- // NSArray *iamges=@[@"PAGCOR",@"ygmdbcjdwyh",@"mqtzxbcwyh",@"zbltbcwyh"];
- // for (int i=0; i<titles.count; i++) {
- // JXLoginBtn *QQBtn = [[JXLoginBtn alloc] init];
- // QQBtn.userInteractionEnabled=NO;
- // [QQBtn setTitle:titles[i] forState:UIControlStateNormal];
- // [QQBtn setImage:[UIImage imageNamed:iamges[i]] forState:UIControlStateNormal];
- // QQBtn.tag=i;
- // [self.view addSubview:QQBtn];
- //
- // if (i>1) {
- // QQBtn.frame=CGRectMake((btnW*1.5)+(i%2)*(btnW +btnW*1.5), (JX_SCREEN_HEIGHT>=812?180:130) + btnW+50+20, btnW, btnW+50);
- // }else {
- // QQBtn.frame=CGRectMake((btnW*1.5)+i*(btnW +btnW*1.5), JX_SCREEN_HEIGHT>=812?180:130, btnW, btnW+50);
- // }
- //
- //
- // }
-
- }
- /**
- * 底部登录框
- */
- - (void)prepareForbackIMG{
-
- UIImageView *bottomView=[[UIImageView alloc]init];
- //bottomView.backgroundColor=[UIColor colorWithWhite:1.0 alpha:0.1];
- bottomView.userInteractionEnabled=YES;
- bottomView.image=[UIImage imageNamed:@"dak"];
- bottomView.layer.cornerRadius=6;
- bottomView.layer.masksToBounds=YES;
- [self.view addSubview:bottomView];
- [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.bottom.mas_equalTo(JX_SCREEN_HEIGHT>=812?-88:-60);
- make.top.mas_equalTo(_loginTopView.mas_bottom).mas_offset(THE_DEVICE_HAVE_HEAD?30:10);
- make.left.mas_equalTo(20);
- make.right.mas_equalTo(-20);
- make.height.mas_equalTo(330);
- }];
-
- UILabel *loginLB = [[UILabel alloc] init];
- loginLB.text=@"登录";
- loginLB.font=[UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
- loginLB.textColor=[UIColor whiteColor];
- [bottomView addSubview:loginLB];
- [loginLB mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(10);
- make.centerX.mas_equalTo(self.view.mas_centerX);
- }];
-
-
- // 微信登录
- UIButton *wxView=[[UIButton alloc]init];
- wxView.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.5];
- wxView.titleLabel.font=[UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
- wxView.layer.cornerRadius=22;
- wxView.layer.masksToBounds=YES;
- wxView.tag=0;
- [wxView setTitle:@"微信登录" forState:UIControlStateNormal];
- [wxView addTarget:self action:@selector(qqLoginBtn:) forControlEvents:UIControlEventTouchUpInside];
- [bottomView addSubview:wxView];
- [wxView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(70);
- make.left.mas_equalTo(25);
- make.right.mas_equalTo(-25);
- make.height.mas_equalTo(54);
- }];
-
- UIImageView *titlesView = [[UIImageView alloc] init];
- titlesView.image=[UIImage imageNamed:@"wx"];
- [wxView addSubview:titlesView];
- [titlesView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(20);
- make.centerY.mas_equalTo(wxView.mas_centerY);
- }];
-
-
- // QQ登录
- UIButton *QQBtn = [[UIButton alloc] init];
- QQBtn.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.5];
- QQBtn.titleLabel.font=[UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
- QQBtn.layer.cornerRadius=22;
- QQBtn.layer.masksToBounds=YES;
- [QQBtn setTitle:@"QQ登录" forState:UIControlStateNormal];
- QQBtn.tag=1;
- [bottomView addSubview:QQBtn];
- [QQBtn addTarget:self action:@selector(qqLoginBtn:) forControlEvents:UIControlEventTouchUpInside];
- [QQBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(wxView.mas_bottom).mas_offset(10);
- make.left.mas_equalTo(25);
- make.right.mas_equalTo(-25);
- make.height.mas_equalTo(54);
- }];
- UIImageView *QQIMG = [[UIImageView alloc] init];
- QQIMG.image=[UIImage imageNamed:@"qq"];
- [QQBtn addSubview:QQIMG];
- [QQIMG mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(20);
- make.centerY.mas_equalTo(QQBtn.mas_centerY);
- }];
-
-
- //手机登录
- UIButton *phoneBtn = [[UIButton alloc] init];
- [phoneBtn setTitle:@"手机登录" forState:UIControlStateNormal];
- phoneBtn.titleLabel.font=[UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
- phoneBtn.tag=2;
- phoneBtn.layer.cornerRadius=22;
- phoneBtn.layer.masksToBounds=YES;
-
- phoneBtn.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.5];
- [bottomView addSubview:phoneBtn];
- [phoneBtn addTarget:self action:@selector(qqLoginBtn:) forControlEvents:UIControlEventTouchUpInside];
- [phoneBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(QQBtn.mas_bottom).mas_offset(10);
- make.left.mas_equalTo(25);
- make.right.mas_equalTo(-25);
- make.height.mas_equalTo(54);
- }];
-
- UIImageView *phoneIMG = [[UIImageView alloc] init];
- phoneIMG.image=[UIImage imageNamed:@"SJ"];
- [phoneBtn addSubview:phoneIMG];
- [phoneIMG mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(20);
- make.centerY.mas_equalTo(phoneBtn.mas_centerY);
- }];
-
-
- UILabel *titleBt = [[UILabel alloc] init];
- titleBt.text=@"时间会证明吉利是最好的选择\n(2012年-至今)";
- titleBt.textAlignment=NSTextAlignmentCenter;
- titleBt.textColor=[UIColor whiteColor];
- titleBt.numberOfLines = 0;
- titleBt.font=[UIFont systemFontOfSize:17 weight:UIFontWeightRegular];
- [bottomView addSubview:titleBt];
-
- [titleBt mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(phoneBtn.mas_bottom).mas_offset(20);
- make.left.mas_equalTo(25);
- make.right.mas_equalTo(-25);
- }];
-
- }
- /**
- * qq微信登录
- */
- - (void)qqLoginBtn:(UIButton *)sender{
-
-
- if (sender.tag==0) { //微信
- [self didWechatToLogin:nil];
- }else if (sender.tag==1) {//手机登录
-
- [self didQQToLogin:nil];
-
- } else { //微信登录
-
- loginVC *vc=[loginVC new];
-
- [g_navigation pushViewController:vc animated:YES];
-
- }
- }
-
- //======================================= 判断自动登录 =========================================
-
-
- - (void)switchLoginWay {
- if (self.isSMSLogin) {
- [self actionQuit];
- }else {
- loginVC *vc = [loginVC alloc];
- vc.isSMSLogin = YES;
- vc = [vc init];
- [g_navigation pushViewController:vc animated:YES];
- }
- }
-
- #pragma mark - 微信登录
- - (void)didWechatToLogin:(UITapGestureRecognizer *)tap {
- // if (![[g_default objectForKey:@"agreement"] boolValue]) {
- // [g_App showAlert:Localized(@"JX_NotAgreeProtocol")];
- // return;
- // }
- self.type = JXLoginWX;
- if (![WXApi isWXAppInstalled]) {
- [g_App showAlert:@"您的手机没有安装微信, 请下载后使用微信登录."];
- return;
- }
-
- SendAuthReq* req = [[SendAuthReq alloc] init];
- req.scope = @"snsapi_userinfo"; // @"post_timeline,sns"
- req.state = @"login";
- req.openID = @"";
-
- [WXApi sendAuthReq:req
- viewController:self
- delegate:[WXApiManager sharedManager]];
- }
- - (void)authRespNotification:(NSNotification *)notif {
- SendAuthResp *response = notif.object;
- NSString *strMsg = [NSString stringWithFormat:@"Auth结果 code:%@,state:%@,errcode:%d", response.code, response.state, response.errCode];
- NSLog(@"-------%@",strMsg);
- if (response.code.length > 0) {
- [g_server getWxOpenId:response.code toView:self];
- }
- }
- #pragma mark - QQ登录
- - (void)didQQToLogin:(UITapGestureRecognizer *)tap {
- self.type = JXLoginQQ;
-
- if (![TencentOAuth iphoneQQInstalled]) {
- [g_App showAlert:@"您的手机没有安装手机QQ, 请下载后使用QQ登录."];
- return;
- }
-
- NSString *appid = g_App.QQ_LOGIN_APPID;
- _oauth = [[TencentOAuth alloc] initWithAppId:appid
- andDelegate:self];
- _oauth.authMode = kAuthModeClientSideToken;
- [_oauth authorize:[self getPermissions] inSafari:NO];
- }
- // QQ登录成功回调
- - (void)tencentDidLogin {
- NSString *qqOpenId = _oauth.openId;
- g_server.openId = qqOpenId;
-
- if (qqOpenId.length > 0) {
- [g_server wxSdkLogin:_user type:1 openId:qqOpenId toView:self];
- }
- }
- - (NSMutableArray *)getPermissions {
- NSMutableArray * g_permissions = [[NSMutableArray alloc] initWithObjects:kOPEN_PERMISSION_GET_USER_INFO,
- kOPEN_PERMISSION_GET_SIMPLE_USER_INFO,
- kOPEN_PERMISSION_ADD_ALBUM,
- kOPEN_PERMISSION_ADD_TOPIC,
- kOPEN_PERMISSION_CHECK_PAGE_FANS,
- kOPEN_PERMISSION_GET_INFO,
- kOPEN_PERMISSION_GET_OTHER_INFO,
- kOPEN_PERMISSION_LIST_ALBUM,
- kOPEN_PERMISSION_UPLOAD_PIC,
- kOPEN_PERMISSION_GET_VIP_INFO,
- kOPEN_PERMISSION_GET_VIP_RICH_INFO, nil];
- return g_permissions;
- }
-
-
- -(void)location:(JXLocation *)location getLocationWithIp:(NSDictionary *)dict {
- if (_isFirstLocation) {
- return;
- }
- NSString *area = [NSString stringWithFormat:@"%@,%@,%@",dict[@"country"],dict[@"region"],dict[@"city"]];
- [g_default setObject:area forKey:kLocationArea];
- [g_default synchronize];
-
- if(self.isAutoLogin && !IsStringNull(_myToken))
- [_wait start:Localized(@"JX_Logining")];
- if (!_isThirdLogin) {
- [g_server getSetting:self];
- }
- }
- - (void)location:(JXLocation *)location getLocationError:(NSError *)error {
- if (_isFirstLocation) {
- return;
- }
- [g_default setObject:nil forKey:kLocationArea];
- [g_default synchronize];
-
- if(self.isAutoLogin && !IsStringNull(_myToken))
- [_wait start:Localized(@"JX_Logining")];
- if (!_isThirdLogin) {
- [g_server getSetting:self];
- }
- }
- -(void)longLimit:(UITextField *)textField
- {
- // if (textField.text.length > 11) {
- // textField.text = [textField.text substringToIndex:11];
- // }
- }
- -(void)dealloc{
- // _pSelf = nil;
- [self.AVPlayer.player pause];
- [self.AVPlayer removeFromParentViewController];
- self.AVPlayer=nil;
- self.showLogView.hidden=YES;
- [g_notify removeObserver:self name:kRegisterNotifaction object:nil];
- // [_user release];
- // [super dealloc];
- }
-
-
- -(void)onClick{
-
- if([_phoneStr length]<=0){
- if ([g_config.regeditPhoneOrName intValue] == 1) {
- [g_App showAlert:Localized(@"JX_InputUserAccount")];
- }else {
- [g_App showAlert:Localized(@"JX_InputPhone")];
- }
- return;
- }
- if([_pwdStr length]<=0){
- [g_App showAlert:self.isSMSLogin ? Localized(@"JX_InputMessageCode") : Localized(@"JX_InputPassWord")];
- return;
- }
- [self.view endEditing:YES];
- if (self.isSMSLogin) {
- _user.verificationCode = _pwdStr;
- }else {
- _user.password = [g_server getMD5String:_pwdStr];
- }
- _user.telephone = _phoneStr;
- self.isAutoLogin = NO;
- [_wait start:Localized(@"JX_Logining")];
- [g_server getSetting:self];
- }
- - (void)actionConfig {
- // 自动登录失败,清除token后,重新赋值一次
- _myToken = [g_default objectForKey:kMY_USER_TOKEN];
-
- if ([g_config.isOpenPositionService intValue] == 0) {
- _isFirstLocation = YES;
- _location = [[JXLocation alloc] init];
- _location.delegate = self;
- g_server.location = _location;
- [g_server locate];
- }
- if((_isAutoLogin && !IsStringNull(_myToken)) || _isThirdLogin)
- if (_isThirdLogin) {
- [g_server thirdLogin:_user type:2 openId:g_server.openId isLogin:NO toView:self];
-
- [g_loginServer thirdLoginV1:_user password:_pwdStr type:self.type openId:g_server.openId isLogin:NO toView:self];
- }else {
- [self performSelector:@selector(autoLogin) withObject:nil afterDelay:.5];
- }
- else if (IsStringNull(_myToken) && !IsStringNull(_phoneStr) && !IsStringNull(_pwdStr)) {
- g_server.isManualLogin = YES;
- [g_App.jxServer login:_user toView:self];
- NSString *areaCode = [_areaCodeBtn stringByReplacingOccurrencesOfString:@"+" withString:@""];
-
- if (self.isSMSLogin) {
- [g_loginServer smsLoginWithUser:_user areaCode:@"410000" account:_phoneStr toView:self];
- }else {
- g_server.temporaryPWD = _pwdStr;
- [g_loginServer loginWithUser:_user password:_pwdStr areaCode:areaCode account:_phoneStr toView:self];
- }
-
- }
- else
- [_wait stop];
- }
-
- -(void)viewDidDisappear:(BOOL)animated{
- [super viewDidDisappear:animated];
- self.showLogView.hidden=YES;
- [self.AVPlayer removeFromParentViewController];
- self.AVPlayer=nil;
-
- }
- #pragma mark --- 请求成功
-
-
-
- - (void)loadDataWeb{
-
- [g_server actGetconfigconcatdomainnow:self];
- }
- /**
- * 背景视频
- */
- -(void)setMoviePlayer:(NSString *)urlMovice{
-
- //初始化AVPlayer
- self.AVPlayer = [[AVPlayerViewController alloc]init];
- //多分屏功能取消
- self.AVPlayer.allowsPictureInPicturePlayback = NO;
- //设置是否显示媒体播放组件
- self.AVPlayer.showsPlaybackControls = false;
-
- //初始化一个播放单位。给AVplayer 使用
- //读取本地视频路径
- NSString *path = [[NSBundle mainBundle] pathForResource:@"login-interface" ofType:@"mp4"];
- //为即将播放的视频内容进行建模
- AVPlayerItem *item = [[AVPlayerItem alloc] initWithURL:[NSURL fileURLWithPath:path]];
- // AVPlayerItem *item = [[AVPlayerItem alloc]initWithURL:[NSURL URLWithString:urlMovice]];
- // AVPlayer *avPlayer= [AVPlayer playerWithURL:[NSURL URLWithString:urlMovice]];
-
- AVPlayer *player = [AVPlayer playerWithPlayerItem:item];
- self.AVPlayer.player = player;
- //layer
- // AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:player];
- [self.AVPlayer.view setFrame:self.view.bounds];
- //设置填充模式
- self.AVPlayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
-
-
- //设置AVPlayerViewController内部的AVPlayer为刚创建的AVPlayer
- // self.AVPlayer.player = player;
- //添加到self.view上面去
- //[self.view.layer addSublayer:layer];
- // [self.view.layer insertSublayer:layer atIndex:0];
- // [self.view.layer insertSublayer:layer above:_backView.layer];
- [self.view insertSubview: self.AVPlayer.view aboveSubview:_backView];
- //开始播放
- [self.AVPlayer.player play];
-
-
-
- //这里设置的是重复播放。
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playDidEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:item];
- //定时器。延迟3秒再出现进入应用按钮
- // [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(prepareForbackIMG) userInfo:nil repeats:YES];
-
- }
-
- //播放完成的代理
- - (void)playDidEnd:(NSNotification *)Notification{
- //播放完成后。设置播放进度为0 。 重新播放
- [self.AVPlayer.player seekToTime:CMTimeMake(0, 1)];
- [self.AVPlayer.player play];
- //开始播放
- // [self.AVPlayer.player pause];
- // [self.AVPlayer removeFromParentViewController];
- // self.AVPlayer=nil;
- }
- -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
-
-
- //NSLog(@"视频地址:%@",aDownload.action);
-
- if ([aDownload.action isEqualToString:act_apiAppFileResourceall]||[aDownload.action isEqualToString:@"config"]) {
-
- [array1 enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
- if ([obj[@"code"] isEqualToString:@"loginermp4"]) {
-
- NSString *fileUrll=obj[@"fileUrl"];
- dispatch_async(dispatch_get_main_queue(), ^{
- // [self setMoviePlayer:fileUrll];
- // [g_App setupLunchADUrl:fileUrll link:@""];
-
- });
- }
-
- if (JX_SCREEN_HEIGHT>=812) {
- if ([obj[@"code"] isEqualToString:@"ggxcmp4_3x"]) {
-
- NSString *fileUrll=obj[@"fileUrl"];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
-
- [g_App setupLunchADUrl:fileUrll link:@""];
-
- });
- }
- }else{
- if ([obj[@"code"] isEqualToString:@"ggxcmp4_2x"]) {
-
- NSString *fileUrll=obj[@"fileUrl"];
-
- dispatch_async(dispatch_get_main_queue(), ^{
-
-
- [g_App setupLunchADUrl:fileUrll link:@""];
-
- });
- }
- }
-
-
-
-
-
- }];
-
- }
- //更新本地好友
- if ([aDownload.action isEqualToString:act_Getconfigconcatdomainnow]) {
- NSString *memberAcc= dict[@"url"];
-
- [[NSUserDefaults standardUserDefaults] setObject:memberAcc forKey:@"www_url"];
- [[NSUserDefaults standardUserDefaults] synchronize];
-
- // [g_notify postNotificationName:@"loadHomeWeb" object:nil userInfo:dict];
- }
-
- if([aDownload.action isEqualToString:act_UserGet]){
-
- JXUserObject *user = [[JXUserObject alloc] init];
- [user getDataFromDict:dict];
-
-
- }
- if([aDownload.action isEqualToString:act_fuwenBenLogin]){
-
-
- //NSString *strValue=[[NSUserDefaults standardUserDefaults] objectForKey:@"guangboxxx"];
- // if (strValue.length==0) {
-
- [[NSUserDefaults standardUserDefaults] setObject:@"10000" forKey:@"guangboxxx"];
- [[NSUserDefaults standardUserDefaults] synchronize];
-
- JXRegisterShowView *showLogView=[[JXRegisterShowView alloc]init];
- showLogView.frame=self.view.bounds;
- showLogView.dataDict= dict;
-
- [self.view addSubview:showLogView];
- self.showLogView=showLogView;
- //}else{ }
-
-
-
-
-
- }
-
- if([aDownload.action isEqualToString:act_UserdeviceLogsecurity]){
-
- NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
- [userDefault setObject:dict[@"data"] forKey:@"user_Data"];
- [userDefault synchronize];
- }
-
- if ([aDownload.action isEqualToString:act_getGradeList])
- {
-
- NSString *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
- NSString *fileName = [path stringByAppendingPathComponent:@"grade.plist"];
-
- [array1 writeToFile:fileName atomically:YES];
-
- // 保存到数据库
- JLBubbleManager *manager = [JLBubbleManager sharedManager];
- FMDatabase* db = [manager openResouceDb];
- BOOL result = [manager checkGradeTableCreatedInDb:db];
- if (result) {
- // self.gradeIndex, self.avatarUrl, self.id, self.name, self.rankUrl, self.grade
- for (NSDictionary *tempDict in array1) {
- JLBubbleManager *manager = [JLBubbleManager mj_objectWithKeyValues:tempDict];
- [manager insertGradeTable];
- }
- }
-
-
-
-
-
- NSMutableArray *imagesArray = [NSMutableArray array];
- for (NSDictionary *tempDict in array1) {
-
- //[imagesArray addObject:[NSURL URLWithString:tempDict[@"avatarUrl"]]];
- //[imagesArray addObject:[NSURL URLWithString:tempDict[@"rankUrl"]]];
-
- NSString *avatarUrl = @"";
- if (tempDict[@"avatarUrl"] == nil) {
- avatarUrl = @"";
- }else {
- avatarUrl = tempDict[@"avatarUrl"];
- }
-
- NSString *rankUrl = @"";
- if (tempDict[@"rankUrl"] == nil) {
- avatarUrl = @"";
- }else {
- rankUrl = tempDict[@"rankUrl"];
- }
-
- [imagesArray addObject:[NSURL URLWithString:avatarUrl]];
- [imagesArray addObject:[NSURL URLWithString:rankUrl]];
-
- NSArray *bubbleFontSet = tempDict[@"bubbleFontSet"];
- for (NSDictionary *bubbleFontDict in bubbleFontSet) {
- JLBubbleModel *model = [JLBubbleModel mj_objectWithKeyValues:bubbleFontDict];
- [imagesArray addObject:[NSURL URLWithString:model.bubble.iosLeftUrl]];
- [imagesArray addObject:[NSURL URLWithString:model.bubble.iosRightUrl]];
- // [imagesArray addObject:[NSURL URLWithString:model.homeUrl]];
- }
- // NSArray *faceSet = tempDict[@"faceSet"];
- // for (NSDictionary *faceSetDict in faceSet) {
- // NSArray *array = faceSetDict[@"path"];
- // for (NSString *url in array) {
- // NSURL *urlPath = [NSURL URLWithString:url];
- // [imagesArray addObject:urlPath];
- // }
- // }
-
- if (result) {
- // int gradeIndex = (int)tempDict[@"gradeIndex"];
- // [JXLabelObject sharedInstance].gradeIndex = gradeIndex;
- // NSData *data = [NSKeyedArchiver archivedDataWithRootObject:tempDict];
- // [JXLabelObject sharedInstance].data = data;
- // [[JXLabelObject sharedInstance] insertGradeTable];
- // NSArray *array = [tempDict allValues];
-
-
- }
- }
-
- // 缓存图片
- [[JLBubbleManager sharedManager] cacheBubbleImage:imagesArray];
- }
-
- if ([aDownload.action isEqualToString:act_getAllBubbleFontList])
- {
-
- NSString *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
- NSString *fileName = [path stringByAppendingPathComponent:@"bubbleFontList.plist"];
-
- [array1 writeToFile:fileName atomically:YES];
- // 保存到数据库
- // 保存到数据库
- JLBubbleManager *manager = [JLBubbleManager sharedManager];
- FMDatabase* db = [manager openResouceDb];
- BOOL result = [manager checkBubbleFontTableCreatedInDb:db];
- if (result) {
- // self.id, self.iosLeftUrl, self.iosRightUrl, self.name, self.code, self.color
- for (NSDictionary *tempDict in array1) {
- JLBubbleModel *model = [JLBubbleModel mj_objectWithKeyValues:tempDict];
- manager.id = model.id;
- manager.iosLeftUrl = model.bubble.iosLeftUrl;
- manager.iosRightUrl = model.bubble.iosRightUrl;
- manager.name = model.bubble.name;
- manager.code = [NSString stringWithFormat:@"%d", model.font.code];
- manager.color = model.font.color;
- [manager insertBubbleFontTable];
- }
- }
-
-
-
- // 缓存图片
- // NSMutableArray *imagesArray = [NSMutableArray array];
- // for (NSDictionary *modelDict in array1) {
- // JLBubbleModel *model = [JLBubbleModel mj_objectWithKeyValues:modelDict];
- // [imagesArray addObject:[NSURL URLWithString:model.bubble.iosLeftUrl]];
- // [imagesArray addObject:[NSURL URLWithString:model.bubble.iosRightUrl]];
- //// [imagesArray addObject:[NSURL URLWithString:model.homeUrl]];
- // }
- // [[JLBubbleManager sharedManager] cacheBubbleImage:imagesArray];
- }
-
- if ([aDownload.action isEqualToString:act_customerLinkList])
- {
- g_App.customerLinkListArray = array1;
- }
-
- if( [aDownload.action isEqualToString:act_Config]){
-
- [g_config didReceive:dict];
- [self actionConfig];
- }
- if([aDownload.action isEqualToString:act_CheckPhone]){
-
- }
- if([aDownload.action isEqualToString:act_SendSMS]){
- [JXMyTools showTipView:Localized(@"JXAlert_SendOK")];
- /*
- _send.selected = YES;
- _send.userInteractionEnabled = NO;
- _send.backgroundColor = [UIColor grayColor];
- _smsCode = [[dict objectForKey:@"code"] copy];
-
- [_send setTitle:@"60s" forState:UIControlStateSelected];
- _seconds = 60;
- _timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(showTime:) userInfo:_send repeats:YES];
- */
- }
- if( [aDownload.action isEqualToString:act_UserLogin] || [aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1] || [aDownload.action isEqualToString:act_sdkLogin] || [aDownload.action isEqualToString:act_sdkLoginV1] || [aDownload.action isEqualToString:act_UserLoginV1] || [aDownload.action isEqualToString:act_UserSMSLogin]){
-
- if ([dict.allKeys containsObject:@"authKey"]) {
- [_wait stop];
- [self createWaitAuthView];
- [self startAuthDevice:[dict objectForKey:@"authKey"]];
-
- return;
- }
-
- if ([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1] || [aDownload.action isEqualToString:act_sdkLogin] || [aDownload.action isEqualToString:act_sdkLoginV1] ) {
-
- g_server.openId = nil;
- [g_default setBool:YES forKey:kTHIRD_LOGIN_AUTO];
- }else {
- [g_default setBool:NO forKey:kTHIRD_LOGIN_AUTO];
- }
- // if (!IsStringNull(_pwd.text)) {
- // _user.password = [g_server getMD5String:_pwd.text];
- // }
- // [g_default setBool:[[dict objectForKey:@"multipleDevices"] boolValue] forKey:kISMultipleLogin];
- // [g_default synchronize];
-
- [g_server doLoginOK:dict user:_user];
-
- if(self.isSwitchUser){
- //切换登录,同步好友
- [g_notify postNotificationName:kXmppClickLoginNotifaction object:nil];
-
- // 更新“我”页面
- [g_notify postNotificationName:kUpdateUserNotifaction object:nil];
- }
- else
- [g_App showMainUI];
- [self actionQuit];
-
- [_wait stop];
- }
- if([aDownload.action isEqualToString:act_userLoginAuto] || [aDownload.action isEqualToString:act_userLoginAutoV1]){
- // int status = [[dict objectForKey:@"serialStatus"] intValue];
- // int token = [[dict objectForKey:@"tokenExists"] intValue];
- // if(status == 2){//序列号一致
- // if(token==1){//Token也存在,说明不用登录了
-
- // [g_default setBool:[[dict objectForKey:@"multipleDevices"] boolValue] forKey:kISMultipleLogin];
- // [g_default synchronize];
- // [g_server getAppResource:@"2" ToView:self];
-
-
- [g_server doLoginOK:dict user:_user];
- [g_App showMainUI];
- [self actionQuit];
- // }else{
- // //Token不存在
- // [g_App showAlert:Localized(@"JX_LoginAgain")];
- // _launchImageView.hidden = YES;
- // }
- // }else{
- // //设备号已换
- // [g_App showAlert:Localized(@"JX_LoginAgainNow")];
- // _launchImageView.hidden = YES;
- // }
-
- [_wait stop];
- }
- if ([aDownload.action isEqualToString:act_GetWxOpenId]) {
- _launchImageView.hidden = NO;
- g_server.openId = [dict objectForKey:@"openid"];
- // [g_server wxSdkLogin:_user type:2 openId:g_server.openId toView:self];
- [g_loginServer wxSdkLoginV1:_user type:2 openId:g_server.openId toView:self];
- }
-
- if ([aDownload.action isEqualToString:act_getAppResource]) {
- // NSLog(@"%@",array1);
- NSMutableArray *tempArray0 = [NSMutableArray array];
- NSMutableArray *tempArray2 = [NSMutableArray array];
- for (NSDictionary *resourceDict in array1) {
- NSString *code = resourceDict[@"code"];
- if ([code isEqualToString:@"0"]) {
- [tempArray0 addObject:resourceDict];
- }else if ([code isEqualToString:@"2"]) {
- [tempArray2 addObject:resourceDict];
- }
- }
- if (tempArray0.count>0) {
- g_App.linkArray = tempArray0;
- g_App.imgUrl = tempArray0[0][@"imgUrl"];
- }
- if (tempArray2.count>0) {
- NSDictionary *adDict = tempArray2.firstObject;
- [g_App setupLunchADUrl:adDict[@"imgUrl"] link:adDict[@"link"]];
- }else {
- [g_notify postNotificationName:kLaunchAdShowFinishNotifaction object:nil];
- }
-
- }
-
- _btn.userInteractionEnabled = YES;
- }
- -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
- _btn.userInteractionEnabled = YES;
- _launchImageView.hidden = YES;
-
- NSLog(@"视频地址:%@",aDownload.action);
-
- if ([aDownload.action isEqualToString:act_UserDeviceIsAuth]) {
- if ([[dict objectForKey:@"resultCode"] intValue] == 101987) {
- [self changeAccount];
- [g_server getSetting:self];
- }
- return 1;
- }
- if ([aDownload.action isEqualToString:act_Config]) {
-
- NSString *url = [g_default stringForKey:kLastApiUrl];
- g_config.apiUrl = url;
-
- [self actionConfig];
- return 1;
- }
- [_wait stop];
- if (([aDownload.action isEqualToString:act_sdkLogin] || [aDownload.action isEqualToString:act_sdkLoginV1]) && [[dict objectForKey:@"resultCode"] intValue] == 1040305) {
- inputPhoneVC *vc = [[inputPhoneVC alloc] init];
- vc.isThirdLogin = YES;
- vc.type = (int)self.type;
- [g_navigation pushViewController:vc animated:YES];
- // loginVC *login = [loginVC alloc];
- // login.isThirdLogin = YES;
- // login.isAutoLogin = NO;
- // login.isSwitchUser= NO;
- // login = [login init];
- // [g_navigation pushViewController:login animated:YES];
- return 1;
- }
- if (([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1]) && [[dict objectForKey:@"resultCode"] intValue] == 1040306) {
- inputPhoneVC *vc = [[inputPhoneVC alloc] init];
- vc.isThirdLogin = YES;
- vc.type = (int)self.type;
- [g_navigation pushViewController:vc animated:YES];
- return 1;
- }
- if([aDownload.action isEqualToString:act_userLoginAuto] || [aDownload.action isEqualToString:act_userLoginAutoV1]){
- [g_default removeObjectForKey:kMY_USER_TOKEN];
- [share_defaults removeObjectForKey:kMY_ShareExtensionToken];
- }
- if ([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1]) {
- // g_server.openId = nil;
- }
- if ([aDownload.action isEqualToString:act_SendSMS]) {
- //[_send setTitle:Localized(@"JX_Send") forState:UIControlStateNormal];
- }
-
- return 1;
- }
- -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
- _btn.userInteractionEnabled = YES;
- _launchImageView.hidden = YES;
- NSLog(@"视频地址:%@",aDownload.action);
- if ([aDownload.action isEqualToString:act_Config]) {
-
- NSString *url = [g_default stringForKey:kLastApiUrl];
- g_config.apiUrl = url;
-
- [self actionConfig];
- return 1;
- }
- if([aDownload.action isEqualToString:act_userLoginAuto] || [aDownload.action isEqualToString:act_userLoginAutoV1]){
- [g_default removeObjectForKey:kMY_USER_TOKEN];
- [share_defaults removeObjectForKey:kMY_ShareExtensionToken];
- }
- if ([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1]) {
- // g_server.openId = nil;
- }
-
- if ([aDownload.action isEqualToString:act_SendSMS]) {
- //[_send setTitle:Localized(@"JX_Send") forState:UIControlStateNormal];
- }
- [_wait stop];
- return 1;
- }
- -(void) didServerConnectStart:(JXConnection*)aDownload{
- // _btn.userInteractionEnabled = NO;
- if([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1] || [aDownload.action isEqualToString:act_sdkLogin]|| [aDownload.action isEqualToString:act_sdkLoginV1]){
- [_wait start];
- }
- }
-
-
- -(void)autoLogin{
-
- // _btn.userInteractionEnabled = ![g_server autoLogin:self];
- [JXRegisterShowView closeView];
- NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kMY_USER_TOKEN];
- _btn.userInteractionEnabled = token.length > 0;
- if (token.length > 0) {
- [g_loginServer autoLoginWithToView:self];
- }else {
- _launchImageView.hidden = YES;
- }
- // if (_btn.userInteractionEnabled) {
- // _launchImageView.hidden = YES;
- // }
-
- }
- -(void)onRegistered:(NSNotification *)notifacation{
- [self actionQuit];
-
- if(!self.isSwitchUser)
- [g_App showMainUI];
- }
- -(void)actionQuit{
- [super actionQuit];
- // _pSelf = nil;
- }
-
- - (void)areaCodeBtnClick:(UIButton *)but{
- [self.view endEditing:YES];
- JXTelAreaListVC *telAreaListVC = [[JXTelAreaListVC alloc] init];
- telAreaListVC.telAreaDelegate = self;
- telAreaListVC.didSelect = @selector(didSelectTelArea:);
- // [g_window addSubview:telAreaListVC.view];
- [g_navigation pushViewController:telAreaListVC animated:YES];
- }
- - (void)didSelectTelArea:(NSString *)areaCode{
- _areaCodeBtn=areaCode;
- }
-
- - (void)didSelectedCheckBox:(QCheckBox *)checkbox checked:(BOOL)checked{
- [g_default setObject:[NSNumber numberWithBool:checked] forKey:@"agreement"];
- [g_default synchronize];
- }
-
- // 获取启动图
- - (NSString *)getLaunchImageName
- {
- NSString *viewOrientation = @"Portrait";
- if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
- viewOrientation = @"Landscape";
- }
- NSString *launchImageName = nil;
- NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
- CGSize viewSize = tyCurrentWindow.bounds.size;
- for (NSDictionary* dict in imagesDict)
- {
- CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
-
- if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
- {
- launchImageName = dict[@"UILaunchImageName"];
- }
- }
- return launchImageName;
- }
- #pragma mark JXLocationDelegate
- - (void)location:(JXLocation *)location CountryCode:(NSString *)countryCode CityName:(NSString *)cityName CityId:(NSString *)cityId Address:(NSString *)address Latitude:(double)lat Longitude:(double)lon{
- g_server.countryCode = countryCode;
- g_server.cityName = cityName;
- g_server.cityId = [cityId intValue];
- g_server.address = address;
- g_server.latitude = lat;
- g_server.longitude = lon;
-
- NSDictionary *dict = @{@"latitude":@(lat),@"longitude":@(lon)};
-
- [g_default setObject:dict forKey:kLocationLogin];
- }
-
-
- - (void)createWaitAuthView{
- self.waitAuthView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH,JX_SCREEN_HEIGHT)];
- self.waitAuthView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
- UITapGestureRecognizer *ges = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeAccount)];
- [self.waitAuthView addGestureRecognizer:ges];
- [self.view addSubview:self.waitAuthView];
-
- UIView *authView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH - 80, JX_SCREEN_HEIGHT / 3)];
- authView.backgroundColor = [UIColor whiteColor];
- authView.layer.cornerRadius = 10;
- authView.layer.masksToBounds = YES;
- CGPoint center = authView.center;
-
- UIImageView *imgV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 95, 95)];
- imgV.image = [UIImage imageNamed:@"ALOGO_120"];
- [authView addSubview:imgV];
- imgV.center = CGPointMake(center.x, 20 + 95/2);
-
- UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH - 200, 50)];
- lab.text = Localized(@"JX_WaitingForAuthorization");
- lab.font = [UIFont systemFontOfSize:17];
- lab.textColor = [UIColor blackColor];
- lab.textAlignment = NSTextAlignmentCenter;
- [authView addSubview:lab];
- lab.center = CGPointMake(center.x, CGRectGetMaxY(imgV.frame) + 30);
-
-
- UIButton *btn = [UIFactory createCommonButton:Localized(@"JX_SwitchAccount") target:self action:@selector(changeAccount)];
- btn.custom_acceptEventInterval = 1.0f;
- [btn.titleLabel setFont:g_factory.font17];
- btn.layer.cornerRadius = 20;
- btn.clipsToBounds = YES;
- btn.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH-100*2, 40);
- [authView addSubview:btn];
- btn.center = CGPointMake(center.x, CGRectGetMaxY(authView.frame) - 40);
- btn.userInteractionEnabled = NO;
-
- [self.waitAuthView addSubview:authView];
- authView.center = self.waitAuthView.center;
- }
- - (void)changeAccount{
- [self.waitAuthView removeFromSuperview];
- dispatch_cancel(_authTimer);
- _authTimer = nil;
- }
- - (void)startAuthDevice:(NSString *)str{
- if (_authTimer) {
- dispatch_cancel(_authTimer);
- _authTimer = nil;
- }
- dispatch_queue_t queue = dispatch_get_main_queue();
- _authTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
- dispatch_time_t start = DISPATCH_TIME_NOW;
- dispatch_time_t interval = 1.0 * NSEC_PER_SEC;
- dispatch_source_set_timer(_authTimer, start, interval, 0);
- dispatch_source_set_event_handler(_authTimer, ^{
- _count ++;
- [g_server loginIsAuthKey:str toView:self];
- if (_count == 300 ) {
- _count = 0;
- [self changeAccount];
- }
- });
- dispatch_resume(_authTimer);
- }
- -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
- [self.view endEditing:YES];
- }
- @end
|