xiongzhu пре 3 година
родитељ
комит
8d15f61248

+ 9 - 1
plugin.xml

@@ -56,7 +56,15 @@
         <source-file src="src/ios/UmengPlugin.m" />
         <source-file src="src/ios/UMModelCreate.h" />
         <source-file src="src/ios/UMModelCreate.m" />
-
+        <!-- <source-file src="src/ios/umeng.xcassets" /> -->
+        <resource-file src="src/ios/images/bg_login.png" />
+        <resource-file src="src/ios/images/bg_login@2x.png" />
+        <resource-file src="src/ios/images/bg_login@3x.png" />
+        <resource-file src="src/ios/images/bg_change.png" />
+        <resource-file src="src/ios/images/bg_change@2x.png" />
+        <resource-file src="src/ios/images/bg_change@3x.png" />
+        <resource-file src="src/ios/images/bg.png" />
+        <resource-file src="src/ios/images/logo.png" />
         <podspec>
             <config>
                 <source url="https://cdn.cocoapods.org/"/>

+ 1 - 1
src/ios/UMModelCreate.h

@@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN
 
 @interface UMModelCreate : NSObject
 /// 创建全屏的model
-+ (UMCustomModel *)createFullScreenWithColor:(NSString*) color;
++ (UMCustomModel *)create;
 @end
 
 NS_ASSUME_NONNULL_END

+ 41 - 36
src/ios/UMModelCreate.m

@@ -33,7 +33,7 @@
 #define UM_Alert_Horizontal_LoginBtn_Height           51.0
 
 /**竖屏全屏*/
-#define UM_LogoImg_OffetY               32.0
+#define UM_LogoImg_OffetY               132.0
 #define UM_SloganTxt_OffetY             150.0
 #define UM_SloganTxt_Height             24.0
 #define UM_NumberTxt_OffetY             220.0
@@ -68,11 +68,11 @@ static CGFloat ratio ;
 }
 
 /// 创建横屏全屏的model
-+ (UMCustomModel *)createFullScreenWithColor:(NSString*) colorHex {
-    UIColor* color = [self colorFromHexString:colorHex];
++ (UMCustomModel *)create
+{
+    UIColor* color = [self colorFromHexString:@"#26f50d"];
     UMCustomModel *model = [[UMCustomModel alloc] init];
-
-    
+    model.supportedInterfaceOrientations = UIInterfaceOrientationMaskAllButUpsideDown;
     model.navColor = [self colorFromHexString:@"#181818"];
     model.navTitle = [[NSAttributedString alloc] initWithString:@"" attributes:@{NSForegroundColorAttributeName : UIColor.whiteColor,NSFontAttributeName : [UIFont systemFontOfSize:20.0]}];
     model.navIsHidden = YES;
@@ -81,35 +81,40 @@ static CGFloat ratio ;
     //        [rightBtn setTitle:@"更多" forState:UIControlStateNormal];
     //        model.navMoreView = rightBtn;
     
-    model.privacyNavColor = color;
-    model.privacyNavBackImage = [UIImage imageNamed:@"icon_nav_back_light"];
-    model.privacyNavTitleFont = [UIFont systemFontOfSize:20.0];
-    model.privacyNavTitleColor = UIColor.whiteColor;
     
-    model.logoImage = [UIImage imageNamed:@"lvzhopu-logo"];
+    model.logoImage = [UIImage imageNamed:@"logo"];
     model.logoIsHidden = NO;
+    model.logoFrameBlock = ^CGRect(CGSize screenSize, CGSize superViewSize, CGRect frame) {
+        frame.origin.x = (screenSize.width - 120) / 2;
+        frame.size.width = 120;
+        return frame;
+    };
+    
     model.sloganIsHidden = YES;
  
-    
     model.numberColor = color;
     model.numberFont = [UIFont systemFontOfSize:30.0];
-    model.loginBtnText = [[NSAttributedString alloc] initWithString:@"" attributes:@{NSForegroundColorAttributeName : UIColor.whiteColor, NSFontAttributeName : [UIFont systemFontOfSize:16.0]}];
-    model.loginBtnBgImgs = @[[UIImage imageNamed:@"btn_login"], [UIImage imageNamed:@"btn_login_dis"], [UIImage imageNamed:@"btn_login"]];
-
+    model.loginBtnText = [[NSAttributedString alloc] initWithString:@"一键登录" attributes:@{NSForegroundColorAttributeName : UIColor.blackColor, NSFontAttributeName : [UIFont systemFontOfSize:16.0]}];
+    UIImage* bgLogin = [[UIImage imageNamed:@"bg_login"] resizableImageWithCapInsets:UIEdgeInsetsMake(15, 15, 15, 15)];
+    model.loginBtnBgImgs = @[bgLogin, bgLogin, bgLogin];
+  
+    model.changeBtnIsHidden = YES;
 
-    //model.autoHideLoginLoading = NO;
+    model.autoHideLoginLoading = NO;
     model.privacyOne = @[@"《用户服务协议》", @"https://www.raex.vip/service.html"];
     model.privacyTwo = @[@"《平台隐私政策》", @"https://www.raex.vip/privacy.html"];
-    model.privacyColors = @[UIColor.lightGrayColor, color];
+    model.privacyColors = @[UIColor.lightGrayColor, [self colorFromHexString:@"#3ab200"]];
     model.privacyAlignment = NSTextAlignmentCenter;
     model.privacyFont = [UIFont fontWithName:@"PingFangSC-Regular" size:13.0];
     model.privacyOperatorPreText = @"《";
     model.privacyOperatorSufText = @"》";
-    
-    //model.checkBoxIsHidden = NO;
-    model.checkBoxWH = 17.0;
-    model.changeBtnTitle = [[NSAttributedString alloc] initWithString:@"切换到其他方式" attributes:@{NSForegroundColorAttributeName:UIColor.whiteColor, NSFontAttributeName : [UIFont systemFontOfSize:16.0]}];
-    model.changeBtnIsHidden = YES;
+    model.privacyNavColor = [self colorFromHexString:@"#181818"];
+    model.privacyNavBackImage = [UIImage imageNamed:@"icon_nav_back_light"];
+    model.privacyNavTitleFont = [UIFont systemFontOfSize:20.0];
+    model.privacyNavTitleColor = UIColor.whiteColor;
+
+    model.checkBoxIsHidden = YES;
+
     //model.prefersStatusBarHidden = NO;
     model.preferredStatusBarStyle = UIStatusBarStyleLightContent;
     //model.presentDirection = PNSPresentationDirectionBottom;
@@ -135,25 +140,25 @@ static CGFloat ratio ;
     };
     model.loginBtnFrameBlock = ^CGRect(CGSize screenSize, CGSize superViewSize, CGRect frame) {
         double scale = screenSize.width / 375;
-        frame.origin.x = (screenSize.width - 290 * scale) / 2;
+        frame.origin.x = 50;
         frame.origin.y = 228;
-        frame.size.width = 290 * scale;
-        frame.size.height = 40 * scale;
+        frame.size.width = screenSize.width - 100;
+        frame.size.height = 50;
         return frame;
     };
    
     //model.privacyFrameBlock =
     
-    model.backgroundImage = [UIImage imageNamed:@"login"];
+    model.backgroundImage = [UIImage imageNamed:@"bg"];
     model.backgroundImageContentMode = UIViewContentModeScaleAspectFill;
     
     //添加自定义控件并对自定义控件进行布局
     __block UIButton *customBtn = [UIButton buttonWithType:UIButtonTypeCustom];
+    [customBtn setTitle:@"取消" forState:UIControlStateNormal];
+    [customBtn.titleLabel setAttributedText:[[NSAttributedString alloc] initWithString:@"取消" attributes:@{NSForegroundColorAttributeName : [self colorFromHexString:@"#939599"], NSFontAttributeName : [UIFont systemFontOfSize:16.0]}]];
+    [customBtn setTitleColor:[self colorFromHexString:@"#939599"] forState:UIControlStateNormal];
     [customBtn addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
-    [[customBtn imageView] setContentMode:UIViewContentModeScaleAspectFill];
-    [customBtn setImage:[UIImage imageNamed:@"btn_change"] forState:UIControlStateNormal];
-    [customBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentFill];
-    [customBtn setContentVerticalAlignment:UIControlContentVerticalAlignmentFill];
+    [customBtn setBackgroundImage:[[UIImage imageNamed:@"bg_change"] resizableImageWithCapInsets:UIEdgeInsetsMake(15, 15, 15, 15)] forState:UIControlStateNormal];
     model.customViewBlock = ^(UIView * _Nonnull superCustomView) {
          [superCustomView addSubview:customBtn];
         //设置背景颜色
@@ -161,11 +166,10 @@ static CGFloat ratio ;
     };
     model.customViewLayoutBlock = ^(CGSize screenSize, CGRect contentViewFrame, CGRect navFrame, CGRect titleBarFrame, CGRect logoFrame, CGRect sloganFrame, CGRect numberFrame, CGRect loginFrame, CGRect changeBtnFrame, CGRect privacyFrame) {
         CGRect frame = customBtn.frame;
-        double scale = screenSize.width / 375;
-        frame.origin.x = (screenSize.width - 290 * scale) / 2;
-        frame.size.width = 290 * scale;
-        frame.size.height = 40 * scale;
-        frame.origin.y = 228 + frame.size.height + 20 * scale;
+        frame.origin.x = 50;
+        frame.size.width = screenSize.width - 100;
+        frame.size.height = 50;
+        frame.origin.y = 228 + frame.size.height + 30;
         customBtn.frame = frame;
     };
     
@@ -178,7 +182,8 @@ static CGFloat ratio ;
     return size.width > size.height;
 }
 
-+(void)buttonClick{
-    NSLog(@"buttonClick");
++(void)buttonClick
+{
+    [UMCommonHandler cancelLoginVCAnimated:YES complete:nil];
 }
 @end

+ 65 - 71
src/ios/UmengPlugin.m

@@ -4,97 +4,91 @@
 #import <UMCommon/UMCommon.h>
 #import <UMVerify/UMVerify.h>
 #import "UMModelCreate.h"
-
+static NSString* umengKey = @"62b5751a05844627b5c56b51";
+static NSString* umengSecret = @"8nhKJ2GPjv4Wu6z32IuLT+PlmxYompSYkGiyqrJegMcuGXq42NGqcfpbXHLPpvTioI7Lf45qgoOr6+04YABvl/XTHSNXmQxM8xQrJpno9DNsTqE9BhyvLPYzfwVZ1uvSHHp5Gq+0RvOfIhUgqLXBVS2XDlqOkEOTxkptzGXEAj+2SCibdJcQ/PaOpBPs+XXoKiNLTPN+h6jwfKk+PiU8O+3c3TfAMDSLp3DL+hHW+rF5ujakUwumwBt6OKI+p9Cs/IXmH9FpXdI=";
+static NSString* umengMessageSecret = @"";
+static NSString* umengAppMasterSecret = @"";
 @interface UmengPlugin : CDVPlugin {
-    // Member variables go here.
+    
 }
-
+@property (nonatomic, assign) BOOL sdkAvailable;
 - (void)coolMethod:(CDVInvokedUrlCommand*)command;
 @end
 
 @implementation UmengPlugin
 
-- (void)coolMethod:(CDVInvokedUrlCommand*)command
+- (id)init
 {
-    NSString* method = [command methodName];
-    if([@"init" isEqualToString: method]) {
-        NSString* appKey = [command.arguments objectAtIndex:0];
-        NSString* channel = [command.arguments objectAtIndex:1];
-        [UMConfigure initWithAppkey:appKey channel:channel];
-        [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK] callbackId:command.callbackId];
-    } else if([@"initVerify" isEqualToString:method]) {
-        NSString* info = [command.arguments objectAtIndex:0];
-        [UMCommonHandler setVerifySDKInfo:info complete:^(NSDictionary * _Nonnull resultDic) {
-            BOOL success = [PNSCodeSuccess isEqualToString:[resultDic objectForKey:@"resultCode"]];
-            if (success) {
-                [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK] callbackId:command.callbackId];
-            } else {
-                [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:resultDic] callbackId:command.callbackId];
-            }
-        }];
-    } else if([@"checkEnv" isEqualToString:method]) {
-        [UMCommonHandler checkEnvAvailableWithAuthType:UMPNSAuthTypeLoginToken complete:^(NSDictionary * _Nullable resultDic) {
-            BOOL success = [PNSCodeSuccess isEqualToString:[resultDic objectForKey:@"resultCode"]];
-            if (success) {
-                [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK] callbackId:command.callbackId];
-            } else {
-                [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:resultDic] callbackId:command.callbackId];
-            }
-        }];
+    self = [super init];
+    if (self != nil) {
+        self.sdkAvailable = false;
     }
+    return self;
 }
 
-
 - (void)pluginInitialize
 {
-    
-    [UMConfigure initWithAppkey:@"62b5751a05844627b5c56b51" channel:nil];
-    [UMCommonHandler setVerifySDKInfo:@"8nhKJ2GPjv4Wu6z32IuLT+PlmxYompSYkGiyqrJegMcuGXq42NGqcfpbXHLPpvTioI7Lf45qgoOr6+04YABvl/XTHSNXmQxM8xQrJpno9DNsTqE9BhyvLPYzfwVZ1uvSHHp5Gq+0RvOfIhUgqLXBVS2XDlqOkEOTxkptzGXEAj+2SCibdJcQ/PaOpBPs+XXoKiNLTPN+h6jwfKk+PiU8O+3c3TfAMDSLp3DL+hHW+rF5ujakUwumwBt6OKI+p9Cs/IXmH9FpXdI=" complete:^(NSDictionary * _Nonnull resultDic) {
+    [UMConfigure setLogEnabled:true];
+    [UMConfigure initWithAppkey:umengKey channel:nil];
+    [UMCommonHandler setVerifySDKInfo:umengSecret complete:^(NSDictionary * _Nonnull resultDic) {
         NSLog(@"setVerifySDKInfo status %@", [resultDic objectForKey:@"resultCode"]);
         BOOL success = [PNSCodeSuccess isEqualToString:[resultDic objectForKey:@"resultCode"]];
         if (success) {
             [UMCommonHandler checkEnvAvailableWithAuthType:UMPNSAuthTypeLoginToken complete:^(NSDictionary * _Nullable resultDic) {
-                BOOL success = [PNSCodeSuccess isEqualToString:[resultDic objectForKey:@"resultCode"]];
-                NSLog(@"checkEnvAvailableWithAuthType status %@", [resultDic objectForKey:@"resultCode"]);
-                if (success) {
-                    UMCustomModel* model = [UMModelCreate createFullScreenWithColor:@"#26f50d"];
-                    model.supportedInterfaceOrientations = UIInterfaceOrientationMaskAllButUpsideDown;
-                    [UMCommonHandler getLoginTokenWithTimeout:3 controller:[self viewController] model:model complete:^(NSDictionary * _Nonnull resultDic) {
-                            
-                        NSString *code = [resultDic objectForKey:@"resultCode"];
-                        if ([PNSCodeLoginControllerPresentSuccess isEqualToString:code]) {
-                            NSLog(@"弹起授权页成功");
-                        } else if ([PNSCodeLoginControllerClickCancel isEqualToString:code]) {
-                            NSLog(@"点击了授权页的返回");
-                        } else if ([PNSCodeLoginControllerClickChangeBtn isEqualToString:code]) {
-                            NSLog(@"点击切换其他登录方式按钮");
-                        } else if ([PNSCodeLoginControllerClickLoginBtn isEqualToString:code]) {
-                            if ([[resultDic objectForKey:@"isChecked"] boolValue] == YES) {
-                                NSLog(@"点击了登录按钮,check box选中,SDK内部接着会去获取登陆Token");
-                            } else {
-                                NSLog(@"点击了登录按钮,check box选中,SDK内部不会去获取登陆Token");
-                            }
-                        } else if ([PNSCodeLoginControllerClickCheckBoxBtn isEqualToString:code]) {
-                            NSLog(@"点击check box");
-                        } else if ([PNSCodeLoginControllerClickProtocol isEqualToString:code]) {
-                            NSLog(@"点击了协议富文本");
-                        } else if ([PNSCodeSuccess isEqualToString:code]) {
-                            //点击登录按钮获取登录Token成功回调
-                            NSString *token = [resultDic objectForKey:@"token"];
-                            dispatch_async(dispatch_get_main_queue(), ^{
-                                [UMCommonHandler cancelLoginVCAnimated:YES complete:nil];
-                            });
-
-                            //拿Token去服务器换手机号
-                               
-                        } else {
-                        //     [ProgressHUD showError:@"获取登录Token失败"];
-                        }
-                    }];
-                }
+                self.sdkAvailable = [PNSCodeSuccess isEqualToString:[resultDic objectForKey:@"resultCode"]];
+                //[self login:@""];
             }];
         }
     }];
 }
 
+- (void) login:(CDVInvokedUrlCommand*)command
+{
+    if(!self.sdkAvailable){
+        [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR] callbackId:command.callbackId];
+        return;
+    }
+    UMCustomModel* model = [UMModelCreate create];
+    [UMCommonHandler getLoginTokenWithTimeout:3 controller:[self viewController] model:model complete:^(NSDictionary * _Nonnull resultDic) {
+            
+        NSString *code = [resultDic objectForKey:@"resultCode"];
+        if ([PNSCodeLoginControllerPresentSuccess isEqualToString:code]) {
+            NSLog(@"弹起授权页成功");
+        } else if ([PNSCodeLoginControllerClickCancel isEqualToString:code]) {
+            NSLog(@"点击了授权页的返回");
+        } else if ([PNSCodeLoginControllerClickChangeBtn isEqualToString:code]) {
+            NSLog(@"点击切换其他登录方式按钮");
+            dispatch_async(dispatch_get_main_queue(), ^{
+                [UMCommonHandler cancelLoginVCAnimated:YES complete:nil];
+            });
+        } else if ([PNSCodeLoginControllerClickLoginBtn isEqualToString:code]) {
+            if ([[resultDic objectForKey:@"isChecked"] boolValue] == YES) {
+                NSLog(@"点击了登录按钮,check box选中,SDK内部接着会去获取登陆Token");
+            } else {
+                NSLog(@"点击了登录按钮,check box选中,SDK内部不会去获取登陆Token");
+            }
+        } else if ([PNSCodeLoginControllerClickCheckBoxBtn isEqualToString:code]) {
+            NSLog(@"点击check box");
+        } else if ([PNSCodeLoginControllerClickProtocol isEqualToString:code]) {
+            NSLog(@"点击了协议富文本");
+        } else if ([PNSCodeSuccess isEqualToString:code]) {
+            //点击登录按钮获取登录Token成功回调
+            NSString *token = [resultDic objectForKey:@"token"];
+            [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{
+                @"token": token,
+                @"umengKey": umengKey
+            }] callbackId:command.callbackId];
+        } else {
+        }
+    }];
+}
+
+- (void) closeLogin:(CDVInvokedUrlCommand*)command
+{
+    dispatch_async(dispatch_get_main_queue(), ^{
+        [UMCommonHandler cancelLoginVCAnimated:YES complete:nil];
+    });
+    [self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK] callbackId:command.callbackId];
+}
+
 @end

BIN
src/ios/images/bg.png


BIN
src/ios/images/bg_change.png


BIN
src/ios/images/bg_change@2x.png


BIN
src/ios/images/bg_change@3x.png


BIN
src/ios/images/bg_login.png


BIN
src/ios/images/bg_login@2x.png


BIN
src/ios/images/bg_login@3x.png


BIN
src/ios/images/logo.png


+ 6 - 0
src/ios/umeng.xcassets/Contents.json

@@ -0,0 +1,6 @@
+{
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

+ 21 - 0
src/ios/umeng.xcassets/bg.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "filename" : "bg.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
src/ios/umeng.xcassets/bg.imageset/bg.png


+ 23 - 0
src/ios/umeng.xcassets/bg_change.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "filename" : "bg_change.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "bg_change@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "bg_change@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
src/ios/umeng.xcassets/bg_change.imageset/bg_change.png


BIN
src/ios/umeng.xcassets/bg_change.imageset/bg_change@2x.png


BIN
src/ios/umeng.xcassets/bg_change.imageset/bg_change@3x.png


+ 23 - 0
src/ios/umeng.xcassets/bg_login.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "filename" : "bg_login.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "filename" : "bg_login@2x.png",
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "filename" : "bg_login@3x.png",
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
src/ios/umeng.xcassets/bg_login.imageset/bg_login.png


BIN
src/ios/umeng.xcassets/bg_login.imageset/bg_login@2x.png


BIN
src/ios/umeng.xcassets/bg_login.imageset/bg_login@3x.png


+ 21 - 0
src/ios/umeng.xcassets/logo.imageset/Contents.json

@@ -0,0 +1,21 @@
+{
+  "images" : [
+    {
+      "filename" : "logo.png",
+      "idiom" : "universal",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}

BIN
src/ios/umeng.xcassets/logo.imageset/logo.png