Commit 7a4a689d cgx

完善手机验证码绑定页面

1 个父辈 3b599e34
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
@property (weak, nonatomic) IBOutlet UIView *codeLine; @property (weak, nonatomic) IBOutlet UIView *codeLine;
@property (weak, nonatomic) IBOutlet UIButton *bindBtn; @property (weak, nonatomic) IBOutlet UIButton *bindBtn;
@property (weak, nonatomic) IBOutlet UILabel *tipsLab; @property (weak, nonatomic) IBOutlet UILabel *tipsLab;
@property (weak, nonatomic) IBOutlet UILabel *timeLab;
@property (nonatomic, strong) NSTimer *countTimer;
@property (nonatomic, assign) int totalSecond;
@end @end
@implementation BindMobileController @implementation BindMobileController
...@@ -32,6 +35,7 @@ ...@@ -32,6 +35,7 @@
} }
- (void)initUI { - (void)initUI {
self.totalSecond = 60;
self.naviBarAlpha = 1.0; self.naviBarAlpha = 1.0;
self.naviBgColor = DSClearColor; self.naviBgColor = DSClearColor;
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG); self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
...@@ -42,10 +46,15 @@ ...@@ -42,10 +46,15 @@
self.mobileLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE); self.mobileLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
self.countryLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE); self.countryLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
self.mobileTF.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE); self.mobileTF.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
UIColor *placeholderColor = [self.dk_manager.themeVersion isEqualToString:DKThemeVersionNormal] ? ColorFromHexA(0x333333, .5) : ColorFromHexA(0xE8E9E9, .5);
NSDictionary *attributes = @{NSForegroundColorAttributeName:placeholderColor, NSFontAttributeName:SysFont(15)};
self.mobileTF.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入手机号" attributes:attributes];
self.verifyLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE); self.verifyLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
self.verifyLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE); self.verifyLab.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
self.verifyTF.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE); self.verifyTF.dk_textColorPicker = DKColorPickerWithKey(Dk_TITLE);
self.verifyTF.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入验证码" attributes:attributes];
self.tipsLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite); self.tipsLab.dk_textColorPicker = DKColorPickerWithColors(SmallTextColor, ColorFromHexA(0xFFFFFF, .3), DSWhite);
self.timeLab.dk_textColorPicker = DKColorPickerWithColors(SubTitleColor, ColorFromHexA(0xFFFFFF, .5), DSWhite);
self.mobileLine.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0xE6E6E6), AlertDarkColor, DSWhite); self.mobileLine.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0xE6E6E6), AlertDarkColor, DSWhite);
self.codeLine.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0xE6E6E6), AlertDarkColor, DSWhite); self.codeLine.dk_backgroundColorPicker = DKColorPickerWithColors(ColorFromHex(0xE6E6E6), AlertDarkColor, DSWhite);
...@@ -57,21 +66,41 @@ ...@@ -57,21 +66,41 @@
[self.bindBtn dk_setTitleColorPicker:DKColorPickerWithKey(Sub_Navi_TITLE) forState:UIControlStateNormal]; [self.bindBtn dk_setTitleColorPicker:DKColorPickerWithKey(Sub_Navi_TITLE) forState:UIControlStateNormal];
} }
- (void)dealloc {
[_countTimer invalidate];
_countTimer = nil;
}
#pragma mark - Action #pragma mark - Action
- (IBAction)getMobileCode:(UIButton *)sender { - (IBAction)getMobileCode:(UIButton *)sender {
if (self.mobileTF.text.length) { if (self.mobileTF.text.length == 0) {
[DSProgressHUD showProgressHUDWithInfo:@""]; [DSProgressHUD showToast:@"请输入手机号"];
[UserRequestModel getMobileCode:self.mobileTF.text completion:^(UserRequestModel * _Nonnull requestModel) { return;
[DSProgressHUD dissmissProgressHUD];
if (requestModel.resCode == DSResCodeSuccess) {
} else {
[DSProgressHUD showToast:requestModel.errMessage];
}
}];
} }
[DSProgressHUD showProgressHUDWithInfo:@""];
[UserRequestModel getMobileCode:self.mobileTF.text completion:^(UserRequestModel * _Nonnull requestModel) {
[DSProgressHUD dissmissProgressHUD];
if (requestModel.resCode == DSResCodeSuccess) {
[self.verifyTF becomeFirstResponder];
self.timeLab.hidden = NO;
self.getCodeBtn.hidden = YES;
[self.countTimer setFireDate:[NSDate date]];
[self.getCodeBtn setTitle:@"重新获取" forState:UIControlStateNormal];
} else {
[DSProgressHUD showToast:requestModel.errMessage];
}
}];
} }
- (IBAction)bindMobile:(UIButton *)sender { - (IBAction)bindMobile:(UIButton *)sender {
if (self.mobileTF.text.length == 0) {
[DSProgressHUD showToast:@"请输入手机号"];
return;
}
if (self.verifyTF.text.length == 0) {
[DSProgressHUD showToast:@"请输入验证码"];
return;
}
if (self.mobileTF.text.length && self.verifyTF.text.length) { if (self.mobileTF.text.length && self.verifyTF.text.length) {
[DSProgressHUD showProgressHUDWithInfo:@""]; [DSProgressHUD showProgressHUDWithInfo:@""];
[UserRequestModel verifyBindMobile:self.mobileTF.text code:self.verifyTF.text completion:^(UserRequestModel * _Nonnull requestModel) { [UserRequestModel verifyBindMobile:self.mobileTF.text code:self.verifyTF.text completion:^(UserRequestModel * _Nonnull requestModel) {
...@@ -93,4 +122,23 @@ ...@@ -93,4 +122,23 @@
return NO; return NO;
} }
#pragma mark - lazy
- (NSTimer *)countTimer {
if (!_countTimer) {
WS(weakSelf);
_countTimer = [NSTimer timerWithTimeInterval:1.0 repeats:YES block:^(NSTimer * _Nonnull timer) {
if (weakSelf.totalSecond == 0) {
weakSelf.getCodeBtn.hidden = NO;
weakSelf.timeLab.hidden = YES;
[weakSelf.countTimer setFireDate:[NSDate distantFuture]];
return;
}
weakSelf.totalSecond--;
weakSelf.timeLab.text = [NSString stringWithFormat:@"%ds后重发", weakSelf.totalSecond];
}];
[[NSRunLoop currentRunLoop] addTimer:_countTimer forMode:NSRunLoopCommonModes];
}
return _countTimer;
}
@end @end
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina5_5" orientation="portrait" appearance="light"/> <device id="retina6_7" orientation="portrait" appearance="light"/>
<dependencies> <dependencies>
<deployment identifier="iOS"/> <deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<objects> <objects>
<viewController storyboardIdentifier="BindMobileController" id="Y6W-OH-hqX" customClass="BindMobileController" sceneMemberID="viewController"> <viewController storyboardIdentifier="BindMobileController" id="Y6W-OH-hqX" customClass="BindMobileController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc"> <view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc">
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/> <rect key="frame" x="0.0" y="0.0" width="428" height="926"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="绑定手机" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8ji-h4-dGD"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="绑定手机" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8ji-h4-dGD">
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
<rect key="frame" x="122" y="282" width="232" height="20"/> <rect key="frame" x="122" y="282" width="232" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/> <fontDescription key="fontDescription" type="system" pointSize="15"/>
<textInputTraits key="textInputTraits"/> <textInputTraits key="textInputTraits" keyboardType="numberPad"/>
</textField> </textField>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xVQ-vH-hwz"> <view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xVQ-vH-hwz">
<rect key="frame" x="30" y="310" width="354" height="1"/> <rect key="frame" x="30" y="310" width="354" height="1"/>
...@@ -65,10 +65,10 @@ ...@@ -65,10 +65,10 @@
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<textField opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Uc9-gm-PJX"> <textField opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Uc9-gm-PJX">
<rect key="frame" x="30" y="380" width="107.5" height="20"/> <rect key="frame" x="30" y="380" width="240" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/> <fontDescription key="fontDescription" type="system" pointSize="15"/>
<textInputTraits key="textInputTraits"/> <textInputTraits key="textInputTraits" keyboardType="numberPad"/>
</textField> </textField>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lnm-IB-3JO"> <button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lnm-IB-3JO">
<rect key="frame" x="286" y="377.5" width="101" height="32"/> <rect key="frame" x="286" y="377.5" width="101" height="32"/>
...@@ -105,13 +105,20 @@ ...@@ -105,13 +105,20 @@
<action selector="bindMobile:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="gR7-5b-lb4"/> <action selector="bindMobile:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="gR7-5b-lb4"/>
</connections> </connections>
</button> </button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="应国家相关法律要求,使用信息发布,即时通讯等互联网服务需要进行身份验证。为保障您对相关服务功能的正常使用,建议您尽快完成手机号验证,感谢您的理解和支持。" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LbC-sS-eWX"> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="应国家相关法律要求,使用信息发布,即时通讯等互联网服务需要进行身份信息验证。为保障您对相关服务功能的正常使用,建议您尽快完成手机号验证,感谢您的理解和支持。" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LbC-sS-eWX">
<rect key="frame" x="15" y="576.5" width="384" height="43"/> <rect key="frame" x="15" y="576.5" width="384" height="43"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="12"/> <fontDescription key="fontDescription" type="system" pointSize="12"/>
<nil key="textColor"/> <nil key="textColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="60s后重试" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bLt-hf-6sC">
<rect key="frame" x="286" y="383" width="102" height="20"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews> </subviews>
<viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/> <viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/> <color key="backgroundColor" systemColor="systemBackgroundColor"/>
...@@ -127,14 +134,15 @@ ...@@ -127,14 +134,15 @@
<outlet property="mobileLine" destination="xVQ-vH-hwz" id="IGM-TL-88Q"/> <outlet property="mobileLine" destination="xVQ-vH-hwz" id="IGM-TL-88Q"/>
<outlet property="mobileTF" destination="VA1-4e-TXw" id="p43-en-Gdb"/> <outlet property="mobileTF" destination="VA1-4e-TXw" id="p43-en-Gdb"/>
<outlet property="selectIcon" destination="yu9-Mt-h1F" id="uRe-ow-ETF"/> <outlet property="selectIcon" destination="yu9-Mt-h1F" id="uRe-ow-ETF"/>
<outlet property="tipsLab" destination="LbC-sS-eWX" id="yH1-if-PRR"/> <outlet property="timeLab" destination="bLt-hf-6sC" id="TZA-ZR-uMp"/>
<outlet property="tipsLab" destination="LbC-sS-eWX" id="9qj-nQ-VXy"/>
<outlet property="verifyLab" destination="2KP-cx-O6s" id="eZH-qm-yQh"/> <outlet property="verifyLab" destination="2KP-cx-O6s" id="eZH-qm-yQh"/>
<outlet property="verifyTF" destination="Uc9-gm-PJX" id="AAM-go-548"/> <outlet property="verifyTF" destination="Uc9-gm-PJX" id="AAM-go-548"/>
</connections> </connections>
</viewController> </viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> <placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects> </objects>
<point key="canvasLocation" x="24.637681159420293" y="39.508928571428569"/> <point key="canvasLocation" x="24.637681159420293" y="39.130434782608695"/>
</scene> </scene>
</scenes> </scenes>
<resources> <resources>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!