1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324 |
- //
- // 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]) {
- NSDictionary *dictMM=[array1 firstObject];
- NSString *memberAcc= dictMM[@"url"];
-
- [[NSUserDefaults standardUserDefaults] setObject:array1 forKey:@"www_Array"];
- [[NSUserDefaults standardUserDefaults] synchronize];
-
- [[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_1200"];
- [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
|