JXMainLoginVc.m 46 KB

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