123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- //
- // LoginBodyView.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/17.
- //
- #import "LoginBodyView.h"
- #import "KeyChainTools.h"
- @interface LoginBodyView ()<UITextFieldDelegate>
- @property (weak, nonatomic) IBOutlet UILabel *registerProtocalLabel;
- @property (weak, nonatomic) IBOutlet UILabel *privacyLabel;
- @property (weak, nonatomic) IBOutlet UIButton *sureButton;
- @property (nonatomic, assign) BOOL isChooseProtocal;
- @property (nonatomic, copy) LoginAction callback;
- @property (weak, nonatomic) IBOutlet UILabel *deviceLabel;
- @property (nonatomic, assign) NSInteger clickCount;
- @end
- @implementation LoginBodyView
- - (void)awakeFromNib {
- [super awakeFromNib];
- [self configSource];
-
- self.deviceLabel.text = [NSString stringWithFormat:@"本机设备号:%@",[KeyChainTools getUUID]];
- self.deviceLabel.hidden = YES;
- _clickCount = 0;
- }
- - (void)configSource {
- self.phoneField.delegate = self;
- [self.sureButton setImage:[UIImage imageNamed:@"login_unseleted"] forState:UIControlStateNormal];
- [self.sureButton setImage:[UIImage imageNamed:@"login_seleted"] forState:UIControlStateSelected];
- self.isChooseProtocal = NO;
- NSMutableAttributedString *attr = [[NSMutableAttributedString alloc] initWithString:@"我已阅读并同意《用户注册协议》" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12.0f], NSForegroundColorAttributeName:HexRGB(0x999999)}];
- [attr addAttributes:@{NSForegroundColorAttributeName:THEMECOLOR} range:NSMakeRange(7, 8)];
- [self.registerProtocalLabel setAttributedText:attr];
-
- NSMutableAttributedString *privacyAttr = [[NSMutableAttributedString alloc] initWithString:@"和《隐私政策》" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12.0f], NSForegroundColorAttributeName:HexRGB(0x999999)}];
- [privacyAttr addAttributes:@{NSForegroundColorAttributeName:THEMECOLOR} range:NSMakeRange(1, 6)];
- [self.privacyLabel setAttributedText:privacyAttr];
- }
- + (instancetype)shareInstance {
- LoginBodyView *view = [[[NSBundle mainBundle] loadNibNamed:@"LoginBodyView" owner:nil options:nil] firstObject];
- return view;
- }
- - (void)loginActionCallback:(LoginAction)callback {
- if (callback) {
- self.callback = callback;
- }
- }
- - (IBAction)getVefiCode:(id)sender {
- [self endEditing:YES];
- if ([NSString isEmptyString:self.phoneField.text]) {
- // 请输入手机号
- [self MBPShow:@"请输入手机号"];
- return;
- }
-
- if (_isChooseProtocal == NO) {
- [self MBPShow:@"请勾选用户协议"];
- return;
- }
- if (self.callback) {
- self.callback(LOGINACTION_CODE, self.phoneField.text);
- }
- }
- - (IBAction)selectButtonAction:(id)sender {
- [self endEditing:YES];
- self.sureButton.selected = !self.sureButton.selected;
- _isChooseProtocal = self.sureButton.isSelected;
- }
- - (IBAction)passwordLogin:(id)sender {
- [self endEditing:YES];
- if (self.callback) {
- self.callback(LOGINACTION_PASSWORD, self.phoneField.text);
- }
- }
- - (IBAction)registerProtocal:(id)sender {
- [self endEditing:YES];
- if (self.callback) {
- self.callback(LOGINACTION_REGPROTOCAL, @"");
- }
- }
- - (IBAction)privacyAction:(id)sender {
- [self endEditing:YES];
- if (self.callback) {
- self.callback(LOGINACTION_PRIVACY, @"");
- }
- }
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
- if ([string isEqualToString:@"\n"]) {
- [self endEditing:YES];
- return YES;
- }
- // 输入控制
- NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string];
- if (newString.length > 11) {
- return NO;
- }
- return YES;
- }
- - (IBAction)tapAction:(id)sender {
- _clickCount++;
- if (_clickCount == 5) {
- self.deviceLabel.text = [NSString stringWithFormat:@"本机设备号:%@",[KeyChainTools getUUID]];
- self.deviceLabel.hidden = NO;
- }
- }
- - (IBAction)copyAction:(id)sender {
- // 复制
- UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
- pasteboard.string = [KeyChainTools getUUID];
- [self MBPShow:@"复制成功"];
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- @end
|