UserLoginPhoneViewController.m 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // UserLoginPhoneViewController.m
  3. // XenonSDK
  4. //
  5. // Created by SAGESSE on 2019/5/29.
  6. // Copyright © 2019 SAGESSE. All rights reserved.
  7. //
  8. #import "XenonSDK.h"
  9. #import "UserLoginPhoneViewController.h"
  10. @interface UserLoginPhoneViewController ()
  11. @end
  12. @implementation UserLoginPhoneViewController
  13. - (NSInteger)smsType {
  14. return 3;
  15. }
  16. - (void)automatic:(NSString*)phone {
  17. // If no button is retrieved, failure.
  18. [self loadViewIfNeeded];
  19. // Automatic data entry.
  20. self.phoneTextField.text = phone;
  21. //self.securityCode(forPrepare: button)
  22. }
  23. - (void)securityCodeForVerify:(id)sender {
  24. [super securityCodeForVerify:sender];
  25. // Must enter phone.
  26. NSString* phone = self.phoneTextField.text;
  27. if (phone.length == 0) {
  28. [XSNetwork showHudFailure:@"请输入手机号"];
  29. return;
  30. }
  31. if (!sdk_verifyPhone(phone)) {
  32. [XSNetwork showHudFailure:@"请输入正确的手机号格式"];
  33. return;
  34. }
  35. NSString* code = self.securityCodeTextField.text;
  36. if (code.length == 0) {
  37. [XSNetwork showHudFailure:@"请输入验证码"];
  38. return;
  39. }
  40. [XSNetwork showHudLoading];
  41. [XSNetwork loginWithPhone:phone code:code complete:^(id object, NSError *error) {
  42. if (error != nil) {
  43. [XSNetwork showHudFailure:error];
  44. return;
  45. }
  46. if (XenonSDK.sharedSDK.sdk_loginCallback) {
  47. XenonSDK.sharedSDK.sdk_loginCallback(object);
  48. }
  49. }];
  50. }
  51. @end