inputPhoneVC.m 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042
  1. //
  2. // inputPhoneVC.m
  3. // shiku_im
  4. //
  5. // Created by flyeagleTang on 14-6-7.
  6. // Copyright (c) 2014年 Reese. All rights reserved.
  7. //
  8. #import "inputPhoneVC.h"
  9. #import "inputPwdVC.h"
  10. #import "JXTelAreaListVC.h"
  11. #import "JXUserObject.h"
  12. #import "PSRegisterBaseVC.h"
  13. #import "resumeData.h"
  14. #import "webpageVC.h"
  15. #import "loginVC.h"
  16. #define HEIGHT 56
  17. @interface inputPhoneVC ()<UITextFieldDelegate>
  18. {
  19. NSTimer *_timer;
  20. UIButton *_areaCodeBtn;
  21. JXUserObject *_user;
  22. UIImageView * _imgCodeImg;
  23. UITextField *_imgCode; //图片验证码
  24. UIButton * _graphicButton;
  25. UIButton* _skipBtn;
  26. BOOL _isSkipSMS;
  27. BOOL _isSendFirst;
  28. // 同意协议勾选
  29. UIImageView * _agreeImgV;
  30. }
  31. //@property (nonatomic, strong) UIView *imgCodeView;
  32. @property (nonatomic, assign) BOOL isSmsRegister;
  33. @property (nonatomic, assign) BOOL isCheckToSMS; // YES:发送短信处验证手机号 NO:注册处验证手机号
  34. @end
  35. @implementation inputPhoneVC
  36. - (id)init
  37. {
  38. self = [super init];
  39. if (self) {
  40. _seconds = 0;
  41. self.isGotoBack = YES;
  42. // self.title = Localized(@"JX_Register");
  43. self.heightFooter = 0;
  44. self.heightHeader = JX_SCREEN_TOP;
  45. //self.view.frame = g_window.bounds;
  46. [self createHeadAndFoot];
  47. self.tableBody.backgroundColor = [UIColor whiteColor];
  48. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyBoardToView)];
  49. [self.tableBody addGestureRecognizer:tap];
  50. _isSendFirst = YES; // 第一次发送短信
  51. int n = INSETS;
  52. int distance = 40; // 左右间距
  53. self.isSmsRegister = NO;
  54. //icon
  55. n += 20;
  56. UIImageView * kuliaoIconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ALOGO_1200"]];
  57. kuliaoIconView.frame = CGRectMake((JX_SCREEN_WIDTH-100)/2, n, 100, 100);
  58. // [self.tableBody addSubview:kuliaoIconView];
  59. UILabel *titleLable = [[UILabel alloc] init];
  60. titleLable.text = @"手机号注册";
  61. titleLable.textColor = [UIColor blackColor];
  62. titleLable.font = [UIFont systemFontOfSize:30 weight:(UIFontWeightRegular)];
  63. [titleLable sizeToFit];
  64. titleLable.frame = CGRectMake(JX_SCREEN_WIDTH/2- titleLable.frame.size.width/2, JX_SCREEN_TOP, titleLable.frame.size.width, titleLable.frame.size.height);
  65. [titleLable sizeToFit];
  66. [self.tableBody addSubview:titleLable];
  67. //手机号
  68. n += 95;
  69. if (!_phone) {
  70. NSString *placeHolder;
  71. if ([g_config.regeditPhoneOrName intValue] == 0) {
  72. placeHolder = Localized(@"JX_InputPhone");
  73. }else {
  74. placeHolder = Localized(@"JX_InputUserAccount");
  75. }
  76. _phone = [UIFactory createTextFieldWith:CGRectMake(distance, n, self_width-distance*2, HEIGHT) delegate:self returnKeyType:UIReturnKeyNext secureTextEntry:NO placeholder:placeHolder font:g_factory.font16];
  77. _phone.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeHolder attributes:@{NSForegroundColorAttributeName:[UIColor lightGrayColor]}];
  78. _phone.borderStyle = UITextBorderStyleNone;
  79. if ([g_config.regeditPhoneOrName intValue] == 1) {
  80. _phone.keyboardType = UIKeyboardTypeDefault; // 仅支持大小写字母数字
  81. }else {
  82. _phone.keyboardType = UIKeyboardTypeNumberPad; // 限制只能数字输入,使用数字键盘
  83. }
  84. _phone.clearButtonMode = UITextFieldViewModeWhileEditing;
  85. [_phone addTarget:self action:@selector(textFieldDidChanged:) forControlEvents:UIControlEventEditingChanged];
  86. [self.tableBody addSubview:_phone];
  87. UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, HEIGHT)];
  88. _phone.leftView = leftView;
  89. _phone.leftViewMode = UITextFieldViewModeAlways;
  90. /*
  91. UIImageView *phIgView = [[UIImageView alloc] initWithFrame:CGRectMake(2, HEIGHT/2-11, 22, 22)];
  92. phIgView.image = [UIImage imageNamed:@"account"];
  93. phIgView.contentMode = UIViewContentModeScaleAspectFit;
  94. [leftView addSubview:phIgView];
  95. */
  96. UILabel *phIgView = [[UILabel alloc] initWithFrame:CGRectMake(2, HEIGHT/2-11, 0, 22)];
  97. phIgView.text = @"";
  98. [leftView addSubview:phIgView];
  99. UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, HEIGHT-LINE_WH, _phone.frame.size.width, LINE_WH)];
  100. line.backgroundColor = THE_LINE_COLOR;
  101. [_phone addSubview:line];
  102. UIView *riPhView = [[UIView alloc] initWithFrame:CGRectMake(_phone.frame.size.width-44, 0, HEIGHT, HEIGHT)];
  103. _phone.rightView = riPhView;
  104. _phone.rightViewMode = UITextFieldViewModeAlways;
  105. NSString *areaStr;
  106. if (![g_default objectForKey:kMY_USER_AREACODE]) {
  107. areaStr = @"+86";
  108. } else {
  109. areaStr = [NSString stringWithFormat:@"+%@",[g_default objectForKey:kMY_USER_AREACODE]];
  110. }
  111. _areaCodeBtn = [[UIButton alloc] initWithFrame:CGRectMake(5, HEIGHT/2-8, HEIGHT-5, 22)];
  112. [_areaCodeBtn setTitle:areaStr forState:UIControlStateNormal];
  113. _areaCodeBtn.titleLabel.font = SYSFONT(15);
  114. _areaCodeBtn.hidden = [g_config.regeditPhoneOrName intValue] == 1;
  115. [_areaCodeBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  116. // [_areaCodeBtn setImage:[UIImage imageNamed:@"account"] forState:UIControlStateNormal];
  117. //[_areaCodeBtn addTarget:self action:@selector(areaCodeBtnClick:) forControlEvents:UIControlEventTouchUpInside];
  118. [self resetBtnEdgeInsets:_areaCodeBtn];
  119. [riPhView addSubview:_areaCodeBtn];
  120. }
  121. n = n+HEIGHT;
  122. //密码
  123. _pwd = [[UITextField alloc] initWithFrame:CGRectMake(distance, n, JX_SCREEN_WIDTH-distance*2, HEIGHT)];
  124. _pwd.delegate = self;
  125. _pwd.font = g_factory.font16;
  126. _pwd.autocorrectionType = UITextAutocorrectionTypeNo;
  127. _pwd.autocapitalizationType = UITextAutocapitalizationTypeNone;
  128. _pwd.enablesReturnKeyAutomatically = YES;
  129. _pwd.returnKeyType = UIReturnKeyDone;
  130. _pwd.clearButtonMode = UITextFieldViewModeWhileEditing;
  131. _pwd.attributedPlaceholder = [[NSAttributedString alloc] initWithString:Localized(@"JX_InputPassWord") attributes:@{NSForegroundColorAttributeName:[UIColor lightGrayColor]}];
  132. _pwd.secureTextEntry = YES;
  133. _pwd.userInteractionEnabled = YES;
  134. [_pwd addTarget:self action:@selector(textFieldDidChanged:) forControlEvents:UIControlEventEditingChanged];
  135. [self.tableBody addSubview:_pwd];
  136. UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, HEIGHT)];
  137. _pwd.leftView = rightView;
  138. _pwd.leftViewMode = UITextFieldViewModeAlways;
  139. // UIImageView *riIgView = [[UIImageView alloc] initWithFrame:CGRectMake(2, HEIGHT/2-11, 22, 22)];
  140. // riIgView.image = [UIImage imageNamed:@"password"];
  141. // riIgView.contentMode = UIViewContentModeScaleAspectFit;
  142. // [rightView addSubview:riIgView];
  143. UIView *verticalLine = [[UIView alloc] initWithFrame:CGRectMake(0, HEIGHT-LINE_WH, _pwd.frame.size.width, LINE_WH)];
  144. verticalLine.backgroundColor = THE_LINE_COLOR;
  145. [_pwd addSubview:verticalLine];
  146. n = n+HEIGHT;
  147. if ([g_config.registerInviteCode intValue] != 0) {
  148. //邀请码
  149. _inviteCode = [[UITextField alloc] initWithFrame:CGRectMake(distance, n, JX_SCREEN_WIDTH-distance*2, HEIGHT)];
  150. _inviteCode.delegate = self;
  151. _inviteCode.font = g_factory.font16;
  152. _inviteCode.autocorrectionType = UITextAutocorrectionTypeNo;
  153. _inviteCode.autocapitalizationType = UITextAutocapitalizationTypeNone;
  154. _inviteCode.enablesReturnKeyAutomatically = YES;
  155. _inviteCode.returnKeyType = UIReturnKeyDone;
  156. _inviteCode.clearButtonMode = UITextFieldViewModeWhileEditing;
  157. _inviteCode.attributedPlaceholder = [[NSAttributedString alloc] initWithString:Localized(@"JX_EnterInvitationCode") attributes:@{NSForegroundColorAttributeName:[UIColor lightGrayColor]}];
  158. _inviteCode.secureTextEntry = YES;
  159. _inviteCode.userInteractionEnabled = YES;
  160. [self.tableBody addSubview:_inviteCode];
  161. UIView *inviteRightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 37, HEIGHT)];
  162. _inviteCode.leftView = inviteRightView;
  163. _inviteCode.leftViewMode = UITextFieldViewModeAlways;
  164. UIImageView *inviteRiIgView = [[UIImageView alloc] initWithFrame:CGRectMake(2, HEIGHT/2-11, 22, 22)];
  165. inviteRiIgView.image = [UIImage imageNamed:@"password"];
  166. inviteRiIgView.contentMode = UIViewContentModeScaleAspectFit;
  167. [inviteRightView addSubview:inviteRiIgView];
  168. verticalLine = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(inviteRightView.frame)-4, _inviteCode.frame.size.width, 0.5)];
  169. verticalLine.backgroundColor = HEXCOLOR(0xD6D6D6);
  170. [inviteRightView addSubview:verticalLine];
  171. n = n+HEIGHT;
  172. }
  173. //图片验证码
  174. _imgCode = [UIFactory createTextFieldWith:CGRectMake(distance, n, self_width-distance*2-70-INSETS-35-4, HEIGHT) delegate:self returnKeyType:UIReturnKeyNext secureTextEntry:NO placeholder:Localized(@"JX_inputImgCode") font:g_factory.font16];
  175. _imgCode.attributedPlaceholder = [[NSAttributedString alloc] initWithString:Localized(@"JX_inputImgCode") attributes:@{NSForegroundColorAttributeName:[UIColor lightGrayColor]}];
  176. _imgCode.borderStyle = UITextBorderStyleNone;
  177. _imgCode.clearButtonMode = UITextFieldViewModeWhileEditing;
  178. [self.tableBody addSubview:_imgCode];
  179. UIView *imCView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, HEIGHT)];
  180. _imgCode.leftView = imCView;
  181. _imgCode.leftViewMode = UITextFieldViewModeAlways;
  182. // UIImageView *imCIView = [[UIImageView alloc] initWithFrame:CGRectMake(2, HEIGHT/2-11, 22, 22)];
  183. // imCIView.image = [UIImage imageNamed:@"verify"];
  184. // imCIView.contentMode = UIViewContentModeScaleAspectFit;
  185. // [imCView addSubview:imCIView];
  186. UIView *imCLine = [[UIView alloc] initWithFrame:CGRectMake(0, HEIGHT-LINE_WH, _phone.frame.size.width, LINE_WH)];
  187. imCLine.backgroundColor = THE_LINE_COLOR;
  188. [_imgCode addSubview:imCLine];
  189. _imgCodeImg = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_imgCode.frame)+INSETS, 0, 70, 35)];
  190. _imgCodeImg.center = CGPointMake(_imgCodeImg.center.x, _imgCode.center.y);
  191. _imgCodeImg.userInteractionEnabled = YES;
  192. [self.tableBody addSubview:_imgCodeImg];
  193. UIView *imgCodeLine = [[UIView alloc] initWithFrame:CGRectMake(_imgCodeImg.frame.size.width, 3, LINE_WH, _imgCodeImg.frame.size.height-6)];
  194. imgCodeLine.backgroundColor = THE_LINE_COLOR;
  195. [_imgCodeImg addSubview:imgCodeLine];
  196. _graphicButton = [UIButton buttonWithType:UIButtonTypeCustom];
  197. _graphicButton.frame = CGRectMake(CGRectGetMaxX(_imgCodeImg.frame)+6, 7, 26, 26);
  198. _graphicButton.center = CGPointMake(_graphicButton.center.x,_imgCode.center.y);
  199. [_graphicButton setBackgroundImage:[UIImage imageNamed:@"refreshGraphic"] forState:UIControlStateNormal];
  200. [_graphicButton setBackgroundImage:[UIImage imageNamed:@"refreshGraphic"] forState:UIControlStateHighlighted];
  201. [_graphicButton addTarget:self action:@selector(refreshGraphicAction:) forControlEvents:UIControlEventTouchUpInside];
  202. [self.tableBody addSubview:_graphicButton];
  203. if ([g_config.isOpenSMSCode boolValue] && [g_config.regeditPhoneOrName intValue] != 1) {
  204. n = n+HEIGHT;
  205. }else {
  206. n = n+INSETS;
  207. }
  208. #ifdef IS_TEST_VERSION
  209. #else
  210. #endif
  211. _code = [[UITextField alloc] initWithFrame:CGRectMake(distance, n, JX_SCREEN_WIDTH-75-distance*2, HEIGHT)];
  212. _code.attributedPlaceholder = [[NSAttributedString alloc] initWithString:Localized(@"JX_InputMessageCode") attributes:@{NSForegroundColorAttributeName:[UIColor lightGrayColor]}];
  213. _code.font = g_factory.font16;
  214. _code.delegate = self;
  215. _code.autocorrectionType = UITextAutocorrectionTypeNo;
  216. _code.autocapitalizationType = UITextAutocapitalizationTypeNone;
  217. _code.enablesReturnKeyAutomatically = YES;
  218. _code.borderStyle = UITextBorderStyleNone;
  219. _code.returnKeyType = UIReturnKeyDone;
  220. _code.clearButtonMode = UITextFieldViewModeWhileEditing;
  221. UIView *codeView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, HEIGHT)];
  222. _code.leftView = codeView;
  223. _code.leftViewMode = UITextFieldViewModeAlways;
  224. // UIImageView *codeIView = [[UIImageView alloc] initWithFrame:CGRectMake(2, HEIGHT/2-11, 22, 22)];
  225. // codeIView.image = [UIImage imageNamed:@"code"];
  226. // codeIView.contentMode = UIViewContentModeScaleAspectFit;
  227. // [codeView addSubview:codeIView];
  228. UIView *codeILine = [[UIView alloc] initWithFrame:CGRectMake(0, HEIGHT-LINE_WH, _phone.frame.size.width, LINE_WH)];
  229. codeILine.backgroundColor = THE_LINE_COLOR;
  230. [_code addSubview:codeILine];
  231. [self.tableBody addSubview:_code];
  232. _send = [UIFactory createButtonWithTitle:@"获取验证码"
  233. titleFont:g_factory.font14
  234. titleColor:HEXCOLOR(0x2A98FF)
  235. normal:nil
  236. highlight:nil ];
  237. _send.frame = CGRectMake(JX_SCREEN_WIDTH-80-distance-11, n+HEIGHT/2-15, 80, 30);
  238. [_send addTarget:self action:@selector(sendSMS) forControlEvents:UIControlEventTouchUpInside];
  239. // _send.backgroundColor = g_theme.themeColor;
  240. _send.layer.masksToBounds = YES;
  241. _send.layer.cornerRadius = 7.f;
  242. [self.tableBody addSubview:_send];
  243. //测试版隐藏了短信验证
  244. if ([g_config.isOpenSMSCode boolValue] && [g_config.regeditPhoneOrName intValue] != 1) {
  245. n = n+HEIGHT+INSETS+INSETS;
  246. }else {
  247. _send.hidden = YES;
  248. _code.hidden = YES;
  249. _imgCode.hidden = YES;
  250. _imgCodeImg.hidden = YES;
  251. _graphicButton.hidden = YES;
  252. }
  253. #ifdef IS_TEST_VERSION
  254. #else
  255. #endif
  256. // 返回登录
  257. CGSize size = [Localized(@"JX_HaveAccountLogin") boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:g_factory.font16} context:nil].size;
  258. UIButton *goLoginBtn = [[UIButton alloc] initWithFrame:CGRectMake(distance, n, size.width+4, size.height)];
  259. //[goLoginBtn setTitle:Localized(@"JX_HaveAccountLogin") forState:UIControlStateNormal];
  260. goLoginBtn.titleLabel.font = g_factory.font16;
  261. [goLoginBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  262. [goLoginBtn addTarget:self action:@selector(goToLoginVC) forControlEvents:UIControlEventTouchUpInside];
  263. [self.tableBody addSubview:goLoginBtn];
  264. #ifdef IS_Skip_SMS
  265. // 跳过当前界面进入下个界面
  266. CGSize skipSize = [Localized(@"JX_NotGetSMSCode") boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:g_factory.font16} context:nil].size;
  267. _skipBtn = [[UIButton alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH-distance-skipSize.width, n, skipSize.width+4, skipSize.height)];
  268. [_skipBtn setTitle:Localized(@"JX_NotGetSMSCode") forState:UIControlStateNormal];
  269. _skipBtn.titleLabel.font = g_factory.font16;
  270. _skipBtn.hidden = YES;
  271. [_skipBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  272. [_skipBtn addTarget:self action:@selector(enterNextPage) forControlEvents:UIControlEventTouchUpInside];
  273. [self.tableBody addSubview:_skipBtn];
  274. #else
  275. #endif
  276. //弃用手机验证
  277. //#ifdef IS_TEST_VERSION
  278. // UIButton* _btn = [UIFactory createCommonButton:@"下一步" target:self action:@selector(onTest)];
  279. //#else
  280. // UIButton* _btn = [UIFactory createCommonButton:@"下一步" target:self action:@selector(onClick)];
  281. //#endif
  282. //新添加的手机验证(注册)
  283. n = n+35;
  284. if (![[g_default objectForKey:@"agreement"] boolValue]) { //用户协议
  285. UIView * protocolView = [[UIView alloc] init];
  286. [self.tableBody addSubview:protocolView];
  287. //
  288. // UIButton * catProtocolbtn = [UIButton buttonWithType:UIButtonTypeSystem];
  289. // catProtocolbtn.frame = CGRectMake(0, 0, protocolView.frame.size.width, 25);
  290. NSString * agreeStr = @"登录注册代表同意";
  291. NSString * protocolStr = Localized(@"JX_ShikuProtocolTitle");
  292. // NSString * agreeProtocolStr = [NSString stringWithFormat:@"%@%@",agreeStr,protocolStr];
  293. // NSMutableAttributedString* tncString = [[NSMutableAttributedString alloc] initWithString:agreeProtocolStr];
  294. //
  295. // [tncString addAttribute:NSUnderlineStyleAttributeName
  296. // value:@(NSUnderlineStyleSingle)
  297. // range:(NSRange){agreeStr.length,[protocolStr length]}];
  298. // [tncString addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(agreeStr.length,[protocolStr length])];
  299. // [tncString addAttribute:NSForegroundColorAttributeName value:[UIColor lightGrayColor] range:NSMakeRange(0,agreeStr.length)];
  300. // [tncString addAttribute:NSUnderlineColorAttributeName value:[UIColor blueColor] range:(NSRange){agreeStr.length,[protocolStr length]}];
  301. // [catProtocolbtn setAttributedTitle:tncString forState:UIControlStateNormal];
  302. // [catProtocolbtn addTarget:self action:@selector(catUserProtocol) forControlEvents:UIControlEventTouchUpInside];
  303. // [protocolView addSubview:catProtocolbtn];
  304. UIButton *agrBtn = [[UIButton alloc] init];
  305. agrBtn.titleLabel.font = SYSFONT(13);
  306. CGSize agreSize = [agreeStr boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:agrBtn.titleLabel.font} context:nil].size;
  307. agrBtn.frame = CGRectMake(0, 0, agreSize.width, agreSize.height);
  308. [agrBtn setTitle:agreeStr forState:UIControlStateNormal];
  309. [agrBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
  310. // [agrBtn addTarget:self
  311. // action:@selector(agrBtnAction:)
  312. // forControlEvents:UIControlEventTouchUpInside];
  313. [protocolView addSubview:agrBtn];
  314. UILabel *protocolLab = [[UILabel alloc] init];
  315. protocolLab.font = SYSFONT(13);
  316. CGSize proSize = [protocolStr boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:protocolLab.font} context:nil].size;
  317. protocolLab.frame = CGRectMake(CGRectGetMaxX(agrBtn.frame), 0, proSize.width, proSize.height);
  318. protocolLab.textColor = HEXCOLOR(0x2A98FF);
  319. NSDictionary *attribtDic = @{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleNone]};
  320. NSMutableAttributedString *attribtStr = [[NSMutableAttributedString alloc]initWithString:protocolStr attributes:attribtDic];
  321. protocolLab.attributedText = attribtStr;
  322. [protocolView addSubview:protocolLab];
  323. protocolLab.userInteractionEnabled = YES;
  324. UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(catUserProtocol)];
  325. [protocolLab addGestureRecognizer:tap];
  326. NSString *agreeStr1 = @"和";
  327. UIButton *agrBtn1 = [[UIButton alloc] init];
  328. agrBtn1.titleLabel.font = SYSFONT(13);
  329. CGSize agreSize1 = [agreeStr1 boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:agrBtn1.titleLabel.font} context:nil].size;
  330. agrBtn1.frame = CGRectMake(CGRectGetMaxX(protocolLab.frame), 0, agreSize1.width, agreSize1.height);
  331. [agrBtn1 setTitle:agreeStr1 forState:UIControlStateNormal];
  332. [agrBtn1 setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
  333. // [agrBtn1 addTarget:self
  334. // action:@selector(agrBtnAction:)
  335. // forControlEvents:UIControlEventTouchUpInside];
  336. [protocolView addSubview:agrBtn1];
  337. NSString *protocolStr1 = @"隐私政策";
  338. UILabel *protocolLab1 = [[UILabel alloc] init];
  339. protocolLab1.font = SYSFONT(13);
  340. CGSize proSize1 = [protocolStr1 boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:protocolLab1.font} context:nil].size;
  341. protocolLab1.frame = CGRectMake(CGRectGetMaxX(agrBtn1.frame), 0, proSize1.width, proSize1.height);
  342. protocolLab1.textColor = HEXCOLOR(0x2A98FF);
  343. NSDictionary *attribtDic1 = @{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleNone]};
  344. NSMutableAttributedString *attribtStr1 = [[NSMutableAttributedString alloc]initWithString:protocolStr1 attributes:attribtDic1];
  345. protocolLab1.attributedText = attribtStr1;
  346. [protocolView addSubview:protocolLab1];
  347. protocolLab1.userInteractionEnabled = YES;
  348. UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(catUserProtocol)];
  349. [protocolLab1 addGestureRecognizer:tap1];
  350. CGFloat w = agreSize.width+proSize.width+agreSize1.width+proSize1.width;
  351. protocolView.frame = CGRectMake((JX_SCREEN_WIDTH -w)/2, n, w, 25);
  352. n+=25;
  353. }
  354. n+=HEIGHT;
  355. UIButton* _btn = [UIFactory createCommonButton:@"同意协议并注册" target:self action:@selector(checkPhoneNumber)];
  356. [_btn.titleLabel setFont:g_factory.font16];
  357. _btn.frame = CGRectMake(40, n, JX_SCREEN_WIDTH-40*2, 40);
  358. _btn.layer.masksToBounds = YES;
  359. _btn.layer.cornerRadius = 20.f;
  360. [self.tableBody addSubview:_btn];
  361. n = n+HEIGHT+INSETS;
  362. NSString *protocolStr2 = @"";
  363. UILabel *protocolLab2 = [[UILabel alloc] init];
  364. protocolLab2.userInteractionEnabled=YES;
  365. protocolLab2.font = SYSFONT(13);
  366. CGSize proSize2 = [protocolStr2 boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:protocolLab2.font} context:nil].size;
  367. protocolLab2.frame = CGRectMake((JX_SCREEN_WIDTH-proSize2.width)/2, n, proSize2.width, proSize2.height);
  368. protocolLab2.textColor = HEXCOLOR(0x2A98FF);
  369. NSDictionary *attribtDic2 = @{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleNone]};
  370. NSMutableAttributedString *attribtStr2 = [[NSMutableAttributedString alloc]initWithString:protocolStr2 attributes:attribtDic2];
  371. protocolLab2.attributedText = attribtStr2;
  372. [self.tableBody addSubview:protocolLab2];
  373. protocolLab2.userInteractionEnabled = YES;
  374. UITapGestureRecognizer *tap4 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onForget)];
  375. [protocolLab2 addGestureRecognizer:tap4];
  376. UILabel *agreeLab = [[UILabel alloc] init];
  377. agreeLab.font = SYSFONT(13);
  378. agreeLab.text = Localized(@"JX_ByRegisteringYouAgree");
  379. agreeLab.textColor = [UIColor redColor];
  380. agreeLab.userInteractionEnabled = YES;
  381. // [self.tableBody addSubview:agreeLab];
  382. UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didAgree)];
  383. [agreeLab addGestureRecognizer:tap1];
  384. UILabel*termsLab = [[UILabel alloc] init];
  385. termsLab.text = Localized(@"《Privacy Policy and Terms of Service》");
  386. termsLab.font = SYSFONT(13);
  387. termsLab.textColor = [UIColor redColor];
  388. termsLab.userInteractionEnabled = YES;
  389. // [self.tableBody addSubview:termsLab];
  390. UITapGestureRecognizer *tapT = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(checkTerms)];
  391. [termsLab addGestureRecognizer:tapT];
  392. CGSize sizeA = [agreeLab.text sizeWithAttributes:@{NSFontAttributeName:agreeLab.font}];
  393. CGSize sizeT = [termsLab.text sizeWithAttributes:@{NSFontAttributeName:termsLab.font}];
  394. UIImageView *agreeNotImgV = [[UIImageView alloc] initWithFrame:CGRectMake((JX_SCREEN_WIDTH-sizeA.width-sizeT.width-15)/2, n-6, 25, 25)];
  395. agreeNotImgV.image = [UIImage imageNamed:@"registered_not_agree"];
  396. agreeNotImgV.userInteractionEnabled = YES;
  397. // [self.tableBody addSubview:agreeNotImgV];
  398. UITapGestureRecognizer *tap2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didAgree)];
  399. [agreeNotImgV addGestureRecognizer:tap2];
  400. agreeLab.frame = CGRectMake(CGRectGetMaxX(agreeNotImgV.frame), n, sizeA.width, sizeA.height);
  401. termsLab.frame = CGRectMake(CGRectGetMaxX(agreeLab.frame), n, sizeT.width, sizeT.height);
  402. _agreeImgV = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMinX(agreeNotImgV.frame), n-10, 25, 30)];
  403. _agreeImgV.image = [UIImage imageNamed:@"registered_agree"];
  404. _agreeImgV.userInteractionEnabled = YES;
  405. // [self.tableBody addSubview:_agreeImgV];
  406. UITapGestureRecognizer *tap3 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didAgree)];
  407. [_agreeImgV addGestureRecognizer:tap3];
  408. //添加提示
  409. // UIImageView * careImage = [[UIImageView alloc]initWithFrame:CGRectMake(INSETS, n+HEIGHT+INSETS+3, INSETS, INSETS)];
  410. // careImage.image = [UIImage imageNamed:@"noread"];
  411. //
  412. // UILabel * careTitle = [[UILabel alloc]initWithFrame:CGRectMake(INSETS*2+2, n+HEIGHT+INSETS, 100, HEIGHT/3)];
  413. // careTitle.font = [UIFont fontWithName:@"Verdana" size:13];
  414. // careTitle.text = Localized(@"inputPhoneVC_BeCareful");
  415. //
  416. // n = n+HEIGHT+INSETS;
  417. // UILabel * careFirst = [[UILabel alloc]initWithFrame:CGRectMake(INSETS*2+2, n+HEIGHT/3+INSETS, JX_SCREEN_WIDTH-12-INSETS*2, HEIGHT/3)];
  418. // careFirst.font = [UIFont fontWithName:@"Verdana" size:11];
  419. // careFirst.text = Localized(@"inputPhoneVC_NotNeedCode");
  420. //
  421. // n = n+HEIGHT/3+INSETS;
  422. // UILabel * careSecond = [[UILabel alloc]initWithFrame:CGRectMake(INSETS*2+2, n+HEIGHT/3+INSETS, JX_SCREEN_WIDTH-INSETS*2-12, HEIGHT/3+15)];
  423. // careSecond.font = [UIFont fontWithName:@"Verdana" size:11];
  424. // careSecond.text = Localized(@"inputPhoneVC_NoReg");
  425. // careSecond.numberOfLines = 0;
  426. //测试版隐藏了短信验证
  427. #ifdef IS_TEST_VERSION
  428. #else
  429. // careFirst.hidden = YES;
  430. // careSecond.hidden = YES;
  431. // careImage.hidden = YES;
  432. // careTitle.hidden = YES;
  433. #endif
  434. // [self.tableBody addSubview:careImage];
  435. // [self.tableBody addSubview:careTitle];
  436. // [self.tableBody addSubview:careFirst];
  437. // [self.tableBody addSubview:careSecond];
  438. }
  439. return self;
  440. }
  441. - (void)onForget {
  442. }
  443. -(void)catUserProtocol{
  444. webpageVC * webVC = [webpageVC alloc];
  445. webVC.url = [self protocolUrl];
  446. webVC.isSend = NO;
  447. // [[NSBundle mainBundle] pathForResource:@"用户协议" ofType:@"html"];
  448. webVC = [webVC init];
  449. // [g_navigation.navigationView addSubview:webVC.view];
  450. [g_navigation pushViewController:webVC animated:YES];
  451. }
  452. -(NSString *)protocolUrl{
  453. NSString * protocolStr = g_config.privacyPolicyPrefix;
  454. NSString * lange = g_constant.sysLanguage;
  455. if (![lange isEqualToString:ZHHANTNAME] && ![lange isEqualToString:NAME]) {
  456. lange = ENNAME;
  457. }
  458. // return [NSString stringWithFormat:@"%@%@.html",protocolStr,lange];
  459. return [NSString stringWithFormat:@"%@",protocolStr];
  460. }
  461. - (void)didAgree {
  462. _agreeImgV.hidden = !_agreeImgV.hidden;
  463. }
  464. - (void)checkTerms {
  465. webpageVC * webVC = [webpageVC alloc];
  466. webVC.url = [self protocolUrl];
  467. webVC.isSend = NO;
  468. webVC = [webVC init];
  469. [g_navigation.navigationView addSubview:webVC.view];
  470. }
  471. //-(NSString *)protocolUrl{
  472. // NSString * protocolStr = g_config.privacyPolicyPrefix;
  473. // NSString * lange = g_constant.sysLanguage;
  474. // if (![lange isEqualToString:ZHHANTNAME] && ![lange isEqualToString:NAME]) {
  475. // lange = ENNAME;
  476. // }
  477. // return [NSString stringWithFormat:@"%@%@.html",protocolStr,lange];
  478. //}
  479. //设置文本框只能输入数字
  480. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
  481. if (_phone == textField) {
  482. return [self validateNumber:string];
  483. }
  484. return YES;
  485. }
  486. - (BOOL)validateNumber:(NSString*)number {
  487. if ([g_config.regeditPhoneOrName intValue] == 1) {
  488. // 如果用户名注册选项开启, 则不筛选
  489. NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"] invertedSet];
  490. NSString *filtered = [[number componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
  491. return [number isEqualToString:filtered];
  492. }
  493. BOOL res = YES;
  494. NSCharacterSet *tmpSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"];
  495. int i = 0;
  496. while (i < number.length) {
  497. NSString *string = [number substringWithRange:NSMakeRange(i, 1)];
  498. NSRange range = [string rangeOfCharacterFromSet:tmpSet];
  499. if (range.length == 0) {
  500. res = NO;
  501. break;
  502. }
  503. i ++;
  504. }
  505. return res;
  506. }
  507. - (void)viewDidLoad
  508. {
  509. [super viewDidLoad];
  510. // Do any additional setup after loading the view.
  511. }
  512. - (void)didReceiveMemoryWarning
  513. {
  514. [super didReceiveMemoryWarning];
  515. // Dispose of any resources that can be recreated.
  516. }
  517. - (void)enterNextPage {
  518. _isSkipSMS = YES;
  519. BOOL isMobile = [self isMobileNumber:_phone.text];
  520. if ([_pwd.text length] < 6) {
  521. [g_App showAlert:Localized(@"JX_TurePasswordAlert")];
  522. return;
  523. }
  524. if (isMobile) {
  525. NSString *areaCode = [_areaCodeBtn.titleLabel.text stringByReplacingOccurrencesOfString:@"+" withString:@""];
  526. [g_server checkPhone:_phone.text areaCode:areaCode verifyType:0 toView:self];
  527. }
  528. }
  529. - (void)textFieldDidChanged:(UITextField *)textField {
  530. if (textField == _phone) { // 限制手机号最多只能输入11位,为了适配外国电话,将不能显示手机号位数
  531. if ([g_config.regeditPhoneOrName intValue] == 1) {
  532. if (_phone.text.length > 10) {
  533. _phone.text = [_phone.text substringToIndex:10];
  534. }
  535. }else {
  536. if (_phone.text.length > 11) {
  537. _phone.text = [_phone.text substringToIndex:11];
  538. }
  539. }
  540. }
  541. if (textField == _pwd) {
  542. if (_pwd.text.length > 17) {
  543. _pwd.text = [_pwd.text substringToIndex:17];
  544. }
  545. }
  546. }
  547. - (void)goToLoginVC {
  548. if (self.isThirdLogin) {
  549. loginVC *login = [loginVC alloc];
  550. login.isThirdLogin = YES;
  551. login.isAutoLogin = NO;
  552. login.isSwitchUser= NO;
  553. login.type = self.type;
  554. login = [login init];
  555. [g_navigation pushViewController:login animated:YES];
  556. }else {
  557. [self actionQuit];
  558. }
  559. }
  560. //验证手机号码格式,无短信验证
  561. - (void)checkPhoneNumber{
  562. // PSRegisterBaseVC *vvc=[PSRegisterBaseVC new];
  563. //
  564. // [g_navigation pushViewController:vvc animated:YES];
  565. //
  566. // return;
  567. _isSkipSMS = NO;
  568. BOOL isMobile = [self isMobileNumber:_phone.text];
  569. if ([_pwd.text length] < 6) {
  570. [g_App showAlert:Localized(@"JX_TurePasswordAlert")];
  571. return;
  572. }
  573. if ([g_config.registerInviteCode intValue] == 1) {
  574. if ([_inviteCode.text length] <= 0) {
  575. [g_App showAlert:Localized(@"JX_EnterInvitationCode")];
  576. return;
  577. }
  578. }
  579. if (isMobile) {
  580. NSString *areaCode = [_areaCodeBtn.titleLabel.text stringByReplacingOccurrencesOfString:@"+" withString:@""];
  581. [g_server checkPhone:_phone.text areaCode:areaCode verifyType:0 toView:self];
  582. }
  583. }
  584. //验证手机号码格式
  585. - (BOOL)isMobileNumber:(NSString *)number{
  586. if ([g_config.isOpenSMSCode boolValue] && [g_config.regeditPhoneOrName intValue] != 1) {
  587. if ([_phone.text length] == 0) {
  588. [g_App showAlert:Localized(@"JX_InputPhone")];
  589. return NO;
  590. }
  591. }
  592. #ifdef IS_TEST_VERSION
  593. #else
  594. // if ([_phone.text length] < 11) { // 为了适配外国电话,将不能显示手机号位数
  595. // [g_App showAlert:Localized(@"inputPhoneVC_InputTurePhone")];
  596. // return NO;
  597. // }
  598. #endif
  599. // if ([_areaCodeBtn.titleLabel.text isEqualToString:@"+86"]) {
  600. // NSString *regex = @"^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$";
  601. // NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
  602. // BOOL isMatch = [pred evaluateWithObject:number];
  603. //
  604. // if (!isMatch) {
  605. // UIAlertView* alert = [[UIAlertView alloc] initWithTitle:Localized(@"JXVerifyAccountVC_Prompt") message:Localized(@"JXVerifyAccountVC_PhoneNumberError") delegate:nil cancelButtonTitle:Localized(@"JXVerifyAccountVC_OK") otherButtonTitles:nil, nil];
  606. // [alert show];
  607. // // [alert release];
  608. // return NO;
  609. // }
  610. // }
  611. return YES;
  612. }
  613. -(void)refreshGraphicAction:(UIButton *)button{
  614. [self getImgCodeImg];
  615. }
  616. -(void)getImgCodeImg{
  617. if([self isMobileNumber:_phone.text]){
  618. // if ([self checkPhoneNum]) {
  619. //请求图片验证码
  620. NSString *areaCode = [_areaCodeBtn.titleLabel.text stringByReplacingOccurrencesOfString:@"+" withString:@""];
  621. NSString * codeUrl = [g_server getImgCode:_phone.text areaCode:areaCode];
  622. NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL URLWithString:codeUrl] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:10.0];
  623. [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
  624. if (!connectionError) {
  625. UIImage * codeImage = [UIImage imageWithData:data];
  626. _imgCodeImg.image = codeImage;
  627. }else{
  628. NSLog(@"%@",connectionError);
  629. [g_App showAlert:connectionError.localizedDescription];
  630. }
  631. }];
  632. // [_imgCodeImg sd_setImageWithURL:[NSURL URLWithString:codeUrl] placeholderImage:[UIImage imageNamed:@"refreshImgCode"] options:SDWebImageRefreshCached completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
  633. // if (!error) {
  634. // _imgCodeImg.image = image;
  635. // }else{
  636. // NSLog(@"%@",error);
  637. // }
  638. // }];
  639. }else{
  640. }
  641. }
  642. #pragma mark----验证短信验证码
  643. -(void)onClick{
  644. if([_phone.text length]<=0){
  645. [g_App showAlert:Localized(@"JX_InputPhone")];
  646. return;
  647. }
  648. if (!_isSkipSMS) {
  649. if([_code.text length]<6){
  650. if([_code.text length]<=0){
  651. [g_App showAlert:@"请输入短信验证码"];
  652. return;
  653. }
  654. [g_App showAlert:Localized(@"inputPhoneVC_MsgCodeNotOK")];
  655. return;
  656. }
  657. if([_smsCode length]<6 && ![_smsCode isEqualToString:@"-1"]){
  658. [g_App showAlert:Localized(@"inputPhoneVC_NoMegCode")];
  659. return;
  660. }
  661. if (!([_phoneStr isEqualToString:_phone.text] && [_imgCodeStr isEqualToString:_imgCode.text] && ([_smsCode isEqualToString:_code.text] || [_smsCode isEqualToString:@"-1"]))) {
  662. if (![_phoneStr isEqualToString:_phone.text]) {
  663. [g_App showAlert:Localized(@"JX_No.Changed,Again")];
  664. }else if (![_imgCodeStr isEqualToString:_imgCode.text]) {
  665. [g_App showAlert:Localized(@"JX_ImageCodeErrorGetAgain")];
  666. }else if (![_smsCode isEqualToString:_code.text]) {
  667. [g_App showAlert:Localized(@"inputPhoneVC_MsgCodeNotOK")];
  668. }
  669. return;
  670. }
  671. }
  672. [self.view endEditing:YES];
  673. if (!_isSkipSMS) {
  674. if([_code.text isEqualToString:_smsCode] || [_smsCode isEqualToString:@"-1"]){
  675. self.isSmsRegister = YES;
  676. [self setUserInfo];
  677. }
  678. else
  679. [g_App showAlert:Localized(@"inputPhoneVC_MsgCodeNotOK")];
  680. } else {
  681. self.isSmsRegister = NO;
  682. [self setUserInfo];
  683. }
  684. }
  685. - (void)setUserInfo {
  686. if (_agreeImgV.isHidden == YES) {
  687. [g_App showAlert:Localized(@"JX_NotAgreeProtocol")];
  688. return;
  689. }
  690. JXUserObject* user = [JXUserObject sharedInstance];
  691. user.telephone = _phone.text;
  692. user.password = [g_server getMD5String:_pwd.text];
  693. // user.companyId = [NSNumber numberWithInt:self.isCompany];
  694. PSRegisterBaseVC* vc = [PSRegisterBaseVC alloc];
  695. vc.password = _pwd.text;
  696. vc.isRegister = YES;
  697. vc.inviteCodeStr = _inviteCode.text;
  698. vc.smsCode = _code.text;
  699. vc.resumeId = nil;
  700. vc.isSmsRegister = self.isSmsRegister;
  701. vc.resume = [[resumeBaseData alloc]init];
  702. vc.user = user;
  703. vc.type = self.type;
  704. vc = [vc init];
  705. [g_navigation pushViewController:vc animated:YES];
  706. [self actionQuit];
  707. }
  708. -(void)onTest{
  709. if (_agreeImgV.isHidden == YES) {
  710. [g_App showAlert:Localized(@"JX_NotAgreeProtocol")];
  711. return;
  712. }
  713. // inputPwdVC* vc = [inputPwdVC alloc];
  714. // vc.telephone = _phone.text;
  715. // vc.isCompany = NO;
  716. // vc = [vc init];
  717. //// [g_window addSubview:vc.view];
  718. // [g_navigation pushViewController:vc animated:YES];
  719. // [self actionQuit];
  720. JXUserObject* user = [JXUserObject sharedInstance];
  721. user.telephone = _phone.text;
  722. user.password = [g_server getMD5String:_pwd.text];
  723. user.areaCode = [_areaCodeBtn.titleLabel.text stringByReplacingOccurrencesOfString:@"+" withString:@""];;
  724. // user.companyId = [NSNumber numberWithInt:self.isCompany];
  725. PSRegisterBaseVC* vc = [PSRegisterBaseVC alloc];
  726. vc.password = _pwd.text;
  727. vc.isRegister = YES;
  728. vc.inviteCodeStr = _inviteCode.text;
  729. vc.smsCode = _code.text;
  730. vc.resumeId = nil;
  731. vc.isSmsRegister = NO;
  732. vc.resume = [[resumeBaseData alloc]init];
  733. vc.user = user;
  734. vc.type = self.type;
  735. vc = [vc init];
  736. [g_navigation pushViewController:vc animated:YES];
  737. [self actionQuit];
  738. }
  739. //选择区号
  740. //- (void)areaCodeBtnClick:(UIButton *)btn{
  741. // [self.view endEditing:YES];
  742. //
  743. // JXTelAreaListVC *telAreaListVC = [[JXTelAreaListVC alloc] init];
  744. // telAreaListVC.telAreaDelegate = self;
  745. // telAreaListVC.didSelect = @selector(didSelectTelArea:);
  746. // [g_window addSubview:telAreaListVC.view];
  747. //}
  748. //
  749. //- (void)didSelectTelArea:(NSString *)areaCode{
  750. // [_areaCodeBtn setTitle:[NSString stringWithFormat:@"+%@",areaCode] forState:UIControlStateNormal];
  751. // [self resetBtnEdgeInsets:_areaCodeBtn];
  752. //}
  753. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  754. [_wait stop];
  755. if([aDownload.action isEqualToString:act_SendSMS]){
  756. [JXMyTools showTipView:Localized(@"JXAlert_SendOK")];
  757. _send.selected = YES;
  758. _send.userInteractionEnabled = NO;
  759. _send.backgroundColor = [UIColor grayColor];
  760. if ([dict objectForKey:@"code"]) {
  761. _smsCode = [[dict objectForKey:@"code"] copy];
  762. }else { // 没有返回短信验证码
  763. _smsCode = @"-1";
  764. }
  765. [_send setTitle:@"60s" forState:UIControlStateSelected];
  766. [_send setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
  767. _seconds = 60;
  768. _timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(showTime:) userInfo:_send repeats:YES];
  769. _phoneStr = _phone.text;
  770. _imgCodeStr = _imgCode.text;
  771. }
  772. /*
  773. if([aDownload.action isEqualToString:act_CheckPhone]){
  774. NSString *areaCode = [_areaCodeBtn.titleLabel.text stringByReplacingOccurrencesOfString:@"+" withString:@""];
  775. _user = [JXUserObject sharedInstance];
  776. _user.areaCode = areaCode;
  777. [g_server sendSMS:[NSString stringWithFormat:@"%@",_phone.text] areaCode:areaCode isRegister:YES toView:self];
  778. [_send setTitle:Localized(@"JX_Sending") forState:UIControlStateNormal];
  779. [_wait start:Localized(@"JX_SendNow")];
  780. [self.view endEditing:YES];
  781. //[g_App.jxServer sendSMS:_phone.text toView:self];
  782. }
  783. */
  784. if([aDownload.action isEqualToString:act_CheckPhone]){
  785. if (self.isCheckToSMS) {
  786. self.isCheckToSMS = NO;
  787. [self onSend];
  788. return;
  789. }
  790. if ([g_config.isOpenSMSCode boolValue] && [g_config.regeditPhoneOrName intValue] != 1) {
  791. [self onClick];
  792. }else {
  793. [self onTest];
  794. }
  795. }
  796. }
  797. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  798. [_wait stop];
  799. if([aDownload.action isEqualToString:act_SendSMS]){
  800. [_send setTitle:Localized(@"JX_Send") forState:UIControlStateNormal];
  801. [g_App showAlert:dict[@"resultMsg"]];
  802. [self getImgCodeImg];
  803. return hide_error;
  804. }
  805. return show_error;
  806. }
  807. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  808. [_wait stop];
  809. return show_error;
  810. }
  811. -(void) didServerConnectStart:(JXConnection*)aDownload{
  812. [_wait stop];
  813. }
  814. -(void)showTime:(NSTimer*)sender{
  815. UIButton *but = (UIButton*)[_timer userInfo];
  816. _seconds--;
  817. [but setTitle:[NSString stringWithFormat:@"%ds",_seconds] forState:UIControlStateSelected];
  818. if (_isSendFirst) {
  819. _isSendFirst = NO;
  820. _skipBtn.hidden = YES;
  821. }
  822. if (_seconds <= 30) {
  823. _skipBtn.hidden = NO;
  824. }
  825. if(_seconds<=0){
  826. but.selected = NO;
  827. but.userInteractionEnabled = YES;
  828. but.backgroundColor = g_theme.themeColor;
  829. [_send setTitle:Localized(@"JX_SendAngin") forState:UIControlStateNormal];
  830. if (_timer) {
  831. _timer = nil;
  832. [sender invalidate];
  833. }
  834. _seconds = 60;
  835. }
  836. }
  837. //验证手机号格式
  838. - (void)sendSMS{
  839. [_phone resignFirstResponder];
  840. [_pwd resignFirstResponder];
  841. [_imgCode resignFirstResponder];
  842. [_code resignFirstResponder];
  843. if([self isMobileNumber:_phone.text]){
  844. //请求验证码
  845. if (_imgCode.text.length < 3) {
  846. [g_App showAlert:Localized(@"JX_inputImgCode")];
  847. }else{
  848. //验证手机号码是否已注册
  849. self.isCheckToSMS = YES;
  850. NSString *areaCode = [_areaCodeBtn.titleLabel.text stringByReplacingOccurrencesOfString:@"+" withString:@""];
  851. [g_server checkPhone:_phone.text areaCode:areaCode verifyType:0 toView:self];
  852. }
  853. }
  854. }
  855. -(void)onSend{
  856. if (!_send.selected) {
  857. [_wait start:Localized(@"JX_Testing")];
  858. //NSString *areaCode = [_areaCodeBtn.titleLabel.text stringByReplacingOccurrencesOfString:@"+" withString:@""];
  859. NSString *areaCode = [_areaCodeBtn.titleLabel.text stringByReplacingOccurrencesOfString:@"+" withString:@""];
  860. _user = [JXUserObject sharedInstance];
  861. _user.areaCode = areaCode;
  862. [g_server sendSMS:[NSString stringWithFormat:@"%@",_phone.text] areaCode:areaCode isRegister:NO imgCode:_imgCode.text toView:self];
  863. [_send setTitle:Localized(@"JX_Sending") forState:UIControlStateNormal];
  864. //[_wait start:Localized(@"JX_SendNow")];
  865. //[g_server checkPhone:_phone.text areaCode:areaCode toView:self];
  866. }
  867. }
  868. -(void)textFieldDidEndEditing:(UITextField *)textField{
  869. if ([g_config.isOpenSMSCode boolValue] && [g_config.regeditPhoneOrName intValue] != 1) {
  870. if (textField == _phone) {
  871. [self getImgCodeImg];
  872. }
  873. }
  874. #ifndef IS_TEST_VERSION
  875. #endif
  876. }
  877. -(BOOL)textFieldShouldReturn:(UITextField *)textField
  878. {
  879. [self.view endEditing:YES];
  880. return YES;
  881. }
  882. - (void)areaCodeBtnClick:(UIButton *)but{
  883. [self.view endEditing:YES];
  884. JXTelAreaListVC *telAreaListVC = [[JXTelAreaListVC alloc] init];
  885. telAreaListVC.telAreaDelegate = self;
  886. telAreaListVC.didSelect = @selector(didSelectTelArea:);
  887. // [g_window addSubview:telAreaListVC.view];
  888. [g_navigation pushViewController:telAreaListVC animated:YES];
  889. }
  890. - (void)didSelectTelArea:(NSString *)areaCode{
  891. [_areaCodeBtn setTitle:[NSString stringWithFormat:@"+%@",areaCode] forState:UIControlStateNormal];
  892. [self resetBtnEdgeInsets:_areaCodeBtn];
  893. }
  894. - (void)resetBtnEdgeInsets:(UIButton *)btn{
  895. [btn setTitleEdgeInsets:UIEdgeInsetsMake(0, -btn.imageView.frame.size.width-2, 0, btn.imageView.frame.size.width+2)];
  896. [btn setImageEdgeInsets:UIEdgeInsetsMake(0, btn.titleLabel.frame.size.width+2, 0, -btn.titleLabel.frame.size.width-2)];
  897. }
  898. - (void)hideKeyBoardToView {
  899. [self.view endEditing:YES];
  900. }
  901. @end