瀏覽代碼

feat:代码整理、三方登录绑定UI、逻辑处理

“wangdongchao” 1 年之前
父節點
當前提交
55455b3f67

+ 6 - 0
Asteria.xcodeproj/project.pbxproj

@@ -229,6 +229,7 @@
 		8810F5A22BFF448C00346FD4 /* ASMyCartNoDataView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8810F5A12BFF448C00346FD4 /* ASMyCartNoDataView.m */; };
 		8810F5A82C01849C00346FD4 /* ASGoodsReviewFootCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 8810F5A72C01849C00346FD4 /* ASGoodsReviewFootCell.m */; };
 		8810F5AB2C045FD600346FD4 /* ToolStripePayment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8810F5AA2C045FD600346FD4 /* ToolStripePayment.swift */; };
+		88516B6E2C12E51600F2E396 /* ASLoginBindingC.m in Sources */ = {isa = PBXBuildFile; fileRef = 88516B6D2C12E51600F2E396 /* ASLoginBindingC.m */; };
 		8C24ECE114420CDEE7B9B22B /* Pods_Asteria.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 54DCE8001991D89B696E7D44 /* Pods_Asteria.framework */; };
 		9A1247942A1B082300126226 /* Fuction_Tool.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A1247932A1B082300126226 /* Fuction_Tool.m */; };
 		9A1247972A1B0A2800126226 /* AS_ForgotC.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A1247962A1B0A2800126226 /* AS_ForgotC.m */; };
@@ -808,6 +809,8 @@
 		8810F5A72C01849C00346FD4 /* ASGoodsReviewFootCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASGoodsReviewFootCell.m; sourceTree = "<group>"; };
 		8810F5A92C045FD600346FD4 /* Asteria-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Asteria-Bridging-Header.h"; sourceTree = "<group>"; };
 		8810F5AA2C045FD600346FD4 /* ToolStripePayment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToolStripePayment.swift; sourceTree = "<group>"; };
+		88516B6C2C12E51600F2E396 /* ASLoginBindingC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLoginBindingC.h; sourceTree = "<group>"; };
+		88516B6D2C12E51600F2E396 /* ASLoginBindingC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASLoginBindingC.m; sourceTree = "<group>"; };
 		9A1247922A1B082300126226 /* Fuction_Tool.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Fuction_Tool.h; sourceTree = "<group>"; };
 		9A1247932A1B082300126226 /* Fuction_Tool.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Fuction_Tool.m; sourceTree = "<group>"; };
 		9A1247952A1B0A2800126226 /* AS_ForgotC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AS_ForgotC.h; sourceTree = "<group>"; };
@@ -2317,6 +2320,8 @@
 			children = (
 				9A5C64562A12064300CBB185 /* AS_LoginC.h */,
 				9A5C64572A12064300CBB185 /* AS_LoginC.m */,
+				88516B6C2C12E51600F2E396 /* ASLoginBindingC.h */,
+				88516B6D2C12E51600F2E396 /* ASLoginBindingC.m */,
 				9ACBEC232A14707400A8F97A /* AS_SignUpC.h */,
 				9ACBEC242A14707400A8F97A /* AS_SignUpC.m */,
 				81E1950D2C01664C005471A1 /* LoginForgotC.h */,
@@ -3096,6 +3101,7 @@
 				81DFA5632A46CD6000DA708B /* Target_WebView.m in Sources */,
 				81354BF52A287BED0082C93A /* KWMineHomeOrderSubView.m in Sources */,
 				9AD345A82A08D571005CA070 /* TYCyclePagerView.m in Sources */,
+				88516B6E2C12E51600F2E396 /* ASLoginBindingC.m in Sources */,
 				8810F55F2BF5EBF400346FD4 /* ASOrderDetailsItemsCell.m in Sources */,
 				8810F5812BF74A5800346FD4 /* ASGoodsDetailsTableView.m in Sources */,
 				9AD346202A08E30E005CA070 /* SelectVCollectionViewCell.m in Sources */,

+ 22 - 0
Asteria/Fuction/Login/VC/ASLoginBindingC.h

@@ -0,0 +1,22 @@
+//
+//  ASLoginBindingC.h
+//  westkissMob
+//
+//  Created by 王猛 on 2022/11/16.
+//
+
+#import <WMBase/WMBase.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+typedef void(^ASBindFinishBlock)(NSDictionary *bindInfo);
+
+@interface ASLoginBindingC : UCMBaseC
+
+@property (nonatomic, copy) ASBindFinishBlock bindFinishBlock;
+
+@property (nonatomic, strong) NSDictionary *thirdLogDic;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 141 - 0
Asteria/Fuction/Login/VC/ASLoginBindingC.m

@@ -0,0 +1,141 @@
+//
+//  ASLoginBindingC.m
+//  westkissMob
+//
+//  Created by 王猛 on 2022/11/16.
+//
+
+#import "ASLoginBindingC.h"
+#import "EamilTFmatchV.h"
+
+#import <OneSignal/OneSignal.h>
+
+@interface ASLoginBindingC ()
+
+@property (nonatomic, strong) EamilTFmatchV *xxx_regMmailV;
+@property (nonatomic, strong) TT_CustonTF *xxx_firstName;
+@property (nonatomic, strong) TT_CustonTF *xxx_lasetName;
+@property (nonatomic, strong) UIButton *xxx_bindBtn;
+
+@end
+
+@implementation ASLoginBindingC
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+
+    self.view.backgroundColor = [UIColor colorWithHexString:@"#FFF8F9"];
+    self.title = @"BINDING";
+    
+    [self tt_addSubviews];
+
+}
+
+- (void)tt_addSubviews{
+    [self.view addSubview:self.xxx_firstName];
+    [self.view addSubview:self.xxx_lasetName];
+    [self.view addSubview:self.xxx_regMmailV];
+    
+    [self.view addSubview:self.xxx_bindBtn];
+    [self.view bringSubviewToFront:self.xxx_regMmailV];
+    
+
+}
+
+
+-(void)handle_xxx_bindBtnEvent:(UIButton *)btn{
+
+    if (self.xxx_firstName.text.length == 0) {
+        [self.view makeToast:@"Please Input FirstName" duration:2 position:CSToastPositionCenter];
+        return;
+    }else if (self.xxx_lasetName.text.length == 0){
+        [self.view makeToast:@"Please Input LastName" duration:2 position:CSToastPositionCenter];
+        return;
+    }else if(self.xxx_regMmailV.xxx_emailTF.text.length == 0 || ![Current_normalTool xxx_isValidateEmail:self.xxx_regMmailV.xxx_emailTF.text]){
+        [self.view makeToast:@"Please prvide an email address." duration:2 position:CSToastPositionCenter];
+        return;
+    }
+    
+    NSMutableDictionary *parDIc = [NSMutableDictionary dictionaryWithDictionary:self.thirdLogDic];
+    parDIc[@"firstName"] = self.xxx_firstName.text;
+    parDIc[@"lastName"]  =self.xxx_lasetName.text;
+    parDIc[@"email"] = self.xxx_regMmailV.xxx_emailTF.text;
+    
+    if (self.bindFinishBlock) {
+        self.bindFinishBlock(parDIc);
+        
+        [self dismissViewControllerAnimated:YES completion:nil];
+    }
+}
+
+-(TT_CustonTF *)xxx_firstName{
+    IPhoneXHeigh
+    if (!_xxx_firstName) {
+        _xxx_firstName = [TT_ControlTool FTT_ControlToolUITextFieldFrame:CGRectMake(20, securitytop_Y+50, (KScreenWidth-60)/2, 50)
+                                                             PlaceHolder:@"* First Name"
+                                                             andLifImage:nil
+                                                           AndRightImage:nil
+                                                          LiftImageFrame:CGRectZero
+                                                         RightImageFrame:CGRectZero
+                                                                  AndTag:0
+                                                         AndKeyboardType:UIKeyboardTypeDefault
+                                                         clearButtonMode:UITextFieldViewModeAlways
+                                                        AndReturnKeyType:UIReturnKeyDone
+                                                           masksToBounds:YES
+                                                            conrenRadius:4
+                                                             BorderColor:[UIColor colorWithHexString:@"#000000"]
+                                                             BorderWidth:1];
+        _xxx_firstName.font = [UIFont systemFontOfSize:14];
+        _xxx_firstName.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
+        _xxx_firstName.textAlignment = NSTextAlignmentCenter;
+        _xxx_firstName.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"* First Name" attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#0B0B0B"]}];
+    }
+    return _xxx_firstName;
+}
+
+-(TT_CustonTF *)xxx_lasetName{
+    if (!_xxx_lasetName) {
+        _xxx_lasetName = [TT_ControlTool FTT_ControlToolUITextFieldFrame:CGRectMake(CGRectGetMaxX(self.xxx_firstName.frame)+20,self.xxx_firstName.mj_y, (KScreenWidth-60)/2, 50)
+                                                             PlaceHolder:@"* Last Name"
+                                                             andLifImage:nil
+                                                           AndRightImage:nil
+                                                          LiftImageFrame:CGRectZero
+                                                         RightImageFrame:CGRectZero
+                                                                  AndTag:0
+                                                         AndKeyboardType:UIKeyboardTypeDefault
+                                                         clearButtonMode:UITextFieldViewModeAlways
+                                                        AndReturnKeyType:UIReturnKeyDone
+                                                           masksToBounds:YES
+                                                            conrenRadius:4
+                                                             BorderColor:[UIColor colorWithHexString:@"#000000"]
+                                                             BorderWidth:1];
+        _xxx_lasetName.font = [UIFont systemFontOfSize:14];
+        _xxx_lasetName.backgroundColor = [UIColor colorWithHexString:@"#FFFFFF"];
+        _xxx_lasetName.textAlignment = NSTextAlignmentCenter;
+        _xxx_lasetName.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"* Last Name" attributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#0B0B0B"]}];
+    }
+    return _xxx_lasetName;
+}
+
+-(EamilTFmatchV *)xxx_regMmailV{
+    if (!_xxx_regMmailV) {
+        _xxx_regMmailV = [[EamilTFmatchV alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(self.xxx_firstName.frame)+30 , KScreenWidth, 50)];
+    }
+    return _xxx_regMmailV;
+}
+
+-(UIButton *)xxx_bindBtn{
+    if(!_xxx_bindBtn){
+        _xxx_bindBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+        _xxx_bindBtn.frame = CGRectMake(20, CGRectGetMaxY(self.xxx_regMmailV.frame)+30, KScreenWidth-40, 45);
+        [_xxx_bindBtn setTitle:@"BINDING" forState:UIControlStateNormal];
+        [_xxx_bindBtn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateNormal];
+        _xxx_bindBtn.backgroundColor = [UIColor colorWithHexString:@"#000000"];
+        _xxx_bindBtn.layer.cornerRadius = 4;
+        _xxx_bindBtn.clipsToBounds = YES;
+        [_xxx_bindBtn addTarget:self action:@selector(handle_xxx_bindBtnEvent:) forControlEvents:UIControlEventTouchUpInside];
+    }
+    return _xxx_bindBtn;
+}
+
+@end

+ 55 - 8
Asteria/Fuction/Login/VC/AS_LoginC.m

@@ -14,6 +14,8 @@
 #import "AS_SignUpC.h"
 #import "LoginForgotC.h"
 
+#import "LoginBindingC.h"
+
 
 
 @interface AS_LoginC () <TT_basevDelegate>
@@ -23,7 +25,7 @@
 @property (nonatomic, strong) UIButton *xxx_logInBtn;
 @property (nonatomic, strong) LoginThirdAuthV *xxx_authV;
 
-
+@property (nonatomic, strong) NSMutableDictionary *thirdLoginParam;
 
 @end
 
@@ -34,6 +36,9 @@
     // Do any additional setup after loading the view.
     self.customNavBar.hidden = YES;
     self.navigationController.navigationBar.hidden = YES;
+    
+    self.thirdLoginParam = [[NSMutableDictionary alloc] initWithCapacity:1];
+    
 }
 - (void)initSubviews{
     [super initSubviews];
@@ -133,6 +138,7 @@
 
 //注册页面
 -(void)handle_signUpEvent:(UIButton *)btn{
+    
     AS_SignUpC *upVC = [[AS_SignUpC alloc]init];
     [self.navigationController pushViewController:upVC animated:YES];
     
@@ -145,19 +151,59 @@
 #pragma mark ---- TT_basevDelegate 三方登录授权成功回调 -----
 
 - (void)tengteng_configtaptype:(NSInteger)num data:(id)data {
-    NSLog(@"======%ld\n=====%@", (long)num, data);
     
-    if (num == ThirdTypeApple) {
+    [self.thirdLoginParam removeAllObjects];
+    
+    [self.thirdLoginParam addEntriesFromDictionary:(NSDictionary *)data];
+    
+    NSString *userInfoStr = [self.thirdLoginParam objectForKey:@"userInfo"];
+    NSDictionary *userInfo = [userInfoStr mj_JSONObject];
+    
+    NSString *emailStr = userInfo[@"email"];
+    
+    if ([emailStr validateEmail]) {
+        [self requestThirdLogin];
+    } else {//是否绑定过邮箱
+        [self requestIsBindEmail:userInfo];
+    }
+
+}
+
+//获取用户是否绑定过邮箱
+- (void)requestIsBindEmail:(NSDictionary *)info{
+    
+    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
+    K_WEAK_SELF;
+    [ASNetTools.shared postWithPath:userVerifyBindEmailUrl param:@{@"identifier":info[@"identifier"], @"type":self.thirdLoginParam[@"hauth_done"]} success:^(id _Nonnull json) {
+        K_STRONG_SELF;
+        [MBProgressHUD hideHUDForView:self.view animated:YES];
         
-    } else if (num == ThirdTypeFaceBook) {
+        LoginBindingC *bindVC = [[LoginBindingC alloc] init];
+        bindVC.modalPresentationStyle = UIModalPresentationFullScreen;
+        K_WEAK_SELF;
+        bindVC.bindFinishBlock = ^(NSDictionary * _Nonnull bindInfo) {
+            K_STRONG_SELF;
+            NSString *userInfoStr = [bindInfo mj_JSONString];
+            [self.thirdLoginParam setObject:userInfoStr forKey:@"userInfo"];
+            
+            [self requestThirdLogin];
+        };
         
-    } else if (num == ThirdTypeGoogle) {
+        [self presentViewController:bindVC animated:YES completion:nil];
         
-    }
-    
+    } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
+        K_STRONG_SELF;
+        [MBProgressHUD hideHUDForView:self.view animated:YES];
+        
+        [self.view makeToast:msg duration:2 position:CSToastPositionCenter];
+    }];
+}
+
+//三方登录接口调用
+- (void)requestThirdLogin {
     [MBProgressHUD showHUDAddedTo:self.view animated:YES];
     K_WEAK_SELF;
-    [ASNetTools.shared formData_postWithPath:userThirdLoginUrl param:(NSDictionary *)data success:^(id _Nonnull json) {
+    [ASNetTools.shared formData_postWithPath:userThirdLoginUrl param:self.thirdLoginParam success:^(id _Nonnull json) {
         K_STRONG_SELF;
         [MBProgressHUD hideHUDForView:self.view animated:YES];
         
@@ -180,6 +226,7 @@
     }];
 }
 
+
 #pragma mark - **************** 懒加载 ****************
 -(UIView *)logNavView{
     IPhoneXHeigh

+ 45 - 27
Asteria/Fuction/UserCenter/Orders/Controller/ASOrderDetailsViewController.m

@@ -25,10 +25,25 @@
 
 @property (nonatomic, strong) ASOrderDetailsModel *orderDetailsModel;
 
+@property (nonatomic, strong) ASPayFinishHeadView *paySuccessView;
+
 @end
 
 @implementation ASOrderDetailsViewController
 
+- (void)viewWillAppear:(BOOL)animated {
+    [super viewWillAppear:animated];
+    if (self.isPay) {
+        //支付成功页面禁止侧滑返回
+        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
+    }
+}
+
+- (void)viewWillDisappear:(BOOL)animated {
+    [super viewWillDisappear:animated];
+    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
+}
+
 - (void)viewDidLoad {
     [super viewDidLoad];
     
@@ -43,9 +58,9 @@
     
     self.orderDetailsVM = [ASOrderDetailsVM new];
     
-    [self requestOrderDetailsData];
-    
+    [self loadSubV];
     
+    [self requestOrderDetailsData];
 }
 
 - (void)requestOrderDetailsData {
@@ -57,7 +72,7 @@
         
         self.orderDetailsModel = orderModel;
         
-        [self loadSubV];
+        [self.tableView reloadData];
         
         [self checkEmpty];
     }];
@@ -65,7 +80,7 @@
 
 - (void)checkEmpty {
     if (!self.orderDetailsModel) {
-        [self showEmptyV: self.tableView];
+        [self showEmptyV:self.tableView];
     } else {
         [self hiddenEmpty];
     }
@@ -74,7 +89,10 @@
 #pragma mark - UITableViewDelegate,UITableViewDataSource
 
 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
-    return 3;
+    if (self.orderDetailsModel) {
+        return 3;
+    }
+    return 0;
 }
 
 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
@@ -105,10 +123,17 @@
     }
 }
 
-// MARK: - loadSubv
+- (void)backAction {
+    if (self.isPay) {
+        [self.navigationController popToRootViewControllerAnimated:YES];
+    } else {
+        [self.navigationController popViewControllerAnimated:YES];
+    }
+}
+
+#pragma mark ---- UI ----
 - (void)loadSubV {
     
-    
     [self.view addSubview:self.tableView];
     [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.equalTo(self.customNavBar.mas_bottom);
@@ -116,26 +141,7 @@
     }];
     
     if (self.isPay) {
-        ASPayFinishHeadView *payFailedView = [[ASPayFinishHeadView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 100) status:1 desc:self.orderId];
-        
-//        K_WEAK_SELF;
-        payFailedView.clickBlock = ^(int type) {
-    //        K_STRONG_SELF;
-        };
-        
-        float viewHeight = [payFailedView getViewHeight];
-        payFailedView.frame = CGRectMake(0, 0, KScreenWidth, viewHeight);
-        
-        self.tableView.tableHeaderView = payFailedView;
-    }
-    
-}
-
-- (void)backAction {
-    if (self.isPay) {
-        [self.navigationController popToRootViewControllerAnimated:YES];
-    } else {
-        [self.navigationController popViewControllerAnimated:YES];
+        self.tableView.tableHeaderView = self.paySuccessView;
     }
 }
 
@@ -155,5 +161,17 @@
     return _tableView;
 }
 
+- (ASPayFinishHeadView *)paySuccessView {
+    if (!_paySuccessView) {
+        _paySuccessView = [[ASPayFinishHeadView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 100) status:1 desc:self.orderId];
+//        K_WEAK_SELF;
+        _paySuccessView.clickBlock = ^(int type) {
+    //        K_STRONG_SELF;
+        };
+        _paySuccessView.frame = CGRectMake(0, 0, KScreenWidth, [_paySuccessView getViewHeight]);
+    }
+    return _paySuccessView;
+}
+
 
 @end

+ 1 - 1
Asteria/Fuction/UserCenter/Orders/ViewModel/ASOrderDetailsVM.h

@@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface ASOrderDetailsVM : NSObject
 
-///获取购物车列表
+///获取订单详情
 #define Order_details          BaseRequestrUrl(@"orders")
 
 - (void)getOrderDetailsWithOrderid:(NSString *)orderid complete:(void(^)(ASOrderDetailsModel *))completeBlock;

+ 2 - 2
Asteria/Fuction/UserCenter/Orders/ViewModel/ASOrderDetailsVM.m

@@ -15,7 +15,7 @@
         @"url": [NSString stringWithFormat:@"/V1/orders/%@", orderid],
     }];
     [ASNetTools.shared postWithPath:getAllOrders param:para success:^(id _Nonnull json) {
-        NSLog(@"---orderDetails---result:%@------",json);
+//        NSLog(@"---orderDetails---result:%@------",json);
         
         ASOrderDetailsModel *orderModel = [ASOrderDetailsModel mj_objectWithKeyValues:json];
         for (ASOrderDetailsItemModel *itemModel in orderModel.items) {
@@ -25,7 +25,7 @@
         completeBlock(orderModel);
         
     } faild:^(NSString * _Nonnull code, NSString * _Nonnull msg) {
-        NSLog(@"---orderDetails---code:%@--msg:%@----", code, msg);
+//        NSLog(@"---orderDetails---code:%@--msg:%@----", code, msg);
         completeBlock(nil);
     }];
 }

+ 2 - 0
Asteria/NetTools/ASNetApis.h

@@ -61,6 +61,8 @@
 #define userBirthUrl BaseRequestrUrl(@"vip/birthday")
 //三方登录
 #define userThirdLoginUrl BaseRequestrUrl(@"callback")
+//验证用户是否绑定过邮箱
+#define userVerifyBindEmailUrl  BaseRequestrUrl(@"socialCustomer")
 
 // MARK: - 修改用户信息
 #define putUserInfo BaseRequestrUrl(@"customers/me")

文件差異過大導致無法顯示
+ 2022 - 2063
Pods/Pods.xcodeproj/project.pbxproj


+ 1 - 0
Pods/Target Support Files/WMBase/WMBase-umbrella.h

@@ -26,6 +26,7 @@
 #import "NSDate+YYadd.h"
 #import "NSDictionary+PropertyCode.h"
 #import "NSString+URL.h"
+#import "NSString+Verify.h"
 #import "SYBJ_ColorS.h"
 #import "UC_CommonmoduleCat.h"
 #import "UIButton+SDCategory.h"