12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652 |
- //
- // loginVC.m
- // shiku_im
- //
- // Created by flyeagleTang on 14-6-7.
- // Copyright (c) 2014年 Reese. All rights reserved.
- //
- #import "loginVC.h"
- #import "forgetPwdVC.h"
- #import "inputPhoneVC.h"
- #import "PSRegisterBaseVC.h"
- #import "JXMainViewController.h"
- #import "JXTelAreaListVC.h"
- #import "QCheckBox.h"
- #import "webpageVC.h"
- #import "JXLocation.h"
- #import "WXApi.h"
- #import "JXLabelObject.h"
- #import "JLBubbleModel.h"
- #import <TencentOpenAPI/TencentOAuth.h>
- #import <TencentOpenAPI/QQApiInterface.h>
- #import "JXShareAnQuanView.h"
-
- #define HEIGHT 35
- #define tyCurrentWindow [[UIApplication sharedApplication].windows firstObject]
- @interface loginVC ()<UITextFieldDelegate,QCheckBoxDelegate,JXLocationDelegate,JXLocationDelegate,WXApiDelegate,WXApiManagerDelegate,TencentSessionDelegate,TencentLoginDelegate>
- {
- UIButton *_areaCodeBtn;
- QCheckBox * _checkProtocolBtn;
- UIButton *_forgetBtn;
- BOOL _isFirstLocation;
- NSString *_myToken;
-
- //短信验证码登录
- UIButton *_switchLogin; //切换登录方式
- UIImageView * _imgCodeImg;
- UITextField *_imgCode; //图片验证码
- UIButton *_send; //发送短信
- UIButton * _graphicButton;
- NSString* _smsCode;
- int _seconds;
- NSTimer *_timer;
- NSInteger setServerNum;
- }
- @property(nonatomic,strong)dispatch_source_t authTimer;
- @property(nonatomic,assign)NSInteger count;
- @property(nonatomic,strong)UIView *waitAuthView;
- @property (nonatomic, retain)TencentOAuth *oauth;
- @property (nonatomic,strong) JXShareAnQuanView *vc;
- @property (nonatomic,copy) NSString *security;
- @end
- @implementation loginVC
- - (void)backBtnCLick{
- [g_navigation dismissViewController:self animated:NO];
- }
- - (id)init
- {
- self = [super init];
- if (self) {
- // _pSelf = self;
- _user = [[JXUserObject alloc] init];
- // self.isGotoBack = self.isSwitchUser;
- // self.title = Localized(@"JX_Login");
- self.heightFooter = 0;
- // self.heightHeader = JX_SCREEN_TOP;
- self.heightHeader = 0;
- //self.view.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH, JX_SCREEN_HEIGHT);
- if (_isThirdLogin) {
- // self.isGotoBack = YES;
- // self.title = Localized(@"JX_BindNo.");
- 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 createHeadAndFoot];
- self.tableBody.backgroundColor = [UIColor clearColor];
- UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.tableBody.bounds];
- imageView.contentMode = UIViewContentModeScaleAspectFill;
- // imageView.image = [UIImage imageNamed:@"new_login_bg"];
- imageView.backgroundColor=[UIColor whiteColor];
- [self.tableBody addSubview:imageView];
- self.isGotoBack = NO;
- _myToken = [g_default objectForKey:kMY_USER_TOKEN];
- [g_default setObject:nil forKey:kMyPayPrivateKey];
- int n = INSETS;
- g_server.isLogin = NO;
- g_navigation.lastVC = nil;
-
- UIButton * backBtn = [[UIButton alloc]initWithFrame:CGRectMake(10, 40, 44, 44)];
- [backBtn setImage:[UIImage imageNamed:@"photo_title_back_black"] forState:UIControlStateNormal];
- [self.view addSubview:backBtn];
- [backBtn addTarget:self action:@selector(backBtnCLick) forControlEvents:UIControlEventTouchUpInside];
-
- #if IS_SetupServer
- // Localized(@"JX_SetupServer")
- UIButton* btn = [UIFactory createButtonWithTitle:@"" titleFont:[UIFont systemFontOfSize:15] titleColor:[UIColor whiteColor] normal:nil highlight:nil];
- [btn setTitleColor:THESIMPLESTYLE ? [UIColor blackColor] : [UIColor whiteColor] forState:UIControlStateNormal];
- btn.backgroundColor = [UIColor clearColor];
- [btn addTarget:self action:@selector(onSetting) forControlEvents:UIControlEventTouchUpInside];
- btn.frame = CGRectMake(JX_SCREEN_WIDTH-88, JX_SCREEN_TOP - 38, 83, 30);
- btn.hidden = _isThirdLogin || self.isSMSLogin;
- //[self.tableHeader addSubview:btn];
- setServerNum = 0;
- #endif
-
- n += 50;
- //icon
- UIImageView * kuliaoIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ALOGO_1200"]];
- kuliaoIconView.frame = CGRectMake((JX_SCREEN_WIDTH-100)/2, n+20, 100, 100);
- // [self.tableBody addSubview:kuliaoIconView];
-
- UILabel *titleLable = [[UILabel alloc] init];
- titleLable.text = @"手机号登录";
- titleLable.textColor = kRGBColor51;
- titleLable.font = [UIFont systemFontOfSize:30 weight:(UIFontWeightBlack)];
- [titleLable sizeToFit];
- titleLable.frame = CGRectMake(JX_SCREEN_WIDTH/2- titleLable.frame.size.width/2, JX_SCREEN_TOP, titleLable.frame.size.width, titleLable.frame.size.height);
- [titleLable sizeToFit];
- [self.tableBody addSubview:titleLable];
-
-
- //title
- NSString * titleStr;
- #if TAR_IM
- titleStr = APP_NAME;
- //#elif TAR_LIVE
- // NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
- // // app名称
- // titleStr = [infoDictionary objectForKey:@"CFBundleDisplayName"];
- #endif
- // UILabel * kuliaoTitleLabel = [UIFactory createLabelWith:CGRectMake(0, CGRectGetMaxY(kuliaoIconView.frame), 100, 35) text:titleStr font:g_factory.font20 textColor:[UIColor blackColor] backgroundColor:[UIColor clearColor]];
- // kuliaoTitleLabel.center = CGPointMake(kuliaoIconView.center.x, kuliaoTitleLabel.center.y);
- // kuliaoTitleLabel.textAlignment = NSTextAlignmentCenter;
- // [self.tableBody addSubview:kuliaoTitleLabel];
-
- // UIButton* lb;
- /*
- lb = [[JXLabel alloc]initWithFrame:CGRectMake(10, 100, 60, 30)];
- lb.textColor = [UIColor blackColor];
- lb.backgroundColor = [UIColor clearColor];
- lb.text = @"手机:";
- [self.tableBody addSubview:lb];
- [lb release];
-
- lb = [[JXLabel alloc]initWithFrame:CGRectMake(10, 150, 60, 30)];
- lb.textColor = [UIColor blackColor];
- lb.backgroundColor = [UIColor clearColor];
- lb.text = @"密码:";
- [self.tableBody addSubview:lb];
- [lb release];*/
- //(INSETS, n, self_width-INSETS-INSETS, HEIGHT)
-
- n += 143;
- //区号
- if (!_phone) {
-
- if ([g_config.regeditPhoneOrName intValue] != 1) {
- _phone = [UIFactory createTextFieldWith:CGRectMake(40, n, JX_SCREEN_WIDTH-40*2, HEIGHT) delegate:self returnKeyType:UIReturnKeyNext secureTextEntry:NO placeholder:Localized(@"JX_InputPhone") font:g_factory.font16];
- _phone.attributedPlaceholder = [[NSAttributedString alloc] initWithString:Localized(@"JX_InputPhone") attributes:@{NSForegroundColorAttributeName: [UIColor lightGrayColor]}];
- _phone.keyboardType = UIKeyboardTypeDefault;
- }else {
- _phone = [UIFactory createTextFieldWith:CGRectMake(40, n, JX_SCREEN_WIDTH-40*2, HEIGHT) delegate:self returnKeyType:UIReturnKeyNext secureTextEntry:NO placeholder:Localized(@"JX_InputUserAccount") font:g_factory.font16];
- _phone.attributedPlaceholder = [[NSAttributedString alloc] initWithString:Localized(@"JX_InputUserAccount") attributes:@{NSForegroundColorAttributeName: [UIColor lightGrayColor]}];
- _phone.keyboardType = UIKeyboardTypeNumberPad;
- }
-
- _phone.borderStyle = UITextBorderStyleNone;
- _phone.clearButtonMode = UITextFieldViewModeWhileEditing;
- UIImage *textFieldBgImage = [UIImage imageNamed:@"new_login_button_bg.png"];
- [_phone setBackground:textFieldBgImage];
- // _phone.keyboardType = UIKeyboardTypeNumberPad;
- [self.tableBody addSubview:_phone];
- [_phone addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
-
- UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 37, HEIGHT)];
- _phone.leftView = leftView;
- _phone.leftViewMode = UITextFieldViewModeAlways;
- UIImageView *phIgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, HEIGHT/2-11, 22, 22)];
- phIgView.image = [UIImage imageNamed:@"account"];
- phIgView.contentMode = UIViewContentModeScaleAspectFit;
- [leftView addSubview:phIgView];
-
- UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, HEIGHT-LINE_WH, _phone.frame.size.width, LINE_WH)];
- line.backgroundColor = THE_LINE_COLOR;
- [_phone addSubview:line];
-
- UIView *riPhView = [[UIView alloc] initWithFrame:CGRectMake(_phone.frame.size.width-44, 0, HEIGHT, HEIGHT)];
- _phone.rightView = riPhView;
- _phone.rightViewMode = UITextFieldViewModeAlways;
- [_phone addTarget:self action:@selector(longLimit:) forControlEvents:UIControlEventEditingChanged];
- NSString *areaStr;
- if (![g_default objectForKey:kMY_USER_AREACODE]) {
- areaStr = @"+86";
- } else {
- areaStr = [NSString stringWithFormat:@"+%@",[g_default objectForKey:kMY_USER_AREACODE]];
- }
- _areaCodeBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, HEIGHT/2-11, HEIGHT-5, 22)];
- [_areaCodeBtn setTitle:areaStr forState:UIControlStateNormal];
- _areaCodeBtn.titleLabel.font = SYSFONT(16);
- [_areaCodeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- // [_areaCodeBtn setImage:[UIImage imageNamed:@"account"] forState:UIControlStateNormal];
- _areaCodeBtn.custom_acceptEventInterval = 1.0f;
- //[_areaCodeBtn addTarget:self action:@selector(areaCodeBtnClick:) forControlEvents:UIControlEventTouchUpInside];
- [self resetBtnEdgeInsets:_areaCodeBtn];
- [riPhView addSubview:_areaCodeBtn];
- }
-
- //账号
- // _phone = [[UITextField alloc] initWithFrame:CGRectMake(50, n+170, JX_SCREEN_WIDTH-50*2, HEIGHT)];
- // _phone.delegate = self;
- // _phone.autocorrectionType = UITextAutocorrectionTypeNo;
- // _phone.autocapitalizationType = UITextAutocapitalizationTypeNone;
- // _phone.enablesReturnKeyAutomatically = YES;
- // _phone.borderStyle = UITextBorderStyleRoundedRect;
- // _phone.returnKeyType = UIReturnKeyDone;
- // _phone.clearButtonMode = UITextFieldViewModeWhileEditing;
- // _phone.placeholder = Localized(@"JX_InputPhone");
- // _phone.userInteractionEnabled = YES;
- // [_phone addTarget:self action:@selector(longLimit:) forControlEvents:UIControlEventEditingChanged];
- // [self.tableBody addSubview:_phone];
- // [_phone release];
- n = n+HEIGHT;
- //监听账号是否被删除
- //
- // UIImageView *leftView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 34, 30)];
- // leftView.image = [UIImage imageNamed:@"userhead"];
- // leftView.contentMode = UIViewContentModeScaleAspectFit;
- // _phone.leftView = leftView;
- // _phone.leftViewMode = UITextFieldViewModeAlways;
-
- if (self.isSMSLogin) {
- //图片验证码
- _imgCode = [UIFactory createTextFieldWith:CGRectMake(40, n, JX_SCREEN_WIDTH-40*2-70-INSETS-35-4, HEIGHT) delegate:self returnKeyType:UIReturnKeyNext secureTextEntry:NO placeholder:Localized(@"JX_inputImgCode") font:g_factory.font16];
- _imgCode.attributedPlaceholder = [[NSAttributedString alloc] initWithString:Localized(@"JX_inputImgCode") attributes:@{NSForegroundColorAttributeName:[UIColor lightGrayColor]}];
- _imgCode.borderStyle = UITextBorderStyleNone;
- _imgCode.clearButtonMode = UITextFieldViewModeWhileEditing;
- [self.tableBody addSubview:_imgCode];
-
- UIView *imCView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 37, HEIGHT)];
- _imgCode.leftView = imCView;
- _imgCode.leftViewMode = UITextFieldViewModeAlways;
- UIImageView *imCIView = [[UIImageView alloc] initWithFrame:CGRectMake(2, HEIGHT/2-11, 22, 22)];
- imCIView.image = [UIImage imageNamed:@"verify"];
- imCIView.contentMode = UIViewContentModeScaleAspectFit;
- [imCView addSubview:imCIView];
-
- UIView *imCLine = [[UIView alloc] initWithFrame:CGRectMake(0, HEIGHT-LINE_WH, _phone.frame.size.width, LINE_WH)];
- imCLine.backgroundColor = THE_LINE_COLOR;
- [_imgCode addSubview:imCLine];
-
- _imgCodeImg = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_imgCode.frame)+INSETS, 0, 70, 35)];
- _imgCodeImg.center = CGPointMake(_imgCodeImg.center.x, _imgCode.center.y);
- _imgCodeImg.userInteractionEnabled = YES;
- [self.tableBody addSubview:_imgCodeImg];
-
- UIView *imgCodeLine = [[UIView alloc] initWithFrame:CGRectMake(_imgCodeImg.frame.size.width, 3, LINE_WH, _imgCodeImg.frame.size.height-6)];
- imgCodeLine.backgroundColor = THE_LINE_COLOR;
- [_imgCodeImg addSubview:imgCodeLine];
-
- _graphicButton = [UIButton buttonWithType:UIButtonTypeCustom];
- _graphicButton.frame = CGRectMake(CGRectGetMaxX(_imgCodeImg.frame)+6, 7, 26, 26);
- _graphicButton.center = CGPointMake(_graphicButton.center.x,_imgCode.center.y);
- [_graphicButton setBackgroundImage:[UIImage imageNamed:@"refreshGraphic"] forState:UIControlStateNormal];
- [_graphicButton setBackgroundImage:[UIImage imageNamed:@"refreshGraphic"] forState:UIControlStateHighlighted];
- [_graphicButton addTarget:self action:@selector(refreshGraphicAction:) forControlEvents:UIControlEventTouchUpInside];
- [self.tableBody addSubview:_graphicButton];
- n = n+HEIGHT;
- }
- n = n+HEIGHT;
- //密码
- _pwd = [[UITextField alloc] initWithFrame:CGRectMake(40, n, JX_SCREEN_WIDTH-40*2, HEIGHT)];
- _pwd.delegate = self;
- _pwd.font = g_factory.font16;
- _pwd.autocorrectionType = UITextAutocorrectionTypeNo;
- _pwd.autocapitalizationType = UITextAutocapitalizationTypeNone;
- _pwd.enablesReturnKeyAutomatically = YES;
- // _pwd.borderStyle = UITextBorderStyleRoundedRect;
- _pwd.returnKeyType = UIReturnKeyDone;
- _pwd.clearButtonMode = UITextFieldViewModeWhileEditing;
- _pwd.attributedPlaceholder = [[NSAttributedString alloc] initWithString:Localized(@"JX_InputPassWord") attributes:@{NSForegroundColorAttributeName: [UIColor lightGrayColor]}];
- _pwd.secureTextEntry = !self.isSMSLogin;
- _pwd.userInteractionEnabled = YES;
- UIImage *textFieldBgImage = [UIImage imageNamed:@"new_login_button_bg.png"];
- [_pwd setBackground:textFieldBgImage];
-
- [self.tableBody addSubview:_pwd];
-
- // UIView *line = [[UIView alloc] initWithFrame:CGRectMake(40,n+1, JX_SCREEN_WIDTH-40*2, 1)];
- // line.backgroundColor = HEXCOLOR(0xD6D6D6);
- // [_pwd addSubview:line];
-
- // //忘记密码
- // UIButton *lbUser = [[UIButton alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH-60-50, n+10, 70, 20)];
- // [lbUser setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- // [lbUser setTitle:Localized(@"JX_ForgetPassWord") forState:UIControlStateNormal];
- // lbUser.titleLabel.font = g_factory.font16;
- // lbUser.custom_acceptEventInterval = 1.0f;
- // [lbUser addTarget:self action:@selector(onForget) forControlEvents:UIControlEventTouchUpInside];
- // lbUser.titleEdgeInsets = UIEdgeInsetsMake(0, -27, 0, 0);
- // [self.tableBody addSubview:lbUser];
- // _forgetBtn = lbUser;
-
- if (self.isSMSLogin) {
- _pwd.attributedPlaceholder = [[NSAttributedString alloc] initWithString:Localized(@"JX_InputMessageCode") attributes:@{NSForegroundColorAttributeName: [UIColor lightGrayColor]}];
-
- _send = [UIFactory createButtonWithTitle:Localized(@"JX_Send")
- titleFont:g_factory.font16
- titleColor:[UIColor whiteColor]
- normal:nil
- highlight:nil ];
- _send.frame = CGRectMake(JX_SCREEN_WIDTH-70-40-11, n+HEIGHT/2-15, 70, 30);
- [_send addTarget:self action:@selector(sendSMS) forControlEvents:UIControlEventTouchUpInside];
- _send.backgroundColor = g_theme.themeColor;
- _send.layer.masksToBounds = YES;
- _send.layer.cornerRadius = 7.f;
- [self.tableBody addSubview:_send];
-
- }else {
- UIView *eyeView = [[UIView alloc]initWithFrame:CGRectMake(_pwd.frame.size.width-HEIGHT, 0, HEIGHT, HEIGHT)];
- _pwd.rightView = eyeView;
- _pwd.rightViewMode = UITextFieldViewModeAlways;
- UIButton *rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, HEIGHT/2-6.5, 21, 13)];
- [rightBtn setBackgroundImage:[UIImage imageNamed:@"ic_password_hide"] forState:UIControlStateNormal];
- [rightBtn setBackgroundImage:[UIImage imageNamed:@"ic_password_display"] forState:UIControlStateSelected];
- [rightBtn addTarget:self action:@selector(passWordRightViewClicked:) forControlEvents:UIControlEventTouchUpInside];
- [eyeView addSubview:rightBtn];
- }
-
- n = n+HEIGHT+INSETS;
-
- UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 37, HEIGHT)];
- _pwd.leftView = rightView;
- _pwd.leftViewMode = UITextFieldViewModeAlways;
- UIImageView *riIgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, HEIGHT/2-11, 22, 22)];
- riIgView.image = [UIImage imageNamed:@"password"];
- riIgView.contentMode = UIViewContentModeScaleAspectFit;
- [rightView addSubview:riIgView];
-
- UIView *verticalLine = [[UIView alloc] initWithFrame:CGRectMake(0, HEIGHT-LINE_WH, _pwd.frame.size.width, LINE_WH)];
- verticalLine.backgroundColor = THE_LINE_COLOR;
- [_pwd addSubview:verticalLine];
-
- n += 6;
-
- //注册用户
- CGSize size =[Localized(@"JX_Register") boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:g_factory.font16} context:nil].size;
- // UIButton *lb = [[UIButton alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH-40-(140 - (140 - size.width) / 2), n, 140, 20)];
- UIButton *lb = [[UIButton alloc]initWithFrame:CGRectMake(JX_SCREEN_WIDTH-14-(140 - (140 - size.width) / 2), 40, 140, 20)];
- lb.titleLabel.font = g_factory.font24;
- [lb setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
- [lb setTitle:@"注册" forState:UIControlStateNormal];
- lb.custom_acceptEventInterval = 1.0f;
- [lb addTarget:self action:@selector(onRegister) forControlEvents:UIControlEventTouchUpInside];
- lb.hidden = self.isSMSLogin;
-
- [self.tableBody addSubview:lb];
-
- if (!self.isSMSLogin) {
- n = n+36;
- }
-
- if (![[g_default objectForKey:@"agreement"] boolValue]) { //用户协议
- UIView * protocolView = [[UIView alloc] init];
- [self.tableBody addSubview:protocolView];
- //
- // UIButton * catProtocolbtn = [UIButton buttonWithType:UIButtonTypeSystem];
- // catProtocolbtn.frame = CGRectMake(0, 0, protocolView.frame.size.width, 25);
- NSString * agreeStr = @"登录注册代表同意";
- NSString * protocolStr = Localized(@"JX_ShikuProtocolTitle");
- // NSString * agreeProtocolStr = [NSString stringWithFormat:@"%@%@",agreeStr,protocolStr];
- // NSMutableAttributedString* tncString = [[NSMutableAttributedString alloc] initWithString:agreeProtocolStr];
- //
- // [tncString addAttribute:NSUnderlineStyleAttributeName
- // value:@(NSUnderlineStyleSingle)
- // range:(NSRange){agreeStr.length,[protocolStr length]}];
- // [tncString addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(agreeStr.length,[protocolStr length])];
- // [tncString addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0,agreeStr.length)];
- // [tncString addAttribute:NSUnderlineColorAttributeName value:[UIColor blueColor] range:(NSRange){agreeStr.length,[protocolStr length]}];
- // [catProtocolbtn setAttributedTitle:tncString forState:UIControlStateNormal];
- // [catProtocolbtn addTarget:self action:@selector(catUserProtocol) forControlEvents:UIControlEventTouchUpInside];
- // [protocolView addSubview:catProtocolbtn];
- UIButton *agrBtn = [[UIButton alloc] init];
- agrBtn.titleLabel.font = SYSFONT(13);
- CGSize agreSize = [agreeStr boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:agrBtn.titleLabel.font} context:nil].size;
- agrBtn.frame = CGRectMake(0, 0, agreSize.width, agreSize.height);
- [agrBtn setTitle:agreeStr forState:UIControlStateNormal];
- [agrBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
-
- [agrBtn addTarget:self
- action:@selector(agrBtnAction:)
- forControlEvents:UIControlEventTouchUpInside];
- [protocolView addSubview:agrBtn];
- UILabel *protocolLab = [[UILabel alloc] init];
- protocolLab.font = SYSFONT(13);
- CGSize proSize = [protocolStr boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:protocolLab.font} context:nil].size;
- protocolLab.frame = CGRectMake(CGRectGetMaxX(agrBtn.frame), 0, proSize.width, proSize.height);
- protocolLab.textColor = HEXCOLOR(0x2A98FF);
-
- NSDictionary *attribtDic = @{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleNone]};
- NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:protocolStr attributes:attribtDic];
- protocolLab.attributedText = attribtStr;
- [protocolView addSubview:protocolLab];
- protocolLab.userInteractionEnabled = YES;
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(catUserProtocol)];
- [protocolLab addGestureRecognizer:tap];
-
- NSString *agreeStr1 = @"和";
- UIButton *agrBtn1 = [[UIButton alloc] init];
- agrBtn1.titleLabel.font = SYSFONT(13);
- CGSize agreSize1 = [agreeStr1 boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:agrBtn1.titleLabel.font} context:nil].size;
- agrBtn1.frame = CGRectMake(CGRectGetMaxX(protocolLab.frame), 0, agreSize1.width, agreSize1.height);
- [agrBtn1 setTitle:agreeStr1 forState:UIControlStateNormal];
- [agrBtn1 setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
-
- [agrBtn1 addTarget:self
- action:@selector(agrBtnAction:)
- forControlEvents:UIControlEventTouchUpInside];
- [protocolView addSubview:agrBtn1];
-
- NSString *protocolStr1 = @"隐私政策";
- UILabel *protocolLab1 = [[UILabel alloc] init];
- protocolLab1.font = SYSFONT(13);
- CGSize proSize1 = [protocolStr1 boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:protocolLab1.font} context:nil].size;
- protocolLab1.frame = CGRectMake(CGRectGetMaxX(agrBtn1.frame), 0, proSize1.width, proSize1.height);
- protocolLab1.textColor = HEXCOLOR(0x2A98FF);
-
- NSDictionary *attribtDic1 = @{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleNone]};
- NSMutableAttributedString *attribtStr1 = [[NSMutableAttributedString alloc]initWithString:protocolStr1 attributes:attribtDic1];
- protocolLab1.attributedText = attribtStr1;
- [protocolView addSubview:protocolLab1];
- protocolLab1.userInteractionEnabled = YES;
- UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(catUserProtocol)];
- [protocolLab1 addGestureRecognizer:tap1];
- CGFloat w = agreSize.width+proSize.width+agreSize1.width+proSize1.width;
- protocolView.frame = CGRectMake((JX_SCREEN_WIDTH -w)/2, n-30, w, 25);
- _checkProtocolBtn = [[QCheckBox alloc] initWithDelegate:self];
- // [self.tableBody addSubview:_checkProtocolBtn];
- _checkProtocolBtn.frame = CGRectMake((JX_SCREEN_WIDTH -w)/2-20, n, 20, 20);
- // CGSize size = [agreeProtocolStr boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:catProtocolbtn.titleLabel.font} context:nil].size;
- // _checkProtocolBtn.frame = CGRectMake((catProtocolbtn.frame.size.width - size.width) / 2 - 28, 3, 20, 20);
- n+=25;
- }
-
- n+=80;
-
- //登陆按钮
- _btn = [UIFactory createCommonButton:@"同意协议并登录" target:self action:@selector(onClick)];
- _btn.custom_acceptEventInterval = 1.0f;
- [_btn.titleLabel setFont:g_factory.font16];
- _btn.layer.cornerRadius = 20.f;
- _btn.clipsToBounds = YES;
- _btn.frame = CGRectMake(60, n, JX_SCREEN_WIDTH-60*2, 40);
- _btn.userInteractionEnabled = NO;
- [self.tableBody addSubview:_btn];
- n = n+HEIGHT+INSETS+INSETS;
-
- //忘记密码
- UIButton *lbUser = [[UIButton alloc]init];
- [lbUser setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
- [lbUser setTitle:Localized(@"JX_ForgetPassWord") forState:UIControlStateNormal];
- lbUser.titleLabel.font = g_factory.font16;
- lbUser.custom_acceptEventInterval = 1.0f;
- [lbUser addTarget:self action:@selector(onForget) forControlEvents:UIControlEventTouchUpInside];
- lbUser.titleEdgeInsets = UIEdgeInsetsMake(0, -27, 0, 0);
- [self.tableBody addSubview:lbUser];
- [lbUser mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.mas_equalTo(self.tableBody.mas_centerX);
- make.top.mas_equalTo(_btn.mas_bottom).mas_offset(20);
- make.width.mas_equalTo(90);
- }];
- // lbUser.hidden = self.isSMSLogin;
- _forgetBtn = lbUser;
-
-
-
-
- NSString *protocolStr2 =@"";// @"登录遇到问题?";
- UILabel *protocolLab2 = [[UILabel alloc] init];
- protocolLab2.font = SYSFONT(13);
- CGSize proSize2 = [protocolStr2 boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:protocolLab2.font} context:nil].size;
- protocolLab2.frame = CGRectMake((JX_SCREEN_WIDTH-proSize2.width)/2, n, proSize2.width, proSize2.height);
- protocolLab2.textColor = HEXCOLOR(0x2A98FF);
-
- NSDictionary *attribtDic2 = @{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleNone]};
- NSMutableAttributedString *attribtStr2 = [[NSMutableAttributedString alloc]initWithString:protocolStr2 attributes:attribtDic2];
- //protocolLab2.attributedText = attribtStr2;
- [self.tableBody addSubview:protocolLab2];
- protocolLab2.userInteractionEnabled = YES;
- UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onForget)];
- //[protocolLab2 addGestureRecognizer:tap2];
-
- n = n+HEIGHT+INSETS;
-
- // 屏幕太小,第三方登录超过登录界面,就另外计算y
- CGFloat wxWidth = 48;
- BOOL isSmall = JX_SCREEN_HEIGHT-JX_SCREEN_TOP - wxWidth - 30 <= CGRectGetMaxY(_btn.frame)+30;
- CGFloat loginY = isSmall ? CGRectGetMaxY(_btn.frame)+30 : JX_SCREEN_HEIGHT-JX_SCREEN_TOP - wxWidth - 60;
- // UIImageView *wxLogin = [[UIImageView alloc] initWithFrame:CGRectMake((JX_SCREEN_WIDTH-wxWidth*3)/4, loginY, wxWidth, wxWidth)];
- UIImageView *wxLogin = [[UIImageView alloc] initWithFrame:CGRectMake((JX_SCREEN_WIDTH/3)-(wxWidth/2), loginY+30, wxWidth/2, wxWidth/2)];
- //wxLogin.image = [UIImage imageNamed:@"wechat_icon"];
- wxLogin.userInteractionEnabled = NO;
- [self.tableBody addSubview:wxLogin];
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didWechatToLogin:)];
- [wxLogin addGestureRecognizer:tap];
- wxLogin.hidden = (_isThirdLogin || self.isSMSLogin);
- if (isSmall) {
- self.tableBody.contentSize = CGSizeMake(0, CGRectGetMaxY(wxLogin.frame)+20);
- }
-
- //QQ登录
- // UIImageView *qqLogin = [[UIImageView alloc] initWithFrame:CGRectMake((JX_SCREEN_WIDTH-wxWidth*3)/4*2+wxWidth, loginY, wxWidth, wxWidth)];
- UIImageView *qqLogin = [[UIImageView alloc] initWithFrame:CGRectMake((JX_SCREEN_WIDTH/3*2)-(wxWidth/2), loginY+30, wxWidth/2, wxWidth/2)];
- //qqLogin.image = [UIImage imageNamed:@"qq_login"];
- qqLogin.userInteractionEnabled = NO;
- [self.tableBody addSubview:qqLogin];
- qqLogin.hidden = (_isThirdLogin || self.isSMSLogin);
-
- UITapGestureRecognizer *qqTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didQQToLogin:)];
- [qqLogin addGestureRecognizer:qqTap];
-
- //短信登录
- UIImageView *smsLogin = [[UIImageView alloc] initWithFrame:CGRectMake((JX_SCREEN_WIDTH-wxWidth*3)/4*3+wxWidth*2, loginY, wxWidth, wxWidth)];
- // smsLogin.image = [UIImage imageNamed:@"sms_login"];
- smsLogin.userInteractionEnabled = NO;
- // [self.tableBody addSubview:smsLogin];
- smsLogin.hidden = (_isThirdLogin || self.isSMSLogin);
-
- UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(switchLoginWay)];
- [smsLogin addGestureRecognizer:tap1];
-
- // 微信登录回调
- [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]) {
- [_phone setText:[g_default objectForKey:kMY_USER_LoginName]];
-
- _user.telephone = _phone.text;
- }
- if ([g_default objectForKey:kMY_USER_PASSWORD]) {
- // [_pwd setText:[g_default objectForKey:kMY_USER_PASSWORD]];
-
- _user.password = _pwd.text;
-
- }
- 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];
- }
- // NSString *area = [g_default objectForKey:kLocationArea];
- // if (area.length > 0) {
-
- 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];
- }
-
- // }else {
- // _isFirstLocation = NO;
- // JXLocation *location = [[JXLocation alloc] init];
- // location.delegate = self;
- // [location getLocationWithIp];
- // }
- }
- return self;
- }
- //验证手机号格式
- - (void)sendSMS{
- if (!_send.selected) {
- NSString *areaCode = [_areaCodeBtn.titleLabel.text stringByReplacingOccurrencesOfString:@"+" withString:@""];
- _user = [JXUserObject sharedInstance];
- _user.areaCode = areaCode;
-
- [g_server sendSMS:[NSString stringWithFormat:@"%@",_phone.text] areaCode:areaCode isRegister:NO imgCode:_imgCode.text toView:self];
- [_send setTitle:Localized(@"JX_Sending") forState:UIControlStateNormal];
- }
- }
- -(void)textFieldDidBeginEditing:(UITextField *)textField{
- if (textField == _imgCode) {
- if (!_imgCodeImg.image) {
-
- [self refreshGraphicAction:nil];
- }
- }
- }
- - (void)switchLoginWay {
- if (self.isSMSLogin) {
- [self actionQuit];
- }else {
- loginVC *vc = [loginVC alloc];
- vc.isSMSLogin = YES;
- vc = [vc init];
- [g_navigation pushViewController:vc animated:YES];
- }
- }
- -(void)refreshGraphicAction:(UIButton *)button{
- NSString *areaCode = [_areaCodeBtn.titleLabel.text stringByReplacingOccurrencesOfString:@"+" withString:@""];
- [g_server checkPhone:_phone.text areaCode:areaCode verifyType:1 toView:self];
- }
- -(void)getImgCodeImg{
- if([self isMobileNumber:_phone.text]){
- // if ([self checkPhoneNum]) {
- //请求图片验证码
- NSString *areaCode = [_areaCodeBtn.titleLabel.text stringByReplacingOccurrencesOfString:@"+" withString:@""];
- NSString * codeUrl = [g_server getImgCode:_phone.text areaCode:areaCode];
-
- NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL URLWithString:codeUrl] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:10.0];
-
- [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
- if (!connectionError) {
- UIImage * codeImage = [UIImage imageWithData:data];
- _imgCodeImg.image = codeImage;
- }else{
- NSLog(@"%@",connectionError);
- [g_App showAlert:connectionError.localizedDescription];
- }
- }];
- }
-
- }
- //验证手机号码格式
- - (BOOL)isMobileNumber:(NSString *)number{
- if ([g_config.isOpenSMSCode boolValue] && [g_config.regeditPhoneOrName intValue] != 1) {
- if ([_phone.text length] == 0) {
- [g_App showAlert:Localized(@"JX_InputPhone")];
- return NO;
- }
- }
- return 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)agrBtnAction:(UIButton *)btn {
-
- _checkProtocolBtn.selected = !_checkProtocolBtn.selected;
- [self didSelectedCheckBox:_checkProtocolBtn checked:_checkProtocolBtn.selected];
- }
- //设置文本框只能输入数字
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
-
- if (_phone == textField) {
- return [self validateNumber:string];
- }
- return YES;
-
- }
- - (BOOL)validateNumber:(NSString*)number {
- // if ([g_config.regeditPhoneOrName intValue] == 1) {
- // 如果用户名注册选项开启, 则不筛选
- NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"] invertedSet];
- NSString *filtered = [[number componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
- return [number isEqualToString:filtered];
- // }
- // BOOL res = YES;
- // NSCharacterSet *tmpSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"];
- // int i = 0;
- // while (i < number.length) {
- // NSString *string = [number substringWithRange:NSMakeRange(i, 1)];
- // NSRange range = [string rangeOfCharacterFromSet:tmpSet];
- // if (range.length == 0) {
- // res = NO;
- // break;
- // }
- // i ++;
- // }
- // return res;
-
- }
- -(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;
- // NSLog(@"loginVC.dealloc");
- [g_notify removeObserver:self name:kRegisterNotifaction object:nil];
- // [_user release];
- // [super dealloc];
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
- [self.view addGestureRecognizer:tap];
-
-
-
- _vc=[JXShareAnQuanView XIBJXShareShowView];
- _vc.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.1];
- _vc.frame=[UIScreen mainScreen].bounds;
- [[UIApplication sharedApplication].keyWindow addSubview:_vc];
-
- [_vc.yanzBtn addTarget:self action:@selector(addBtnClick) forControlEvents:UIControlEventTouchUpInside];
-
- _vc.hidden=YES;
- _security=@"";
-
-
-
- }
- //登录登录
- - (void)addBtnClick{
-
- if (_vc.yaoqinTF.text.length==0) {
- [SVProgressHUD showWithStatus:@"请输入安全码"];
- [SVProgressHUD dismissWithDelay:0.7];
- return;
- }
-
- _user.security=_vc.yaoqinTF.text;
- _security=_vc.yaoqinTF.text;
-
- [self onClick];
- }
- - (void)tapAction:(UITapGestureRecognizer *)tap {
- [self.view endEditing:YES];
- }
- - (void)didReceiveMemoryWarning
- {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- - (void) textFieldDidChange:(UITextField *) TextField{
- if ([TextField.text isEqualToString:@""]) {
- _pwd.text = @"";
- }
- // if (TextField == _phone) { // 限制手机号最多只能输入11位,为了适配外国电话,将不能显示手机号位数
- // if ([g_config.regeditPhoneOrName intValue] == 1) {
- // if (_phone.text.length > 10) {
- // _phone.text = [_phone.text substringToIndex:10];
- // }
- // }else {
- // if (_phone.text.length > 11) {
- // _phone.text = [_phone.text substringToIndex:11];
- // }
- // }
- // }
- }
- -(void)onClick{
-
- AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
- [manager startMonitoring];
-
- [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
- if (status != AFNetworkReachabilityStatusNotReachable) {
-
-
- }else {
-
- [JXMyTools showTipView:Localized(@"JX_NetWorkError")];
-
- return;
- }
- }];
-
-
- // self.isSwitchUser = NO;
-
- if([_phone.text length]<=0){
- if ([g_config.regeditPhoneOrName intValue] == 1) {
- [g_App showAlert:Localized(@"JX_InputUserAccount")];
- }else {
- [g_App showAlert:Localized(@"JX_InputPhone")];
- }
- return;
- }
- if([_pwd.text length]<=0){
- [g_App showAlert:self.isSMSLogin ? Localized(@"JX_InputMessageCode") : Localized(@"JX_InputPassWord")];
- return;
- }
- // if (![[g_default objectForKey:@"agreement"] boolValue]) {
- // [g_App showAlert:Localized(@"JX_NotAgreeProtocol")];
- // return;
- // }
- [self.view endEditing:YES];
- if (self.isSMSLogin) {
- _user.verificationCode = _pwd.text;
- }else {
- _user.password = [g_server getMD5String:_pwd.text];
- }
- _user.telephone = _phone.text;
- _user.areaCode = [_areaCodeBtn.titleLabel.text stringByReplacingOccurrencesOfString:@"+" withString:@""];
- self.isAutoLogin = NO;
- [_wait start:Localized(@"JX_Logining")];
- [g_server getSetting:self];
- // [g_App.jxServer login:_user toView:self];
- }
- - (void)actionConfig {
- // 自动登录失败,清除token后,重新赋值一次
- _myToken = [g_default objectForKey:kMY_USER_TOKEN];
- if ([g_config.regeditPhoneOrName intValue] == 1) {
- _areaCodeBtn.hidden = YES;
- _forgetBtn.hidden = YES;
- // _phone.keyboardType = UIKeyboardTypeDefault; // 仅支持大小写字母数字
- _phone.placeholder = Localized(@"JX_InputUserAccount");
- }else {
- _areaCodeBtn.hidden = NO;
- // _forgetBtn.hidden = NO;
- // _phone.keyboardType = UIKeyboardTypeNumberPad; // 限制只能数字输入,使用数字键盘
- _phone.placeholder = Localized(@"JX_InputPhone");
- // 短信登录界面不显示忘记密码
- _forgetBtn.hidden = self.isSMSLogin;
- }
- 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:_pwd.text 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(_phone.text) && !IsStringNull(_pwd.text)) {
- g_server.isManualLogin = YES;
- // [g_App.jxServer login:_user toView:self];
- NSString *areaCode = [_areaCodeBtn.titleLabel.text stringByReplacingOccurrencesOfString:@"+" withString:@""];
-
- if (self.isSMSLogin) {
- [g_loginServer smsLoginWithUser:_user areaCode:areaCode account:_phone.text toView:self];
- }else {
- g_server.temporaryPWD = _pwd.text;
-
-
- /*[g_loginServer loginWithUser:_user password:_pwd.text areaCode:areaCode account:_phone.text toView:self];
- NSLog(@"name: %@", [[UIDevice currentDevice] name]);
- NSLog(@"systemName: %@", [[UIDevice currentDevice] systemName]);
- NSLog(@"systemVersion: %@", [[UIDevice currentDevice] systemVersion]);
- NSLog(@"model: %@", [[UIDevice currentDevice] model]);
- NSLog(@"localizedModel: %@", [[UIDevice currentDevice] localizedModel]);
- */
- NSString *modelAll=[NSString stringWithFormat:@"%@ :%@%@",[[UIDevice currentDevice] name],[[UIDevice currentDevice] systemName], [[UIDevice currentDevice] systemVersion]];
-
-
- _user.model=modelAll;
-
- // [g_loginServer loginWithUser:_user password:_pwd.text areaCode:areaCode account:_phone.text toView:self];
- [g_loginServer loginWithUserNew:_user password:_pwd.text areaCode:areaCode account:_phone.text model:modelAll security:_security toView:self];
- }
-
- }
- else
- [_wait stop];
- }
- -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
- [_wait stop];
- 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]){
- [self getImgCodeImg];
- }
- 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
-
- _vc.hidden=YES;
- [g_App showMainUI]; //1
- [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]; //2
- [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;
- NSString * errorCode = [NSString stringWithFormat:@"%@",[dict objectForKey:@"resultMsg"]];
- [_wait stop];
-
- if ([aDownload.action isEqualToString:act_UserDeviceIsAuth]) {
- if ([[dict objectForKey:@"resultCode"] intValue] == 101987) {
- [self changeAccount];
- [g_server getSetting:self];
- }
- return hide_error;
- }
- if ([aDownload.action isEqualToString:act_AuthGetLoginCode]) {
-
- [SVProgressHUD showWithStatus:errorCode];
- [SVProgressHUD dismissWithDelay:1.2];;
-
- }
- if ([aDownload.action isEqualToString:act_Config]) {
-
- NSString *url = [g_default stringForKey:kLastApiUrl];
- g_config.apiUrl = url;
-
- [self actionConfig];
- return hide_error;
- }
- [_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 = 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 show_error;
- }
- if (([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1]) && [[dict objectForKey:@"resultCode"] intValue] == 1040306) {
- _vc.hidden=NO;
-
- inputPhoneVC *vc = [[inputPhoneVC alloc] init];
- vc.isThirdLogin = YES;
- vc.type = self.type;
- [g_navigation pushViewController:vc animated:YES];
- return show_error;
- }
- if([aDownload.action isEqualToString:act_userLoginAuto] || [aDownload.action isEqualToString:act_userLoginAutoV1]){
- [g_default removeObjectForKey:kMY_USER_TOKEN];
- [share_defaults removeObjectForKey:kMY_ShareExtensionToken];
- _vc.hidden=NO;
- }
- if ([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1]) {
- // g_server.openId = nil;
- _vc.hidden=NO;
- }
- if ([aDownload.action isEqualToString:act_SendSMS]) {
- [_send setTitle:Localized(@"JX_Send") forState:UIControlStateNormal];
-
- }if ([aDownload.action isEqualToString:act_UserLoginV1]) { //密码正确登录的时候
- [_wait stop];
- //user/login/v1
- [SVProgressHUD dismissWithDelay:1.2];
- [SVProgressHUD showWithStatus:@"安全码错误"];
-
- _vc.hidden=NO;
- }
-
-
- return 1;
- }
- -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
- _btn.userInteractionEnabled = YES;
- _launchImageView.hidden = YES;
- if ([aDownload.action isEqualToString:act_Config]) {
-
- NSString *url = [g_default stringForKey:kLastApiUrl];
- g_config.apiUrl = url;
-
- if (_myToken==nil||_myToken.length==0) {
-
- }else{
-
- [self actionConfig];
- }
- return hide_error;
- }
- if([aDownload.action isEqualToString:act_userLoginAuto] || [aDownload.action isEqualToString:act_userLoginAutoV1]){
- [g_default removeObjectForKey:kMY_USER_TOKEN];
- [share_defaults removeObjectForKey:kMY_ShareExtensionToken];
-
- _vc.hidden=NO;
- }
- if ([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1]) {
- // g_server.openId = nil;
- _vc.hidden=NO;
- }
-
- if ([aDownload.action isEqualToString:act_SendSMS]) {
-
- [_send setTitle:Localized(@"JX_Send") forState:UIControlStateNormal];
-
-
- }if ([aDownload.action isEqualToString:act_UserLoginV1]) {
- _vc.hidden=NO;
- }
- [_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)onRegister{
- inputPhoneVC* vc = [[inputPhoneVC alloc]init];
- // PSRegisterBaseVC *vc = [[PSRegisterBaseVC alloc] init];
- // [g_window addSubview:vc.view];
- [g_navigation pushViewController:vc animated:YES];
- }
- -(void)onForget{
- forgetPwdVC* vc = [[forgetPwdVC alloc] init];
- vc.isModify = NO;
- // [g_window addSubview:vc.view];
- [g_navigation pushViewController:vc animated:YES];
- }
- -(void)autoLogin{
-
- // _btn.userInteractionEnabled = ![g_server autoLogin:self];
-
- 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];//3
- }
- -(void)actionQuit{
- [super actionQuit];
- // _pSelf = nil;
- }
- - (BOOL)textFieldShouldReturn:(UITextField *)textField
- {
- if (textField == _phone) {
- [_pwd becomeFirstResponder];
- }else{
- [self.view endEditing:YES];
- }
- return YES;
- }
- - (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 setTitle:[NSString stringWithFormat:@"+%@",areaCode] forState:UIControlStateNormal];
- [self resetBtnEdgeInsets:_areaCodeBtn];
- }
- - (void)resetBtnEdgeInsets:(UIButton *)btn{
- [btn setTitleEdgeInsets:UIEdgeInsetsMake(0, -btn.imageView.frame.size.width-2, 0, btn.imageView.frame.size.width+2)];
- [btn setImageEdgeInsets:UIEdgeInsetsMake(0, btn.titleLabel.frame.size.width+2, 0, -btn.titleLabel.frame.size.width-2)];
- }
- - (void)passWordRightViewClicked:(UIButton *)but{
- [_pwd resignFirstResponder];
- but.selected = !but.selected;
- _pwd.secureTextEntry = !but.selected;
-
- }
- - (void)didSelectedCheckBox:(QCheckBox *)checkbox checked:(BOOL)checked{
- [g_default setObject:[NSNumber numberWithBool:checked] forKey:@"agreement"];
- [g_default synchronize];
- }
- -(void)catUserProtocol{
- webpageVC * webVC = [webpageVC alloc];
- webVC.url = [self protocolUrl];
- webVC.isSend = NO;
- // [[NSBundle mainBundle] pathForResource:@"用户协议" ofType:@"html"];
- webVC = [webVC init];
- // [g_navigation.navigationView addSubview:webVC.view];
- [g_navigation pushViewController:webVC animated:YES];
- }
- -(NSString *)protocolUrl{
- NSString * protocolStr = g_config.privacyPolicyPrefix;
- NSString * lange = g_constant.sysLanguage;
- if (![lange isEqualToString:ZHHANTNAME] && ![lange isEqualToString:NAME]) {
- lange = ENNAME;
- }
- // return [NSString stringWithFormat:@"%@%@.html",protocolStr,lange];
- return [NSString stringWithFormat:@"%@",protocolStr];
- }
- // 获取启动图
- - (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)showTime:(NSTimer*)sender{
- UIButton *but = (UIButton*)[_timer userInfo];
- _seconds--;
- [but setTitle:[NSString stringWithFormat:@"%ds",_seconds] forState:UIControlStateSelected];
-
- if(_seconds<=0){
- but.selected = NO;
- but.userInteractionEnabled = YES;
- but.backgroundColor = g_theme.themeColor;
- [_send setTitle:Localized(@"JX_SendAngin") forState:UIControlStateNormal];
- if (_timer) {
- _timer = nil;
- [sender invalidate];
- }
- _seconds = 60;
-
- }
- }
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
- [self.view endEditing:YES];
- }
- - (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);
- }
- @end
|