JXMainLoginVc.m 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334
  1. //
  2. // JXMainLoginVc.m
  3. // shiku_im
  4. //
  5. // Created by 123 on 2020/5/6.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JXMainLoginVc.h"
  9. #import <AVFoundation/AVFoundation.h>
  10. #import <AVKit/AVKit.h>
  11. #import "loginVC.h"
  12. #import "JXRegisterShowView.h"
  13. #import "JXLoginBtn.h"
  14. #import "JXLocation.h"
  15. #import "JLBubbleModel.h"
  16. #import "WXApi.h"
  17. #import <TencentOpenAPI/TencentOAuth.h>
  18. #import <TencentOpenAPI/QQApiInterface.h>
  19. #import "inputPhoneVC.h"
  20. #import "JXTelAreaListVC.h"
  21. #import "JXLoginTopView.h"
  22. @interface JXMainLoginVc ()<UITextFieldDelegate,JXLocationDelegate,JXLocationDelegate,WXApiDelegate,WXApiManagerDelegate,TencentSessionDelegate,TencentLoginDelegate>
  23. {
  24. NSString *_myToken;
  25. NSInteger setServerNum;
  26. BOOL _isFirstLocation;
  27. }
  28. //播放器ViewController
  29. @property(nonatomic, strong)AVPlayerViewController *AVPlayer;
  30. @property(nonatomic,strong)dispatch_source_t authTimer;
  31. @property(nonatomic,assign)NSInteger count;
  32. @property(nonatomic,strong)UIView *waitAuthView;
  33. @property (nonatomic, strong)TencentOAuth *oauth;
  34. @property (nonatomic,copy) NSString *phoneStr;
  35. @property (nonatomic,copy) NSString *pwdStr;
  36. @property (nonatomic,copy) NSString *phone3;
  37. @property (nonatomic,copy) NSString *areaCodeBtn;
  38. @property (nonatomic,weak) JXRegisterShowView *showLogView;
  39. @property (nonatomic,weak) UIImageView *backView;
  40. @property (nonatomic,weak) JXLoginTopView *loginTopView;
  41. @end
  42. @implementation JXMainLoginVc
  43. - (void)viewWillDisappear:(BOOL)animated{
  44. [super viewWillDisappear:animated];
  45. [_showLogView removeFromSuperview];
  46. }
  47. - (void)viewWillAppear:(BOOL)animated {
  48. [super viewWillAppear:animated];
  49. }
  50. - (void)viewDidLoad {
  51. [super viewDidLoad];
  52. // Do any additional setup after loading the view.
  53. //初始化AVPlayer
  54. UIImageView *backView = [[UIImageView alloc] init];
  55. backView.image=[UIImage imageNamed:@"new_login_bg"];
  56. backView.contentMode = UIViewContentModeScaleAspectFill;
  57. backView.frame=self.view.bounds;
  58. [self.view addSubview:backView];
  59. _backView = backView;
  60. [self setMoviePlayer:@""];
  61. [self loadDataWeb];
  62. //[self setMoviePlayer];
  63. long time = (long)[[NSDate date] timeIntervalSince1970];
  64. time = (time *1000 + g_server.timeDifference);
  65. NSString *salt = [NSString stringWithFormat:@"%ld", time];
  66. //视频地址
  67. [g_server getact_apiAppFileResourceall:salt toView:self];
  68. [g_server getact_UserdeviceLogsecurity:salt userId:g_server.myself.userId andToView:self];
  69. NSString *xieyiValue = [[NSUserDefaults standardUserDefaults] objectForKey:@"yonghuxieyi"];
  70. if (xieyiValue.length>0) {
  71. }else{
  72. [[NSUserDefaults standardUserDefaults] setObject:@"yonghuxieyi" forKey:@"yonghuxieyi"];
  73. [[NSUserDefaults standardUserDefaults] synchronize];
  74. [g_server act_UserfuwenBenLogin:salt type:@"1000" title:@"用户协议" andToView:self];
  75. }
  76. // 获取自己的用户信息
  77. [g_server getUser:MY_USER_ID toView:self];
  78. [self CreateTopBtnIMG];
  79. [self prepareForbackIMG];
  80. _user = [[JXUserObject alloc] init];
  81. self.heightFooter = 0;
  82. self.heightHeader = 0;
  83. if (_isThirdLogin) {
  84. self.title = Localized(@"JX_BindExistingAccount");
  85. }
  86. if (self.isSMSLogin) {
  87. self.title = Localized(@"JX_SMSLogin");
  88. self.isGotoBack = YES;
  89. }
  90. [g_server getAppResource:@"0" ToView:self];
  91. [g_server customerLinkList:self];
  92. // 获取所有气泡
  93. [g_server getAllBubbleFontListToView:self];
  94. // 获取所有等级
  95. [g_server getAllGradeListToView:self];
  96. g_server.isManualLogin = NO;
  97. self.isGotoBack = NO;
  98. _myToken = [g_default objectForKey:kMY_USER_TOKEN];
  99. [g_default setObject:nil forKey:kMyPayPrivateKey];
  100. g_server.isLogin = NO;
  101. g_navigation.lastVC = nil;
  102. // 微信登录回调
  103. [WXApiManager sharedManager].delegate = self;
  104. if ([g_default objectForKey:kMY_USER_NICKNAME])
  105. _user.userNickname = MY_USER_NAME;
  106. if ([g_default objectForKey:kMY_USER_ID])
  107. _user.userId = [g_default objectForKey:kMY_USER_ID];
  108. if ([g_default objectForKey:kMY_USER_COMPANY_ID])
  109. _user.companyId = [g_default objectForKey:kMY_USER_COMPANY_ID];
  110. if ([g_default objectForKey:kMY_USER_LoginName]) {
  111. _phoneStr=[g_default objectForKey:kMY_USER_LoginName];
  112. _user.telephone = _phoneStr;
  113. }
  114. if ([g_default objectForKey:kMY_USER_PASSWORD]) {
  115. // [_pwd setText:[g_default objectForKey:kMY_USER_PASSWORD]];
  116. _phoneStr=[g_default objectForKey:kMY_USER_PASSWORD];
  117. _user.password = _phoneStr;
  118. }
  119. if ([g_default objectForKey:kLocationLogin]) {
  120. NSDictionary *dict = [g_default objectForKey:kLocationLogin];
  121. g_server.longitude = [[dict objectForKey:@"longitude"] doubleValue];
  122. g_server.latitude = [[dict objectForKey:@"latitude"] doubleValue];
  123. }
  124. [g_notify addObserver:self selector:@selector(onRegistered:) name:kRegisterNotifaction object:nil];
  125. [g_notify addObserver:self selector:@selector(authRespNotification:) name:kWxSendAuthRespNotification object:nil];
  126. if(!self.isAutoLogin || IsStringNull(_myToken)) {
  127. _btn.userInteractionEnabled = YES;
  128. }else {
  129. _launchImageView = [[UIImageView alloc] init];
  130. _launchImageView.frame = self.view.bounds;
  131. _launchImageView.image = [UIImage imageNamed:[self getLaunchImageName]];
  132. [self.view addSubview:_launchImageView];
  133. }
  134. if(self.isAutoLogin && !IsStringNull(_myToken))
  135. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  136. // [_wait start:Localized(@"JX_Logining")];
  137. [_wait startWithClearColor];
  138. });
  139. if (!_isThirdLogin) {
  140. NSString *logoutUser = [g_default objectForKey:@"logoutUser"];
  141. if (logoutUser.length>0) {
  142. [g_server getSetting:self];
  143. }
  144. [g_default removeObjectForKey:@"logoutUser"];
  145. }
  146. }
  147. /**
  148. * 头部图片
  149. */
  150. - (void)CreateTopBtnIMG{
  151. UIImageView *logoIMG=[[UIImageView alloc]init];
  152. logoIMG.image=[UIImage imageNamed:@"jxlOGO"];
  153. [self.view addSubview:logoIMG];
  154. self.logoIMG=logoIMG;
  155. [logoIMG mas_makeConstraints:^(MASConstraintMaker *make) {
  156. make.top.mas_equalTo(JX_SCREEN_HEIGHT>=812?100:(SCREENSIZE_IS_PLUS?64:30));
  157. make.centerX.mas_equalTo(self.view.mas_centerX);
  158. make.width.mas_equalTo(150);
  159. make.height.mas_equalTo(40);
  160. }];
  161. UILabel *titleBt = [[UILabel alloc] init];
  162. titleBt.text=@"官方认证";
  163. titleBt.textAlignment=NSTextAlignmentCenter;
  164. titleBt.textColor=[UIColor whiteColor];
  165. titleBt.font=[UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
  166. [self.view addSubview:titleBt];
  167. [titleBt mas_makeConstraints:^(MASConstraintMaker *make) {
  168. make.top.mas_equalTo(logoIMG.mas_bottom).mas_offset(15);
  169. make.centerX.mas_equalTo(self.view.mas_centerX);
  170. }];
  171. UILabel *leftLine = [[UILabel alloc] init];
  172. leftLine.text=@"---------";
  173. leftLine.backgroundColor=[UIColor whiteColor];
  174. [self.view addSubview:leftLine];
  175. [leftLine mas_makeConstraints:^(MASConstraintMaker *make) {
  176. make.centerY.mas_equalTo(titleBt.mas_centerY).mas_offset(0);
  177. make.right.mas_equalTo(titleBt.mas_left).mas_offset(-20);
  178. make.height.mas_equalTo(1);
  179. }];
  180. UILabel *rightLine = [[UILabel alloc] init];
  181. rightLine.text=@"---------";
  182. rightLine.backgroundColor=[UIColor whiteColor];
  183. [self.view addSubview:rightLine];
  184. [rightLine mas_makeConstraints:^(MASConstraintMaker *make) {
  185. make.centerY.mas_equalTo(titleBt.mas_centerY).mas_offset(0);
  186. make.left.mas_equalTo(titleBt.mas_right).mas_offset(20);
  187. make.height.mas_equalTo(1);
  188. }];
  189. JXLoginTopView *loginTopView = [JXLoginTopView customView];
  190. [self.view addSubview:loginTopView];
  191. [loginTopView mas_makeConstraints:^(MASConstraintMaker *make) {
  192. make.top.mas_equalTo(titleBt.mas_bottom).mas_offset(20);
  193. make.centerX.mas_equalTo(self.view.mas_centerX).mas_offset(0);
  194. make.height.mas_equalTo(180);
  195. make.width.mas_equalTo(220);
  196. }];
  197. _loginTopView = loginTopView;
  198. // CGFloat btnW=(JX_SCREEN_WIDTH-100)/5;
  199. // NSArray *titles=@[@"菲律宾政府PAGCOR",@"英国曼岛博彩监督委员会",@"马其他在线博彩委员会",@"直布罗陀博彩委员会"];
  200. // NSArray *iamges=@[@"PAGCOR",@"ygmdbcjdwyh",@"mqtzxbcwyh",@"zbltbcwyh"];
  201. // for (int i=0; i<titles.count; i++) {
  202. // JXLoginBtn *QQBtn = [[JXLoginBtn alloc] init];
  203. // QQBtn.userInteractionEnabled=NO;
  204. // [QQBtn setTitle:titles[i] forState:UIControlStateNormal];
  205. // [QQBtn setImage:[UIImage imageNamed:iamges[i]] forState:UIControlStateNormal];
  206. // QQBtn.tag=i;
  207. // [self.view addSubview:QQBtn];
  208. //
  209. // if (i>1) {
  210. // QQBtn.frame=CGRectMake((btnW*1.5)+(i%2)*(btnW +btnW*1.5), (JX_SCREEN_HEIGHT>=812?180:130) + btnW+50+20, btnW, btnW+50);
  211. // }else {
  212. // QQBtn.frame=CGRectMake((btnW*1.5)+i*(btnW +btnW*1.5), JX_SCREEN_HEIGHT>=812?180:130, btnW, btnW+50);
  213. // }
  214. //
  215. //
  216. // }
  217. }
  218. /**
  219. * 底部登录框
  220. */
  221. - (void)prepareForbackIMG{
  222. UIImageView *bottomView=[[UIImageView alloc]init];
  223. //bottomView.backgroundColor=[UIColor colorWithWhite:1.0 alpha:0.1];
  224. bottomView.userInteractionEnabled=YES;
  225. bottomView.image=[UIImage imageNamed:@"dak"];
  226. bottomView.layer.cornerRadius=6;
  227. bottomView.layer.masksToBounds=YES;
  228. [self.view addSubview:bottomView];
  229. [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
  230. // make.bottom.mas_equalTo(JX_SCREEN_HEIGHT>=812?-88:-60);
  231. make.top.mas_equalTo(_loginTopView.mas_bottom).mas_offset(THE_DEVICE_HAVE_HEAD?30:10);
  232. make.left.mas_equalTo(20);
  233. make.right.mas_equalTo(-20);
  234. make.height.mas_equalTo(330);
  235. }];
  236. UILabel *loginLB = [[UILabel alloc] init];
  237. loginLB.text=@"登录";
  238. loginLB.font=[UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
  239. loginLB.textColor=[UIColor whiteColor];
  240. [bottomView addSubview:loginLB];
  241. [loginLB mas_makeConstraints:^(MASConstraintMaker *make) {
  242. make.top.mas_equalTo(10);
  243. make.centerX.mas_equalTo(self.view.mas_centerX);
  244. }];
  245. // 微信登录
  246. UIButton *wxView=[[UIButton alloc]init];
  247. wxView.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.5];
  248. wxView.titleLabel.font=[UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
  249. wxView.layer.cornerRadius=22;
  250. wxView.layer.masksToBounds=YES;
  251. wxView.tag=0;
  252. [wxView setTitle:@"微信登录" forState:UIControlStateNormal];
  253. [wxView addTarget:self action:@selector(qqLoginBtn:) forControlEvents:UIControlEventTouchUpInside];
  254. [bottomView addSubview:wxView];
  255. [wxView mas_makeConstraints:^(MASConstraintMaker *make) {
  256. make.top.mas_equalTo(70);
  257. make.left.mas_equalTo(25);
  258. make.right.mas_equalTo(-25);
  259. make.height.mas_equalTo(54);
  260. }];
  261. UIImageView *titlesView = [[UIImageView alloc] init];
  262. titlesView.image=[UIImage imageNamed:@"wx"];
  263. [wxView addSubview:titlesView];
  264. [titlesView mas_makeConstraints:^(MASConstraintMaker *make) {
  265. make.left.mas_equalTo(20);
  266. make.centerY.mas_equalTo(wxView.mas_centerY);
  267. }];
  268. // QQ登录
  269. UIButton *QQBtn = [[UIButton alloc] init];
  270. QQBtn.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.5];
  271. QQBtn.titleLabel.font=[UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
  272. QQBtn.layer.cornerRadius=22;
  273. QQBtn.layer.masksToBounds=YES;
  274. [QQBtn setTitle:@"QQ登录" forState:UIControlStateNormal];
  275. QQBtn.tag=1;
  276. [bottomView addSubview:QQBtn];
  277. [QQBtn addTarget:self action:@selector(qqLoginBtn:) forControlEvents:UIControlEventTouchUpInside];
  278. [QQBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  279. make.top.mas_equalTo(wxView.mas_bottom).mas_offset(10);
  280. make.left.mas_equalTo(25);
  281. make.right.mas_equalTo(-25);
  282. make.height.mas_equalTo(54);
  283. }];
  284. UIImageView *QQIMG = [[UIImageView alloc] init];
  285. QQIMG.image=[UIImage imageNamed:@"qq"];
  286. [QQBtn addSubview:QQIMG];
  287. [QQIMG mas_makeConstraints:^(MASConstraintMaker *make) {
  288. make.left.mas_equalTo(20);
  289. make.centerY.mas_equalTo(QQBtn.mas_centerY);
  290. }];
  291. //手机登录
  292. UIButton *phoneBtn = [[UIButton alloc] init];
  293. [phoneBtn setTitle:@"手机登录" forState:UIControlStateNormal];
  294. phoneBtn.titleLabel.font=[UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
  295. phoneBtn.tag=2;
  296. phoneBtn.layer.cornerRadius=22;
  297. phoneBtn.layer.masksToBounds=YES;
  298. phoneBtn.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.5];
  299. [bottomView addSubview:phoneBtn];
  300. [phoneBtn addTarget:self action:@selector(qqLoginBtn:) forControlEvents:UIControlEventTouchUpInside];
  301. [phoneBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  302. make.top.mas_equalTo(QQBtn.mas_bottom).mas_offset(10);
  303. make.left.mas_equalTo(25);
  304. make.right.mas_equalTo(-25);
  305. make.height.mas_equalTo(54);
  306. }];
  307. UIImageView *phoneIMG = [[UIImageView alloc] init];
  308. phoneIMG.image=[UIImage imageNamed:@"SJ"];
  309. [phoneBtn addSubview:phoneIMG];
  310. [phoneIMG mas_makeConstraints:^(MASConstraintMaker *make) {
  311. make.left.mas_equalTo(20);
  312. make.centerY.mas_equalTo(phoneBtn.mas_centerY);
  313. }];
  314. UILabel *titleBt = [[UILabel alloc] init];
  315. titleBt.text=@"时间会证明吉利是最好的选择\n(2012年-至今)";
  316. titleBt.textAlignment=NSTextAlignmentCenter;
  317. titleBt.textColor=[UIColor whiteColor];
  318. titleBt.numberOfLines = 0;
  319. titleBt.font=[UIFont systemFontOfSize:17 weight:UIFontWeightRegular];
  320. [bottomView addSubview:titleBt];
  321. [titleBt mas_makeConstraints:^(MASConstraintMaker *make) {
  322. make.top.mas_equalTo(phoneBtn.mas_bottom).mas_offset(20);
  323. make.left.mas_equalTo(25);
  324. make.right.mas_equalTo(-25);
  325. }];
  326. }
  327. /**
  328. * qq微信登录
  329. */
  330. - (void)qqLoginBtn:(UIButton *)sender{
  331. if (sender.tag==0) { //微信
  332. [self didWechatToLogin:nil];
  333. }else if (sender.tag==1) {//手机登录
  334. [self didQQToLogin:nil];
  335. } else { //微信登录
  336. loginVC *vc=[loginVC new];
  337. [g_navigation pushViewController:vc animated:YES];
  338. }
  339. }
  340. //======================================= 判断自动登录 =========================================
  341. - (void)switchLoginWay {
  342. if (self.isSMSLogin) {
  343. [self actionQuit];
  344. }else {
  345. loginVC *vc = [loginVC alloc];
  346. vc.isSMSLogin = YES;
  347. vc = [vc init];
  348. [g_navigation pushViewController:vc animated:YES];
  349. }
  350. }
  351. #pragma mark - 微信登录
  352. - (void)didWechatToLogin:(UITapGestureRecognizer *)tap {
  353. // if (![[g_default objectForKey:@"agreement"] boolValue]) {
  354. // [g_App showAlert:Localized(@"JX_NotAgreeProtocol")];
  355. // return;
  356. // }
  357. self.type = JXLoginWX;
  358. if (![WXApi isWXAppInstalled]) {
  359. [g_App showAlert:@"您的手机没有安装微信, 请下载后使用微信登录."];
  360. return;
  361. }
  362. SendAuthReq* req = [[SendAuthReq alloc] init];
  363. req.scope = @"snsapi_userinfo"; // @"post_timeline,sns"
  364. req.state = @"login";
  365. req.openID = @"";
  366. [WXApi sendAuthReq:req
  367. viewController:self
  368. delegate:[WXApiManager sharedManager]];
  369. }
  370. - (void)authRespNotification:(NSNotification *)notif {
  371. SendAuthResp *response = notif.object;
  372. NSString *strMsg = [NSString stringWithFormat:@"Auth结果 code:%@,state:%@,errcode:%d", response.code, response.state, response.errCode];
  373. NSLog(@"-------%@",strMsg);
  374. if (response.code.length > 0) {
  375. [g_server getWxOpenId:response.code toView:self];
  376. }
  377. }
  378. #pragma mark - QQ登录
  379. - (void)didQQToLogin:(UITapGestureRecognizer *)tap {
  380. self.type = JXLoginQQ;
  381. if (![TencentOAuth iphoneQQInstalled]) {
  382. [g_App showAlert:@"您的手机没有安装手机QQ, 请下载后使用QQ登录."];
  383. return;
  384. }
  385. NSString *appid = g_App.QQ_LOGIN_APPID;
  386. _oauth = [[TencentOAuth alloc] initWithAppId:appid
  387. andDelegate:self];
  388. _oauth.authMode = kAuthModeClientSideToken;
  389. [_oauth authorize:[self getPermissions] inSafari:NO];
  390. }
  391. // QQ登录成功回调
  392. - (void)tencentDidLogin {
  393. NSString *qqOpenId = _oauth.openId;
  394. g_server.openId = qqOpenId;
  395. if (qqOpenId.length > 0) {
  396. [g_server wxSdkLogin:_user type:1 openId:qqOpenId toView:self];
  397. }
  398. }
  399. - (NSMutableArray *)getPermissions {
  400. NSMutableArray * g_permissions = [[NSMutableArray alloc] initWithObjects:kOPEN_PERMISSION_GET_USER_INFO,
  401. kOPEN_PERMISSION_GET_SIMPLE_USER_INFO,
  402. kOPEN_PERMISSION_ADD_ALBUM,
  403. kOPEN_PERMISSION_ADD_TOPIC,
  404. kOPEN_PERMISSION_CHECK_PAGE_FANS,
  405. kOPEN_PERMISSION_GET_INFO,
  406. kOPEN_PERMISSION_GET_OTHER_INFO,
  407. kOPEN_PERMISSION_LIST_ALBUM,
  408. kOPEN_PERMISSION_UPLOAD_PIC,
  409. kOPEN_PERMISSION_GET_VIP_INFO,
  410. kOPEN_PERMISSION_GET_VIP_RICH_INFO, nil];
  411. return g_permissions;
  412. }
  413. -(void)location:(JXLocation *)location getLocationWithIp:(NSDictionary *)dict {
  414. if (_isFirstLocation) {
  415. return;
  416. }
  417. NSString *area = [NSString stringWithFormat:@"%@,%@,%@",dict[@"country"],dict[@"region"],dict[@"city"]];
  418. [g_default setObject:area forKey:kLocationArea];
  419. [g_default synchronize];
  420. if(self.isAutoLogin && !IsStringNull(_myToken))
  421. [_wait start:Localized(@"JX_Logining")];
  422. if (!_isThirdLogin) {
  423. [g_server getSetting:self];
  424. }
  425. }
  426. - (void)location:(JXLocation *)location getLocationError:(NSError *)error {
  427. if (_isFirstLocation) {
  428. return;
  429. }
  430. [g_default setObject:nil forKey:kLocationArea];
  431. [g_default synchronize];
  432. if(self.isAutoLogin && !IsStringNull(_myToken))
  433. [_wait start:Localized(@"JX_Logining")];
  434. if (!_isThirdLogin) {
  435. [g_server getSetting:self];
  436. }
  437. }
  438. -(void)longLimit:(UITextField *)textField
  439. {
  440. // if (textField.text.length > 11) {
  441. // textField.text = [textField.text substringToIndex:11];
  442. // }
  443. }
  444. -(void)dealloc{
  445. // _pSelf = nil;
  446. [self.AVPlayer.player pause];
  447. [self.AVPlayer removeFromParentViewController];
  448. self.AVPlayer=nil;
  449. self.showLogView.hidden=YES;
  450. [g_notify removeObserver:self name:kRegisterNotifaction object:nil];
  451. // [_user release];
  452. // [super dealloc];
  453. }
  454. -(void)onClick{
  455. if([_phoneStr length]<=0){
  456. if ([g_config.regeditPhoneOrName intValue] == 1) {
  457. [g_App showAlert:Localized(@"JX_InputUserAccount")];
  458. }else {
  459. [g_App showAlert:Localized(@"JX_InputPhone")];
  460. }
  461. return;
  462. }
  463. if([_pwdStr length]<=0){
  464. [g_App showAlert:self.isSMSLogin ? Localized(@"JX_InputMessageCode") : Localized(@"JX_InputPassWord")];
  465. return;
  466. }
  467. [self.view endEditing:YES];
  468. if (self.isSMSLogin) {
  469. _user.verificationCode = _pwdStr;
  470. }else {
  471. _user.password = [g_server getMD5String:_pwdStr];
  472. }
  473. _user.telephone = _phoneStr;
  474. self.isAutoLogin = NO;
  475. [_wait start:Localized(@"JX_Logining")];
  476. [g_server getSetting:self];
  477. }
  478. - (void)actionConfig {
  479. // 自动登录失败,清除token后,重新赋值一次
  480. _myToken = [g_default objectForKey:kMY_USER_TOKEN];
  481. if ([g_config.isOpenPositionService intValue] == 0) {
  482. _isFirstLocation = YES;
  483. _location = [[JXLocation alloc] init];
  484. _location.delegate = self;
  485. g_server.location = _location;
  486. [g_server locate];
  487. }
  488. if((_isAutoLogin && !IsStringNull(_myToken)) || _isThirdLogin)
  489. if (_isThirdLogin) {
  490. [g_server thirdLogin:_user type:2 openId:g_server.openId isLogin:NO toView:self];
  491. [g_loginServer thirdLoginV1:_user password:_pwdStr type:self.type openId:g_server.openId isLogin:NO toView:self];
  492. }else {
  493. [self performSelector:@selector(autoLogin) withObject:nil afterDelay:.5];
  494. }
  495. else if (IsStringNull(_myToken) && !IsStringNull(_phoneStr) && !IsStringNull(_pwdStr)) {
  496. g_server.isManualLogin = YES;
  497. [g_App.jxServer login:_user toView:self];
  498. NSString *areaCode = [_areaCodeBtn stringByReplacingOccurrencesOfString:@"+" withString:@""];
  499. if (self.isSMSLogin) {
  500. [g_loginServer smsLoginWithUser:_user areaCode:@"410000" account:_phoneStr toView:self];
  501. }else {
  502. g_server.temporaryPWD = _pwdStr;
  503. [g_loginServer loginWithUser:_user password:_pwdStr areaCode:areaCode account:_phoneStr toView:self];
  504. }
  505. }
  506. else
  507. [_wait stop];
  508. }
  509. -(void)viewDidDisappear:(BOOL)animated{
  510. [super viewDidDisappear:animated];
  511. self.showLogView.hidden=YES;
  512. [self.AVPlayer removeFromParentViewController];
  513. self.AVPlayer=nil;
  514. }
  515. #pragma mark --- 请求成功
  516. - (void)loadDataWeb{
  517. [g_server actGetconfigconcatdomainnow:self];
  518. }
  519. /**
  520. * 背景视频
  521. */
  522. -(void)setMoviePlayer:(NSString *)urlMovice{
  523. //初始化AVPlayer
  524. self.AVPlayer = [[AVPlayerViewController alloc]init];
  525. //多分屏功能取消
  526. self.AVPlayer.allowsPictureInPicturePlayback = NO;
  527. //设置是否显示媒体播放组件
  528. self.AVPlayer.showsPlaybackControls = false;
  529. //初始化一个播放单位。给AVplayer 使用
  530. //读取本地视频路径
  531. NSString *path = [[NSBundle mainBundle] pathForResource:@"login-interface" ofType:@"mp4"];
  532. //为即将播放的视频内容进行建模
  533. AVPlayerItem *item = [[AVPlayerItem alloc] initWithURL:[NSURL fileURLWithPath:path]];
  534. // AVPlayerItem *item = [[AVPlayerItem alloc]initWithURL:[NSURL URLWithString:urlMovice]];
  535. // AVPlayer *avPlayer= [AVPlayer playerWithURL:[NSURL URLWithString:urlMovice]];
  536. AVPlayer *player = [AVPlayer playerWithPlayerItem:item];
  537. self.AVPlayer.player = player;
  538. //layer
  539. // AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:player];
  540. [self.AVPlayer.view setFrame:self.view.bounds];
  541. //设置填充模式
  542. self.AVPlayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
  543. //设置AVPlayerViewController内部的AVPlayer为刚创建的AVPlayer
  544. // self.AVPlayer.player = player;
  545. //添加到self.view上面去
  546. //[self.view.layer addSublayer:layer];
  547. // [self.view.layer insertSublayer:layer atIndex:0];
  548. // [self.view.layer insertSublayer:layer above:_backView.layer];
  549. [self.view insertSubview: self.AVPlayer.view aboveSubview:_backView];
  550. //开始播放
  551. [self.AVPlayer.player play];
  552. //这里设置的是重复播放。
  553. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playDidEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:item];
  554. //定时器。延迟3秒再出现进入应用按钮
  555. // [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(prepareForbackIMG) userInfo:nil repeats:YES];
  556. }
  557. //播放完成的代理
  558. - (void)playDidEnd:(NSNotification *)Notification{
  559. //播放完成后。设置播放进度为0 。 重新播放
  560. [self.AVPlayer.player seekToTime:CMTimeMake(0, 1)];
  561. [self.AVPlayer.player play];
  562. //开始播放
  563. // [self.AVPlayer.player pause];
  564. // [self.AVPlayer removeFromParentViewController];
  565. // self.AVPlayer=nil;
  566. }
  567. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  568. //NSLog(@"视频地址:%@",aDownload.action);
  569. if ([aDownload.action isEqualToString:act_apiAppFileResourceall]||[aDownload.action isEqualToString:@"config"]) {
  570. [array1 enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
  571. if ([obj[@"code"] isEqualToString:@"loginermp4"]) {
  572. NSString *fileUrll=obj[@"fileUrl"];
  573. dispatch_async(dispatch_get_main_queue(), ^{
  574. // [self setMoviePlayer:fileUrll];
  575. // [g_App setupLunchADUrl:fileUrll link:@""];
  576. });
  577. }
  578. if (JX_SCREEN_HEIGHT>=812) {
  579. if ([obj[@"code"] isEqualToString:@"ggxcmp4_3x"]) {
  580. NSString *fileUrll=obj[@"fileUrl"];
  581. dispatch_async(dispatch_get_main_queue(), ^{
  582. [g_App setupLunchADUrl:fileUrll link:@""];
  583. });
  584. }
  585. }else{
  586. if ([obj[@"code"] isEqualToString:@"ggxcmp4_2x"]) {
  587. NSString *fileUrll=obj[@"fileUrl"];
  588. dispatch_async(dispatch_get_main_queue(), ^{
  589. [g_App setupLunchADUrl:fileUrll link:@""];
  590. });
  591. }
  592. }
  593. }];
  594. }
  595. //更新本地好友
  596. if ([aDownload.action isEqualToString:act_Getconfigconcatdomainnow]) {
  597. NSDictionary *dictMM=[array1 firstObject];
  598. NSString *memberAcc= dictMM[@"url"];
  599. [[NSUserDefaults standardUserDefaults] setObject:array1 forKey:@"www_Array"];
  600. [[NSUserDefaults standardUserDefaults] synchronize];
  601. [[NSUserDefaults standardUserDefaults] setObject:memberAcc forKey:@"www_url"];
  602. [[NSUserDefaults standardUserDefaults] synchronize];
  603. // [g_notify postNotificationName:@"loadHomeWeb" object:nil userInfo:dict];
  604. }
  605. if([aDownload.action isEqualToString:act_UserGet]){
  606. JXUserObject *user = [[JXUserObject alloc] init];
  607. [user getDataFromDict:dict];
  608. }
  609. if([aDownload.action isEqualToString:act_fuwenBenLogin]){
  610. //NSString *strValue=[[NSUserDefaults standardUserDefaults] objectForKey:@"guangboxxx"];
  611. // if (strValue.length==0) {
  612. [[NSUserDefaults standardUserDefaults] setObject:@"10000" forKey:@"guangboxxx"];
  613. [[NSUserDefaults standardUserDefaults] synchronize];
  614. JXRegisterShowView *showLogView=[[JXRegisterShowView alloc]init];
  615. showLogView.frame=self.view.bounds;
  616. showLogView.dataDict= dict;
  617. [self.view addSubview:showLogView];
  618. self.showLogView=showLogView;
  619. //}else{ }
  620. }
  621. if([aDownload.action isEqualToString:act_UserdeviceLogsecurity]){
  622. NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
  623. [userDefault setObject:dict[@"data"] forKey:@"user_Data"];
  624. [userDefault synchronize];
  625. }
  626. if ([aDownload.action isEqualToString:act_getGradeList])
  627. {
  628. NSString *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
  629. NSString *fileName = [path stringByAppendingPathComponent:@"grade.plist"];
  630. [array1 writeToFile:fileName atomically:YES];
  631. // 保存到数据库
  632. JLBubbleManager *manager = [JLBubbleManager sharedManager];
  633. FMDatabase* db = [manager openResouceDb];
  634. BOOL result = [manager checkGradeTableCreatedInDb:db];
  635. if (result) {
  636. // self.gradeIndex, self.avatarUrl, self.id, self.name, self.rankUrl, self.grade
  637. for (NSDictionary *tempDict in array1) {
  638. JLBubbleManager *manager = [JLBubbleManager mj_objectWithKeyValues:tempDict];
  639. [manager insertGradeTable];
  640. }
  641. }
  642. NSMutableArray *imagesArray = [NSMutableArray array];
  643. for (NSDictionary *tempDict in array1) {
  644. //[imagesArray addObject:[NSURL URLWithString:tempDict[@"avatarUrl"]]];
  645. //[imagesArray addObject:[NSURL URLWithString:tempDict[@"rankUrl"]]];
  646. NSString *avatarUrl = @"";
  647. if (tempDict[@"avatarUrl"] == nil) {
  648. avatarUrl = @"";
  649. }else {
  650. avatarUrl = tempDict[@"avatarUrl"];
  651. }
  652. NSString *rankUrl = @"";
  653. if (tempDict[@"rankUrl"] == nil) {
  654. avatarUrl = @"";
  655. }else {
  656. rankUrl = tempDict[@"rankUrl"];
  657. }
  658. [imagesArray addObject:[NSURL URLWithString:avatarUrl]];
  659. [imagesArray addObject:[NSURL URLWithString:rankUrl]];
  660. NSArray *bubbleFontSet = tempDict[@"bubbleFontSet"];
  661. for (NSDictionary *bubbleFontDict in bubbleFontSet) {
  662. JLBubbleModel *model = [JLBubbleModel mj_objectWithKeyValues:bubbleFontDict];
  663. [imagesArray addObject:[NSURL URLWithString:model.bubble.iosLeftUrl]];
  664. [imagesArray addObject:[NSURL URLWithString:model.bubble.iosRightUrl]];
  665. // [imagesArray addObject:[NSURL URLWithString:model.homeUrl]];
  666. }
  667. // NSArray *faceSet = tempDict[@"faceSet"];
  668. // for (NSDictionary *faceSetDict in faceSet) {
  669. // NSArray *array = faceSetDict[@"path"];
  670. // for (NSString *url in array) {
  671. // NSURL *urlPath = [NSURL URLWithString:url];
  672. // [imagesArray addObject:urlPath];
  673. // }
  674. // }
  675. if (result) {
  676. // int gradeIndex = (int)tempDict[@"gradeIndex"];
  677. // [JXLabelObject sharedInstance].gradeIndex = gradeIndex;
  678. // NSData *data = [NSKeyedArchiver archivedDataWithRootObject:tempDict];
  679. // [JXLabelObject sharedInstance].data = data;
  680. // [[JXLabelObject sharedInstance] insertGradeTable];
  681. // NSArray *array = [tempDict allValues];
  682. }
  683. }
  684. // 缓存图片
  685. [[JLBubbleManager sharedManager] cacheBubbleImage:imagesArray];
  686. }
  687. if ([aDownload.action isEqualToString:act_getAllBubbleFontList])
  688. {
  689. NSString *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
  690. NSString *fileName = [path stringByAppendingPathComponent:@"bubbleFontList.plist"];
  691. [array1 writeToFile:fileName atomically:YES];
  692. // 保存到数据库
  693. // 保存到数据库
  694. JLBubbleManager *manager = [JLBubbleManager sharedManager];
  695. FMDatabase* db = [manager openResouceDb];
  696. BOOL result = [manager checkBubbleFontTableCreatedInDb:db];
  697. if (result) {
  698. // self.id, self.iosLeftUrl, self.iosRightUrl, self.name, self.code, self.color
  699. for (NSDictionary *tempDict in array1) {
  700. JLBubbleModel *model = [JLBubbleModel mj_objectWithKeyValues:tempDict];
  701. manager.id = model.id;
  702. manager.iosLeftUrl = model.bubble.iosLeftUrl;
  703. manager.iosRightUrl = model.bubble.iosRightUrl;
  704. manager.name = model.bubble.name;
  705. manager.code = [NSString stringWithFormat:@"%d", model.font.code];
  706. manager.color = model.font.color;
  707. [manager insertBubbleFontTable];
  708. }
  709. }
  710. // 缓存图片
  711. // NSMutableArray *imagesArray = [NSMutableArray array];
  712. // for (NSDictionary *modelDict in array1) {
  713. // JLBubbleModel *model = [JLBubbleModel mj_objectWithKeyValues:modelDict];
  714. // [imagesArray addObject:[NSURL URLWithString:model.bubble.iosLeftUrl]];
  715. // [imagesArray addObject:[NSURL URLWithString:model.bubble.iosRightUrl]];
  716. //// [imagesArray addObject:[NSURL URLWithString:model.homeUrl]];
  717. // }
  718. // [[JLBubbleManager sharedManager] cacheBubbleImage:imagesArray];
  719. }
  720. if ([aDownload.action isEqualToString:act_customerLinkList])
  721. {
  722. g_App.customerLinkListArray = array1;
  723. }
  724. if( [aDownload.action isEqualToString:act_Config]){
  725. [g_config didReceive:dict];
  726. [self actionConfig];
  727. }
  728. if([aDownload.action isEqualToString:act_CheckPhone]){
  729. }
  730. if([aDownload.action isEqualToString:act_SendSMS]){
  731. [JXMyTools showTipView:Localized(@"JXAlert_SendOK")];
  732. /*
  733. _send.selected = YES;
  734. _send.userInteractionEnabled = NO;
  735. _send.backgroundColor = [UIColor grayColor];
  736. _smsCode = [[dict objectForKey:@"code"] copy];
  737. [_send setTitle:@"60s" forState:UIControlStateSelected];
  738. _seconds = 60;
  739. _timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(showTime:) userInfo:_send repeats:YES];
  740. */
  741. }
  742. 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]){
  743. if ([dict.allKeys containsObject:@"authKey"]) {
  744. [_wait stop];
  745. [self createWaitAuthView];
  746. [self startAuthDevice:[dict objectForKey:@"authKey"]];
  747. return;
  748. }
  749. if ([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1] || [aDownload.action isEqualToString:act_sdkLogin] || [aDownload.action isEqualToString:act_sdkLoginV1] ) {
  750. g_server.openId = nil;
  751. [g_default setBool:YES forKey:kTHIRD_LOGIN_AUTO];
  752. }else {
  753. [g_default setBool:NO forKey:kTHIRD_LOGIN_AUTO];
  754. }
  755. // if (!IsStringNull(_pwd.text)) {
  756. // _user.password = [g_server getMD5String:_pwd.text];
  757. // }
  758. // [g_default setBool:[[dict objectForKey:@"multipleDevices"] boolValue] forKey:kISMultipleLogin];
  759. // [g_default synchronize];
  760. [g_server doLoginOK:dict user:_user];
  761. if(self.isSwitchUser){
  762. //切换登录,同步好友
  763. [g_notify postNotificationName:kXmppClickLoginNotifaction object:nil];
  764. // 更新“我”页面
  765. [g_notify postNotificationName:kUpdateUserNotifaction object:nil];
  766. }
  767. else
  768. [g_App showMainUI];
  769. [self actionQuit];
  770. [_wait stop];
  771. }
  772. if([aDownload.action isEqualToString:act_userLoginAuto] || [aDownload.action isEqualToString:act_userLoginAutoV1]){
  773. // int status = [[dict objectForKey:@"serialStatus"] intValue];
  774. // int token = [[dict objectForKey:@"tokenExists"] intValue];
  775. // if(status == 2){//序列号一致
  776. // if(token==1){//Token也存在,说明不用登录了
  777. // [g_default setBool:[[dict objectForKey:@"multipleDevices"] boolValue] forKey:kISMultipleLogin];
  778. // [g_default synchronize];
  779. // [g_server getAppResource:@"2" ToView:self];
  780. [g_server doLoginOK:dict user:_user];
  781. [g_App showMainUI];
  782. [self actionQuit];
  783. // }else{
  784. // //Token不存在
  785. // [g_App showAlert:Localized(@"JX_LoginAgain")];
  786. // _launchImageView.hidden = YES;
  787. // }
  788. // }else{
  789. // //设备号已换
  790. // [g_App showAlert:Localized(@"JX_LoginAgainNow")];
  791. // _launchImageView.hidden = YES;
  792. // }
  793. [_wait stop];
  794. }
  795. if ([aDownload.action isEqualToString:act_GetWxOpenId]) {
  796. _launchImageView.hidden = NO;
  797. g_server.openId = [dict objectForKey:@"openid"];
  798. // [g_server wxSdkLogin:_user type:2 openId:g_server.openId toView:self];
  799. [g_loginServer wxSdkLoginV1:_user type:2 openId:g_server.openId toView:self];
  800. }
  801. if ([aDownload.action isEqualToString:act_getAppResource]) {
  802. // NSLog(@"%@",array1);
  803. NSMutableArray *tempArray0 = [NSMutableArray array];
  804. NSMutableArray *tempArray2 = [NSMutableArray array];
  805. for (NSDictionary *resourceDict in array1) {
  806. NSString *code = resourceDict[@"code"];
  807. if ([code isEqualToString:@"0"]) {
  808. [tempArray0 addObject:resourceDict];
  809. }else if ([code isEqualToString:@"2"]) {
  810. [tempArray2 addObject:resourceDict];
  811. }
  812. }
  813. if (tempArray0.count>0) {
  814. g_App.linkArray = tempArray0;
  815. g_App.imgUrl = tempArray0[0][@"imgUrl"];
  816. }
  817. if (tempArray2.count>0) {
  818. NSDictionary *adDict = tempArray2.firstObject;
  819. [g_App setupLunchADUrl:adDict[@"imgUrl"] link:adDict[@"link"]];
  820. }else {
  821. [g_notify postNotificationName:kLaunchAdShowFinishNotifaction object:nil];
  822. }
  823. }
  824. _btn.userInteractionEnabled = YES;
  825. }
  826. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  827. _btn.userInteractionEnabled = YES;
  828. _launchImageView.hidden = YES;
  829. NSLog(@"视频地址:%@",aDownload.action);
  830. if ([aDownload.action isEqualToString:act_UserDeviceIsAuth]) {
  831. if ([[dict objectForKey:@"resultCode"] intValue] == 101987) {
  832. [self changeAccount];
  833. [g_server getSetting:self];
  834. }
  835. return 1;
  836. }
  837. if ([aDownload.action isEqualToString:act_Config]) {
  838. NSString *url = [g_default stringForKey:kLastApiUrl];
  839. g_config.apiUrl = url;
  840. [self actionConfig];
  841. return 1;
  842. }
  843. [_wait stop];
  844. if (([aDownload.action isEqualToString:act_sdkLogin] || [aDownload.action isEqualToString:act_sdkLoginV1]) && [[dict objectForKey:@"resultCode"] intValue] == 1040305) {
  845. inputPhoneVC *vc = [[inputPhoneVC alloc] init];
  846. vc.isThirdLogin = YES;
  847. vc.type = (int)self.type;
  848. [g_navigation pushViewController:vc animated:YES];
  849. // loginVC *login = [loginVC alloc];
  850. // login.isThirdLogin = YES;
  851. // login.isAutoLogin = NO;
  852. // login.isSwitchUser= NO;
  853. // login = [login init];
  854. // [g_navigation pushViewController:login animated:YES];
  855. return 1;
  856. }
  857. if (([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1]) && [[dict objectForKey:@"resultCode"] intValue] == 1040306) {
  858. inputPhoneVC *vc = [[inputPhoneVC alloc] init];
  859. vc.isThirdLogin = YES;
  860. vc.type = (int)self.type;
  861. [g_navigation pushViewController:vc animated:YES];
  862. return 1;
  863. }
  864. if([aDownload.action isEqualToString:act_userLoginAuto] || [aDownload.action isEqualToString:act_userLoginAutoV1]){
  865. [g_default removeObjectForKey:kMY_USER_TOKEN];
  866. [share_defaults removeObjectForKey:kMY_ShareExtensionToken];
  867. }
  868. if ([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1]) {
  869. // g_server.openId = nil;
  870. }
  871. if ([aDownload.action isEqualToString:act_SendSMS]) {
  872. //[_send setTitle:Localized(@"JX_Send") forState:UIControlStateNormal];
  873. }
  874. return 1;
  875. }
  876. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  877. _btn.userInteractionEnabled = YES;
  878. _launchImageView.hidden = YES;
  879. NSLog(@"视频地址:%@",aDownload.action);
  880. if ([aDownload.action isEqualToString:act_Config]) {
  881. NSString *url = [g_default stringForKey:kLastApiUrl];
  882. g_config.apiUrl = url;
  883. [self actionConfig];
  884. return 1;
  885. }
  886. if([aDownload.action isEqualToString:act_userLoginAuto] || [aDownload.action isEqualToString:act_userLoginAutoV1]){
  887. [g_default removeObjectForKey:kMY_USER_TOKEN];
  888. [share_defaults removeObjectForKey:kMY_ShareExtensionToken];
  889. }
  890. if ([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1]) {
  891. // g_server.openId = nil;
  892. }
  893. if ([aDownload.action isEqualToString:act_SendSMS]) {
  894. //[_send setTitle:Localized(@"JX_Send") forState:UIControlStateNormal];
  895. }
  896. [_wait stop];
  897. return 1;
  898. }
  899. -(void) didServerConnectStart:(JXConnection*)aDownload{
  900. // _btn.userInteractionEnabled = NO;
  901. if([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1] || [aDownload.action isEqualToString:act_sdkLogin]|| [aDownload.action isEqualToString:act_sdkLoginV1]){
  902. [_wait start];
  903. }
  904. }
  905. -(void)autoLogin{
  906. // _btn.userInteractionEnabled = ![g_server autoLogin:self];
  907. [JXRegisterShowView closeView];
  908. NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kMY_USER_TOKEN];
  909. _btn.userInteractionEnabled = token.length > 0;
  910. if (token.length > 0) {
  911. [g_loginServer autoLoginWithToView:self];
  912. }else {
  913. _launchImageView.hidden = YES;
  914. }
  915. // if (_btn.userInteractionEnabled) {
  916. // _launchImageView.hidden = YES;
  917. // }
  918. }
  919. -(void)onRegistered:(NSNotification *)notifacation{
  920. [self actionQuit];
  921. if(!self.isSwitchUser)
  922. [g_App showMainUI];
  923. }
  924. -(void)actionQuit{
  925. [super actionQuit];
  926. // _pSelf = nil;
  927. }
  928. - (void)areaCodeBtnClick:(UIButton *)but{
  929. [self.view endEditing:YES];
  930. JXTelAreaListVC *telAreaListVC = [[JXTelAreaListVC alloc] init];
  931. telAreaListVC.telAreaDelegate = self;
  932. telAreaListVC.didSelect = @selector(didSelectTelArea:);
  933. // [g_window addSubview:telAreaListVC.view];
  934. [g_navigation pushViewController:telAreaListVC animated:YES];
  935. }
  936. - (void)didSelectTelArea:(NSString *)areaCode{
  937. _areaCodeBtn=areaCode;
  938. }
  939. - (void)didSelectedCheckBox:(QCheckBox *)checkbox checked:(BOOL)checked{
  940. [g_default setObject:[NSNumber numberWithBool:checked] forKey:@"agreement"];
  941. [g_default synchronize];
  942. }
  943. // 获取启动图
  944. - (NSString *)getLaunchImageName
  945. {
  946. NSString *viewOrientation = @"Portrait";
  947. if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
  948. viewOrientation = @"Landscape";
  949. }
  950. NSString *launchImageName = nil;
  951. NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
  952. CGSize viewSize = tyCurrentWindow.bounds.size;
  953. for (NSDictionary* dict in imagesDict)
  954. {
  955. CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
  956. if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
  957. {
  958. launchImageName = dict[@"UILaunchImageName"];
  959. }
  960. }
  961. return launchImageName;
  962. }
  963. #pragma mark JXLocationDelegate
  964. - (void)location:(JXLocation *)location CountryCode:(NSString *)countryCode CityName:(NSString *)cityName CityId:(NSString *)cityId Address:(NSString *)address Latitude:(double)lat Longitude:(double)lon{
  965. g_server.countryCode = countryCode;
  966. g_server.cityName = cityName;
  967. g_server.cityId = [cityId intValue];
  968. g_server.address = address;
  969. g_server.latitude = lat;
  970. g_server.longitude = lon;
  971. NSDictionary *dict = @{@"latitude":@(lat),@"longitude":@(lon)};
  972. [g_default setObject:dict forKey:kLocationLogin];
  973. }
  974. - (void)createWaitAuthView{
  975. self.waitAuthView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH,JX_SCREEN_HEIGHT)];
  976. self.waitAuthView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
  977. UITapGestureRecognizer *ges = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeAccount)];
  978. [self.waitAuthView addGestureRecognizer:ges];
  979. [self.view addSubview:self.waitAuthView];
  980. UIView *authView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH - 80, JX_SCREEN_HEIGHT / 3)];
  981. authView.backgroundColor = [UIColor whiteColor];
  982. authView.layer.cornerRadius = 10;
  983. authView.layer.masksToBounds = YES;
  984. CGPoint center = authView.center;
  985. UIImageView *imgV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 95, 95)];
  986. imgV.image = [UIImage imageNamed:@"ALOGO_1200"];
  987. [authView addSubview:imgV];
  988. imgV.center = CGPointMake(center.x, 20 + 95/2);
  989. UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH - 200, 50)];
  990. lab.text = Localized(@"JX_WaitingForAuthorization");
  991. lab.font = [UIFont systemFontOfSize:17];
  992. lab.textColor = [UIColor blackColor];
  993. lab.textAlignment = NSTextAlignmentCenter;
  994. [authView addSubview:lab];
  995. lab.center = CGPointMake(center.x, CGRectGetMaxY(imgV.frame) + 30);
  996. UIButton *btn = [UIFactory createCommonButton:Localized(@"JX_SwitchAccount") target:self action:@selector(changeAccount)];
  997. btn.custom_acceptEventInterval = 1.0f;
  998. [btn.titleLabel setFont:g_factory.font17];
  999. btn.layer.cornerRadius = 20;
  1000. btn.clipsToBounds = YES;
  1001. btn.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH-100*2, 40);
  1002. [authView addSubview:btn];
  1003. btn.center = CGPointMake(center.x, CGRectGetMaxY(authView.frame) - 40);
  1004. btn.userInteractionEnabled = NO;
  1005. [self.waitAuthView addSubview:authView];
  1006. authView.center = self.waitAuthView.center;
  1007. }
  1008. - (void)changeAccount{
  1009. [self.waitAuthView removeFromSuperview];
  1010. dispatch_cancel(_authTimer);
  1011. _authTimer = nil;
  1012. }
  1013. - (void)startAuthDevice:(NSString *)str{
  1014. if (_authTimer) {
  1015. dispatch_cancel(_authTimer);
  1016. _authTimer = nil;
  1017. }
  1018. dispatch_queue_t queue = dispatch_get_main_queue();
  1019. _authTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
  1020. dispatch_time_t start = DISPATCH_TIME_NOW;
  1021. dispatch_time_t interval = 1.0 * NSEC_PER_SEC;
  1022. dispatch_source_set_timer(_authTimer, start, interval, 0);
  1023. dispatch_source_set_event_handler(_authTimer, ^{
  1024. _count ++;
  1025. [g_server loginIsAuthKey:str toView:self];
  1026. if (_count == 300 ) {
  1027. _count = 0;
  1028. [self changeAccount];
  1029. }
  1030. });
  1031. dispatch_resume(_authTimer);
  1032. }
  1033. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  1034. [self.view endEditing:YES];
  1035. }
  1036. @end