This commit is contained in:
lianxiang
2018-09-29 20:12:56 +08:00
parent cb0accdb66
commit fc47921130
99 changed files with 1635 additions and 563 deletions
@@ -46,6 +46,7 @@
[self.checkBtn addTarget:self action:@selector(checkBtnAction:) forControlEvents:UIControlEventTouchUpInside];
[self resetBackimg];
}
-(void)resetBackimg{
@@ -122,7 +123,7 @@
NSDictionary *param = @{
@"mobile":phoneNumber
};
GiGaBaseAPiRequest *api = [GiGaBaseAPiRequest initWithRequestPath:@"msg/sms/v1/registersendcode" method:RequestPostMethod parms:param];
GiGaBaseAPiRequest *api = [GiGaBaseAPiRequest initWithRequestPath:kApiUserRegistSendCode method:RequestPostMethod parms:param];
[api requstDataWithResult:^(GiGaAPIResult *result) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
@@ -182,9 +183,10 @@
// [self.navigationController pushViewController:webView animated:YES];
GiGaWebViewController *webView = [[GiGaWebViewController alloc] init];
webView.souceType = WebSourceTypeUrlLink;
webView.url = @"http://www.youtansu.com";
webView.url = @"http://app.mianmoshijian.com/userAgrerment.html";
[self.navigationController pushViewController:webView animated:YES];
}
#pragma mark 注册
@@ -216,11 +218,16 @@
-(void)regeist:(UIButton *)btn{
btn.userInteractionEnabled = NO;
NSDictionary *weixinInfoDic = [GiGaUserDefault getWeiXinAccessToenDic];
//NSDictionary *weixinInfoDic = [GiGaUserDefault getWeiXinAccessToenDic];
NSString *wechatCode = [GiGaUserDefault getWeiXinCode];
NSDictionary *param = nil;
if (weixinInfoDic) {
param = @{@"username":self.phoneNumberTextField.text,@"verifiedCode":self.codeTextField.text,@"password":self.passTexFied.text,@"openid":weixinInfoDic[@"openid"]};
if (wechatCode) {
param = @{@"username":self.phoneNumberTextField.text,@"verifiedCode":self.codeTextField.text,@"password":self.passTexFied.text,@"wechatCode":wechatCode};
}else{
param = @{@"username":self.phoneNumberTextField.text,@"verifiedCode":self.codeTextField.text,@"password":self.passTexFied.text};
}
@@ -230,21 +237,49 @@
btn.userInteractionEnabled = YES;
GILog(@"注册->%@",result.message);
if (result.code == 0) {
NC_POST_NAME_OBJECT(kUserRegistSucccess,self.phoneNumberTextField.text);
GIGA_ShowToast(result.message);
[self.navigationController popToRootViewControllerAnimated:YES];
}else if (result.code == GiGAErrorCode_USER_EXIST){
GIGA_ShowToast(@"用户已存在");
NC_POST_NAME_OBJECT(kUserRegistSucccess,self.phoneNumberTextField.text);
if (result.success) {
// NC_POST_NAME_OBJECT(kUserRegistSucccess,self.phoneNumberTextField.text);
// GIGA_ShowToast(result.message);
// [self.navigationController popToRootViewControllerAnimated:YES];
if (result.dic) {
//token 登陆标志
[GiGaUserDefault saveToken:result.dic[@"token"]];
//埋点
[MobClick endEvent:MobClick_UserLogin];
GIGA_WIndowTost(@"登录成功!");
//请求用户数据
[[GiGaUserManager shareUser] synsisUserInfo:^(GiGaUser *user) {
GILog(@"user.userId:%@",user.userId);
NC_POST_NAME_OBJECT(kUserLoginSuccessNoti, nil);
[self dismissViewControllerAnimated:YES completion:nil];
} userErrorMsgBlock:^(NSDictionary *errorCodemsg) {
GILog(@"%@",errorCodemsg);
}];
}
}else{
GIGA_ShowToast(result.message);
}
}];
}
-(void)userloginAuto{
[[GiGaUserManager shareUser] synsisUserInfo:^(GiGaUser *user) {
GILog(@"user.userId:%@",user.userId);
NC_POST_NAME_OBJECT(kUserLoginSuccessNoti, nil);
} userErrorMsgBlock:^(NSDictionary *errorCodemsg) {
}];
}
-(void)checkBtnAction:(UIButton *)btn{
btn.selected = !btn.selected;
if (btn.selected) {
@@ -253,7 +288,7 @@
self.registBtn.userInteractionEnabled = YES;
}else{
[btn setImage:[UIImage imageNamed:@"btn_turndown"] forState:UIControlStateSelected];
[btn setImage:[UIImage imageNamed:@"btn_turndown"] forState:UIControlStateNormal];
[self.registBtn setBackgroundColor:[UIColor lightGrayColor]];
self.registBtn.userInteractionEnabled = NO;
@@ -265,4 +300,5 @@
// Dispose of any resources that can be recreated.
}
@end
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@@ -31,14 +31,14 @@
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="img_circle_avatar" translatesAutoresizingMaskIntoConstraints="NO" id="SEO-0F-Irb">
<rect key="frame" x="130" y="87" width="114" height="114"/>
<rect key="frame" x="130.5" y="87" width="114" height="114"/>
<constraints>
<constraint firstAttribute="width" constant="114" id="GOs-M2-rAk"/>
<constraint firstAttribute="height" constant="114" id="af0-Mm-2fL"/>
</constraints>
</imageView>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入手机号" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="uJG-KF-a91">
<rect key="frame" x="66" y="230" width="244" height="48"/>
<rect key="frame" x="66" y="230" width="243" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="pzi-4C-7s8"/>
</constraints>
@@ -47,14 +47,14 @@
<textInputTraits key="textInputTraits" keyboardType="numberPad"/>
</textField>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ubQ-Za-dV7">
<rect key="frame" x="65" y="280" width="245" height="1"/>
<rect key="frame" x="65" y="280" width="244" height="1"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.94901960784313721" blue="0.94901960784313721" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="Gbv-lr-zmA"/>
</constraints>
</view>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="短信验证码" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="dR7-iu-Eup">
<rect key="frame" x="66" y="286" width="131" height="48"/>
<rect key="frame" x="66" y="286" width="130" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="Iqo-gI-2Z3"/>
</constraints>
@@ -63,7 +63,7 @@
<textInputTraits key="textInputTraits" keyboardType="numberPad"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qAH-Fa-AmF">
<rect key="frame" x="222" y="286" width="88" height="48"/>
<rect key="frame" x="221" y="286" width="88" height="48"/>
<constraints>
<constraint firstAttribute="width" constant="88" id="kZw-pm-n5p"/>
<constraint firstAttribute="height" constant="48" id="oB6-lP-x7P"/>
@@ -76,14 +76,14 @@
</state>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Trq-bz-kQT">
<rect key="frame" x="65" y="336" width="245" height="1"/>
<rect key="frame" x="65" y="336" width="244" height="1"/>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="BYZ-mC-rOK"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Pb5-1e-TXp">
<rect key="frame" x="65" y="395" width="245" height="1"/>
<rect key="frame" x="65.5" y="395" width="244" height="1"/>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="SYH-LK-7FR"/>
@@ -105,7 +105,7 @@
<color key="highlightedColor" red="0.56862745100000001" green="0.56862745100000001" blue="0.56862745100000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</label>
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="设置登录密码" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="UUC-74-fsa">
<rect key="frame" x="65" y="345" width="245" height="48"/>
<rect key="frame" x="65.5" y="345" width="244" height="48"/>
<constraints>
<constraint firstAttribute="height" constant="48" id="o8f-Xh-HGs"/>
</constraints>
@@ -142,7 +142,7 @@
<constraint firstItem="ubQ-Za-dV7" firstAttribute="top" secondItem="uJG-KF-a91" secondAttribute="bottom" constant="2" id="aeU-Sw-M2f"/>
<constraint firstItem="Vxb-TL-wDd" firstAttribute="leading" secondItem="b06-w9-r2g" secondAttribute="trailing" constant="3.5" id="bJR-59-KMw"/>
<constraint firstItem="qAH-Fa-AmF" firstAttribute="centerY" secondItem="dR7-iu-Eup" secondAttribute="centerY" id="eJi-uE-qBs"/>
<constraint firstItem="hZA-nj-Wmu" firstAttribute="leading" secondItem="piO-PU-j8g" secondAttribute="leading" constant="84" id="fcO-XF-ODc"/>
<constraint firstItem="hZA-nj-Wmu" firstAttribute="leading" relation="lessThanOrEqual" secondItem="piO-PU-j8g" secondAttribute="leading" constant="84" id="fcO-XF-ODc"/>
<constraint firstItem="uJG-KF-a91" firstAttribute="centerX" secondItem="piO-PU-j8g" secondAttribute="centerX" id="flh-N1-FvK"/>
<constraint firstItem="qAH-Fa-AmF" firstAttribute="trailing" secondItem="uJG-KF-a91" secondAttribute="trailing" id="fsZ-rC-rlA"/>
<constraint firstAttribute="trailing" secondItem="ubQ-Za-dV7" secondAttribute="trailing" constant="65" id="j6B-5X-ymb"/>
+33 -26
View File
@@ -188,14 +188,16 @@
-(void)loginWithAction:(UIButton *)btn{
NSDictionary *weixinInfoDic = [GiGaUserDefault getWeiXinAccessToenDic];
// NSDictionary *weixinInfoDic = [GiGaUserDefault getWeiXinAccessToenDic];
NSString *wechatCode = [GiGaUserDefault getWeiXinCode];
NSDictionary *params = nil;
if (weixinInfoDic) {
if (wechatCode) {
params = @{
@"username":self.acountTextField.text,
@"password":self.passwordTextField.text,
@"openid":weixinInfoDic[@"openid"],
@"wechatCode":wechatCode,
};
}else{
@@ -241,33 +243,37 @@
}
}
//授权成功获取access_token
//授权成功获取access_token(改服务器获取)
-(void)WeiXinLongIn:(NSNotification *)notification{
//检查网络
//[self testNetworkStatus];
//保存code 首次授权微信登陆需要先绑定手机号(必须注册手机账号)
[GiGaUserDefault saveWeiXinCode:notification.object[@"code"]];
[self.view makeToastActivity:CSToastPositionCenter];
NSDictionary *param = @{
@"appid":WXin_APPID,
@"secret":WXin_APPSecret,
@"code":notification.object[@"code"],
@"grant_type":@"authorization_code"
@"code":notification.object[@"code"]
};
[WeiIXinApiManager weixinAccessTokeRequstUrl:@"https://api.weixin.qq.com/sns/oauth2/access_token" parameters:param success:^(id response) {
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingAllowFragments error:nil];
GILog(@"access_token back -->%@",dict);
[GiGaUserDefault saveWeiXinaccesstokenInfoWithDic:dict];
[self requstWeiXinUserinfo];
} failure:^(NSError *err) {
[self.view makeToast:err.localizedDescription];
GILog(@"access_token err-->%@",err.localizedDescription);
}];
[self gigaUploadweixinInfo:param];
// NSDictionary *param = @{
// @"appid":WXin_APPID,
// @"secret":WXin_APPSecret,
// @"code":notification.object[@"code"],
// @"grant_type":@"authorization_code"
// };
//
// [WeiIXinApiManager weixinAccessTokeRequstUrl:@"https://api.weixin.qq.com/sns/oauth2/access_token" parameters:param success:^(id response) {
// NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingAllowFragments error:nil];
// GILog(@"access_token back -->%@",dict);
// [GiGaUserDefault saveWeiXinaccesstokenInfoWithDic:dict];
// [self requstWeiXinUserinfo];
//
// } failure:^(NSError *err) {
// [self.view makeToast:err.localizedDescription];
// GILog(@"access_token err-->%@",err.localizedDescription);
// }];
}
//获取微信用户信息
//获取微信用户信息 (改由服务器请求获取)
-(void)requstWeiXinUserinfo{
@@ -280,7 +286,7 @@
[WeiIXinApiManager getWeiXinUserInfoUrl:@"https://api.weixin.qq.com/sns/userinfo" parameters:param success:^(id response) {
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingAllowFragments error:nil];
GILog(@"weixinUser info back -->%@",dict);
[self gigaUploadweixinInfo:dict];
// [self gigaUploadweixinInfo:dict];
} failure:^(NSError *err) {
[self.view makeToast:err.localizedDescription];
@@ -292,7 +298,8 @@
-(void)gigaUploadweixinInfo:(NSDictionary *)weiXinUserinfo{
[self.view makeToastActivity:CSToastPositionCenter];
NSString *url = [NSString stringWithFormat:@"%@sys/v1/wechatlogin",[GiGaServerConfig getMainUrl]];
NSString *url = [NSString stringWithFormat:@"%@%@",[GiGaServerConfig getMainUrl],kApiWeiChatLogin];
[GiGaNetManager requestMethod:RequestPostMethod Url:url params:weiXinUserinfo responseBlock:^(NSDictionary *responseDict, NSDictionary *responseHeaderFields, NSError *error) {
[self.view hideToastActivity];
if (!error) {
@@ -303,8 +310,8 @@
}else if([responseDict[@"code"] integerValue] == 500){
//登录流程待定
[self.view makeToast:responseDict[@"msg"] duration:2.0 position:CSToastPositionCenter];
[self jxt_showAlertWithTitle:@"温馨提示" message:@"请绑定手机号" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
[self jxt_showAlertWithTitle:@"温馨提示" message:@"绑定手机" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"知道了");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
}];
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14113" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14088"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@@ -53,7 +53,7 @@
</constraints>
<nil key="textColor"/>
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="12"/>
<textInputTraits key="textInputTraits" keyboardType="numbersAndPunctuation"/>
<textInputTraits key="textInputTraits" keyboardType="numbersAndPunctuation" secureTextEntry="YES"/>
</textField>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ZJU-Uo-5TM">
<rect key="frame" x="65" y="331" width="245" height="2"/>
@@ -96,14 +96,14 @@
<state key="normal" image="btn_tab_desplay"/>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="img_circle_avatar" translatesAutoresizingMaskIntoConstraints="NO" id="RIl-8E-GcR">
<rect key="frame" x="131" y="82" width="114" height="114"/>
<rect key="frame" x="130.5" y="82" width="114" height="114"/>
<constraints>
<constraint firstAttribute="height" constant="114" id="JgO-PU-ypI"/>
<constraint firstAttribute="width" constant="114" id="mG0-1p-gP7"/>
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" hasAttributedTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dnL-WV-spY">
<rect key="frame" x="115" y="523" width="144" height="38"/>
<rect key="frame" x="115.5" y="523" width="144" height="38"/>
<constraints>
<constraint firstAttribute="height" constant="38" id="l1O-3i-Plv"/>
<constraint firstAttribute="width" constant="144" id="zzO-p2-ENu"/>
@@ -122,7 +122,7 @@
</state>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="F5p-cf-frr">
<rect key="frame" x="108" y="436" width="161" height="40"/>
<rect key="frame" x="107" y="436" width="161" height="40"/>
<constraints>
<constraint firstAttribute="width" constant="161" id="EU3-ax-K1r"/>
<constraint firstAttribute="height" constant="40" id="W9a-lX-GbY"/>
@@ -64,7 +64,9 @@
[self.view makeToast:@"链接为空" duration:1 position:CSToastPositionCenter];
return;
}
NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:self.url]];
NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:self.url]];
[req setValue:@"ios" forHTTPHeaderField:@"device"];
[_webview loadRequest:req];
}
break;