Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
L
LuckFarm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lmj
LuckFarm
Commits
5e820025
Commit
5e820025
authored
Nov 12, 2020
by
Mazy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add wechat login
parent
8b9529d2
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
343 additions
and
23 deletions
+343
-23
AppDelegate.mm
GYDemo/GYDemo/AppDelegate.mm
+25
-11
Contents.json
...s.xcassets/setting/wechat_login_bg.imageset/Contents.json
+22
-0
wechat_login_bg@2x.png
...s/setting/wechat_login_bg.imageset/wechat_login_bg@2x.png
+0
-0
wechat_login_bg@3x.png
...s/setting/wechat_login_bg.imageset/wechat_login_bg@3x.png
+0
-0
Contents.json
...assets/setting/wechat_login_btn_bg.imageset/Contents.json
+22
-0
wechat_login_btn_bg@2x.png
...g/wechat_login_btn_bg.imageset/wechat_login_btn_bg@2x.png
+0
-0
wechat_login_btn_bg@3x.png
...g/wechat_login_btn_bg.imageset/wechat_login_btn_bg@3x.png
+0
-0
Contents.json
...ets/setting/wechat_login_logo_icon.imageset/Contents.json
+22
-0
wechat_login_logo_icon@2x.png
...at_login_logo_icon.imageset/wechat_login_logo_icon@2x.png
+0
-0
wechat_login_logo_icon@3x.png
...at_login_logo_icon.imageset/wechat_login_logo_icon@3x.png
+0
-0
Main.storyboard
GYDemo/GYDemo/Base.lproj/Main.storyboard
+127
-1
GYPrefixHeader.pch
GYDemo/GYDemo/GYPrefixHeader.pch
+2
-0
IOSADManager.m
GYDemo/GYDemo/SCAds/IOSADManager.m
+1
-1
GYLoginViewController.m
GYDemo/GYDemo/ViewController/GYLoginViewController.m
+120
-8
GYNative.storyboard
GYDemo/GYDemo/ViewController/GYNative.storyboard
+2
-2
UserInterfaceState.xcuserstate
...cuserdata/mazy.xcuserdatad/UserInterfaceState.xcuserstate
+0
-0
No files found.
GYDemo/GYDemo/AppDelegate.mm
View file @
5e820025
...
...
@@ -21,8 +21,7 @@
#import "GYGiftAlertView.h"
#import <UMCommon/UMCommon.h>
#import "GYSettingViewController.h"
#import "GYLoginViewController.h"
UnityFramework* UnityFrameworkLoad()
{
...
...
@@ -356,8 +355,6 @@ NSDictionary* appLaunchOpts;
}
}];
}
// 获取地块列表
...
...
@@ -691,24 +688,41 @@ NSDictionary* appLaunchOpts;
dispatch_async(dispatch_get_main_queue(), ^{
[self initUnity];
[[[self ufw] appController].window makeKeyAndVisible];
[[CGUserManager shared] addLocCollection:@"tab_imp" value:@"1"];
if(![[data Read] objectForKey:@"firstInstall"]){
[data WirteDic:@"1" Key:@"firstInstall"];
}else{
}
});
}];
[[IOSADManager shareADManager] showADType:ADType_OpenScreen resultBlock:^(BOOL success) {
[[IOSADManager shareADManager] requestVideoAD];
}];
NSString *status = [[CGUserManager shared].appSwitch[@"isopenH5"] stringValue];
NSLog(@"isopenH5 = %@", status);
if ([status isEqualToString:@"1"]) {
Data * data = [[Data alloc] init];
if([[data Read] objectForKey:@"refresh_token"] == nil) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(launchAdSuccesShow) name:LaunchAdSuccesShow object:nil];
}
}
return YES;
}
- (void)launchAdSuccesShow {
// WEAKSELF;
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
GYLoginViewController *loginVC = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"GYLoginViewController"];
loginVC.modalPresentationStyle = UIModalPresentationFullScreen;
UINavigationController *naviVC = [[UINavigationController alloc] initWithRootViewController:loginVC];
naviVC.modalPresentationStyle = UIModalPresentationFullScreen;
[[[self ufw] appController].window.rootViewController.view addSubview:naviVC.view];
[[[self ufw] appController].window.rootViewController addChildViewController:naviVC];
// [[[self ufw] appController].window.rootViewController presentViewController:naviVC animated:false completion:nil];
// });
}
- (void)unityVideo:(BOOL)video{
if (video) {
[[self ufw] sendMessageToGOWithName: "TitleView" functionName: "unity_changeMusicStatus" message: [@"1" UTF8String]];
...
...
GYDemo/GYDemo/Assets.xcassets/setting/wechat_login_bg.imageset/Contents.json
0 → 100644
View file @
5e820025
{
"images"
:
[
{
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"filename"
:
"wechat_login_bg@2x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"filename"
:
"wechat_login_bg@3x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
GYDemo/GYDemo/Assets.xcassets/setting/wechat_login_bg.imageset/wechat_login_bg@2x.png
0 → 100644
View file @
5e820025
244 KB
GYDemo/GYDemo/Assets.xcassets/setting/wechat_login_bg.imageset/wechat_login_bg@3x.png
0 → 100644
View file @
5e820025
522 KB
GYDemo/GYDemo/Assets.xcassets/setting/wechat_login_btn_bg.imageset/Contents.json
0 → 100644
View file @
5e820025
{
"images"
:
[
{
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"filename"
:
"wechat_login_btn_bg@2x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"filename"
:
"wechat_login_btn_bg@3x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
GYDemo/GYDemo/Assets.xcassets/setting/wechat_login_btn_bg.imageset/wechat_login_btn_bg@2x.png
0 → 100644
View file @
5e820025
12.5 KB
GYDemo/GYDemo/Assets.xcassets/setting/wechat_login_btn_bg.imageset/wechat_login_btn_bg@3x.png
0 → 100644
View file @
5e820025
29.3 KB
GYDemo/GYDemo/Assets.xcassets/setting/wechat_login_logo_icon.imageset/Contents.json
0 → 100644
View file @
5e820025
{
"images"
:
[
{
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"filename"
:
"wechat_login_logo_icon@2x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"filename"
:
"wechat_login_logo_icon@3x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
GYDemo/GYDemo/Assets.xcassets/setting/wechat_login_logo_icon.imageset/wechat_login_logo_icon@2x.png
0 → 100644
View file @
5e820025
60.2 KB
GYDemo/GYDemo/Assets.xcassets/setting/wechat_login_logo_icon.imageset/wechat_login_logo_icon@3x.png
0 → 100644
View file @
5e820025
137 KB
GYDemo/GYDemo/Base.lproj/Main.storyboard
View file @
5e820025
...
...
@@ -2,7 +2,133 @@
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB"
version=
"3.0"
toolsVersion=
"17156"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
useTraitCollections=
"YES"
useSafeAreas=
"YES"
colorMatched=
"YES"
>
<device
id=
"retina6_1"
orientation=
"portrait"
appearance=
"light"
/>
<dependencies>
<deployment
identifier=
"iOS"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"17125"
/>
<capability
name=
"Safe area layout guides"
minToolsVersion=
"9.0"
/>
<capability
name=
"System colors in document resources"
minToolsVersion=
"11.0"
/>
<capability
name=
"documents saved in the Xcode 8 format"
minToolsVersion=
"8.0"
/>
</dependencies>
<scenes/>
<scenes>
<!--Login View Controller-->
<scene
sceneID=
"dLe-sG-7LZ"
>
<objects>
<viewController
storyboardIdentifier=
"GYLoginViewController"
useStoryboardIdentifierAsRestorationIdentifier=
"YES"
id=
"Ux2-xp-g9C"
customClass=
"GYLoginViewController"
sceneMemberID=
"viewController"
>
<view
key=
"view"
contentMode=
"scaleToFill"
id=
"dYL-zr-8sU"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"896"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<subviews>
<imageView
clipsSubviews=
"YES"
userInteractionEnabled=
"NO"
contentMode=
"scaleToFill"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
image=
"wechat_login_bg"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"UOH-Jk-9M5"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"896"
/>
</imageView>
<button
opaque=
"NO"
contentMode=
"scaleToFill"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
buttonType=
"system"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"TWR-n9-3GS"
>
<rect
key=
"frame"
x=
"366"
y=
"54"
width=
"33"
height=
"32"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"16"
/>
<state
key=
"normal"
title=
"跳过"
>
<color
key=
"titleColor"
white=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
</state>
<connections>
<action
selector=
"skipAction:"
destination=
"Ux2-xp-g9C"
eventType=
"touchUpInside"
id=
"FAD-tB-Jj2"
/>
</connections>
</button>
<view
contentMode=
"scaleToFill"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"7mW-as-1Ow"
>
<rect
key=
"frame"
x=
"366"
y=
"80"
width=
"33"
height=
"0.5"
/>
<color
key=
"backgroundColor"
systemColor=
"systemBackgroundColor"
/>
<constraints>
<constraint
firstAttribute=
"height"
constant=
"0.5"
id=
"WfN-fn-KKv"
/>
</constraints>
</view>
<button
opaque=
"NO"
contentMode=
"scaleToFill"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"kyj-A5-ZZN"
>
<rect
key=
"frame"
x=
"83.5"
y=
"423.5"
width=
"247"
height=
"59.5"
/>
<state
key=
"normal"
image=
"wechat_login_btn_bg"
/>
<connections>
<action
selector=
"weichatLoginAction:"
destination=
"Ux2-xp-g9C"
eventType=
"touchUpInside"
id=
"igX-Hu-OSY"
/>
</connections>
</button>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"微信登录才能提现哦~"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"j4f-2W-n3v"
>
<rect
key=
"frame"
x=
"115.5"
y=
"498"
width=
"183.5"
height=
"21.5"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"18"
/>
<color
key=
"textColor"
red=
"0.70196078431372544"
green=
"0.23137254901960785"
blue=
"0.0039215686274509803"
alpha=
"1"
colorSpace=
"calibratedRGB"
/>
<nil
key=
"highlightedColor"
/>
</label>
<imageView
clipsSubviews=
"YES"
userInteractionEnabled=
"NO"
contentMode=
"scaleAspectFit"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
image=
"wechat_login_logo_icon"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"iEN-Z8-WSa"
>
<rect
key=
"frame"
x=
"147.5"
y=
"197"
width=
"119.5"
height=
"146.5"
/>
</imageView>
<stackView
opaque=
"NO"
contentMode=
"scaleToFill"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"HN2-80-MUu"
>
<rect
key=
"frame"
x=
"78"
y=
"823"
width=
"258"
height=
"29"
/>
<subviews>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"登陆即同意"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"Whn-XS-fJg"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"71.5"
height=
"29"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"14"
/>
<color
key=
"textColor"
red=
"0.49803921568627452"
green=
"0.28627450980392155"
blue=
"0.039215686274509803"
alpha=
"1"
colorSpace=
"calibratedRGB"
/>
<nil
key=
"highlightedColor"
/>
</label>
<button
opaque=
"NO"
tag=
"1000"
contentMode=
"scaleToFill"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
buttonType=
"system"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"vcR-Dv-jn1"
>
<rect
key=
"frame"
x=
"71.5"
y=
"0.0"
width=
"86"
height=
"29"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"14"
/>
<state
key=
"normal"
title=
"《用户协议》"
>
<color
key=
"titleColor"
red=
"0.77254901960784317"
green=
"0.40392156862745099"
blue=
"0.074509803921568626"
alpha=
"1"
colorSpace=
"calibratedRGB"
/>
</state>
<connections>
<action
selector=
"showUserAgentAndPolicyAction:"
destination=
"Ux2-xp-g9C"
eventType=
"touchUpInside"
id=
"kma-9F-cgW"
/>
</connections>
</button>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"和"
textAlignment=
"natural"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"ToV-NI-nOm"
>
<rect
key=
"frame"
x=
"157.5"
y=
"0.0"
width=
"14.5"
height=
"29"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"14"
/>
<color
key=
"textColor"
red=
"0.49803921569999998"
green=
"0.28627450980000002"
blue=
"0.039215686270000001"
alpha=
"1"
colorSpace=
"calibratedRGB"
/>
<nil
key=
"highlightedColor"
/>
</label>
<button
opaque=
"NO"
tag=
"2000"
contentMode=
"scaleToFill"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
buttonType=
"system"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"V0X-bT-J7t"
>
<rect
key=
"frame"
x=
"172"
y=
"0.0"
width=
"86"
height=
"29"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
pointSize=
"14"
/>
<state
key=
"normal"
title=
"《隐私政策》"
>
<color
key=
"titleColor"
red=
"0.7725490196"
green=
"0.4039215686"
blue=
"0.074509803920000006"
alpha=
"1"
colorSpace=
"calibratedRGB"
/>
</state>
<connections>
<action
selector=
"showUserAgentAndPolicyAction:"
destination=
"Ux2-xp-g9C"
eventType=
"touchUpInside"
id=
"AYd-WZ-V8I"
/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
<viewLayoutGuide
key=
"safeArea"
id=
"CnQ-kP-08k"
/>
<color
key=
"backgroundColor"
systemColor=
"systemBackgroundColor"
/>
<constraints>
<constraint
firstItem=
"CnQ-kP-08k"
firstAttribute=
"bottom"
secondItem=
"HN2-80-MUu"
secondAttribute=
"bottom"
constant=
"10"
id=
"5CH-CY-arC"
/>
<constraint
firstItem=
"iEN-Z8-WSa"
firstAttribute=
"centerX"
secondItem=
"CnQ-kP-08k"
secondAttribute=
"centerX"
id=
"AHn-2D-iCo"
/>
<constraint
firstItem=
"7mW-as-1Ow"
firstAttribute=
"leading"
secondItem=
"TWR-n9-3GS"
secondAttribute=
"leading"
id=
"Hgv-Aa-Z7O"
/>
<constraint
firstItem=
"j4f-2W-n3v"
firstAttribute=
"top"
secondItem=
"kyj-A5-ZZN"
secondAttribute=
"bottom"
constant=
"15"
id=
"PKs-Y9-tVp"
/>
<constraint
firstItem=
"UOH-Jk-9M5"
firstAttribute=
"top"
secondItem=
"dYL-zr-8sU"
secondAttribute=
"top"
id=
"QGc-z2-3hQ"
/>
<constraint
firstItem=
"kyj-A5-ZZN"
firstAttribute=
"top"
secondItem=
"iEN-Z8-WSa"
secondAttribute=
"bottom"
constant=
"80"
id=
"Qj0-mv-hk5"
/>
<constraint
firstItem=
"UOH-Jk-9M5"
firstAttribute=
"leading"
secondItem=
"dYL-zr-8sU"
secondAttribute=
"leading"
id=
"VCs-gc-xud"
/>
<constraint
firstItem=
"j4f-2W-n3v"
firstAttribute=
"centerX"
secondItem=
"CnQ-kP-08k"
secondAttribute=
"centerX"
id=
"W7j-vc-krB"
/>
<constraint
firstItem=
"CnQ-kP-08k"
firstAttribute=
"trailing"
secondItem=
"TWR-n9-3GS"
secondAttribute=
"trailing"
constant=
"15"
id=
"X4i-6n-n9J"
/>
<constraint
firstItem=
"7mW-as-1Ow"
firstAttribute=
"top"
secondItem=
"TWR-n9-3GS"
secondAttribute=
"bottom"
constant=
"-6"
id=
"aKg-UE-pBn"
/>
<constraint
firstAttribute=
"bottom"
secondItem=
"UOH-Jk-9M5"
secondAttribute=
"bottom"
id=
"bO1-z3-h9L"
/>
<constraint
firstItem=
"7mW-as-1Ow"
firstAttribute=
"trailing"
secondItem=
"TWR-n9-3GS"
secondAttribute=
"trailing"
id=
"bZ9-TX-c1y"
/>
<constraint
firstItem=
"TWR-n9-3GS"
firstAttribute=
"top"
secondItem=
"CnQ-kP-08k"
secondAttribute=
"top"
constant=
"10"
id=
"kUB-dB-HDp"
/>
<constraint
firstItem=
"kyj-A5-ZZN"
firstAttribute=
"centerY"
secondItem=
"CnQ-kP-08k"
secondAttribute=
"centerY"
id=
"rBv-t9-VV4"
/>
<constraint
firstItem=
"UOH-Jk-9M5"
firstAttribute=
"trailing"
secondItem=
"CnQ-kP-08k"
secondAttribute=
"trailing"
id=
"rqx-g0-qN2"
/>
<constraint
firstItem=
"HN2-80-MUu"
firstAttribute=
"centerX"
secondItem=
"CnQ-kP-08k"
secondAttribute=
"centerX"
id=
"w50-oT-za8"
/>
<constraint
firstItem=
"kyj-A5-ZZN"
firstAttribute=
"centerX"
secondItem=
"CnQ-kP-08k"
secondAttribute=
"centerX"
id=
"zM5-QF-b1p"
/>
</constraints>
</view>
<connections>
<outlet
property=
"skipButton"
destination=
"TWR-n9-3GS"
id=
"6t1-G5-K5k"
/>
<outlet
property=
"skipLineView"
destination=
"7mW-as-1Ow"
id=
"b3a-vj-xcn"
/>
</connections>
</viewController>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"5xP-ph-tof"
userLabel=
"First Responder"
customClass=
"UIResponder"
sceneMemberID=
"firstResponder"
/>
</objects>
<point
key=
"canvasLocation"
x=
"747.82608695652175"
y=
"-385.04464285714283"
/>
</scene>
</scenes>
<resources>
<image
name=
"wechat_login_bg"
width=
"375"
height=
"667"
/>
<image
name=
"wechat_login_btn_bg"
width=
"247"
height=
"59.5"
/>
<image
name=
"wechat_login_logo_icon"
width=
"119.5"
height=
"146.5"
/>
<systemColor
name=
"systemBackgroundColor"
>
<color
white=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
</systemColor>
</resources>
</document>
GYDemo/GYDemo/GYPrefixHeader.pch
View file @
5e820025
...
...
@@ -28,6 +28,8 @@
#define WXLoginState @"WTF"
#define WXLoginName @"WXLogin"
#define LaunchAdSuccesShow @"LaunchAdSuccesShow"
#define UMAppkey @"5f966f0d45b2b751a91b6012"
#define saltA @"HXHJ4KDL1QPFHGA0" // md5盐值
...
...
GYDemo/GYDemo/SCAds/IOSADManager.m
View file @
5e820025
...
...
@@ -575,7 +575,7 @@ static IOSADManager * manager = nil;
weakSelf
.
adShowBlock
(
success
);
weakSelf
.
showNow
=
NO
;
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
LaunchAdSuccesShow
object
:
nil
];
}
else
if
(
model
.
loadADType
==
ADType_BigImage
){
//原生
[
weakSelf
clearCache
:
model
];
...
...
GYDemo/GYDemo/ViewController/GYLoginViewController.m
View file @
5e820025
...
...
@@ -6,8 +6,13 @@
//
#import "GYLoginViewController.h"
#import "WXApi.h"
#import "GYWebViewController.h"
@interface
GYLoginViewController
()
@interface
GYLoginViewController
()
<
WXApiDelegate
>
@property
(
weak
,
nonatomic
)
IBOutlet
UIButton
*
skipButton
;
@property
(
weak
,
nonatomic
)
IBOutlet
UIView
*
skipLineView
;
@end
...
...
@@ -16,16 +21,123 @@
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
// Do any additional setup after loading the view.
// 隐藏 navigation bar 的 "返回"(或其他)
self
.
navigationItem
.
backBarButtonItem
=
[[
UIBarButtonItem
alloc
]
initWithTitle
:
@""
style
:(
UIBarButtonItemStylePlain
)
target
:
nil
action
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
WXLoginOauth
:
)
name
:
WXLoginName
object
:
nil
];
NSString
*
status
=
[[
CGUserManager
shared
].
appSwitch
[
@"isopenH5"
]
stringValue
];
NSLog
(
@"isopenH5 = %@"
,
status
);
if
([
status
isEqualToString
:
@"1"
])
{
self
.
skipButton
.
hidden
=
true
;
self
.
skipLineView
.
hidden
=
true
;
}
else
{
self
.
skipButton
.
hidden
=
false
;
self
.
skipLineView
.
hidden
=
false
;
}
}
/*
#pragma mark - Navigation
-
(
void
)
viewWillAppear
:
(
BOOL
)
animated
{
[
super
viewWillAppear
:
animated
];
[
self
.
navigationController
setNavigationBarHidden
:
true
animated
:
true
];
}
//
In a storyboard-based application, you will often want to do a little preparation before navigation
- (
void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id
)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
//
/ 跳过
-
(
IBAction
)
skipAction
:
(
UIButton
*
)
sender
{
[
self
.
view
removeFromSuperview
];
[
self
removeFromParentViewController
];
}
*/
/// 微信登录
-
(
IBAction
)
weichatLoginAction
:
(
UIButton
*
)
sender
{
Data
*
data
=
[[
Data
alloc
]
init
];
if
([[
data
Read
]
objectForKey
:
@"refresh_token"
]){
[
self
WXLoginOauth
:
nil
];
}
else
{
[[
CGUserManager
shared
]
addLocCollection
:
@"click_login"
value
:
@""
];
// 构造SendAuthReq结构体
SendAuthReq
*
req
=
[[
SendAuthReq
alloc
]
init
];
req
.
scope
=
@"snsapi_userinfo"
;
req
.
state
=
WXLoginState
;
//第三方向微信终端发送一个SendAuthReq消息结构
[
WXApi
sendAuthReq
:
req
viewController
:
self
delegate
:
UIApplication
.
sharedApplication
.
delegate
completion
:^
(
BOOL
success
)
{
if
(
!
success
){
[[
CGUserManager
shared
]
addLocCollection
:
@"login_fail"
value
:
@""
];
}
}];
}
}
-
(
void
)
WXLoginOauth
:
(
NSNotification
*
)
notification
{
NSDictionary
*
dict
=
notification
.
userInfo
;
[[
CGNetworkTools
shared
]
pureGetWithAdsTrackingAction
:[
NSString
stringWithFormat
:
@"https://api.weixin.qq.com/sns/oauth2/access_token?appid=%@&secret=%@&code=%@&grant_type=%@"
,
WXAppId
,
WXAppSecret
,
dict
[
@"code"
],
@"authorization_code"
]
success
:
^
(
id
_Nonnull
response
)
{
Data
*
data
=
[[
Data
alloc
]
init
];
if
([[
response
objectForKey
:
@"expires_in"
]
integerValue
]
==
7200
)
{
[
data
WirteDic
:[
response
objectForKey
:
@"openid"
]
Key
:
@"openid"
];
[
data
WirteDic
:[
response
objectForKey
:
@"access_token"
]
Key
:
@"access_token"
];
[
data
WirteDic
:[
response
objectForKey
:
@"refresh_token"
]
Key
:
@"refresh_token"
];
[
self
authWXLogin
];
}
else
if
([[
response
objectForKey
:
@"errcode"
]
integerValue
]
==
40163
||
[[
response
objectForKey
:
@"errcode"
]
integerValue
]
==
40029
)
{
[[
CGNetworkTools
shared
]
pureGetWithAdsTrackingAction
:[
NSString
stringWithFormat
:
@"https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=%@&grant_type=refresh_token&refresh_token=%@"
,
WXAppId
,[[
data
Read
]
objectForKey
:
@"refresh_token"
]]
success
:
^
(
id
_Nonnull
response
)
{
if
([[
response
objectForKey
:
@"expires_in"
]
integerValue
]
==
7200
)
{
[
data
WirteDic
:[
response
objectForKey
:
@"openid"
]
Key
:
@"openid"
];
[
data
WirteDic
:[
response
objectForKey
:
@"access_token"
]
Key
:
@"access_token"
];
[
data
WirteDic
:[
response
objectForKey
:
@"refresh_token"
]
Key
:
@"refresh_token"
];
[
self
authWXLogin
];
}
else
{
[[
CGUserManager
shared
]
addLocCollection
:
@"login_fail"
value
:[
NSString
stringWithFormat
:
@"%@"
,
[
response
objectForKey
:
@"errcode"
]]];
}
}
failure
:^
(
NSError
*
_Nonnull
error
)
{
[[
CGUserManager
shared
]
addLocCollection
:
@"login_fail"
value
:
@"netWork"
];
}];
}
else
{
[[
CGUserManager
shared
]
addLocCollection
:
@"login_fail"
value
:[
NSString
stringWithFormat
:
@"%@"
,
[
response
objectForKey
:
@"errcode"
]]];
}
}
failure
:^
(
NSError
*
_Nonnull
error
)
{
[[
CGUserManager
shared
]
addLocCollection
:
@"login_fail"
value
:
@"netWork"
];
}];
}
-
(
void
)
authWXLogin
{
Data
*
data
=
[[
Data
alloc
]
init
];
[[
CGNetworkTools
shared
]
postWithAction
:
wxLogin
parameters
:@{
@"accessToken"
:
[[
data
Read
]
objectForKey
:
@"access_token"
],
@"openid"
:
[[
data
Read
]
objectForKey
:
@"openid"
]}
success
:^
(
id
_Nonnull
response
)
{
if
([[
response
objectForKey
:
@"status"
]
integerValue
]
==
200
){
Data
*
data
=
[[
Data
alloc
]
init
];
[
data
WirteDic
:[[[
response
objectForKey
:
@"result"
]
objectForKey
:
@"data"
]
objectForKey
:
@"flushToken"
]
Key
:
@"flushToken"
];
[
self
skipAction
:
nil
];
}
}
failure
:^
(
NSError
*
_Nonnull
error
)
{
}];
}
-
(
IBAction
)
showUserAgentAndPolicyAction
:
(
UIButton
*
)
sender
{
if
(
sender
.
tag
==
1000
)
{
// 用户协议
GYWebViewController
*
webVc
=
[[
GYWebViewController
alloc
]
init
];
webVc
.
url
=
[[
CGUserManager
shared
].
h5_url
objectForKey
:
@"user"
];
webVc
.
showNav
=
TRUE
;
webVc
.
webTitle
=
@"用户协议"
;
[
self
.
navigationController
pushViewController
:
webVc
animated
:
true
];
}
else
{
// 隐私政策
GYWebViewController
*
webVc
=
[[
GYWebViewController
alloc
]
init
];
webVc
.
url
=
[[
CGUserManager
shared
].
h5_url
objectForKey
:
@"privacy"
];
webVc
.
showNav
=
TRUE
;
webVc
.
webTitle
=
@"隐私政策"
;
[
self
.
navigationController
pushViewController
:
webVc
animated
:
true
];
}
}
@end
GYDemo/GYDemo/ViewController/GYNative.storyboard
View file @
5e820025
...
...
@@ -124,7 +124,7 @@
</viewController>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"CKR-G4-A1x"
userLabel=
"First Responder"
customClass=
"UIResponder"
sceneMemberID=
"firstResponder"
/>
</objects>
<point
key=
"canvasLocation"
x=
"
949
"
y=
"88"
/>
<point
key=
"canvasLocation"
x=
"
696
"
y=
"88"
/>
</scene>
<!--Setting View Controller-->
<scene
sceneID=
"h25-Pj-YFy"
>
...
...
@@ -265,7 +265,7 @@
</viewController>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"mKI-BA-4uc"
userLabel=
"First Responder"
customClass=
"UIResponder"
sceneMemberID=
"firstResponder"
/>
</objects>
<point
key=
"canvasLocation"
x=
"1
900.0000000000002"
y=
"87.72321428571427
8"
/>
<point
key=
"canvasLocation"
x=
"1
462"
y=
"8
8"
/>
</scene>
</scenes>
<resources>
...
...
farm.xcworkspace/xcuserdata/mazy.xcuserdatad/UserInterfaceState.xcuserstate
View file @
5e820025
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment