Browse Source

修改返回刷新问题

Steven 1 year ago
parent
commit
a357befb38
18 changed files with 254 additions and 45 deletions
  1. 4 4
      KulexiuForStudent/KulexiuForStudent.xcodeproj/project.pbxproj
  2. 16 1
      KulexiuForStudent/KulexiuForStudent/Common/Base/KSBaseWKWebViewController.m
  3. 2 1
      KulexiuForStudent/KulexiuForStudent/Common/Base/KSNetworkingManager.h
  4. 3 1
      KulexiuForStudent/KulexiuForStudent/Common/Base/KSNetworkingManager.m
  5. 0 2
      KulexiuForStudent/KulexiuForStudent/Common/Define/KSDomain.h
  6. 8 14
      KulexiuForStudent/KulexiuForStudent/Common/Tools/Extension/UIView+Hints.m
  7. 4 4
      KulexiuForStudent/KulexiuForStudent/Module/Chat/Controller/ChatAddressViewController.m
  8. 1 1
      KulexiuForStudent/KulexiuForStudent/Module/Chat/GroupNotice/View/GroupNoticeCell.m
  9. 1 1
      KulexiuForStudent/KulexiuForStudent/Module/Chat/GroupNotice/View/GroupNoticeCell.xib
  10. 1 0
      KulexiuForStudent/KulexiuForStudent/Module/Chat/View/ChatAddressBodyView.m
  11. 2 2
      KulexiuForStudent/KulexiuForStudent/Module/Login/Model/UserInfoManager.m
  12. 1 0
      KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/PasswordModify/ForgetPasswordViewController.m
  13. 2 0
      KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/PasswordModify/NewPwdModifyViewController.h
  14. 108 6
      KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/PasswordModify/NewPwdModifyViewController.m
  15. 1 0
      KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/PasswordModify/PasswordCheckViewController.m
  16. 11 1
      KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/View/PasswordModify/PasswordModifyBodyView.h
  17. 44 4
      KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/View/PasswordModify/PasswordModifyBodyView.m
  18. 45 3
      KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/View/PasswordModify/PasswordModifyBodyView.xib

+ 4 - 4
KulexiuForStudent/KulexiuForStudent.xcodeproj/project.pbxproj

@@ -8533,7 +8533,7 @@
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_ENTITLEMENTS = KulexiuForStudent/KulexiuForStudent.entitlements;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 1.5.1;
+				CURRENT_PROJECT_VERSION = 1.5.2;
 				DEVELOPMENT_TEAM = B2AP53HHTU;
 				ENABLE_BITCODE = NO;
 				ENABLE_MODULE_VERIFIER = YES;
@@ -8589,7 +8589,7 @@
 					"$(PROJECT_DIR)/KulexiuForStudent/Common/ThirdPart/UMSocialSDK/share/share_ios_6.10.5/SocialLibraries/Sina/SinaSDK",
 					"$(PROJECT_DIR)/KulexiuForStudent/Common/ThirdPart/UMSocialSDK/share/share_ios_6.10.5/UMSocialSDKPlugin",
 				);
-				MARKETING_VERSION = 1.5.1;
+				MARKETING_VERSION = 1.5.2;
 				MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
 				MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
 				PRODUCT_BUNDLE_IDENTIFIER = com.Colexiu.KulexiuForStudent;
@@ -8612,7 +8612,7 @@
 				CLANG_ENABLE_MODULES = YES;
 				CODE_SIGN_ENTITLEMENTS = KulexiuForStudent/KulexiuForStudent.entitlements;
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 1.5.1;
+				CURRENT_PROJECT_VERSION = 1.5.2;
 				DEVELOPMENT_TEAM = B2AP53HHTU;
 				ENABLE_BITCODE = NO;
 				ENABLE_MODULE_VERIFIER = YES;
@@ -8668,7 +8668,7 @@
 					"$(PROJECT_DIR)/KulexiuForStudent/Common/ThirdPart/UMSocialSDK/share/share_ios_6.10.5/SocialLibraries/Sina/SinaSDK",
 					"$(PROJECT_DIR)/KulexiuForStudent/Common/ThirdPart/UMSocialSDK/share/share_ios_6.10.5/UMSocialSDKPlugin",
 				);
-				MARKETING_VERSION = 1.5.1;
+				MARKETING_VERSION = 1.5.2;
 				MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
 				MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
 				PRODUCT_BUNDLE_IDENTIFIER = com.Colexiu.KulexiuForStudent;

+ 16 - 1
KulexiuForStudent/KulexiuForStudent/Common/Base/KSBaseWKWebViewController.m

@@ -478,6 +478,21 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
         }];
          */
     }
+    else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"setStatusBarTextColor"]) { // 设置状态栏颜色
+        NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
+        BOOL whiteColor = [valueDic ks_boolValueForKey:@"statusBarTextColor"];
+        if (whiteColor) {
+            [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
+        }
+        else {
+            if (@available(iOS 13.0, *)) {
+                [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDarkContent;
+            } else {
+                // Fallback on earlier versions
+                [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
+            }
+        }
+    }
     else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"paymentOrder"]) {
         NSDictionary *content = [parm ks_dictionaryValueForKey:@"content"];
         NSString *channel = [content ks_stringValueForKey:@"payChannel"];
@@ -989,7 +1004,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
     
     CALayer *layer = [CALayer layer];
     layer.frame = CGRectMake(0, 0, 0, 3);
-    layer.backgroundColor = THEMECOLOR.CGColor;
+    layer.backgroundColor = CLIENT_THEMECOLOR.CGColor;
     [progress.layer addSublayer:layer];
     self.progressLayer = layer;
 }

+ 2 - 1
KulexiuForStudent/KulexiuForStudent/Common/Base/KSNetworkingManager.h

@@ -954,9 +954,10 @@ NS_ASSUME_NONNULL_BEGIN
 /// 设置用户密码
 /// @param post post
 /// @param password password
+/// @param code code
 /// @param success 成功
 /// @param faliure 失败
-+ (void)setPasswordRequest:(NSString *)post password:(NSString *)password success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure;
++ (void)setPasswordRequest:(NSString *)post password:(NSString *)password code:(NSString *)code success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure;
 @end
 
 NS_ASSUME_NONNULL_END

+ 3 - 1
KulexiuForStudent/KulexiuForStudent/Common/Base/KSNetworkingManager.m

@@ -1834,13 +1834,15 @@
 /// 设置用户密码
 /// @param post post
 /// @param password password
+/// @param code code
 /// @param success 成功
 /// @param faliure 失败
-+ (void)setPasswordRequest:(NSString *)post password:(NSString *)password success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
++ (void)setPasswordRequest:(NSString *)post password:(NSString *)password code:(NSString *)code success:(void(^)(NSDictionary *dic))success faliure:(void(^)(NSError *error))faliure {
     [self configRequestMethodForm];
     NSMutableDictionary *parm = [NSMutableDictionary dictionary];
     [parm setValue:password forKey:@"password"];
     [parm setValue:UserDefault(UIDKey) forKey:@"id"];
+    [parm setValue:code forKey:@"code"];
     NSString *url = [NSString stringWithFormat:@"%@%@",hostURL, @"/api-auth/user/setPassword"];
     [self request:post andWithUrl:url and:parm success:success faliure:faliure];
 }

+ 0 - 2
KulexiuForStudent/KulexiuForStudent/Common/Define/KSDomain.h

@@ -22,8 +22,6 @@
 #define SEALCLASSHOST (@"https://dev.colexiu.com/api-classroom")
 #define WEBHOST (@"https://dev.colexiu.com/student")
 #define TENANT_WEBHOST (@"https://dev.colexiu.com/tenant")
-//#define WEBHOST (@"http://192.168.3.220:5000")
-//#define TENANT_WEBHOST (@"http://192.168.3.220:5000/tenant.html")
 #define SOCKET_URL (@"wss://dev.colexiu.com/audioAnalysis")
 #define JSPUSH_ENVIRONMENT (NO)
 #define RCIM_KEY (@"0vnjpoad0jbdz")

+ 8 - 14
KulexiuForStudent/KulexiuForStudent/Common/Tools/Extension/UIView+Hints.m

@@ -168,20 +168,14 @@
     [self removeHUDActivityView];
     
     //如果有键盘弹出,则在键盘层显示,防止被键盘window 遮挡住
-     UIWindow *keyWindow = nil;
-    NSArray *windowsArray = [UIApplication sharedApplication].windows;
-    
-    //window数量大于2表示不存在双层window
-    if (windowsArray && [windowsArray count]>1) {
-        keyWindow = [windowsArray lastObject];
-    }
-     if (keyWindow) {
-        view = keyWindow;
-    }else if(!view){
-        view = self;
-    }else{
-        return nil;
-    }
+    UIWindow *keyWindow = [NSObject getKeyWindow];
+    if (keyWindow) {
+       view = keyWindow;
+   }else if(!view){
+       view = self;
+   }else{
+       return nil;
+   }
     
 ////移除视图中的提示
 //    [view removeHUDActivityView];

+ 4 - 4
KulexiuForStudent/KulexiuForStudent/Module/Chat/Controller/ChatAddressViewController.m

@@ -116,7 +116,7 @@
 - (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
     ChatAddressBodyView *listView = [[ChatAddressBodyView alloc] init];
     listView.naviController = self.navigationController;
-    [self.listViewArray addObject:listView];
+    [self.listViewArray replaceObjectAtIndex:index withObject:listView];
     if (index == 0) {
         listView.selectIndex = 0;
     }else if (index == 1) {
@@ -132,8 +132,8 @@
     if (self.listViewArray.count > index) {
         id value = self.listViewArray[index];
         if ([value isKindOfClass:[KSJXBodyView class]]) {
-            KSJXBodyView *listView = (KSJXBodyView *)value;
-            [listView beginFirstRefresh];
+            ChatAddressBodyView *listView = (ChatAddressBodyView *)value;
+            [listView refreshAndRequestData];
         }
     }
 
@@ -152,7 +152,7 @@
 
 - (NSMutableArray *)listViewArray {
     if (!_listViewArray) {
-        _listViewArray = [NSMutableArray array];
+        _listViewArray = [NSMutableArray arrayWithArray:@[@"",@""]];
     }
     return _listViewArray;
 }

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Module/Chat/GroupNotice/View/GroupNoticeCell.m

@@ -54,7 +54,7 @@
         self.noticeTitle.text = [NSString returnNoNullStringWithString:model.title];
         NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
         [paragraphStyle setLineSpacing:4];//调整行间距
-        NSMutableAttributedString *attrs = [[NSMutableAttributedString alloc] initWithString:[NSString returnNoNullStringWithString:model.content] attributes:@{NSParagraphStyleAttributeName:paragraphStyle,NSFontAttributeName:[UIFont systemFontOfSize:14.0f],NSForegroundColorAttributeName:HexRGB(0x333333)}];
+        NSMutableAttributedString *attrs = [[NSMutableAttributedString alloc] initWithString:[NSString returnNoNullStringWithString:model.content] attributes:@{NSParagraphStyleAttributeName:paragraphStyle,NSFontAttributeName:[UIFont systemFontOfSize:14.0f],NSForegroundColorAttributeName:HexRGB(0x777777)}];
         self.noticeContent.attributedText = attrs;
         
         self.focusLabel.hidden = model.top ? NO : YES;

+ 1 - 1
KulexiuForStudent/KulexiuForStudent/Module/Chat/GroupNotice/View/GroupNoticeCell.xib

@@ -83,7 +83,7 @@
                             </view>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" verticalCompressionResistancePriority="749" text="" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="gxd-9e-9Xw">
                                 <rect key="frame" x="12" y="85" width="309" height="64"/>
-                                <fontDescription key="fontDescription" type="system" weight="semibold" pointSize="15"/>
+                                <fontDescription key="fontDescription" type="system" weight="medium" pointSize="15"/>
                                 <color key="textColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 <nil key="highlightedColor"/>
                             </label>

+ 1 - 0
KulexiuForStudent/KulexiuForStudent/Module/Chat/View/ChatAddressBodyView.m

@@ -266,6 +266,7 @@
 }
 
 - (void)beginRefreshImmediately {
+    [self.tableView.mj_header setState:MJRefreshStateIdle];
     [self.tableView.mj_header beginRefreshing];
 }
 

+ 2 - 2
KulexiuForStudent/KulexiuForStudent/Module/Login/Model/UserInfoManager.m

@@ -178,7 +178,7 @@
             UserDefaultSet(self.userInfo.imToken, IM_TOKEN);
             UserDefaultSet(self.userInfo.username, NicknameKey);
             UserDefaultSet(self.userInfo.heardUrl, AvatarUrlKey);
-            if (self.userInfo.tenantId > 0) {
+            if (self.userInfo.tenantId != 0) {
                 UserDefaultSetObjectForKey(@(self.userInfo.tenantId), TENANT_ID);
             }
             [[NSUserDefaults standardUserDefaults] synchronize];
@@ -359,7 +359,7 @@
             UserDefaultSet(self.userInfo.imToken, IM_TOKEN);
             UserDefaultSet(self.userInfo.username, NicknameKey);
             UserDefaultSet(self.userInfo.heardUrl, AvatarUrlKey);
-            if (self.userInfo.tenantId > 0) {
+            if (self.userInfo.tenantId != 0) {
                 UserDefaultSetObjectForKey(@(self.userInfo.tenantId), TENANT_ID);
             }
             [[NSUserDefaults standardUserDefaults] synchronize];

+ 1 - 0
KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/PasswordModify/ForgetPasswordViewController.m

@@ -78,6 +78,7 @@
 
 - (void)modifyPasswordAction {
     NewPwdModifyViewController *ctrl = [[NewPwdModifyViewController alloc] init];
+    ctrl.needCode = NO;
     [self.navigationController pushViewController:ctrl animated:YES];
 }
 

+ 2 - 0
KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/PasswordModify/NewPwdModifyViewController.h

@@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface NewPwdModifyViewController : KSBaseViewController
 
+@property (nonatomic, assign) BOOL needCode;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 108 - 6
KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/PasswordModify/NewPwdModifyViewController.m

@@ -7,9 +7,13 @@
 
 #import "NewPwdModifyViewController.h"
 #import "PasswordModifyBodyView.h"
+#import "VeriCheckView.h"
 
 @interface NewPwdModifyViewController ()
-
+{
+    NSTimer *_time;
+    int _count;
+}
 @property (nonatomic, strong) PasswordModifyBodyView *bodyView;
 
 @end
@@ -26,21 +30,38 @@
 - (void)configUI {
     self.bodyView = [PasswordModifyBodyView shareInstance];
     [self.view addSubview:self.bodyView];
+    self.bodyView.needVefiCode = self.needCode;
     [self.bodyView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.left.right.top.bottom.mas_equalTo(self.view);
     }];
     
     MJWeakSelf;
-    [self.bodyView modifyPasswordCallback:^(NSString *password) {
-        [weakSelf updatePassword:password];
-        
+    [self.bodyView modifyPasswordCallback:^(MODIFYTYPE type, NSString * _Nullable password, NSString * _Nullable code) {
+        [weakSelf modifyAction:type password:password code:code];
     }];
 }
 
+- (void)modifyAction:(MODIFYTYPE)type password:(NSString *)password code:(NSString *)code {
+    switch (type) {
+        case MODIFYTYPE_CODE: // 发送验证码
+        {
+            // 图形化验证
+            [self veriCodeSendCheck];
+        }
+            break;
+        case MODIFYTYPE_SURE:
+        {
+            [self updatePassword:password code:code];
+        }
+            break;
+        default:
+            break;
+    }
+}
 
-- (void)updatePassword:(NSString *)password {
+- (void)updatePassword:(NSString *)password code:(NSString *)code {
     [LOADING_MANAGER showHUD];
-    [KSNetworkingManager setPasswordRequest:KS_POST password:password success:^(NSDictionary * _Nonnull dic) {
+    [KSNetworkingManager setPasswordRequest:KS_POST password:password code:code success:^(NSDictionary * _Nonnull dic) {
         [LOADING_MANAGER removeHUD];
         if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
             [LOADING_MANAGER KSShowMsg:@"修改成功" promptCompletion:^{
@@ -59,6 +80,87 @@
 - (void)toLoginView {
     [APPLOGIN_MANAGER logoutAction];
 }
+
+#pragma mark --- 验证码
+- (void)veriCodeSendCheck {
+    NSString *phoneNo = UserDefault(PHONEKEY);
+    // 图形化验证
+    VeriCheckView *view = [VeriCheckView shareInstanceShowInView:self.view];
+    __weak typeof(view) weakView = view;
+    [view showViewCallback:^(NSDictionary * _Nonnull parm) {
+        [self veriImageCodeWithParm:parm checkView:weakView];
+    }];
+    [view disPlayImageWithPhone:phoneNo];
+}
+
+- (void)veriImageCodeWithParm:(NSDictionary *)parm checkView:(VeriCheckView *)checkView {
+    [LOADING_MANAGER showHUD];
+    [KSNetworkingManager verifyLoginImageRequest:KS_POST phone:[parm ks_stringValueForKey:@"phone"] code:[parm ks_stringValueForKey:@"code"] success:^(NSDictionary * _Nonnull dic) {
+        if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
+            [checkView hiddView];
+            [self sendSMSRequestWithParm:parm];
+        }
+        else {
+            [LOADING_MANAGER removeHUD];
+            [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
+        }
+    } faliure:^(NSError * _Nonnull error) {
+        [LOADING_MANAGER removeHUD];
+    }];
+}
+
+// 发送短信
+- (void)sendSMSRequestWithParm:(NSDictionary *)parm {
+    [KSNetworkingManager sendSmsRequest:KS_POST mobile:[parm ks_stringValueForKey:@"phone"] type:@"PASSWD" success:^(NSDictionary * _Nonnull dic) {
+        [LOADING_MANAGER removeHUD];
+        if ([dic ks_integerValueForKey:@"code"] == 200 && [dic ks_boolValueForKey:@"status"]) {
+            [LOADING_MANAGER MBShowAUTOHidingInWindow:@"验证码已发送"];
+            [self codeButtonCountDown];
+        }
+        else {
+            [LOADING_MANAGER MBShowAUTOHidingInWindow:MESSAGEKEY];
+        }
+    } faliure:^(NSError * _Nonnull error) {
+        [LOADING_MANAGER removeHUD];
+    }];
+}
+
+- (void)codeButtonCountDown {
+    _bodyView.codeButton.userInteractionEnabled = NO;
+    [_bodyView.codeButton setTitleColor:HexRGB(0xe5e5e5) forState:UIControlStateNormal];
+    __weak typeof(self) weakSelf = self;
+    _time = [NSTimer scheduledTimerWithTimeInterval:1 target:weakSelf selector:@selector(buttonChangeAction) userInfo:nil repeats:YES];
+    _count = 59;
+}
+
+- (void)clearButtonState {
+    [_time invalidate];
+    _time = nil;
+    _count = 0;
+    [_bodyView.codeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
+    [_bodyView.codeButton setTitleColor:CLIENT_THEMECOLOR forState:UIControlStateNormal];
+    _bodyView.codeButton.userInteractionEnabled = YES;
+}
+
+#pragma mark  ---- 验证码按钮状态
+- (void)buttonChangeAction {
+    _bodyView.codeButton.userInteractionEnabled = NO;
+    NSString *title = [NSString stringWithFormat:@"%ds",_count];
+    [_bodyView.codeButton setTitle:title forState:UIControlStateNormal];
+    _count--;
+    if(_count == -1){
+        [_time invalidate];
+        _time = nil;
+        [_bodyView.codeButton setTitle:@"获取验证码" forState:UIControlStateNormal];
+        [_bodyView.codeButton setTitleColor:CLIENT_THEMECOLOR forState:UIControlStateNormal];
+        _bodyView.codeButton.userInteractionEnabled = YES;
+    }
+}
+
+- (void)dealloc {
+    [_time invalidate];
+    _time = nil;
+}
 /*
 #pragma mark - Navigation
 

+ 1 - 0
KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/Controller/PasswordModify/PasswordCheckViewController.m

@@ -73,6 +73,7 @@
 
 - (void)modifyPasswordAction {
     NewPwdModifyViewController *ctrl = [[NewPwdModifyViewController alloc] init];
+    ctrl.needCode = YES;
     [self.navigationController pushViewController:ctrl animated:YES];
 }
 /*

+ 11 - 1
KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/View/PasswordModify/PasswordModifyBodyView.h

@@ -7,12 +7,22 @@
 
 #import <UIKit/UIKit.h>
 
-typedef void(^ModifyPwdCallback)(NSString *password);
+typedef NS_ENUM(NSInteger, MODIFYTYPE) {
+    MODIFYTYPE_CODE,
+    MODIFYTYPE_SURE,
+};
+
+typedef void(^ModifyPwdCallback)(MODIFYTYPE type, NSString * _Nullable password, NSString * _Nullable code);
 
 NS_ASSUME_NONNULL_BEGIN
 
 @interface PasswordModifyBodyView : UIView
 
+@property (weak, nonatomic) IBOutlet UIButton *codeButton;
+
+// 是否需要验证码
+@property (nonatomic, assign) BOOL needVefiCode;
+
 + (instancetype)shareInstance;
 
 - (void)modifyPasswordCallback:(ModifyPwdCallback)callback;

+ 44 - 4
KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/View/PasswordModify/PasswordModifyBodyView.m

@@ -11,20 +11,26 @@
 
 @property (weak, nonatomic) IBOutlet UILabel *phoneLabel;
 
+@property (weak, nonatomic) IBOutlet UITextField *codeField;
+
 @property (weak, nonatomic) IBOutlet UITextField *firstField;
 
 @property (weak, nonatomic) IBOutlet UITextField *secondField;
 
 @property (weak, nonatomic) IBOutlet UIButton *sureButton;
 
+@property (weak, nonatomic) IBOutlet UIView *codeView;
+
+@property (weak, nonatomic) IBOutlet NSLayoutConstraint *codeViewHeight;
 @property (nonatomic, copy) ModifyPwdCallback callback;
 
 @end
 
 @implementation PasswordModifyBodyView
+
 - (void)awakeFromNib {
     [super awakeFromNib];
-    
+    self.codeField.delegate = self;
     self.firstField.delegate = self;
     self.secondField.delegate = self;
     if (@available(iOS 10.0, *)) {
@@ -38,6 +44,8 @@
     NSString *phoneStr = UserDefault(PHONEKEY);
     self.phoneLabel.text = [phoneStr stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
     [self.sureButton setBackgroundColor:CLIENT_THEMESORTCOLOR];
+    [self.codeButton setTitleColor:CLIENT_THEMECOLOR forState:UIControlStateNormal];
+    self.needVefiCode = NO;
 }
 
 + (instancetype)shareInstance {
@@ -51,6 +59,13 @@
     }
 }
 
+- (IBAction)sendCode:(id)sender {
+    [self endEditing:YES];
+    if (self.callback) {
+        self.callback(MODIFYTYPE_CODE, self.firstField.text, self.codeField.text);
+    }
+}
+
 - (IBAction)sureAction:(id)sender {
     [self endEditing:YES];
     
@@ -66,8 +81,14 @@
         [LOADING_MANAGER MBShowAUTOHidingInWindow:@"两次输入密码不一致"];
         return;
     }
+    if (self.needVefiCode) {
+        if ([NSString isEmptyString:self.codeField.text]) {
+            [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请输入验证码"];
+            return;
+        }
+    }
     if (self.callback) {
-        self.callback(self.firstField.text);
+        self.callback(MODIFYTYPE_SURE,self.firstField.text, self.codeField.text);
     }
     
 }
@@ -81,12 +102,31 @@
         return YES;
     }
     NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string];
-    if (newString.length > 20) {
-        return NO;
+    if (textField == self.codeField) {
+        if (newString.length > 6) {
+            return NO;
+        }
+    }
+    else {
+        if (newString.length > 20) {
+            return NO;
+        }
     }
+    
     return YES;
 }
 
+- (void)setNeedVefiCode:(BOOL)needVefiCode {
+    _needVefiCode = needVefiCode;
+    if (needVefiCode) {
+        self.codeView.hidden = NO;
+        self.codeViewHeight.constant = 58.0f;
+    }
+    else {
+        self.codeView.hidden = YES;
+        self.codeViewHeight.constant = 0.0f;
+    }
+}
 /*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.

+ 45 - 3
KulexiuForStudent/KulexiuForStudent/Module/Mine/Setting/View/PasswordModify/PasswordModifyBodyView.xib

@@ -14,7 +14,7 @@
             <autoresizingMask key="autoresizingMask"/>
             <subviews>
                 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ERA-Oi-5zj">
-                    <rect key="frame" x="13" y="68" width="367" height="116"/>
+                    <rect key="frame" x="13" y="68" width="367" height="174"/>
                     <subviews>
                         <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YLP-IF-9d1">
                             <rect key="frame" x="0.0" y="0.0" width="367" height="58"/>
@@ -54,16 +54,54 @@
                                 <constraint firstItem="TeQ-fb-lcH" firstAttribute="top" secondItem="Dnp-Yn-EXW" secondAttribute="top" id="qAF-z8-9FT"/>
                             </constraints>
                         </view>
+                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="sY3-pJ-TtJ">
+                            <rect key="frame" x="0.0" y="116" width="367" height="58"/>
+                            <subviews>
+                                <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入验证码" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="sGY-l5-ocy">
+                                    <rect key="frame" x="12" y="0.0" width="253" height="58"/>
+                                    <color key="textColor" red="0.2666666667" green="0.2666666667" blue="0.2666666667" alpha="1" colorSpace="calibratedRGB"/>
+                                    <fontDescription key="fontDescription" type="system" pointSize="16"/>
+                                    <textInputTraits key="textInputTraits" keyboardType="numberPad" enablesReturnKeyAutomatically="YES"/>
+                                </textField>
+                                <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lmy-BV-N3z">
+                                    <rect key="frame" x="275" y="14" width="80" height="30"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="30" id="6HL-mu-god"/>
+                                        <constraint firstAttribute="width" constant="80" id="6Ob-Qs-xPw"/>
+                                    </constraints>
+                                    <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                    <state key="normal" title="获取验证码">
+                                        <color key="titleColor" red="0.1764705882" green="0.78039215689999997" blue="0.66666666669999997" alpha="1" colorSpace="calibratedRGB"/>
+                                    </state>
+                                    <connections>
+                                        <action selector="sendCode:" destination="iN0-l3-epB" eventType="touchUpInside" id="pAk-BY-8Ry"/>
+                                    </connections>
+                                </button>
+                            </subviews>
+                            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                            <constraints>
+                                <constraint firstAttribute="bottom" secondItem="sGY-l5-ocy" secondAttribute="bottom" id="HQn-U6-d0H"/>
+                                <constraint firstAttribute="height" constant="58" id="HeD-aY-gsX"/>
+                                <constraint firstItem="lmy-BV-N3z" firstAttribute="centerY" secondItem="sY3-pJ-TtJ" secondAttribute="centerY" id="NOf-m3-RXa"/>
+                                <constraint firstAttribute="trailing" secondItem="lmy-BV-N3z" secondAttribute="trailing" constant="12" id="PRF-dI-j4P"/>
+                                <constraint firstItem="sGY-l5-ocy" firstAttribute="leading" secondItem="sY3-pJ-TtJ" secondAttribute="leading" constant="12" id="Tth-DR-Zaz"/>
+                                <constraint firstItem="lmy-BV-N3z" firstAttribute="leading" secondItem="sGY-l5-ocy" secondAttribute="trailing" constant="10" id="c71-tJ-VIV"/>
+                                <constraint firstItem="sGY-l5-ocy" firstAttribute="top" secondItem="sY3-pJ-TtJ" secondAttribute="top" id="pew-Ff-jT1"/>
+                            </constraints>
+                        </view>
                     </subviews>
                     <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                     <constraints>
                         <constraint firstItem="YLP-IF-9d1" firstAttribute="leading" secondItem="ERA-Oi-5zj" secondAttribute="leading" id="7vv-8l-wgJ"/>
+                        <constraint firstAttribute="bottom" secondItem="sY3-pJ-TtJ" secondAttribute="bottom" id="JMT-gx-OLQ"/>
+                        <constraint firstItem="sY3-pJ-TtJ" firstAttribute="leading" secondItem="ERA-Oi-5zj" secondAttribute="leading" id="KKF-SQ-hLN"/>
                         <constraint firstItem="Dnp-Yn-EXW" firstAttribute="leading" secondItem="ERA-Oi-5zj" secondAttribute="leading" id="Nup-vq-Cy1"/>
-                        <constraint firstAttribute="bottom" secondItem="Dnp-Yn-EXW" secondAttribute="bottom" id="Trg-w5-OGV"/>
                         <constraint firstItem="Dnp-Yn-EXW" firstAttribute="top" secondItem="YLP-IF-9d1" secondAttribute="bottom" id="gPo-i8-vlC"/>
                         <constraint firstAttribute="trailing" secondItem="YLP-IF-9d1" secondAttribute="trailing" id="ghd-eP-rrg"/>
+                        <constraint firstAttribute="trailing" secondItem="sY3-pJ-TtJ" secondAttribute="trailing" id="gvC-F5-AF9"/>
                         <constraint firstItem="YLP-IF-9d1" firstAttribute="top" secondItem="ERA-Oi-5zj" secondAttribute="top" id="ogb-Xu-eOs"/>
                         <constraint firstAttribute="trailing" secondItem="Dnp-Yn-EXW" secondAttribute="trailing" id="xo0-aN-9PH"/>
+                        <constraint firstItem="sY3-pJ-TtJ" firstAttribute="top" secondItem="Dnp-Yn-EXW" secondAttribute="bottom" id="zHj-ta-aoT"/>
                     </constraints>
                     <userDefinedRuntimeAttributes>
                         <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
@@ -92,7 +130,7 @@
                     </constraints>
                 </view>
                 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Xt4-BL-cN2">
-                    <rect key="frame" x="25" y="214" width="343" height="44"/>
+                    <rect key="frame" x="25" y="272" width="343" height="44"/>
                     <color key="backgroundColor" red="0.1764705882" green="0.78039215689999997" blue="0.66666666669999997" alpha="1" colorSpace="calibratedRGB"/>
                     <constraints>
                         <constraint firstAttribute="height" constant="44" id="seA-iz-3zL"/>
@@ -125,6 +163,10 @@
             <nil key="simulatedBottomBarMetrics"/>
             <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
             <connections>
+                <outlet property="codeButton" destination="lmy-BV-N3z" id="pOL-UW-jcu"/>
+                <outlet property="codeField" destination="sGY-l5-ocy" id="y4y-Ns-UGR"/>
+                <outlet property="codeView" destination="sY3-pJ-TtJ" id="gNT-68-3ic"/>
+                <outlet property="codeViewHeight" destination="HeD-aY-gsX" id="c39-c0-aUC"/>
                 <outlet property="firstField" destination="TBJ-No-0fV" id="rjc-SC-X50"/>
                 <outlet property="phoneLabel" destination="T0L-Jg-T8V" id="OMB-Vq-OaZ"/>
                 <outlet property="secondField" destination="TeQ-fb-lcH" id="GAD-n5-Lop"/>