JXMainLoginVc.m 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324
  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. NSDictionary *dictMM=[array1 firstObject];
  594. NSString *memberAcc= dictMM[@"url"];
  595. [[NSUserDefaults standardUserDefaults] setObject:array1 forKey:@"www_Array"];
  596. [[NSUserDefaults standardUserDefaults] synchronize];
  597. [[NSUserDefaults standardUserDefaults] setObject:memberAcc forKey:@"www_url"];
  598. [[NSUserDefaults standardUserDefaults] synchronize];
  599. // [g_notify postNotificationName:@"loadHomeWeb" object:nil userInfo:dict];
  600. }
  601. if([aDownload.action isEqualToString:act_UserGet]){
  602. JXUserObject *user = [[JXUserObject alloc] init];
  603. [user getDataFromDict:dict];
  604. }
  605. if([aDownload.action isEqualToString:act_fuwenBenLogin]){
  606. //NSString *strValue=[[NSUserDefaults standardUserDefaults] objectForKey:@"guangboxxx"];
  607. // if (strValue.length==0) {
  608. [[NSUserDefaults standardUserDefaults] setObject:@"10000" forKey:@"guangboxxx"];
  609. [[NSUserDefaults standardUserDefaults] synchronize];
  610. JXRegisterShowView *showLogView=[[JXRegisterShowView alloc]init];
  611. showLogView.frame=self.view.bounds;
  612. showLogView.dataDict= dict;
  613. [self.view addSubview:showLogView];
  614. self.showLogView=showLogView;
  615. //}else{ }
  616. }
  617. if([aDownload.action isEqualToString:act_UserdeviceLogsecurity]){
  618. NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
  619. [userDefault setObject:dict[@"data"] forKey:@"user_Data"];
  620. [userDefault synchronize];
  621. }
  622. if ([aDownload.action isEqualToString:act_getGradeList])
  623. {
  624. NSString *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
  625. NSString *fileName = [path stringByAppendingPathComponent:@"grade.plist"];
  626. [array1 writeToFile:fileName atomically:YES];
  627. // 保存到数据库
  628. JLBubbleManager *manager = [JLBubbleManager sharedManager];
  629. FMDatabase* db = [manager openResouceDb];
  630. BOOL result = [manager checkGradeTableCreatedInDb:db];
  631. if (result) {
  632. // self.gradeIndex, self.avatarUrl, self.id, self.name, self.rankUrl, self.grade
  633. for (NSDictionary *tempDict in array1) {
  634. JLBubbleManager *manager = [JLBubbleManager mj_objectWithKeyValues:tempDict];
  635. [manager insertGradeTable];
  636. }
  637. }
  638. NSMutableArray *imagesArray = [NSMutableArray array];
  639. for (NSDictionary *tempDict in array1) {
  640. //[imagesArray addObject:[NSURL URLWithString:tempDict[@"avatarUrl"]]];
  641. //[imagesArray addObject:[NSURL URLWithString:tempDict[@"rankUrl"]]];
  642. NSString *avatarUrl = @"";
  643. if (tempDict[@"avatarUrl"] == nil) {
  644. avatarUrl = @"";
  645. }else {
  646. avatarUrl = tempDict[@"avatarUrl"];
  647. }
  648. NSString *rankUrl = @"";
  649. if (tempDict[@"rankUrl"] == nil) {
  650. avatarUrl = @"";
  651. }else {
  652. rankUrl = tempDict[@"rankUrl"];
  653. }
  654. [imagesArray addObject:[NSURL URLWithString:avatarUrl]];
  655. [imagesArray addObject:[NSURL URLWithString:rankUrl]];
  656. NSArray *bubbleFontSet = tempDict[@"bubbleFontSet"];
  657. for (NSDictionary *bubbleFontDict in bubbleFontSet) {
  658. JLBubbleModel *model = [JLBubbleModel mj_objectWithKeyValues:bubbleFontDict];
  659. [imagesArray addObject:[NSURL URLWithString:model.bubble.iosLeftUrl]];
  660. [imagesArray addObject:[NSURL URLWithString:model.bubble.iosRightUrl]];
  661. // [imagesArray addObject:[NSURL URLWithString:model.homeUrl]];
  662. }
  663. // NSArray *faceSet = tempDict[@"faceSet"];
  664. // for (NSDictionary *faceSetDict in faceSet) {
  665. // NSArray *array = faceSetDict[@"path"];
  666. // for (NSString *url in array) {
  667. // NSURL *urlPath = [NSURL URLWithString:url];
  668. // [imagesArray addObject:urlPath];
  669. // }
  670. // }
  671. if (result) {
  672. // int gradeIndex = (int)tempDict[@"gradeIndex"];
  673. // [JXLabelObject sharedInstance].gradeIndex = gradeIndex;
  674. // NSData *data = [NSKeyedArchiver archivedDataWithRootObject:tempDict];
  675. // [JXLabelObject sharedInstance].data = data;
  676. // [[JXLabelObject sharedInstance] insertGradeTable];
  677. // NSArray *array = [tempDict allValues];
  678. }
  679. }
  680. // 缓存图片
  681. [[JLBubbleManager sharedManager] cacheBubbleImage:imagesArray];
  682. }
  683. if ([aDownload.action isEqualToString:act_getAllBubbleFontList])
  684. {
  685. NSString *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
  686. NSString *fileName = [path stringByAppendingPathComponent:@"bubbleFontList.plist"];
  687. [array1 writeToFile:fileName atomically:YES];
  688. // 保存到数据库
  689. // 保存到数据库
  690. JLBubbleManager *manager = [JLBubbleManager sharedManager];
  691. FMDatabase* db = [manager openResouceDb];
  692. BOOL result = [manager checkBubbleFontTableCreatedInDb:db];
  693. if (result) {
  694. // self.id, self.iosLeftUrl, self.iosRightUrl, self.name, self.code, self.color
  695. for (NSDictionary *tempDict in array1) {
  696. JLBubbleModel *model = [JLBubbleModel mj_objectWithKeyValues:tempDict];
  697. manager.id = model.id;
  698. manager.iosLeftUrl = model.bubble.iosLeftUrl;
  699. manager.iosRightUrl = model.bubble.iosRightUrl;
  700. manager.name = model.bubble.name;
  701. manager.code = [NSString stringWithFormat:@"%d", model.font.code];
  702. manager.color = model.font.color;
  703. [manager insertBubbleFontTable];
  704. }
  705. }
  706. // 缓存图片
  707. // NSMutableArray *imagesArray = [NSMutableArray array];
  708. // for (NSDictionary *modelDict in array1) {
  709. // JLBubbleModel *model = [JLBubbleModel mj_objectWithKeyValues:modelDict];
  710. // [imagesArray addObject:[NSURL URLWithString:model.bubble.iosLeftUrl]];
  711. // [imagesArray addObject:[NSURL URLWithString:model.bubble.iosRightUrl]];
  712. //// [imagesArray addObject:[NSURL URLWithString:model.homeUrl]];
  713. // }
  714. // [[JLBubbleManager sharedManager] cacheBubbleImage:imagesArray];
  715. }
  716. if ([aDownload.action isEqualToString:act_customerLinkList])
  717. {
  718. g_App.customerLinkListArray = array1;
  719. }
  720. if( [aDownload.action isEqualToString:act_Config]){
  721. [g_config didReceive:dict];
  722. [self actionConfig];
  723. }
  724. if([aDownload.action isEqualToString:act_CheckPhone]){
  725. }
  726. if([aDownload.action isEqualToString:act_SendSMS]){
  727. [JXMyTools showTipView:Localized(@"JXAlert_SendOK")];
  728. /*
  729. _send.selected = YES;
  730. _send.userInteractionEnabled = NO;
  731. _send.backgroundColor = [UIColor grayColor];
  732. _smsCode = [[dict objectForKey:@"code"] copy];
  733. [_send setTitle:@"60s" forState:UIControlStateSelected];
  734. _seconds = 60;
  735. _timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(showTime:) userInfo:_send repeats:YES];
  736. */
  737. }
  738. 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]){
  739. if ([dict.allKeys containsObject:@"authKey"]) {
  740. [_wait stop];
  741. [self createWaitAuthView];
  742. [self startAuthDevice:[dict objectForKey:@"authKey"]];
  743. return;
  744. }
  745. if ([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1] || [aDownload.action isEqualToString:act_sdkLogin] || [aDownload.action isEqualToString:act_sdkLoginV1] ) {
  746. g_server.openId = nil;
  747. [g_default setBool:YES forKey:kTHIRD_LOGIN_AUTO];
  748. }else {
  749. [g_default setBool:NO forKey:kTHIRD_LOGIN_AUTO];
  750. }
  751. // if (!IsStringNull(_pwd.text)) {
  752. // _user.password = [g_server getMD5String:_pwd.text];
  753. // }
  754. // [g_default setBool:[[dict objectForKey:@"multipleDevices"] boolValue] forKey:kISMultipleLogin];
  755. // [g_default synchronize];
  756. [g_server doLoginOK:dict user:_user];
  757. if(self.isSwitchUser){
  758. //切换登录,同步好友
  759. [g_notify postNotificationName:kXmppClickLoginNotifaction object:nil];
  760. // 更新“我”页面
  761. [g_notify postNotificationName:kUpdateUserNotifaction object:nil];
  762. }
  763. else
  764. [g_App showMainUI];
  765. [self actionQuit];
  766. [_wait stop];
  767. }
  768. if([aDownload.action isEqualToString:act_userLoginAuto] || [aDownload.action isEqualToString:act_userLoginAutoV1]){
  769. // int status = [[dict objectForKey:@"serialStatus"] intValue];
  770. // int token = [[dict objectForKey:@"tokenExists"] intValue];
  771. // if(status == 2){//序列号一致
  772. // if(token==1){//Token也存在,说明不用登录了
  773. // [g_default setBool:[[dict objectForKey:@"multipleDevices"] boolValue] forKey:kISMultipleLogin];
  774. // [g_default synchronize];
  775. // [g_server getAppResource:@"2" ToView:self];
  776. [g_server doLoginOK:dict user:_user];
  777. [g_App showMainUI];
  778. [self actionQuit];
  779. // }else{
  780. // //Token不存在
  781. // [g_App showAlert:Localized(@"JX_LoginAgain")];
  782. // _launchImageView.hidden = YES;
  783. // }
  784. // }else{
  785. // //设备号已换
  786. // [g_App showAlert:Localized(@"JX_LoginAgainNow")];
  787. // _launchImageView.hidden = YES;
  788. // }
  789. [_wait stop];
  790. }
  791. if ([aDownload.action isEqualToString:act_GetWxOpenId]) {
  792. _launchImageView.hidden = NO;
  793. g_server.openId = [dict objectForKey:@"openid"];
  794. // [g_server wxSdkLogin:_user type:2 openId:g_server.openId toView:self];
  795. [g_loginServer wxSdkLoginV1:_user type:2 openId:g_server.openId toView:self];
  796. }
  797. if ([aDownload.action isEqualToString:act_getAppResource]) {
  798. // NSLog(@"%@",array1);
  799. NSMutableArray *tempArray0 = [NSMutableArray array];
  800. NSMutableArray *tempArray2 = [NSMutableArray array];
  801. for (NSDictionary *resourceDict in array1) {
  802. NSString *code = resourceDict[@"code"];
  803. if ([code isEqualToString:@"0"]) {
  804. [tempArray0 addObject:resourceDict];
  805. }else if ([code isEqualToString:@"2"]) {
  806. [tempArray2 addObject:resourceDict];
  807. }
  808. }
  809. if (tempArray0.count>0) {
  810. g_App.linkArray = tempArray0;
  811. g_App.imgUrl = tempArray0[0][@"imgUrl"];
  812. }
  813. if (tempArray2.count>0) {
  814. NSDictionary *adDict = tempArray2.firstObject;
  815. [g_App setupLunchADUrl:adDict[@"imgUrl"] link:adDict[@"link"]];
  816. }else {
  817. [g_notify postNotificationName:kLaunchAdShowFinishNotifaction object:nil];
  818. }
  819. }
  820. _btn.userInteractionEnabled = YES;
  821. }
  822. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  823. _btn.userInteractionEnabled = YES;
  824. _launchImageView.hidden = YES;
  825. NSLog(@"视频地址:%@",aDownload.action);
  826. if ([aDownload.action isEqualToString:act_UserDeviceIsAuth]) {
  827. if ([[dict objectForKey:@"resultCode"] intValue] == 101987) {
  828. [self changeAccount];
  829. [g_server getSetting:self];
  830. }
  831. return 1;
  832. }
  833. if ([aDownload.action isEqualToString:act_Config]) {
  834. NSString *url = [g_default stringForKey:kLastApiUrl];
  835. g_config.apiUrl = url;
  836. [self actionConfig];
  837. return 1;
  838. }
  839. [_wait stop];
  840. if (([aDownload.action isEqualToString:act_sdkLogin] || [aDownload.action isEqualToString:act_sdkLoginV1]) && [[dict objectForKey:@"resultCode"] intValue] == 1040305) {
  841. inputPhoneVC *vc = [[inputPhoneVC alloc] init];
  842. vc.isThirdLogin = YES;
  843. vc.type = (int)self.type;
  844. [g_navigation pushViewController:vc animated:YES];
  845. // loginVC *login = [loginVC alloc];
  846. // login.isThirdLogin = YES;
  847. // login.isAutoLogin = NO;
  848. // login.isSwitchUser= NO;
  849. // login = [login init];
  850. // [g_navigation pushViewController:login animated:YES];
  851. return 1;
  852. }
  853. if (([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1]) && [[dict objectForKey:@"resultCode"] intValue] == 1040306) {
  854. inputPhoneVC *vc = [[inputPhoneVC alloc] init];
  855. vc.isThirdLogin = YES;
  856. vc.type = (int)self.type;
  857. [g_navigation pushViewController:vc animated:YES];
  858. return 1;
  859. }
  860. if([aDownload.action isEqualToString:act_userLoginAuto] || [aDownload.action isEqualToString:act_userLoginAutoV1]){
  861. [g_default removeObjectForKey:kMY_USER_TOKEN];
  862. [share_defaults removeObjectForKey:kMY_ShareExtensionToken];
  863. }
  864. if ([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1]) {
  865. // g_server.openId = nil;
  866. }
  867. if ([aDownload.action isEqualToString:act_SendSMS]) {
  868. //[_send setTitle:Localized(@"JX_Send") forState:UIControlStateNormal];
  869. }
  870. return 1;
  871. }
  872. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  873. _btn.userInteractionEnabled = YES;
  874. _launchImageView.hidden = YES;
  875. NSLog(@"视频地址:%@",aDownload.action);
  876. if ([aDownload.action isEqualToString:act_Config]) {
  877. NSString *url = [g_default stringForKey:kLastApiUrl];
  878. g_config.apiUrl = url;
  879. [self actionConfig];
  880. return 1;
  881. }
  882. if([aDownload.action isEqualToString:act_userLoginAuto] || [aDownload.action isEqualToString:act_userLoginAutoV1]){
  883. [g_default removeObjectForKey:kMY_USER_TOKEN];
  884. [share_defaults removeObjectForKey:kMY_ShareExtensionToken];
  885. }
  886. if ([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1]) {
  887. // g_server.openId = nil;
  888. }
  889. if ([aDownload.action isEqualToString:act_SendSMS]) {
  890. //[_send setTitle:Localized(@"JX_Send") forState:UIControlStateNormal];
  891. }
  892. [_wait stop];
  893. return 1;
  894. }
  895. -(void) didServerConnectStart:(JXConnection*)aDownload{
  896. // _btn.userInteractionEnabled = NO;
  897. if([aDownload.action isEqualToString:act_thirdLogin] || [aDownload.action isEqualToString:act_thirdLoginV1] || [aDownload.action isEqualToString:act_sdkLogin]|| [aDownload.action isEqualToString:act_sdkLoginV1]){
  898. [_wait start];
  899. }
  900. }
  901. -(void)autoLogin{
  902. // _btn.userInteractionEnabled = ![g_server autoLogin:self];
  903. [JXRegisterShowView closeView];
  904. NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kMY_USER_TOKEN];
  905. _btn.userInteractionEnabled = token.length > 0;
  906. if (token.length > 0) {
  907. [g_loginServer autoLoginWithToView:self];
  908. }else {
  909. _launchImageView.hidden = YES;
  910. }
  911. // if (_btn.userInteractionEnabled) {
  912. // _launchImageView.hidden = YES;
  913. // }
  914. }
  915. -(void)onRegistered:(NSNotification *)notifacation{
  916. [self actionQuit];
  917. if(!self.isSwitchUser)
  918. [g_App showMainUI];
  919. }
  920. -(void)actionQuit{
  921. [super actionQuit];
  922. // _pSelf = nil;
  923. }
  924. - (void)areaCodeBtnClick:(UIButton *)but{
  925. [self.view endEditing:YES];
  926. JXTelAreaListVC *telAreaListVC = [[JXTelAreaListVC alloc] init];
  927. telAreaListVC.telAreaDelegate = self;
  928. telAreaListVC.didSelect = @selector(didSelectTelArea:);
  929. // [g_window addSubview:telAreaListVC.view];
  930. [g_navigation pushViewController:telAreaListVC animated:YES];
  931. }
  932. - (void)didSelectTelArea:(NSString *)areaCode{
  933. _areaCodeBtn=areaCode;
  934. }
  935. - (void)didSelectedCheckBox:(QCheckBox *)checkbox checked:(BOOL)checked{
  936. [g_default setObject:[NSNumber numberWithBool:checked] forKey:@"agreement"];
  937. [g_default synchronize];
  938. }
  939. // 获取启动图
  940. - (NSString *)getLaunchImageName
  941. {
  942. NSString *viewOrientation = @"Portrait";
  943. if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
  944. viewOrientation = @"Landscape";
  945. }
  946. NSString *launchImageName = nil;
  947. NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
  948. CGSize viewSize = tyCurrentWindow.bounds.size;
  949. for (NSDictionary* dict in imagesDict)
  950. {
  951. CGSize imageSize = CGSizeFromString(dict[@"UILaunchImageSize"]);
  952. if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:dict[@"UILaunchImageOrientation"]])
  953. {
  954. launchImageName = dict[@"UILaunchImageName"];
  955. }
  956. }
  957. return launchImageName;
  958. }
  959. #pragma mark JXLocationDelegate
  960. - (void)location:(JXLocation *)location CountryCode:(NSString *)countryCode CityName:(NSString *)cityName CityId:(NSString *)cityId Address:(NSString *)address Latitude:(double)lat Longitude:(double)lon{
  961. g_server.countryCode = countryCode;
  962. g_server.cityName = cityName;
  963. g_server.cityId = [cityId intValue];
  964. g_server.address = address;
  965. g_server.latitude = lat;
  966. g_server.longitude = lon;
  967. NSDictionary *dict = @{@"latitude":@(lat),@"longitude":@(lon)};
  968. [g_default setObject:dict forKey:kLocationLogin];
  969. }
  970. - (void)createWaitAuthView{
  971. self.waitAuthView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH,JX_SCREEN_HEIGHT)];
  972. self.waitAuthView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
  973. UITapGestureRecognizer *ges = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeAccount)];
  974. [self.waitAuthView addGestureRecognizer:ges];
  975. [self.view addSubview:self.waitAuthView];
  976. UIView *authView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH - 80, JX_SCREEN_HEIGHT / 3)];
  977. authView.backgroundColor = [UIColor whiteColor];
  978. authView.layer.cornerRadius = 10;
  979. authView.layer.masksToBounds = YES;
  980. CGPoint center = authView.center;
  981. UIImageView *imgV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 95, 95)];
  982. imgV.image = [UIImage imageNamed:@"ALOGO_1200"];
  983. [authView addSubview:imgV];
  984. imgV.center = CGPointMake(center.x, 20 + 95/2);
  985. UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, JX_SCREEN_WIDTH - 200, 50)];
  986. lab.text = Localized(@"JX_WaitingForAuthorization");
  987. lab.font = [UIFont systemFontOfSize:17];
  988. lab.textColor = [UIColor blackColor];
  989. lab.textAlignment = NSTextAlignmentCenter;
  990. [authView addSubview:lab];
  991. lab.center = CGPointMake(center.x, CGRectGetMaxY(imgV.frame) + 30);
  992. UIButton *btn = [UIFactory createCommonButton:Localized(@"JX_SwitchAccount") target:self action:@selector(changeAccount)];
  993. btn.custom_acceptEventInterval = 1.0f;
  994. [btn.titleLabel setFont:g_factory.font17];
  995. btn.layer.cornerRadius = 20;
  996. btn.clipsToBounds = YES;
  997. btn.frame = CGRectMake(0, 0, JX_SCREEN_WIDTH-100*2, 40);
  998. [authView addSubview:btn];
  999. btn.center = CGPointMake(center.x, CGRectGetMaxY(authView.frame) - 40);
  1000. btn.userInteractionEnabled = NO;
  1001. [self.waitAuthView addSubview:authView];
  1002. authView.center = self.waitAuthView.center;
  1003. }
  1004. - (void)changeAccount{
  1005. [self.waitAuthView removeFromSuperview];
  1006. dispatch_cancel(_authTimer);
  1007. _authTimer = nil;
  1008. }
  1009. - (void)startAuthDevice:(NSString *)str{
  1010. if (_authTimer) {
  1011. dispatch_cancel(_authTimer);
  1012. _authTimer = nil;
  1013. }
  1014. dispatch_queue_t queue = dispatch_get_main_queue();
  1015. _authTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
  1016. dispatch_time_t start = DISPATCH_TIME_NOW;
  1017. dispatch_time_t interval = 1.0 * NSEC_PER_SEC;
  1018. dispatch_source_set_timer(_authTimer, start, interval, 0);
  1019. dispatch_source_set_event_handler(_authTimer, ^{
  1020. _count ++;
  1021. [g_server loginIsAuthKey:str toView:self];
  1022. if (_count == 300 ) {
  1023. _count = 0;
  1024. [self changeAccount];
  1025. }
  1026. });
  1027. dispatch_resume(_authTimer);
  1028. }
  1029. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
  1030. [self.view endEditing:YES];
  1031. }
  1032. @end