Initial commit

This commit is contained in:
ifish
2017-08-15 16:59:01 +08:00
commit bdc83e07ef
5766 changed files with 423223 additions and 0 deletions
Binary file not shown.
@@ -0,0 +1,13 @@
//
// AgreementViewController.h
// Ifish
//
// Created by imac on 15/10/26.
// Copyright © 2015年 imac. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "BaseVIewContorller.h"
@interface AgreementViewController : BaseVIewContorller
@end
@@ -0,0 +1,87 @@
//
// AgreementViewController.m
// Ifish
//
// Created by imac on 15/10/26.
// Copyright © 2015年 imac. All rights reserved.
//
#import "AgreementViewController.h"
#import "MBProgressHUD.h"
@interface AgreementViewController ()<UIWebViewDelegate,MBProgressHUDDelegate>
@property(nonatomic,strong)UIWebView*myWebView;
@property(nonatomic,strong)MBProgressHUD *HUD;
@end
@implementation AgreementViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self initWebView];
[self addTitleViewWithTitle:@"爱鱼奇用户注册协议"];
}
-(void)creatHUd{
_HUD=[MBProgressHUD showHUDAddedTo:self.myWebView animated:YES];
_HUD.delegate=self;
_HUD.color=[UIColor lightGrayColor];
_HUD.labelText=@"loding...";
_HUD.detailsLabelText=@"加载中";
_HUD.backgroundColor=[UIColor colorWithRed:36.0/256.0 green:72.0/256.0 blue:107.0/256.0 alpha:1];;
_HUD.dimBackground=YES;
}
-(void)initWebView{
self.myWebView=[[UIWebView alloc]initWithFrame:self.view.bounds];
// NSURLRequest*requst=[NSURLRequest requestWithURL:[NSURL URLWithString:kIfishHtml]];
NSString*filepath=[[NSBundle mainBundle]pathForResource:@"service" ofType:@"html"];
NSString*html=[NSString stringWithContentsOfFile:filepath encoding:NSUTF8StringEncoding error:nil];
[self.myWebView loadHTMLString:html baseURL:[NSURL URLWithString:filepath]];
[self.view addSubview:self.myWebView];
}
-(void)webViewDidStartLoad:(UIWebView *)webView{
[self creatHUd];
}
-(void)webViewDidFinishLoad:(UIWebView *)webView{
[_HUD hide:YES afterDelay:2.0];
}
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
[_HUD hide:YES afterDelay:2.0];
[self showLableAction:@"加载失败"];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)showLableAction:(NSString *)str{
UILabel *laberAction =[[UILabel alloc]init];
laberAction.frame =CGRectMake(kScreenSize.width/2 - 75, kScreenSize.height/2 - 75, 150, 50);
laberAction.clipsToBounds =YES;
laberAction.layer.cornerRadius =3;
laberAction.alpha =1.0;
laberAction.text =str;
laberAction.textAlignment =NSTextAlignmentCenter;
laberAction.backgroundColor =[UIColor grayColor];
[UIView animateWithDuration:2.0 animations:^{
laberAction.alpha =0;
}completion:^(BOOL finished) {
[laberAction removeFromSuperview];
}];
[self.view addSubview:laberAction];
}
/*
#pragma mark - Navigation
// 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.
}
*/
@end
@@ -0,0 +1,19 @@
//
// ForgetViewController.h
// Ifish
//
// Created by imac on 15/9/27.
// Copyright © 2015年 imac. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "BaseVIewContorller.h"
@interface ForgetViewController : BaseVIewContorller
@property (weak, nonatomic) IBOutlet UITextField *phoneNumberFiled;
@property (weak, nonatomic) IBOutlet UITextField *verifyTextFiled;
- (IBAction)nextStep:(id)sender;
@property (weak, nonatomic) IBOutlet UIView *countryView;
@property (weak, nonatomic) IBOutlet UIButton *countryCodeBtn;
@end
@@ -0,0 +1,239 @@
//
// ForgetViewController.m
// Ifish
//
// Created by imac on 15/9/27.
// Copyright © 2015年 imac. All rights reserved.
//
#import "ForgetViewController.h"
#import "ResetViewController.h"
#import "AFNetworking.h"
#import "XWCountryCodeController.h"
@interface ForgetViewController ()
@property (weak, nonatomic) IBOutlet UIButton *timerButton;
@property (weak, nonatomic) IBOutlet UIButton *nextTepBtn;
@property(nonatomic,copy)NSString*verifyData;
@property(nonatomic,copy) NSString *areaCode;
@end
@implementation ForgetViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self addTitleViewWithTitle:@"忘记密码"];
self.view.backgroundColor= [UIColor colorWithPatternImage:[UIImage imageNamed:@"enter_background"]];
[self setTextkeyboadType];
// UIImage *backImage = [UIImage imageNamed:@"leftItem"];
// [[UIBarButtonItem appearance] setBackButtonBackgroundImage:[backImage resizableImageWithCapInsets:UIEdgeInsetsMake(0,20,0, 0)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
// [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0,-60) forBarMetrics:UIBarMetricsDefault];
//
//默认86
self.areaCode = @"86";
[_timerButton addTarget:self action:@selector(timeTap) forControlEvents:UIControlEventTouchUpInside];
[self.countryCodeBtn addTarget:self action:@selector(countryCodeBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
-(void)setTextkeyboadType{
self.phoneNumberFiled.layer.masksToBounds=YES;
self.phoneNumberFiled.layer.cornerRadius=6;
self.verifyTextFiled.layer.masksToBounds=YES;
self.verifyTextFiled.layer.cornerRadius=6;
_timerButton.layer.masksToBounds=YES;
_timerButton.layer.cornerRadius=6;
_timerButton.backgroundColor=COLOR_LABEL_TITLE;
_nextTepBtn.layer.masksToBounds=YES;
_nextTepBtn.layer.cornerRadius=6;
_nextTepBtn.backgroundColor=COLOR_LABEL_TITLE;
self.countryView.layer.masksToBounds = YES;
self.countryView.layer.cornerRadius = 6;
UIView*phoneView=[[UIView alloc]initWithFrame:CGRectMake(0,0, 10, 10)];
self.phoneNumberFiled.leftView=phoneView;
self.phoneNumberFiled.leftViewMode=UITextFieldViewModeAlways;
UIView*phoneView1=[[UIView alloc]initWithFrame:CGRectMake(0,0, 10, 10)];
self.verifyTextFiled.leftView=phoneView1;
self.verifyTextFiled.leftViewMode=UITextFieldViewModeAlways;
}
-(void)timeTap{
if (self.phoneNumberFiled.text.length==0) {
[self.view makeToast:@"请输入正确手机号"];
return;
}
__block int timeout=60; //倒计时时间
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_source_t _timer1 = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
dispatch_source_set_timer(_timer1,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
dispatch_source_set_event_handler(_timer1, ^{
if(timeout<=0){ //倒计时结束,关闭
dispatch_source_cancel(_timer1);
dispatch_async(dispatch_get_main_queue(), ^{
//设置界面的按钮显示 根据自己需求设置
[_timerButton setTitle:@"发送验证码" forState:UIControlStateNormal];
_timerButton.userInteractionEnabled = YES;
});
}else{
// int minutes = timeout / 60;
int seconds = timeout % 60;
NSString *strTime=@"";
if (seconds==0) {
strTime=@"60";
}else{
strTime = [NSString stringWithFormat:@"%.2d", seconds];
}
dispatch_async(dispatch_get_main_queue(), ^{
//设置界面的按钮显示 根据自己需求设置
NSLog(@"____%@",strTime);
[_timerButton setTitle:[NSString stringWithFormat:@"%@秒后发送",strTime] forState:UIControlStateNormal];
_timerButton.userInteractionEnabled = NO;
_timerButton.backgroundColor=[UIColor lightGrayColor];
});
timeout--;
}
});
dispatch_resume(_timer1);
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
NSString*forgetPhoneNumber=self.phoneNumberFiled.text;
[userdefult setObject:forgetPhoneNumber forKey:@"forgetPhoneNumber"];
[userdefult synchronize];
[self getVerifycode];
}
#pragma mark - 获取验证码新(SMS
-(void)getVerifycode{
[IFISHHTTPTOOL getverifyWithTimerButton:_timerButton addphoneNumber:self.phoneNumberFiled.text zone:self.areaCode result:^(NSError *err) {
}];
}
#define mark - 获取阿里验证码 已去
-(void)getAliVerify{
[AFHttpTool getSecurityCodeWithPhoneNumber:self.phoneNumberFiled.text sendType:@"2" success:^(id response) {
if (response) {
NSDictionary *reDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
_verifyData=reDic[@"data"];
if ([reDic[@"result"] isEqualToString:@"100"]) {
[self.view makeToast:@"验证码发送成功"];
}else if([reDic[@"result"] isEqualToString:@"101"]){
[self.view makeToast:@"获取验证失败"];
// 获取验证失败
}else if ([reDic[@"result"] isEqualToString:@"201"]){
[self.view makeToast:@"手机已经注册过"];
}else if([reDic[@"result"] isEqualToString:@"202"]){
[self.view makeToast:@"手机未注册"];
}else if([reDic[@"result"] isEqualToString:@"203"]){
}
}
} failure:^(NSError *err) {
UIAlertView *alter =[[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请检查您的网络" delegate:self cancelButtonTitle:@"取消" otherButtonTitles: nil];
[alter show];
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark-处理收键盘
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[self hiddenKeybord];
}
-(void)hiddenKeybord{
[self.phoneNumberFiled resignFirstResponder];
[self.verifyTextFiled resignFirstResponder];
}
- (IBAction)nextStep:(id)sender {
//BOOL isMacth=[dataContorl valiMobile:self.phoneNumberFiled.text];
if (self.verifyTextFiled.text.length==0) {
[self.view makeToast:@"请输入正确验证码和手机号"];
return;
}
__weak typeof(self)weakSelf=self;
[SMSSDK commitVerificationCode:weakSelf.verifyTextFiled.text phoneNumber:weakSelf.phoneNumberFiled.text zone:weakSelf.areaCode result:^(SMSSDKUserInfo *userInfo, NSError *error) {
{
if (!error)
{
NSLog(@"验证成功");
ResetViewController*vc=[[ResetViewController alloc]init];
[weakSelf.navigationController pushViewController:vc animated:YES];
}
else
{
NSLog(@"错误信息:%@",error);
NSString *str =@"验证码验证失败";
[self.view makeToast:str];
}
}
}];
}
#pragma mark - 选择国家
-(void)countryCodeBtnAction
{
XWCountryCodeController *CountryCodeVC = [[XWCountryCodeController alloc] init];
[CountryCodeVC toReturnCountryCode:^(NSString *countryCodeStr) {
[self.countryCodeBtn setTitle:countryCodeStr forState:UIControlStateNormal];
NSArray *array = [countryCodeStr componentsSeparatedByString:@"+"];
self.areaCode = array[1];
}];
[self presentViewController:CountryCodeVC animated:YES completion:nil];
}
@end
@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina5_5" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ForgetViewController">
<connections>
<outlet property="countryCodeBtn" destination="kqZ-N3-UXK" id="Koj-0F-kCD"/>
<outlet property="countryView" destination="Kuc-iA-yGB" id="lJV-d6-vuw"/>
<outlet property="nextTepBtn" destination="ONp-Rz-9VY" id="svf-xf-Go3"/>
<outlet property="phoneNumberFiled" destination="9AU-7X-or2" id="oi7-IL-dVy"/>
<outlet property="timerButton" destination="qvS-eF-OGr" id="eFS-2p-xwc"/>
<outlet property="verifyTextFiled" destination="m6b-aY-UbD" id="KIH-4Q-u1O"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Fse-85-LUi">
<rect key="frame" x="21" y="93" width="372" height="300.33333333333331"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入您的手机号" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="9AU-7X-or2">
<rect key="frame" x="25" y="75.666666666666657" width="322" height="47.666666666666686"/>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="9AU-7X-or2" secondAttribute="height" multiplier="283:42" id="IW4-cg-TR8"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" keyboardType="numberPad"/>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入短信验证码" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="m6b-aY-UbD">
<rect key="frame" x="25" y="132.33333333333337" width="322" height="47.666666666666657"/>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="m6b-aY-UbD" secondAttribute="height" multiplier="283:42" id="FIB-ry-7SG"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ONp-Rz-9VY">
<rect key="frame" x="25" y="208" width="322" height="49"/>
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="ONp-Rz-9VY" secondAttribute="height" multiplier="283:43" id="7QK-kc-iEt"/>
</constraints>
<state key="normal" title="下一步">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="nextStep:" destination="-1" eventType="touchUpInside" id="eCT-th-Hqi"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qvS-eF-OGr">
<rect key="frame" x="261" y="132.33333333333337" width="86" height="47.666666666666657"/>
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="86" id="p4x-JI-IVe"/>
</constraints>
<state key="normal" title="语音验证码">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Kuc-iA-yGB">
<rect key="frame" x="25" y="20" width="322" height="47.666666666666657"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="国家/地区" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4t2-r8-Y7e">
<rect key="frame" x="10" y="13" width="71" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="kBo-mD-Uyr"/>
<constraint firstAttribute="width" constant="71" id="sSK-8u-5YK"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="kqZ-N3-UXK">
<rect key="frame" x="102" y="5" width="212" height="39"/>
<constraints>
<constraint firstAttribute="width" constant="212" id="mfY-IJ-ZE0"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="区号">
<color key="titleColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
</button>
</subviews>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="kqZ-N3-UXK" firstAttribute="centerY" secondItem="Kuc-iA-yGB" secondAttribute="centerY" id="Epi-7M-LkN"/>
<constraint firstAttribute="width" secondItem="Kuc-iA-yGB" secondAttribute="height" multiplier="283:42" id="Nq1-PQ-s9o"/>
<constraint firstItem="kqZ-N3-UXK" firstAttribute="top" secondItem="Kuc-iA-yGB" secondAttribute="top" constant="5" id="SvQ-gG-zEs"/>
<constraint firstAttribute="trailing" secondItem="kqZ-N3-UXK" secondAttribute="trailing" constant="8" id="ViY-4n-Z5K"/>
<constraint firstAttribute="bottom" secondItem="kqZ-N3-UXK" secondAttribute="bottom" constant="3.6666666666666572" id="mUU-ug-PrM"/>
<constraint firstItem="4t2-r8-Y7e" firstAttribute="leading" secondItem="Kuc-iA-yGB" secondAttribute="leading" constant="10" id="vKq-xC-I44"/>
<constraint firstItem="4t2-r8-Y7e" firstAttribute="centerY" secondItem="Kuc-iA-yGB" secondAttribute="centerY" id="wUe-7b-dhI"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="ONp-Rz-9VY" firstAttribute="centerX" secondItem="Fse-85-LUi" secondAttribute="centerX" id="1Uc-9K-ZcF"/>
<constraint firstItem="m6b-aY-UbD" firstAttribute="leading" secondItem="Fse-85-LUi" secondAttribute="leading" constant="25" id="2bO-03-WdP"/>
<constraint firstItem="Kuc-iA-yGB" firstAttribute="leading" secondItem="Fse-85-LUi" secondAttribute="leading" constant="25" id="3Ls-er-sDi"/>
<constraint firstAttribute="trailing" secondItem="m6b-aY-UbD" secondAttribute="trailing" constant="25" id="4po-zB-k2O"/>
<constraint firstItem="qvS-eF-OGr" firstAttribute="height" secondItem="m6b-aY-UbD" secondAttribute="height" id="7fW-dZ-bcG"/>
<constraint firstAttribute="trailing" secondItem="9AU-7X-or2" secondAttribute="trailing" constant="25" id="BPA-jS-yUj"/>
<constraint firstItem="ONp-Rz-9VY" firstAttribute="top" secondItem="m6b-aY-UbD" secondAttribute="bottom" constant="28" id="C7t-Kf-WQ8"/>
<constraint firstItem="9AU-7X-or2" firstAttribute="top" secondItem="Kuc-iA-yGB" secondAttribute="bottom" constant="8" id="L1w-J9-O6C"/>
<constraint firstItem="m6b-aY-UbD" firstAttribute="top" secondItem="9AU-7X-or2" secondAttribute="bottom" constant="9" id="LbP-7q-Ho8"/>
<constraint firstItem="qvS-eF-OGr" firstAttribute="leading" secondItem="m6b-aY-UbD" secondAttribute="trailing" constant="-86" id="Lij-Yz-btH"/>
<constraint firstAttribute="trailing" secondItem="Kuc-iA-yGB" secondAttribute="trailing" constant="25" id="MoP-80-S8X"/>
<constraint firstItem="m6b-aY-UbD" firstAttribute="centerX" secondItem="Fse-85-LUi" secondAttribute="centerX" id="Qur-Jo-Efx"/>
<constraint firstAttribute="trailing" secondItem="ONp-Rz-9VY" secondAttribute="trailing" constant="25" id="dmo-K3-nIC"/>
<constraint firstAttribute="width" secondItem="Fse-85-LUi" secondAttribute="height" multiplier="333:224" constant="-74.33035714285711" id="hja-fF-Y7Q"/>
<constraint firstItem="qvS-eF-OGr" firstAttribute="top" secondItem="m6b-aY-UbD" secondAttribute="top" id="kfP-5U-Shn"/>
<constraint firstItem="ONp-Rz-9VY" firstAttribute="leading" secondItem="Fse-85-LUi" secondAttribute="leading" constant="25" id="lyF-sE-wiC"/>
<constraint firstItem="qvS-eF-OGr" firstAttribute="bottom" secondItem="m6b-aY-UbD" secondAttribute="bottom" id="mHf-AZ-g3T"/>
<constraint firstItem="9AU-7X-or2" firstAttribute="leading" secondItem="Fse-85-LUi" secondAttribute="leading" constant="25" id="mco-Fk-Z4F"/>
<constraint firstItem="Kuc-iA-yGB" firstAttribute="top" secondItem="Fse-85-LUi" secondAttribute="top" constant="20" id="nK2-hI-tfT"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="Fse-85-LUi" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" constant="93" id="7zB-k3-mMF"/>
<constraint firstItem="Fse-85-LUi" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="21" id="DIH-iP-b1m"/>
<constraint firstItem="Fse-85-LUi" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="LLh-ff-Y3Y"/>
<constraint firstAttribute="trailing" secondItem="Fse-85-LUi" secondAttribute="trailing" constant="21" id="lcA-DR-slz"/>
</constraints>
<point key="canvasLocation" x="368" y="327"/>
</view>
</objects>
</document>
Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

@@ -0,0 +1,47 @@
// 好用请starhttps://github.com/AllLuckly/LBLaunchImageAd
// LBLaunchImageAdView.h
// LBLaunchImageAd
// 技术交流群:534926022(免费) 511040024(0.8元/人付费)
// Created by gold on 16/6/8.
// Copyright © 2016年 Bison. All rights reserved.
// iOS开发学习app下载https://itunes.apple.com/cn/app/it-blog-for-ios-developers/id1067787090?mt=8
typedef enum {
LogoAdType = 0,///带logo的广告
FullScreenAdType = 1,///全屏的广告
}AdType;
typedef enum {
skipAdType = 1,///点击跳过
clickAdType = 2,///点击广告
overtimeAdType = 3,///倒计时完成跳过
}clickType;
#import <UIKit/UIKit.h>
typedef void (^LBClick) (const clickType);
@interface LBLaunchImageAdView : UIView
@property (nonatomic, strong) UIImageView *aDImgView;
///倒计时总时长,默认6秒
@property (nonatomic, assign) NSInteger adTime;
///跳过按钮 可自定义
@property (nonatomic, strong) UIButton *skipBtn;
///本地图片名字
@property (nonatomic, copy) NSString *localAdImgName;
///网络图片URL
@property (nonatomic, copy) NSString *imgUrl;
@property (nonatomic, copy)LBClick clickBlock;
/*
* adType 广告类型
*/
- (void(^)(AdType const adType))getLBlaunchImageAdViewType;
@end
@@ -0,0 +1,254 @@
// 好用请starhttps://github.com/AllLuckly/LBLaunchImageAd
// LBLaunchImageAdView.m
// LBLaunchImageAd
// 技术交流群:534926022(免费) 511040024(0.8元/人付费)
// Created by gold on 16/6/8.
// Copyright © 2016年 Bison. All rights reserved.
// iOS开发学习app下载https://itunes.apple.com/cn/app/it-blog-for-ios-developers/id1067787090?mt=8
#import "LBLaunchImageAdView.h"
#import "UIImageView+WebCache.h"
#define mainHeight [[UIScreen mainScreen] bounds].size.height
#define mainWidth [[UIScreen mainScreen] bounds].size.width
@interface LBLaunchImageAdView()
{
NSTimer *countDownTimer;
}
@property (strong, nonatomic) NSString *isClick;
@end
@implementation LBLaunchImageAdView
#pragma mark - 获取广告类型
- (void (^)(AdType adType))getLBlaunchImageAdViewType{
__weak typeof(self) weakSelf = self;
return ^(AdType adType){
[weakSelf addLBlaunchImageAdView:adType];
};
}
#pragma mark - 点击广告
- (void)activiTap:(UITapGestureRecognizer*)recognizer{
_isClick = @"2";
//[self startcloseAnimation];
[self closeAddImgAnimation];
}
#pragma mark - 开启关闭动画
- (void)startcloseAnimation{
CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
opacityAnimation.duration = 0.5;
opacityAnimation.fromValue = [NSNumber numberWithFloat:1.0];
opacityAnimation.toValue = [NSNumber numberWithFloat:0.3];
opacityAnimation.removedOnCompletion = NO;
opacityAnimation.fillMode = kCAFillModeForwards;
[self.aDImgView.layer addAnimation:opacityAnimation forKey:@"animateOpacity"];
[NSTimer scheduledTimerWithTimeInterval:opacityAnimation.duration
target:self
selector:@selector(closeAddImgAnimation)
userInfo:nil
repeats:NO];
}
- (void)skipBtnClick{
_isClick = @"1";
//[self startcloseAnimation];
[self closeAddImgAnimation];
}
#pragma mark - 关闭动画完成时处理事件
-(void)closeAddImgAnimation
{
[countDownTimer invalidate];
countDownTimer = nil;
//self.hidden = YES;
//self.aDImgView.hidden = YES;
[self removeFromSuperview];
if ([_isClick integerValue] == 2) {
if (self.clickBlock) {//点击广告
self.clickBlock(clickAdType);
}
}else if([_isClick integerValue] == 1){
if (self.clickBlock) {//点击跳过
self.clickBlock(skipAdType);
}
}else{
if (self.clickBlock) {
self.clickBlock(overtimeAdType);
}
}
}
- (void)onTimer {
if (_adTime == 0) {
[countDownTimer invalidate];
countDownTimer = nil;
//[self startcloseAnimation];
_isClick = @"3";
[self closeAddImgAnimation];
}else{
[self.skipBtn setTitle:[NSString stringWithFormat:@"%@ | 跳过",@(_adTime--)] forState:UIControlStateNormal];
}
}
#pragma mark - 指定宽度按比例缩放
- (UIImage *)imageCompressForWidth:(UIImage *)sourceImage targetWidth:(CGFloat)defineWidth {
UIImage *newImage = nil;
CGSize imageSize = sourceImage.size;
CGFloat width = imageSize.width;
CGFloat height = imageSize.height;
CGFloat targetWidth = defineWidth;
CGFloat targetHeight = height / (width / targetWidth);
CGSize size = CGSizeMake(targetWidth, targetHeight);
CGFloat scaleFactor = 0.0;
CGFloat scaledWidth = targetWidth;
CGFloat scaledHeight = targetHeight;
CGPoint thumbnailPoint = CGPointMake(0.0, 0.0);
if(CGSizeEqualToSize(imageSize, size) == NO){
CGFloat widthFactor = targetWidth / width;
CGFloat heightFactor = targetHeight / height;
if(widthFactor > heightFactor){
scaleFactor = widthFactor;
}
else{
scaleFactor = heightFactor;
}
scaledWidth = width * scaleFactor;
scaledHeight = height * scaleFactor;
if(widthFactor > heightFactor){
thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;
}else if(widthFactor < heightFactor){
thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
}
}
// UIGraphicsBeginImageContext(size);
UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale);
CGRect thumbnailRect = CGRectZero;
thumbnailRect.origin = thumbnailPoint;
thumbnailRect.size.width = scaledWidth;
thumbnailRect.size.height = scaledHeight;
[sourceImage drawInRect:thumbnailRect];
newImage = UIGraphicsGetImageFromCurrentImageContext();
if(newImage == nil){
NSLog(@"scale image fail");
}
UIGraphicsEndImageContext();
return newImage;
}
- (void)setLocalAdImgName:(NSString *)localAdImgName{
_localAdImgName = localAdImgName;
if (_localAdImgName) {
if ([_localAdImgName rangeOfString:@".gif"].location != NSNotFound ) {
_localAdImgName = [_localAdImgName stringByReplacingOccurrencesOfString:@".gif" withString:@""];
NSData *gifData = [NSData dataWithContentsOfFile: [[NSBundle mainBundle] pathForResource:_localAdImgName ofType:@"gif"]];
UIWebView *webView = [[UIWebView alloc] initWithFrame:self.aDImgView.frame];
webView.backgroundColor = [UIColor clearColor];
webView.scalesPageToFit = YES;
webView.scrollView.scrollEnabled = NO;
[webView loadData:gifData MIMEType:@"image/gif" textEncodingName:@"" baseURL:[NSURL URLWithString:@""]];
UIButton *clearBtn = [UIButton buttonWithType:UIButtonTypeCustom];
clearBtn.frame = webView.frame;
clearBtn.backgroundColor = [UIColor clearColor];
[clearBtn addTarget:self action:@selector(activiTap:) forControlEvents:UIControlEventTouchUpInside];
[webView addSubview:clearBtn];
[self.aDImgView addSubview:webView];
[self.aDImgView bringSubviewToFront:_skipBtn];
}else{
self.aDImgView.image = [UIImage imageNamed:_localAdImgName];
}
}
}
-(void)setImgUrl:(NSString *)imgUrl{
_imgUrl = imgUrl;
if (_imgUrl) {
SDWebImageManager *manager = [SDWebImageManager sharedManager];
[manager downloadImageWithURL:[NSURL URLWithString:_imgUrl] options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) {
} completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
if (image) {
[self.aDImgView setImage:[self imageCompressForWidth:image targetWidth:mainWidth]];
}
}];
}
}
- (void)addLBlaunchImageAdView:(AdType)adType{
_adTime = 3;
//获取启动图片
CGSize viewSize = [UIApplication sharedApplication].delegate.window.bounds.size;
//横屏请设置成 @"Landscape"
NSString *viewOrientation = @"Portrait";
__block NSString *launchImageName = nil;
NSArray* imagesDict = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"UILaunchImages"];
[imagesDict enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
CGSize imageSize = CGSizeFromString(obj[@"UILaunchImageSize"]);
if (CGSizeEqualToSize(imageSize, viewSize) && [viewOrientation isEqualToString:obj[@"UILaunchImageOrientation"]])
{
launchImageName = obj[@"UILaunchImageName"];
}
}];
UIImage * launchImage = [UIImage imageNamed:launchImageName];
self.backgroundColor = [UIColor colorWithPatternImage:launchImage];
self.frame = CGRectMake(0, 0, mainWidth, mainHeight);
if (adType == FullScreenAdType) {
self.aDImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, mainWidth, mainHeight)];
}else{
self.aDImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, mainWidth, mainWidth*1.50)];
}
self.aDImgView.userInteractionEnabled = YES;
self.skipBtn = [UIButton buttonWithType:UIButtonTypeCustom];
self.skipBtn.frame = CGRectMake(mainWidth - 70, 20, 60, 30);
//self.skipBtn.backgroundColor = [UIColor brownColor];
self.skipBtn.titleLabel.font = [UIFont systemFontOfSize:14];
[self.skipBtn addTarget:self action:@selector(skipBtnClick) forControlEvents:UIControlEventTouchUpInside];
[self.skipBtn setBackgroundColor:[UIColor redColor]];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.skipBtn.bounds byRoundingCorners:UIRectCornerBottomRight | UIRectCornerTopRight cornerRadii:CGSizeMake(15, 15)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = self.skipBtn.bounds;
maskLayer.path = maskPath.CGPath;
self.skipBtn.layer.mask = maskLayer;
self.aDImgView.tag = 1101;
[self addSubview:self.aDImgView];
[self.aDImgView addSubview:self.skipBtn];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(activiTap:)];
[self.aDImgView addGestureRecognizer:tap];
CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
opacityAnimation.duration = 0.8;
opacityAnimation.fromValue = [NSNumber numberWithFloat:0.0];
opacityAnimation.toValue = [NSNumber numberWithFloat:0.8];
opacityAnimation.fillMode = kCAFillModeForwards;
opacityAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[self.aDImgView.layer addAnimation:opacityAnimation forKey:@"animateOpacity"];
countDownTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
//[[UIApplication sharedApplication].delegate.window addSubview:self];
}
@end
@@ -0,0 +1,17 @@
//
// NSObject+LBLaunchImage.h
// LBLaunchImageAdDemo
//
// Created by gold on 17/4/1.
// Copyright © 2017年 Bison. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "LBLaunchImageAdView.h"
@interface NSObject (LBLaunchImage)
+ (void)makeLBLaunchImageAdView:(void(^)(LBLaunchImageAdView *))block;
@end
@@ -0,0 +1,18 @@
//
// NSObject+LBLaunchImage.m
// LBLaunchImageAdDemo
//
// Created by gold on 17/4/1.
// Copyright © 2017年 Bison. All rights reserved.
//
#import "NSObject+LBLaunchImage.h"
@implementation NSObject (LBLaunchImage)
+ (void)makeLBLaunchImageAdView:(void(^)(LBLaunchImageAdView *))block{
LBLaunchImageAdView *imgAdView = [[LBLaunchImageAdView alloc]init];
block(imgAdView);
}
@end
@@ -0,0 +1,34 @@
//
// LogInViewController.h
// Ifish
//
// Created by imac on 15/9/28.
// Copyright © 2015年 imac. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "BaseVIewContorller.h"
#import "Utils.h"
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
@interface LogInViewController : BaseVIewContorller
{
BMKGeoCodeSearch*_geocodesearch;
}
@property (weak, nonatomic) IBOutlet UITextField *loginPhoneNumberTextField;
@property (weak, nonatomic) IBOutlet UITextField *loginPasswordTextField;
- (IBAction)LogIn:(id)sender;
@property (weak, nonatomic) IBOutlet UIButton *wangJiBtn;
@property (weak, nonatomic) IBOutlet UIImageView *userIconImg;
@property(nonatomic,strong) NSMutableArray*deviceArry;
@property(nonatomic,strong) NSMutableArray*venderArray;
//新加摄像头数组
@property(nonatomic,strong) NSMutableArray*cameraArr;
@end
@@ -0,0 +1,477 @@
//
// LogInViewController.m
// Ifish
//
// Created by imac on 15/9/28.
// Copyright © 2015年 imac. All rights reserved.
//
#import "LogInViewController.h"
//#import "JPUSHService.h"
#import "ForgetViewController.h"
#import "CenterViewController.h"
#import "LeftViewController.h"
#import "RightViewController.h"
#import "AFNetworking.h"
#import "ICSDrawerController.h"
#import "AppDelegate.h"
#import "UserModel.h"
#import "DataCenter.h"
#import "ConnectWifiViewController.h"
#import "MyMD5.h"
#import "RegistViewController.h"
#import "PuasiphysicalSkinViewController.h"
#import "IfishBlackListCenterViewController.h"
//#import <RongIMKit/RongIMKit.h>
//#import <RongIMLib/RongIMLib.h>
//#import "FirstConnectWifiController.h"
//#import "SelectDeviceViewController.h"
#import "IfishDataUnity.h"
#import "NetManager.h"
#import "UDManager.h"
#import "AccountResult.h"
#import "LoginResult.h"
#import "RegisterResult.h"
#import "Toast+UIView.h"
#import "IfishNewsModel.h"
#import <BaiduMapAPI_Location/BMKLocationService.h>
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
#import "IfishUserDataUnity.h"
@interface LogInViewController ()<UITextFieldDelegate,BMKLocationServiceDelegate,BMKGeoCodeSearchDelegate>
@property (weak, nonatomic) IBOutlet UIButton *logInButton;
@property(nonatomic,strong)UIActivityIndicatorView*indicatorView;
@property(nonatomic)BMKLocationService*locService;
@property(nonatomic) double longitude;
@property(nonatomic) double latitude;
@property(nonatomic,copy) NSString *adderss;
@end
extern BOOL firstLogIn;
BOOL formLogIn;// //连接页面是否来自登录界面初始化
@implementation LogInViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor= [UIColor colorWithPatternImage:[UIImage imageNamed:@"enter_background"]];
[self getLocation];
_logInButton.backgroundColor=COLOR_LABEL_TITLE;
_logInButton.layer.cornerRadius = 5;
[self.loginPhoneNumberTextField setValue:[UIColor colorWithRed:153/255.0f green:153/255.0f blue:153/255.0f alpha:1] forKeyPath:@"_placeholderLabel.textColor"];
[self.loginPasswordTextField setValue:[UIColor colorWithRed:153/255.0f green:153/255.0f blue:153/255.0f alpha:1] forKeyPath:@"_placeholderLabel.textColor"];
[self.wangJiBtn addTarget:self action:@selector(forgetPassword:) forControlEvents:UIControlEventTouchUpInside];
[self.wangJiBtn setTitleColor:[UIColor colorWithRed:146/255.0f green:146/255.0f blue:146/255.0f alpha:1] forState:UIControlStateNormal];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
self.deviceArry=[[NSMutableArray alloc] init];
self.cameraArr = [[NSMutableArray alloc] init];
self.loginPasswordTextField.delegate=self;
self.loginPhoneNumberTextField.delegate=self;
UILabel*labe=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 44)];
labe.text=@"登录";
labe.textAlignment=NSTextAlignmentCenter;
labe.textColor=[UIColor whiteColor];
self.navigationItem.titleView=labe;
self.navigationItem.hidesBackButton=YES;
//可自定义按钮背景
// UIButton*rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
// rightButton.frame = CGRectMake(25, 0, 60, 60);
// rightButton.backgroundColor = [UIColor redColor];
// [rightButton setTitle:@"注册" forState:UIControlStateNormal];
// [rightButton addTarget:self action:@selector(backItemBtn) forControlEvents:UIControlEventTouchUpInside];
// UIImageView*imageView=[[UIImageView alloc]initWithFrame:CGRectMake(25,0,60,60)];
// [imageView addSubview:rightButton];
// imageView.userInteractionEnabled=YES;
// UIBarButtonItem*rightItem = [[UIBarButtonItem alloc]initWithCustomView:imageView];
UIBarButtonItem*rightItem= [[UIBarButtonItem alloc] initWithTitle:@"注册" style:UIBarButtonItemStyleDone target:self action:@selector(backItemBtn)];
// rightItem.tintColor=[UIColor whiteColor];
// [rightItem setTintColor:[UIColor whiteColor]];
self.navigationItem.rightBarButtonItem= rightItem;
[self.navigationItem.rightBarButtonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:14],UITextAttributeFont, [UIColor whiteColor], UITextAttributeTextColor, nil] forState:UIControlStateNormal];
[self initTextViewImg];
//self.view.backgroundColor=COLOR_MIAN;
[self setTextkeyboadType];
self.bakbutton.hidden=YES;
[self creatMyindicaterView];
formLogIn=YES;
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
NSString *name=[userdefult objectForKey:@"name"];
if (name) {
self.loginPhoneNumberTextField.text = name;
}
}
#pragma mark 定位
-(void)getLocation{
//初始化BMKLocationService
_locService=[[BMKLocationService alloc]init];
_locService.delegate=self;
//启动LocationService
[_locService startUserLocationService];
_geocodesearch=[[BMKGeoCodeSearch alloc]init];
}
-(void)viewWillAppear:(BOOL)animated{
_geocodesearch.delegate=self;// 此处记得不用的时候需要置nil,否则影响内存的释放
_locService.delegate=self;
}
-(void)viewWillDisappear:(BOOL)animated{
_locService.delegate=nil;
}
-(void)backItemBtn{
if (firstLogIn==YES) {
[self.navigationController popToRootViewControllerAnimated:YES];
}else{
RegistViewController*regist=[[RegistViewController alloc]init];
[self.navigationController pushViewController:regist animated:YES];
}
// [self.navigationController popViewControllerAnimated:YES];
}
-(void)creatMyindicaterView{
_indicatorView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
_indicatorView.frame=CGRectMake(kScreenSize.width/2-20,kScreenSize.height/2-20,40, 40);
[self.view addSubview:_indicatorView];
}
-(void)setTextkeyboadType{
// self.phoneNumberTextField.keyboardType=UIKeyboardTypeNumberPad;
self.loginPasswordTextField.secureTextEntry=YES;
}
-(void)initTextViewImg{
UIView*phoneView=[[UIView alloc]initWithFrame:CGRectMake(0,0, 50, 30)];
UIImageView*phoneIcon=[[UIImageView alloc]initWithFrame:CGRectMake(15,5, 17,20)];
phoneIcon.image=[UIImage imageNamed:@"phone"];
[phoneView addSubview:phoneIcon];
self.loginPhoneNumberTextField.leftView=phoneView;
self.loginPhoneNumberTextField.leftViewMode=UITextFieldViewModeAlways;
self.loginPhoneNumberTextField.layer.cornerRadius=6;
[self.loginPhoneNumberTextField setValue:[UIColor colorWithRed:146.0/255.0 green:146.0/255.0 blue:146.0/255.0 alpha:1] forKeyPath:@"_placeholderLabel.textColor"];
UIView*passView=[[UIView alloc]initWithFrame:CGRectMake(0,30, 50, 30)];
UIImageView*passIcon=[[UIImageView alloc]initWithFrame:CGRectMake(15,5, 17, 20)];
passIcon.image=[UIImage imageNamed:@"password"];
[passView addSubview:passIcon];
self.loginPasswordTextField.leftView=passView;
self.loginPasswordTextField.leftViewMode=UITextFieldViewModeAlways;
self.loginPasswordTextField.layer.cornerRadius=6;
[self.loginPasswordTextField setValue:[UIColor colorWithRed:146.0/255.0 green:146.0/255.0 blue:146.0/255.0 alpha:1] forKeyPath:@"_placeholderLabel.textColor"];
// 设置用户头像
// int i = (arc4random()%11) + 1;// 设置随机头像
// self.userIconImg.image=[UIImage imageNamed:[NSString stringWithFormat:@"acount%d.png",i]];
//
}
#pragma mark-处理收键盘
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[self hiddenKeybord];
}
-(void)hiddenKeybord{
[self.loginPhoneNumberTextField resignFirstResponder];
[self.loginPasswordTextField resignFirstResponder];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (IBAction)LogIn:(id)sender {
//NSString * MOBILE = @"^((13[0-9])|(15[^4,\\D])|(18[0,0-9]))\\d{8}$";
//包含港澳台
// BOOL isMacth=[dataContorl valiMobile:self.loginPhoneNumberTextField.text];
//
// if (!isMacth) {
// [self.view makeToast:@"请输入正确的手机号"];
// return;
// }
UIButton *btn = (UIButton *)sender;
btn.userInteractionEnabled = NO;
btn.backgroundColor = [UIColor lightGrayColor];
[_indicatorView startAnimating];
NSString*tokenStr=[MyMD5 md5:self.loginPasswordTextField.text ];
if (!self.adderss) {
NSLog(@"addressnil");
self.adderss = @"暂时未获取到地址信息";
}
if (!self.latitude) {
self.latitude = 0;
}
if (!self.longitude) {
self.longitude =0;
}
__weak typeof (self) weakSelf=self;
[AFHttpTool userLogInWithPhoneNumber:self.loginPhoneNumberTextField.text password:tokenStr phoneType:@"ios" address:self.adderss
longitude:self.longitude
latitude:self.latitude
success:^(id response) {
NSDictionary*dict=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
NSString *result=dict[@"result"];
btn.userInteractionEnabled = YES;
btn.backgroundColor = RGB(0, 184, 239);
if ([result isEqualToString:@"100"]) {
// 登录成功
NSDictionary*DataDic=dict[@"data"];
NSString*phoneNumber=self.loginPhoneNumberTextField.text;
NSString*password=self.loginPasswordTextField.text;
[[IfishUserDataUnity shareDataInstance] userloginValidationSuccsess:DataDic phoneNumber:phoneNumber passward:password];
}else if ([result isEqualToString:@"101"]){
[weakSelf.view makeToast:@"登录失败"];
//登录失败
}else if ([result isEqualToString:@"204"]){
// 验证失败,密码不正确
[weakSelf.view makeToast:@"验证失败,密码不正确"];
}else if ([result isEqualToString:@"202"]){
// 用户不存在
[weakSelf.view makeToast:@"用户不存在"];
}else if ([result isEqualToString:@"400"]){
// 用户不存在
[weakSelf.view makeToast:@"完全校验失败"];
}
[_indicatorView stopAnimating];
} failure:^(NSError *err) {
btn.userInteractionEnabled = YES;
btn.backgroundColor = RGB(0, 184, 239);
[_indicatorView stopAnimating];
[weakSelf.view makeToast:@"请求失败"];
NSString *errstr = [NSString stringWithFormat:@"%@",err];
BLYLog(BuglyLogLevelWarn, errstr);
}];
}
- (void)tagsAliasCallback:(int)iResCode tags:(NSSet*)tags alias:(NSString*)alias {
NSLog(@"rescode: %d, \ntags: %@, \nalias: %@\n", iResCode, tags , alias);
}
#pragma mark - 注册摄像头成功后 登陆摄像头服务器 已去
-(void)logInYooseeServerWith:(NSString*)email addpassword:(NSString*)password{
AppDelegate *appdelegate=(AppDelegate *)[UIApplication sharedApplication].delegate;
NSString *token=appdelegate.token;
NSString *ifishEmial=[NSString stringWithFormat:@"ifish7%@@ifish7.com",self.loginPhoneNumberTextField.text];
// NSString *ifishPassW=[NSString stringWithFormat:@"ifish%@",userName];
NSString *ifishPassW=@"lian1030";
[[NetManager sharedManager] loginWithUserName:ifishEmial password:ifishPassW token: token callBack:^(id JSON) {
LoginResult *loginResult = (LoginResult*)JSON;
//登陆成功返回 LoginResult数据模型 存储
[UDManager setIsLogin:YES];
[UDManager setLoginInfo:loginResult];
NSLog(@"摄像头服务器成功登陆%@",JSON);
[[NetManager sharedManager] getAccountInfo:loginResult.contactId sessionId:loginResult.sessionId callBack:^(id JSN){
AccountResult *accountResult = (AccountResult*)JSN;
loginResult.email = accountResult.email;
loginResult.phone = accountResult.phone;
loginResult.countryCode = accountResult.countryCode;
[UDManager setLoginInfo:loginResult];
}];
//都登陆成功 跳主界面
}];
}
-(void)showTitle:(NSString*)title messsage:(NSString*)message{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:title message:message delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
}
- (IBAction)forgetPassword:(id)sender {
ForgetViewController*vc=[[ForgetViewController alloc]init];
[self.navigationController pushViewController:vc animated:YES];
}
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
// NSTimeInterval animationDuration=0.30f;
//
// [UIView beginAnimations:@"ResizeForKeyboard" context:nil];
//
// [UIView setAnimationDuration:animationDuration];
if (textField == self.loginPhoneNumberTextField) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(phonekeyboradWillShow:) name:UIKeyboardWillShowNotification object:nil];
}if (textField == self.loginPasswordTextField) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(passkeyboradWillShow:) name:UIKeyboardWillShowNotification object:nil];
}
return YES;
}
- (void) phonekeyboradWillShow:(NSNotification *)notification{
CGFloat kbHeight = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
//计算出键盘顶端到inputTextView panel底端的距离(加上自定义的缓冲距离INTERVAL_KEYBOARD)
CGFloat offset = (_loginPhoneNumberTextField.frame.origin.y+_loginPhoneNumberTextField.frame.size.height+INTERVAL_KEYBOARD) - (self.view.frame.size.height - kbHeight);
// 取得键盘的动画时间,这样可以在视图上移的时候更连贯
double duration = [[notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
//将视图上移计算好的偏移
if(offset > 0) {
[UIView animateWithDuration:duration animations:^{
self.view.frame = CGRectMake(0.0f, -offset, self.view.frame.size.width, self.view.frame.size.height);
}];
}
}
-(void)passkeyboradWillShow:(NSNotification *)notification{
CGFloat kbHeight = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
CGFloat offset = (_loginPasswordTextField.frame.origin.y+_loginPasswordTextField.frame.size.height+INTERVAL_KEYBOARD) - (self.view.frame.size.height - kbHeight);
// 取得键盘的动画时间,这样可以在视图上移的时候更连贯
double duration = [[notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
//将视图上移计算好的偏移
if(offset > 0) {
[UIView animateWithDuration:duration animations:^{
self.view.frame = CGRectMake(0.0f, -offset, self.view.frame.size.width, self.view.frame.size.height);
}];
}
}
//恢复原始视图位置
- (void) keyboardWillHide:(NSNotification *)notify {
// 键盘动画时间
double duration = [[notify.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
//视图下沉恢复原状
[UIView animateWithDuration:duration animations:^{
self.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
}];
}
//处理方向变更信息
- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
{
//NSLog(@"heading is %@",userLocation.heading);
}
//处理位置坐标更新
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
{
NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
self.latitude = userLocation.location.coordinate.latitude;
self.longitude = userLocation.location.coordinate.longitude;
static dispatch_once_t disOnce;
dispatch_once(&disOnce, ^ {
[self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
});
}
/**
* 地理反编码
*/
-(void)reverseGeoCodeWithlatitude:(CLLocationDegrees)latitude addlongitude:(CLLocationDegrees)longitude{
CLLocationCoordinate2D pt=(CLLocationCoordinate2D){latitude,longitude};
BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
reverseGeocodeSearchOption.reverseGeoPoint=pt;
BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
if(flag)
{
NSLog(@"反geo检索发送成功");
}
else
{
NSLog(@"反geo检索发送失败");
}
}
-(void)dealloc{
if (_geocodesearch!=nil) {
_geocodesearch=nil;
}
}
#pragma mark BMKGeoCodeSearchDelegate
-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
NSLog(@"address%@",result.address);
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
NSString*address=result.address;
self.adderss = address;
[userdefult setObject:address forKey:@"address"];
[userdefult setDouble:self.latitude forKey:@"userlatitude"];
[userdefult setDouble:self.longitude forKey:@"userlongitude"];
[userdefult synchronize];
_geocodesearch.delegate=nil;
}
@end
@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="LogInViewController">
<connections>
<outlet property="logInButton" destination="zvp-5f-hP6" id="kvm-8x-kbT"/>
<outlet property="loginPasswordTextField" destination="09y-SO-yq2" id="1PZ-Pq-9FF"/>
<outlet property="loginPhoneNumberTextField" destination="kgb-uB-ZOY" id="D0I-Sg-nfj"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
<outlet property="wangJiBtn" destination="Ckf-mu-FkR" id="sqO-FC-gwi"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="enter_logo.png" translatesAutoresizingMaskIntoConstraints="NO" id="Uda-6x-kdh">
<rect key="frame" x="161" y="116" width="52" height="52"/>
<constraints>
<constraint firstAttribute="width" secondItem="Uda-6x-kdh" secondAttribute="height" multiplier="1:1" id="Uhy-nv-vfv"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" 爱鱼奇" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pee-cm-j3l">
<rect key="frame" x="157.5" y="187" width="60" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="JWX-yY-DRi"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="nvl-4w-l5s">
<rect key="frame" x="21" y="230" width="333" height="240"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入手机号" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="kgb-uB-ZOY">
<rect key="frame" x="16" y="21" width="301" height="42"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.94901960784313721" green="0.94901960784313721" blue="0.94901960784313721" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<textInputTraits key="textInputTraits" keyboardType="numberPad"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="_placeholderLabel.textColor">
<color key="value" red="0.0" green="0.0" blue="0.50196081400000003" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入密码" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="09y-SO-yq2">
<rect key="frame" x="16" y="71" width="301" height="42"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
<textInputTraits key="textInputTraits" keyboardType="numbersAndPunctuation"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zvp-5f-hP6">
<rect key="frame" x="16" y="141" width="301" height="43"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" heightSizable="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.72156862745098038" blue="0.93725490196078431" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<state key="normal" title="登录">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="LogIn:" destination="-1" eventType="touchUpInside" id="s03-cw-qML"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ckf-mu-FkR">
<rect key="frame" x="123" y="192" width="86" height="31"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="13"/>
<state key="normal" title="忘记密码?">
<color key="titleColor" red="0.77647058823529413" green="0.77647058823529413" blue="0.77647058823529413" alpha="1" colorSpace="calibratedRGB"/>
</state>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" secondItem="nvl-4w-l5s" secondAttribute="height" multiplier="111:80" id="RkC-qN-0qd"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" www.ifish7.com" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="T1G-Eq-r75">
<rect key="frame" x="107.5" y="626" width="160" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="160" id="Jpf-Ew-HRc"/>
<constraint firstAttribute="height" constant="21" id="ecg-PZ-CcK"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="pee-cm-j3l" firstAttribute="top" secondItem="Uda-6x-kdh" secondAttribute="bottom" constant="19" id="4bi-Ds-pAV"/>
<constraint firstItem="Uda-6x-kdh" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" constant="116" id="AbK-ny-OJZ"/>
<constraint firstItem="Uda-6x-kdh" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="GZt-9f-uyE"/>
<constraint firstItem="nvl-4w-l5s" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="21" id="HeI-4j-0Ju"/>
<constraint firstItem="nvl-4w-l5s" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="HxM-iG-8fE"/>
<constraint firstItem="nvl-4w-l5s" firstAttribute="top" secondItem="pee-cm-j3l" secondAttribute="bottom" constant="22" id="db6-mE-nRJ"/>
<constraint firstAttribute="bottom" secondItem="T1G-Eq-r75" secondAttribute="bottom" constant="20" id="gcY-4k-5Vo"/>
<constraint firstItem="pee-cm-j3l" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="iYG-ef-KPA"/>
<constraint firstAttribute="trailing" secondItem="nvl-4w-l5s" secondAttribute="trailing" constant="21" id="rYO-yl-ZTZ"/>
<constraint firstItem="T1G-Eq-r75" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="whX-W5-ucD"/>
</constraints>
<point key="canvasLocation" x="555.5" y="108.5"/>
</view>
</objects>
<resources>
<image name="enter_logo.png" width="52" height="52"/>
</resources>
</document>
@@ -0,0 +1,32 @@
//
// RegistViewController.h
// Ifish
//
// Created by imac on 15/9/27.
// Copyright © 2015年 imac. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "MBProgressHUD.h"
#import "BaseVIewContorller.h"
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
@interface RegistViewController : UIViewController
{
BMKGeoCodeSearch*_geocodesearch;
}
@property (weak, nonatomic) IBOutlet UITextField *phoneNumberTextField;
@property (weak, nonatomic) IBOutlet UITextField *verifyTextField;
@property (weak, nonatomic) IBOutlet UITextField *passwordTextField;
@property (weak, nonatomic) IBOutlet UIView *countryView;
- (IBAction)registBtn:(id)sender;
- (IBAction)chooseBtn:(id)sender;
@property(nonatomic,strong)UIScrollView*scrollView;
- (IBAction)verifyBtn:(id)sender;
@property (weak, nonatomic) IBOutlet UIButton *countrySelectBtn;
@end
@@ -0,0 +1,719 @@
//
// RegistViewController.m
// Ifish
//
// Created by imac on 15/9/27.
// Copyright © 2015年 imac. All rights reserved.
//
#import "RegistViewController.h"
//#import "JPUSHService.h"
#import "LogInViewController.h"
#import "UserModel.h"
#import "AFNetworking.h"
#import "MyMD5.h"
#import "LeftViewController.h"
#import "CenterViewController.h"
#import "RightViewController.h"
#import "AgreementViewController.h"
#import "MyIntroductionViewController.h"
#import "ConnectWifiViewController.h"
#import "ChatroomModel.h"
//#import <RongIMKit/RongIMKit.h>
//#import <RongIMLib/RongIMLib.h>
#import <BaiduMapAPI_Location/BMKLocationService.h>
#import <BaiduMapAPI_Search/BMKSearchComponent.h>
#import <BaiduMapAPI_Utils/BMKUtilsComponent.h>
//#import "FirstConnectWifiController.h"
//#import "SelectDeviceViewController.h"
//#import "IfishSelectCardViewController.h"
#import "IfishBindDeviceSelectViewController.h"
#import "IfishMianTabViewController.h"
#import "IfishUserDataUnity.h"
#import "IfishNewsModel.h"
#import <SMS_SDK/SMSSDK.h>
#import <SMS_SDK/Extend/SMSSDK+ExtexdMethods.h>
#import "XWCountryCodeController.h"
@interface RegistViewController ()<UITextFieldDelegate,UIAlertViewDelegate,MBProgressHUDDelegate,BMKLocationServiceDelegate,BMKGeoCodeSearchDelegate>
{
BOOL _showed;//显示过了
// dispatch_source_t _timer1;
UIButton *hpBtn;
BOOL gouxuan;
}
@property (weak, nonatomic) IBOutlet UIButton *timeBtn;
@property(nonatomic,copy)NSString*verifyData;
@property(nonatomic,copy) NSString *areaCode;
@property (weak, nonatomic) IBOutlet UIButton *registBtn;
- (IBAction)agreementBtn:(id)sender;
@property(nonatomic,strong)MBProgressHUD *HUD;
@property(nonatomic,strong)NSMutableArray*deviceArry;
@property(nonatomic,strong)UIActivityIndicatorView*indicatorView;
@property(nonatomic)BMKLocationService*locService;
@property(nonatomic) double longitude;
@property(nonatomic) double latitude;
@property(nonatomic,copy) NSString *adderss;
@end
extern BOOL formLogIn;
@implementation RegistViewController
-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
_deviceArry=[[NSMutableArray alloc]init];
//默认中国大陆
self.areaCode = @"86";
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
[self.countrySelectBtn addTarget:self action:@selector(countrySelectBtnAction:) forControlEvents:UIControlEventTouchUpInside];
self.registBtn.backgroundColor=COLOR_LABEL_TITLE;
self.view.backgroundColor= [UIColor colorWithPatternImage:[UIImage imageNamed:@"enter_background"]];
[self.passwordTextField setValue:[UIColor colorWithRed:153/255.0f green:153/255.0f blue:153/255.0f alpha:1] forKeyPath:@"_placeholderLabel.textColor"];
[self.phoneNumberTextField setValue:[UIColor colorWithRed:153/255.0f green:153/255.0f blue:153/255.0f alpha:1] forKeyPath:@"_placeholderLabel.textColor"];
[self.verifyTextField setValue:[UIColor colorWithRed:153/255.0f green:153/255.0f blue:153/255.0f alpha:1] forKeyPath:@"_placeholderLabel.textColor"];
[self addNaviItem];
[self setTextkeyboadType];
self.phoneNumberTextField.delegate=self;
self.verifyTextField.delegate=self;
self.passwordTextField.delegate=self;
self.navigationItem.hidesBackButton=YES;
[self getLocation];
}
#pragma mark 定位
-(void)getLocation{
//初始化BMKLocationService
_locService=[[BMKLocationService alloc]init];
_locService.delegate=self;
//启动LocationService
[_locService startUserLocationService];
_geocodesearch=[[BMKGeoCodeSearch alloc]init];
}
#pragma mark-- 获取验证(阿里)
-(void)timeFire{
[IFISHHTTPTOOL getVerifyCodeWithTimerButton:_timeBtn addPhoneNumber:self.phoneNumberTextField.text addSendType:@"1" backData:^(NSString *verifycode) {
_verifyData=verifycode;
NSLog(@"%@",_verifyData);
}];
}
#pragma mark - 获取验证码新(SMS
-(void)getVerifycode{
//原来只支持香港澳门 台湾 大陆 已废弃
//BOOL isMacth=[dataContorl valiMobile:self.phoneNumberTextField.text];
//if (!isMacth) {
// [self.view makeToast:@"请输入正确手机号"];
// return;
//}
//NSString *zone = [dataContorl areaCode:self.phoneNumberTextField.text];
//self.areaCode = zone;
[IFISHHTTPTOOL getverifyWithTimerButton:_timeBtn addphoneNumber:self.phoneNumberTextField.text zone:self.areaCode result:^(NSError *err) {
}];
}
#pragma mark-设置键盘样式
-(void)setTextkeyboadType{
// self.phoneNumberTextField.keyboardType=UIKeyboardTypeNumberPad;
self.passwordTextField.secureTextEntry=YES;
self.phoneNumberTextField.layer.masksToBounds=YES;
CGRect verifyTextFieldRect= CGRectMake(self.verifyTextField.bounds.origin.x,self.verifyTextField.bounds.origin.x,kScreenSize.width-31*2 -80,self.verifyTextField.bounds.size.height);
UIBezierPath *maskPath=[UIBezierPath bezierPathWithRoundedRect:verifyTextFieldRect byRoundingCorners:UIRectCornerTopLeft|UIRectCornerBottomLeft cornerRadii:CGSizeMake(8, 8)];
CAShapeLayer *maskLayer =[[CAShapeLayer alloc] init];
maskLayer.frame = verifyTextFieldRect;
maskLayer.path = maskPath.CGPath;
//self.verifyTextField.layer.mask = maskLayer;
self.verifyTextField.layer.masksToBounds=YES;
self.verifyTextField.layer.cornerRadius=8;
// CGRect timeBtnRect= CGRectMake(_timeBtn.bounds.origin.x,_timeBtn.bounds.origin.x,_timeBtn.bounds.size.width,_timeBtn.bounds.size.height);
// UIBezierPath *maskPathtimeBtn=[UIBezierPath bezierPathWithRoundedRect:timeBtnRect byRoundingCorners:UIRectCornerBottomRight | UIRectCornerTopRight cornerRadii:CGSizeMake(8, 8)];
// CAShapeLayer *maskLayertimeBtn =[[CAShapeLayer alloc] init];
// maskLayertimeBtn.frame = timeBtnRect;
// maskLayertimeBtn.path = maskPathtimeBtn.CGPath;
//_timeBtn.layer.mask = maskLayertimeBtn;
self.phoneNumberTextField.layer.cornerRadius=8;
self.passwordTextField.layer.masksToBounds=YES;
self.passwordTextField.layer.cornerRadius=8;
//_timeBtn.backgroundColor=COLOR_LABEL_TITLE;
//[_timeBtn setImage:[UIImage imageNamed:@"registered_icon_validation"] forState:UIControlStateNormal];
[_timeBtn setBackgroundImage:[UIImage imageNamed:@"registered_icon_validation"] forState:UIControlStateNormal];
_registBtn.backgroundColor=COLOR_LABEL_TITLE;
_registBtn.layer.masksToBounds=YES;
_registBtn.layer.cornerRadius=8;
UIView*phoneView=[[UIView alloc]initWithFrame:CGRectMake(0,0, 10, 10)];
self.phoneNumberTextField.leftView=phoneView;
self.phoneNumberTextField.leftViewMode=UITextFieldViewModeAlways;
UIView*phoneView1=[[UIView alloc]initWithFrame:CGRectMake(0,0, 10, 10)];
self.verifyTextField.leftView=phoneView1;
UIView*phoneView2=[[UIView alloc]initWithFrame:CGRectMake(0,0, 10, 10)];
self.verifyTextField.leftViewMode=UITextFieldViewModeAlways;
self.passwordTextField.leftView=phoneView2;
self.passwordTextField.leftViewMode=UITextFieldViewModeAlways;
// [_searchBar setSearchTextPositionAdjustment:UIOffsetMake(10, 0)];
self.countryView.layer.masksToBounds = YES;
self.countryView.layer.cornerRadius = 8;
}
#pragma mark-设置导航按钮
-(void)addNaviItem{
UILabel*labe=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 44)];
labe.text=@"注册";
labe.textAlignment=NSTextAlignmentCenter;
labe.textColor=[UIColor whiteColor];
self.navigationItem.titleView=labe;
// UIButton*rightButton = [[UIButton alloc]initWithFrame:CGRectMake(25,0,60,60)];
// [rightButton setTitle:@"登录" forState:UIControlStateNormal];
// rightButton.backgroundColor=[UIColor clearColor];
// [rightButton addTarget:self action:@selector(rightItemBtn:) forControlEvents:UIControlEventTouchUpInside];
// UIImageView*imageView=[[UIImageView alloc]initWithFrame:CGRectMake(25,0,60,60)];
//
// [imageView addSubview:rightButton];
// imageView.userInteractionEnabled=YES;
// UIBarButtonItem*rightItem = [[UIBarButtonItem alloc]initWithCustomView:imageView];
// self.navigationItem.rightBarButtonItem= rightItem;
UIBarButtonItem*rightItem= [[UIBarButtonItem alloc] initWithTitle:@"登录" style:UIBarButtonItemStyleDone target:self action:@selector(rightItemBtn:)];
// rightItem.tintColor=[UIColor whiteColor];
// [rightItem setTintColor:[UIColor whiteColor]];
self.navigationItem.rightBarButtonItem= rightItem;
[self.navigationItem.rightBarButtonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:14],UITextAttributeFont, [UIColor whiteColor], UITextAttributeTextColor, nil] forState:UIControlStateNormal];
}
-(void)rightItemBtn:(id)sender{
LogInViewController *login=[[LogInViewController alloc]init];
[self.navigationController pushViewController:login animated:YES];
}
-(void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
//-(BOOL)isExistUserName:(NSString *)name{
//
// //DataCenter 去本地 检测 有没有存储
// UserModel *model=[[DataCenter defaultDtacenter]valueForKey:name];
// if (model) {
// return YES;//存在
//
// }else{
// return NO;
// }
//}
#pragma mark-处理收键盘
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
// [self resumeView];
return YES;
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[self hiddenKeybord];
//[self resumeView];
}
-(void)hiddenKeybord{
[self.phoneNumberTextField resignFirstResponder];
[self.passwordTextField resignFirstResponder];
[self.verifyTextField resignFirstResponder];
}
#pragma mark-点击注册
- (IBAction)registBtn:(id)sender {
UIButton *btn = (UIButton *)sender;
if (self.verifyTextField.text.length==0) {
[self.view makeToast:@"请输入验证码"];
return;
}
if (self.phoneNumberTextField.text.length==0||self.passwordTextField.text.length==0) {
[self.view makeToast:@"用户名或者密码不能为空"];
return;
}
//self.verifyTextField.text=_verifyData;
if (self.passwordTextField.text.length<6) {
[self.view makeToast:@"请输入最小六位密码"];
return;
}
btn.userInteractionEnabled=NO;
btn.backgroundColor=[UIColor lightGrayColor];
[SMSSDK commitVerificationCode:self.verifyTextField.text phoneNumber:self.phoneNumberTextField.text zone:self.areaCode result:^(SMSSDKUserInfo *userInfo, NSError *error) {
{
if (!error)
{
NSLog(@"验证成功");
[self ifishAddUser];
}
else
{
NSLog(@"错误信息:%@",error);
NSString *str =@"验证码验证失败";
[self.view makeToast:str];
btn.userInteractionEnabled=YES;
btn.backgroundColor=COLOR_LABEL_TITLE;
}
}
}];
}
#pragma mark - 注册
-(void)ifishAddUser{
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
NSString*address=[userDefsult objectForKey:@"address"];
NSString*passStr=[MyMD5 md5:self.passwordTextField.text];
if (!address) {
NSLog(@"addressnil");
address = @"暂时未获取到地址信息";
}
if (!self.latitude) {
self.latitude = 0;
}
if (!self.longitude) {
self.longitude =0;
}
__weak typeof (self) weakSelf = self;
[AFHttpTool addUserWithPhoneNumber:weakSelf.phoneNumberTextField.text password:passStr phoneType:@"ios" address:address longitude:weakSelf.longitude
latitude:weakSelf.latitude success:^(id response) {
if (response) {
NSDictionary*resultDic=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
NSLog(@"resultDic:%@",resultDic);
if ([resultDic[@"result"] isEqualToString:@"100"])
{
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
NSString*userName=weakSelf.phoneNumberTextField.text;
NSString*password=weakSelf.passwordTextField.text;
[userdefult setObject:password forKey:@"password"];
[userdefult setObject:userName forKey:@"name"];
//是否退出登陆
[userdefult setObject:@"0" forKey:@"isExit"];
[userdefult synchronize];
[weakSelf logIn];
}else if ([resultDic[@"result"] isEqualToString:@"201"]){
[weakSelf.view makeToast:@"手机号已经注册过"];
}else{
[weakSelf.view makeToast:@"注册失败"];
}
}
} failure:^(NSError *err) {
_registBtn.userInteractionEnabled=YES;
_registBtn.backgroundColor=COLOR_LABEL_TITLE;
UIAlertView *alter =[[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"请检查您的网络"
delegate:self cancelButtonTitle:@"确定" otherButtonTitles: nil];
[alter show];
NSString *erstr =[NSString stringWithFormat:@"%@",err];
BLYLog(BuglyLogLevelError, erstr);
}];
}
#pragma mark- 极光别名注册
- (void)tagsAliasCallback:(int)iResCode tags:(NSSet*)tags alias:(NSString*)alias {
NSLog(@"rescode: %d, \ntags: %@, \nalias: %@\n", iResCode, tags , alias);
}
#pragma mark-爱鱼奇协议按钮
- (IBAction)chooseBtn:(id)sender {
UIButton*xuanBtn=(UIButton*)sender;
if (gouxuan) {
[xuanBtn setBackgroundImage:[UIImage imageNamed:@"registered_icon_tick_uncheck"] forState:UIControlStateNormal];
_registBtn.userInteractionEnabled=YES;
_registBtn.backgroundColor=COLOR_LABEL_TITLE;
gouxuan=NO;
}else{
[xuanBtn setBackgroundImage:[UIImage imageNamed:@"registered_icon_tick_selected"] forState:UIControlStateNormal];
_registBtn.userInteractionEnabled=NO;
_registBtn.backgroundColor=[UIColor lightGrayColor];
gouxuan=YES;
}
}
//
/////键盘消失事件
- (void) keyboardWillHide:(NSNotification *)notify {
// 键盘动画时间
double duration = [[notify.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
//视图下沉恢复原状
[UIView animateWithDuration:duration animations:^{
self.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
}];
}
-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
// 适应第三方键盘
if (textField==self.phoneNumberTextField) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboradWillShow1:) name:UIKeyboardWillShowNotification object:nil];
}else if (textField==self.verifyTextField){
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboradWillShow2:) name:UIKeyboardWillShowNotification object:nil];
}else if (textField==self.passwordTextField){
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboradWillShow3:) name:UIKeyboardWillShowNotification object:nil];
}
return YES;
}
//恢复原始视图位置
//-(void)resumeView
//{
//
// NSTimeInterval animationDuration=0.30f;
// [UIView beginAnimations:@"ResizeForKeyboard" context:nil];
// [UIView setAnimationDuration:animationDuration];
// float width = self.view.frame.size.width;
// float height = self.view.frame.size.height;
// //如果当前View是父视图,则Y为20个像素高度,如果当前View为其他View的子视图,则动态调节Y的高度
// float Y = 0.0f;
// CGRect rect=CGRectMake(0.0f,Y,width,height);
// self.view.frame=rect;
// [UIView commitAnimations];
//
//}
- (void) keyboradWillShow1:(NSNotification *)notification {
//获取键盘高度,在不同设备上,以及中英文下是不同的
CGFloat kbHeight = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
//计算出键盘顶端到inputTextView panel底端的距离(加上自定义的缓冲距离INTERVAL_KEYBOARD)
CGFloat offset = (_phoneNumberTextField.frame.origin.y+_phoneNumberTextField.frame.size.height+INTERVAL_KEYBOARD) - (self.view.frame.size.height - kbHeight);
// 取得键盘的动画时间,这样可以在视图上移的时候更连贯
double duration = [[notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
//将视图上移计算好的偏移
if(offset > 0) {
[UIView animateWithDuration:duration animations:^{
self.view.frame = CGRectMake(0.0f, -offset, self.view.frame.size.width, self.view.frame.size.height);
}];
}
}
- (void) keyboradWillShow2:(NSNotification *)notification {
//获取键盘高度,在不同设备上,以及中英文下是不同的
CGFloat kbHeight = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
//计算出键盘顶端到inputTextView panel底端的距离(加上自定义的缓冲距离INTERVAL_KEYBOARD)
CGFloat offset = (_verifyTextField.frame.origin.y+_verifyTextField.frame.size.height+INTERVAL_KEYBOARD) - (self.view.frame.size.height - kbHeight);
// 取得键盘的动画时间,这样可以在视图上移的时候更连贯
double duration = [[notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
//将视图上移计算好的偏移
if(offset > 0) {
[UIView animateWithDuration:duration animations:^{
self.view.frame = CGRectMake(0.0f, -offset, self.view.frame.size.width, self.view.frame.size.height);
}];
}
}
- (void) keyboradWillShow3:(NSNotification *)notification {
//获取键盘高度,在不同设备上,以及中英文下是不同的
CGFloat kbHeight = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size.height;
//计算出键盘顶端到inputTextView panel底端的距离(加上自定义的缓冲距离INTERVAL_KEYBOARD)
CGFloat offset = (_passwordTextField.frame.origin.y+_passwordTextField.frame.size.height+INTERVAL_KEYBOARD) - (self.view.frame.size.height - kbHeight);
// 取得键盘的动画时间,这样可以在视图上移的时候更连贯
double duration = [[notification.userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
//将视图上移计算好的偏移
if(offset > 0) {
[UIView animateWithDuration:duration animations:^{
self.view.frame = CGRectMake(0.0f, -offset, self.view.frame.size.width, self.view.frame.size.height);
}];
}
}
//爱鱼奇协议
- (IBAction)agreementBtn:(id)sender {
AgreementViewController*agreement=[[AgreementViewController alloc]init];
[self.navigationController pushViewController:agreement animated:YES];
}
- (IBAction)verifyBtn:(id)sender {
// [self timeFire];
[self getVerifycode];
}
-(void)showTitle:(NSString*)title messsage:(NSString*)message{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:title message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:nil, nil];
NSTimeInterval dismissSeconds=1.0;
[alert show];
[self performSelector:@selector(dismissAlert:) withObject:alert afterDelay:dismissSeconds];
}
-(void)dismissAlert:(UIAlertView*)alertView{
[alertView dismissWithClickedButtonIndex:[alertView cancelButtonIndex] animated:YES];
}
#pragma mark 引导页
-(void)viewWillAppear:(BOOL)animated{
_geocodesearch.delegate=self;// 此处记得不用的时候需要置nil,否则影响内存的释放
_locService.delegate=self;
static dispatch_once_t disOnce;
dispatch_once(&disOnce, ^ {
if (_showed) {
return;
}
NSUserDefaults *accountDefaults = [NSUserDefaults standardUserDefaults];
if ([accountDefaults boolForKey:@"showed"]==YES) {
return;
}else{
[self showIntroduce];
}
});
}
-(void)viewWillDisappear:(BOOL)animated{
// _geocodesearch.delegate=nil;
_locService.delegate=nil;
}
-(void)showIntroduce{
MyIntroductionViewController*introductionVC=[[MyIntroductionViewController alloc]init];
NSMutableArray * imageNames = [NSMutableArray array];
for (int i=1; i<=3; i++) {
[imageNames addObject:[NSString stringWithFormat:@"introlImage_%d",i]];
}
introductionVC.imageNames=imageNames;
introductionVC.hiddenPageControl=NO;
introductionVC.introductionStyle=LXIntroductionStyleFullScreenGoButton;
introductionVC.goActionCallBack=^(MyIntroductionViewController* intrVC){
[intrVC dismissViewControllerAnimated:YES completion:nil];
_showed=YES;
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
[userdefult setBool:YES forKey:@"showed"];
};
[self presentViewController:introductionVC animated:YES completion:nil];
}
#pragma mark 注册成功自动登录
-(void)logIn{
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
NSString*name=[userDefsult objectForKey:@"name"];
NSString*password=[userDefsult objectForKey:@"password"];
NSString*tokenStr=[MyMD5 md5:password];
[AFHttpTool userLogInWithPhoneNumber:name password:tokenStr phoneType:@"ios" address:self.adderss
longitude:self.longitude
latitude:self.latitude success:^(id response) {
NSDictionary*dict=[NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
NSString *result=dict[@"result"];
_registBtn.userInteractionEnabled=YES;
_registBtn.backgroundColor=COLOR_LABEL_TITLE;
if ([result isEqualToString:@"100"]) {
NSDictionary*DataDic=dict[@"data"];
[[IfishUserDataUnity shareDataInstance] userAutologinSuccsess:DataDic];
}else if ([result isEqualToString:@"101"]){
[self showTitle:@"" messsage:@"登录失败"];
//登录失败
}else if ([result isEqualToString:@"204"]){
// 验证失败,密码不正确
[self showTitle:@"" messsage:@"验证失败,密码不正确"];
}else if ([result isEqualToString:@"202"]){
// 用户不存在
[self showTitle:@"" messsage:@"用户不存在"];
}else if ([result isEqualToString:@"400"]){
//
[self showTitle:@"" messsage:@"安全验证失败"];
}
[_indicatorView stopAnimating];
} failure:^(NSError *err) {
_registBtn.userInteractionEnabled=YES;
_registBtn.backgroundColor=COLOR_LABEL_TITLE;
[_indicatorView stopAnimating];
UIAlertView *alter =[[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"登录异常" delegate:self cancelButtonTitle:@"知道了" otherButtonTitles: nil];
[alter show];
NSLog(@"失败");
NSString *erstr =[NSString stringWithFormat:@"%@",err];
BLYLog(BuglyLogLevelError, erstr);
}];
}
-(void)creatMyindicaterView{
_indicatorView=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
_indicatorView.frame=CGRectMake(kScreenSize.width/2-20,kScreenSize.height/2-20,40, 40);
[self.view addSubview:_indicatorView];
}
//实现相关delegate 处理位置信息更新
//处理方向变更信息
- (void)didUpdateUserHeading:(BMKUserLocation *)userLocation
{
//NSLog(@"heading is %@",userLocation.heading);
}
//处理位置坐标更新
- (void)didUpdateBMKUserLocation:(BMKUserLocation *)userLocation
{
NSLog(@"didUpdateUserLocation lat %f,long %f",userLocation.location.coordinate.latitude,userLocation.location.coordinate.longitude);
self.latitude = userLocation.location.coordinate.latitude;
self.longitude = userLocation.location.coordinate.longitude;
static dispatch_once_t disOnce;
dispatch_once(&disOnce, ^ {
[self reverseGeoCodeWithlatitude:userLocation.location.coordinate.latitude addlongitude:userLocation.location.coordinate.longitude];
});
}
/**
* 地理反编码
*/
-(void)reverseGeoCodeWithlatitude:(CLLocationDegrees)latitude addlongitude:(CLLocationDegrees)longitude{
CLLocationCoordinate2D pt=(CLLocationCoordinate2D){latitude,longitude};
BMKReverseGeoCodeOption *reverseGeocodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
reverseGeocodeSearchOption.reverseGeoPoint=pt;
BOOL flag = [_geocodesearch reverseGeoCode:reverseGeocodeSearchOption];
if(flag)
{
NSLog(@"反geo检索发送成功");
}
else
{
NSLog(@"反geo检索发送失败");
}
}
-(void)dealloc{
if (_geocodesearch!=nil) {
_geocodesearch=nil;
}
}
#pragma mark BMKGeoCodeSearchDelegate
-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{
NSLog(@"address%@",result.address);
NSUserDefaults*userdefult=[NSUserDefaults standardUserDefaults];
NSString*address=result.address;
self.adderss = address;
[userdefult setObject:address forKey:@"address"];
[userdefult setDouble:self.latitude forKey:@"userlatitude"];
[userdefult setDouble:self.longitude forKey:@"userlongitude"];
[userdefult synchronize];
_geocodesearch.delegate=nil;
}
#pragma mark - countrySelectBtnAction
-(void)countrySelectBtnAction:(UIButton *)btn{
XWCountryCodeController *CountryCodeVC = [[XWCountryCodeController alloc] init];
//CountryCodeVC.deleagete = self;
[CountryCodeVC toReturnCountryCode:^(NSString *countryCodeStr) {
[self.countrySelectBtn setTitle:countryCodeStr forState:UIControlStateNormal];
NSArray *array = [countryCodeStr componentsSeparatedByString:@"+"];
self.areaCode = array[1];
}];
[self presentViewController:CountryCodeVC animated:YES completion:nil];
}
@end
@@ -0,0 +1,222 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RegistViewController">
<connections>
<outlet property="countrySelectBtn" destination="n5p-Vd-ZyI" id="YhZ-1f-3xz"/>
<outlet property="countryView" destination="42g-iR-QpF" id="SVZ-QG-x9J"/>
<outlet property="passwordTextField" destination="7xd-HS-1kK" id="tmw-kh-qyQ"/>
<outlet property="phoneNumberTextField" destination="iE3-ny-LX2" id="kOJ-c7-cq8"/>
<outlet property="registBtn" destination="I52-cD-mf7" id="Kam-09-yMp"/>
<outlet property="timeBtn" destination="JFw-B7-IwK" id="6a6-Xs-pmB"/>
<outlet property="verifyTextField" destination="nOn-jr-IQE" id="ijZ-Xl-BiV"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="爱鱼奇" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hYY-oA-nHl">
<rect key="frame" x="151" y="593" width="73" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="YMB-XW-gtX"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="24"/>
<color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" www.ifish7.com" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ur3-Na-90E">
<rect key="frame" x="142" y="616" width="91" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="ERL-IB-9QU"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" red="0.20000000000000001" green="0.20000000000000001" blue="0.20000000000000001" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="enter_logo.png" translatesAutoresizingMaskIntoConstraints="NO" id="O0L-5W-OS6">
<rect key="frame" x="161" y="531" width="52" height="52"/>
<constraints>
<constraint firstAttribute="width" secondItem="O0L-5W-OS6" secondAttribute="height" multiplier="1:1" id="fSV-46-RYD"/>
</constraints>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="SR2-Pu-ao5">
<rect key="frame" x="21" y="93" width="333" height="340.5"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入您的手机号" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="iE3-ny-LX2">
<rect key="frame" x="25" y="71" width="283" height="42"/>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="iE3-ny-LX2" secondAttribute="height" multiplier="283:42" id="lT9-zT-aKL"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<textInputTraits key="textInputTraits" keyboardType="numberPad"/>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入验证码" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="nOn-jr-IQE">
<rect key="frame" x="25" y="121" width="283" height="42"/>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="nOn-jr-IQE" secondAttribute="height" multiplier="283:42" id="n5r-mc-jar"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" keyboardType="numberPad"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JFw-B7-IwK">
<rect key="frame" x="228" y="121" width="80" height="42"/>
<constraints>
<constraint firstAttribute="width" constant="80" id="N1G-p8-Udv"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<state key="normal" title="语音验证码" backgroundImage="registered_icon_validation.png">
<color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="verifyBtn:" destination="-1" eventType="touchUpInside" id="5TO-Ue-tgS"/>
</connections>
</button>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入您的密码" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="7xd-HS-1kK">
<rect key="frame" x="25" y="171" width="283" height="42"/>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="7xd-HS-1kK" secondAttribute="height" multiplier="283:42" id="lla-8H-DoS"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="I52-cD-mf7">
<rect key="frame" x="25" y="241" width="283" height="43"/>
<color key="backgroundColor" red="0.0" green="0.71764705882352942" blue="0.93333333333333335" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="I52-cD-mf7" secondAttribute="height" multiplier="283:43" id="cSL-5y-1oN"/>
</constraints>
<state key="normal" title="注册">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="registBtn:" destination="-1" eventType="touchUpInside" id="71r-yp-nJr"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LoQ-C1-iph">
<rect key="frame" x="25" y="293" width="16" height="16"/>
<constraints>
<constraint firstAttribute="width" constant="16" id="RBU-vl-U55"/>
<constraint firstAttribute="height" constant="16" id="aik-Sp-SHV"/>
</constraints>
<state key="normal" backgroundImage="registered_icon_tick_uncheck.png"/>
<connections>
<action selector="chooseBtn:" destination="-1" eventType="touchUpInside" id="fNS-Yb-Dfi"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Pnt-Um-Tap">
<rect key="frame" x="49" y="287" width="146" height="28"/>
<constraints>
<constraint firstAttribute="height" constant="28" id="6Sw-Nc-gLW"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<state key="normal" title="我已同意爱鱼奇使用协议">
<color key="titleColor" red="0.70980392156862748" green="0.70980392156862748" blue="0.70980392156862748" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="agreementBtn:" destination="-1" eventType="touchUpInside" id="ggt-vQ-tlg"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="42g-iR-QpF">
<rect key="frame" x="25" y="21" width="283" height="42"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="n5p-Vd-ZyI">
<rect key="frame" x="128" y="6.5" width="147" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="147" id="bST-Mi-MC4"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<state key="normal" title="中国 +86">
<color key="titleColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="国家/地区" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="D0R-l5-Uoe">
<rect key="frame" x="10" y="10.5" width="73" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="73" id="ETL-6a-81N"/>
<constraint firstAttribute="height" constant="21" id="FPM-9d-hDt"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="D0R-l5-Uoe" firstAttribute="centerY" secondItem="42g-iR-QpF" secondAttribute="centerY" id="5TH-pu-LBT"/>
<constraint firstAttribute="trailing" secondItem="n5p-Vd-ZyI" secondAttribute="trailing" constant="8" id="Hqw-V4-tfZ"/>
<constraint firstItem="n5p-Vd-ZyI" firstAttribute="centerY" secondItem="42g-iR-QpF" secondAttribute="centerY" id="lMn-v0-4yF"/>
<constraint firstItem="D0R-l5-Uoe" firstAttribute="leading" secondItem="42g-iR-QpF" secondAttribute="leading" constant="10" id="ofb-sX-4eP"/>
<constraint firstAttribute="width" secondItem="42g-iR-QpF" secondAttribute="height" multiplier="283:42" id="rdP-1c-cDT"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="LoQ-C1-iph" firstAttribute="leading" secondItem="SR2-Pu-ao5" secondAttribute="leading" constant="25" id="02S-qu-cBa"/>
<constraint firstAttribute="trailing" secondItem="7xd-HS-1kK" secondAttribute="trailing" constant="25" id="07q-of-Hip"/>
<constraint firstItem="7xd-HS-1kK" firstAttribute="centerX" secondItem="SR2-Pu-ao5" secondAttribute="centerX" id="3gd-IU-TMN"/>
<constraint firstItem="nOn-jr-IQE" firstAttribute="leading" secondItem="SR2-Pu-ao5" secondAttribute="leading" constant="25" id="6VE-4O-kdQ"/>
<constraint firstAttribute="trailing" secondItem="I52-cD-mf7" secondAttribute="trailing" constant="25" id="6Vl-Cm-hqd"/>
<constraint firstItem="I52-cD-mf7" firstAttribute="leading" secondItem="SR2-Pu-ao5" secondAttribute="leading" constant="25" id="7WF-hP-l9D"/>
<constraint firstAttribute="trailing" secondItem="42g-iR-QpF" secondAttribute="trailing" constant="25" id="Arw-Vj-JaJ"/>
<constraint firstItem="JFw-B7-IwK" firstAttribute="top" secondItem="nOn-jr-IQE" secondAttribute="top" id="B6q-9T-0nQ"/>
<constraint firstAttribute="trailing" secondItem="nOn-jr-IQE" secondAttribute="trailing" constant="25" id="BqD-SS-c5h"/>
<constraint firstItem="Pnt-Um-Tap" firstAttribute="centerY" secondItem="LoQ-C1-iph" secondAttribute="centerY" id="D7n-jE-lyh"/>
<constraint firstItem="7xd-HS-1kK" firstAttribute="leading" secondItem="SR2-Pu-ao5" secondAttribute="leading" constant="25" id="Ghr-d7-hbN"/>
<constraint firstItem="Pnt-Um-Tap" firstAttribute="leading" secondItem="LoQ-C1-iph" secondAttribute="trailing" constant="8" id="H8i-4E-QXN"/>
<constraint firstItem="iE3-ny-LX2" firstAttribute="leading" secondItem="SR2-Pu-ao5" secondAttribute="leading" constant="25" id="Mwx-3S-JUa"/>
<constraint firstItem="JFw-B7-IwK" firstAttribute="leading" secondItem="nOn-jr-IQE" secondAttribute="trailing" constant="-80" id="QRt-rk-8zr"/>
<constraint firstItem="I52-cD-mf7" firstAttribute="top" secondItem="7xd-HS-1kK" secondAttribute="bottom" constant="28" id="TLH-RA-nOC"/>
<constraint firstItem="JFw-B7-IwK" firstAttribute="height" secondItem="nOn-jr-IQE" secondAttribute="height" id="TWk-fJ-dMA"/>
<constraint firstItem="nOn-jr-IQE" firstAttribute="top" secondItem="iE3-ny-LX2" secondAttribute="bottom" constant="8" symbolic="YES" id="XyG-Qo-cPp"/>
<constraint firstItem="iE3-ny-LX2" firstAttribute="centerX" secondItem="SR2-Pu-ao5" secondAttribute="centerX" id="Zaa-h7-urA"/>
<constraint firstAttribute="trailing" secondItem="iE3-ny-LX2" secondAttribute="trailing" constant="25" id="aOl-em-1x8"/>
<constraint firstItem="7xd-HS-1kK" firstAttribute="top" secondItem="nOn-jr-IQE" secondAttribute="bottom" constant="8" id="biI-hb-OQE"/>
<constraint firstItem="I52-cD-mf7" firstAttribute="centerX" secondItem="SR2-Pu-ao5" secondAttribute="centerX" id="e0y-xf-AYF"/>
<constraint firstItem="nOn-jr-IQE" firstAttribute="centerX" secondItem="SR2-Pu-ao5" secondAttribute="centerX" id="eMW-44-dZ3"/>
<constraint firstAttribute="width" secondItem="SR2-Pu-ao5" secondAttribute="height" multiplier="333:290" constant="-57.413793103448256" id="hxK-ez-n9r"/>
<constraint firstItem="iE3-ny-LX2" firstAttribute="top" secondItem="42g-iR-QpF" secondAttribute="bottom" constant="8" id="lZm-wX-xbg"/>
<constraint firstItem="42g-iR-QpF" firstAttribute="leading" secondItem="SR2-Pu-ao5" secondAttribute="leading" constant="25" id="liw-h5-NJ8"/>
<constraint firstItem="LoQ-C1-iph" firstAttribute="top" secondItem="I52-cD-mf7" secondAttribute="bottom" constant="9" id="loD-LC-V1s"/>
<constraint firstItem="42g-iR-QpF" firstAttribute="top" secondItem="SR2-Pu-ao5" secondAttribute="top" constant="21" id="sVJ-BR-cLd"/>
<constraint firstItem="JFw-B7-IwK" firstAttribute="bottom" secondItem="nOn-jr-IQE" secondAttribute="bottom" id="wAg-Wh-1lt"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="O0L-5W-OS6" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" constant="-0.5" id="4rw-a4-PkY"/>
<constraint firstItem="SR2-Pu-ao5" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="82b-ax-1QC"/>
<constraint firstItem="hYY-oA-nHl" firstAttribute="top" secondItem="O0L-5W-OS6" secondAttribute="bottom" constant="10" id="C7p-nT-vPL"/>
<constraint firstAttribute="trailing" secondItem="SR2-Pu-ao5" secondAttribute="trailing" constant="21" id="QNp-Yy-Bg8"/>
<constraint firstItem="hYY-oA-nHl" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="eSa-a3-a4g"/>
<constraint firstAttribute="bottom" secondItem="Ur3-Na-90E" secondAttribute="bottom" constant="30" id="gJB-ua-pHI"/>
<constraint firstItem="Ur3-Na-90E" firstAttribute="top" secondItem="hYY-oA-nHl" secondAttribute="bottom" constant="2" id="ikP-76-AfN"/>
<constraint firstItem="SR2-Pu-ao5" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" constant="93" id="oqG-Fy-gWM"/>
<constraint firstItem="SR2-Pu-ao5" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="21" id="qmu-s8-j7c"/>
<constraint firstItem="Ur3-Na-90E" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="yZr-tw-zcf"/>
</constraints>
<point key="canvasLocation" x="-68.5" y="86.5"/>
</view>
</objects>
<resources>
<image name="enter_logo.png" width="52" height="52"/>
<image name="registered_icon_tick_uncheck.png" width="14" height="14"/>
<image name="registered_icon_validation.png" width="146" height="88"/>
</resources>
</document>
@@ -0,0 +1,16 @@
//
// ResetViewController.h
// Ifish
//
// Created by imac on 15/9/27.
// Copyright © 2015年 imac. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "BaseVIewContorller.h"
@interface ResetViewController : BaseVIewContorller
@property (weak, nonatomic) IBOutlet UITextField *nwPasswordField;
@property (weak, nonatomic) IBOutlet UITextField *RepeadNewPassFiled;
- (IBAction)finishButton:(id)sender;
@end
@@ -0,0 +1,108 @@
//
// ResetViewController.m
// Ifish
//
// Created by imac on 15/9/27.
// Copyright © 2015年 imac. All rights reserved.
//
#import "ResetViewController.h"
#import "LogInViewController.h"
#include "AFNetworking.h"
#import "MyMD5.h"
@interface ResetViewController ()
@property (weak, nonatomic) IBOutlet UIButton *wanchengBtn;
@end
extern BOOL firstLogIn;
@implementation ResetViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self addTitleViewWithTitle:@"重置密码"];
[self setTextkeyboadType];
self.view.backgroundColor= [UIColor colorWithPatternImage:[UIImage imageNamed:@"enter_background"]];
_wanchengBtn.backgroundColor=COLOR_LABEL_TITLE;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)setTextkeyboadType{
// self.phoneNumberTextField.keyboardType=UIKeyboardTypeNumberPad;
self.RepeadNewPassFiled.secureTextEntry=YES;
self.nwPasswordField.secureTextEntry=YES;
self.RepeadNewPassFiled.layer.masksToBounds=YES;
self.RepeadNewPassFiled.layer.cornerRadius=6;
self.nwPasswordField.layer.masksToBounds=YES;
self.nwPasswordField.layer.cornerRadius=6;
_wanchengBtn.layer.masksToBounds=YES;
_wanchengBtn.layer.cornerRadius=6;
UIView*phoneView=[[UIView alloc]initWithFrame:CGRectMake(0,0, 10, 10)];
self.RepeadNewPassFiled.leftViewMode=UITextFieldViewModeAlways;
self.RepeadNewPassFiled.leftView=phoneView;
UIView*phoneView1=[[UIView alloc]initWithFrame:CGRectMake(0,0, 10, 10)];
self.nwPasswordField.leftView=phoneView1;
self.nwPasswordField.leftViewMode=UITextFieldViewModeAlways;
}
#pragma mark-处理收键盘
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[self hiddenKeybord];
}
-(void)hiddenKeybord{
[self.nwPasswordField resignFirstResponder];
[self.RepeadNewPassFiled resignFirstResponder];
}
- (IBAction)finishButton:(id)sender {
if ((self.nwPasswordField.text.length>=6&&self.nwPasswordField.text.length<=16)&&(self.RepeadNewPassFiled.text.length>=6&&self.nwPasswordField.text.length<=16)&&[self.nwPasswordField.text isEqualToString:self.RepeadNewPassFiled.text]) {
AFHTTPRequestOperationManager*mannager=[AFHTTPRequestOperationManager manager];
mannager.responseSerializer=[AFHTTPResponseSerializer serializer];
NSMutableDictionary * para = [NSMutableDictionary dictionary];
NSUserDefaults*userDefsult=[NSUserDefaults standardUserDefaults];
NSString*forgetPhoneNumber=[userDefsult objectForKey:@"forgetPhoneNumber"];
[para setValue:forgetPhoneNumber forKey:@"phoneNumber"];
NSString*pass=[MyMD5 md5:self.RepeadNewPassFiled.text];
[para setValue:pass forKey:@"userPassword"];
[mannager POST:kResetPassword parameters:para success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary*dict=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
NSString *result=dict[@"result"];
if ([result isEqualToString:@"100"]) {
[self showTitle:@"" messsage:@"修改成功"];
if (firstLogIn) {
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
}else{
[self.navigationController popToRootViewControllerAnimated:YES];
}
}else if ([result isEqualToString:@"101"]){
[self showTitle:@"" messsage:@" 修改失败"];
}else if ([result isEqualToString:@"201"]){
[self showTitle:@"" messsage:@"用户不存在"];
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[self showTitle:@"提醒" messsage:@"请检查网络"];
}];
}else if (![self.nwPasswordField.text isEqualToString:self.RepeadNewPassFiled.text]){
[self showTitle:@"" messsage:@" 两次输入密码不一致"];
}else {
[self showTitle:@"" messsage:@" 请输入6-16位密码"];
}
}
@end
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina3_5" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ResetViewController">
<connections>
<outlet property="RepeadNewPassFiled" destination="4cJ-8f-ous" id="Egb-VX-Le4"/>
<outlet property="nwPasswordField" destination="DCC-ij-T4b" id="fiX-RP-wfD"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
<outlet property="wanchengBtn" destination="H14-N5-30v" id="aHm-NZ-nVW"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="X4l-xG-txc">
<rect key="frame" x="21" y="93" width="278" height="187"/>
<subviews>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="重复新密码" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="4cJ-8f-ous">
<rect key="frame" x="25" y="63" width="228" height="33.5"/>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="4cJ-8f-ous" secondAttribute="height" multiplier="283:42" id="46V-Yh-Baa"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="H14-N5-30v">
<rect key="frame" x="25" y="124.5" width="228" height="35"/>
<color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="H14-N5-30v" secondAttribute="height" multiplier="283:43" id="SAH-aH-ccU"/>
</constraints>
<state key="normal" title="完成">
<color key="titleColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</state>
<connections>
<action selector="finishButton:" destination="-1" eventType="touchUpInside" id="sVt-Yg-Zcv"/>
</connections>
</button>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="新密码" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="DCC-ij-T4b">
<rect key="frame" x="25" y="21" width="228" height="34"/>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" secondItem="DCC-ij-T4b" secondAttribute="height" multiplier="283:42" id="LAh-0J-n3x"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits"/>
</textField>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="4cJ-8f-ous" firstAttribute="centerX" secondItem="X4l-xG-txc" secondAttribute="centerX" id="4xw-gJ-edp"/>
<constraint firstItem="DCC-ij-T4b" firstAttribute="leading" secondItem="X4l-xG-txc" secondAttribute="leading" constant="25" id="7LF-qb-TzK"/>
<constraint firstAttribute="trailing" secondItem="H14-N5-30v" secondAttribute="trailing" constant="25" id="8dN-zu-wV4"/>
<constraint firstItem="H14-N5-30v" firstAttribute="centerX" secondItem="X4l-xG-txc" secondAttribute="centerX" id="Anf-oJ-phn"/>
<constraint firstItem="H14-N5-30v" firstAttribute="top" secondItem="4cJ-8f-ous" secondAttribute="bottom" constant="28" id="NfC-A4-DZU"/>
<constraint firstItem="4cJ-8f-ous" firstAttribute="top" secondItem="DCC-ij-T4b" secondAttribute="bottom" constant="8" id="WfO-JI-6SP"/>
<constraint firstAttribute="trailing" secondItem="4cJ-8f-ous" secondAttribute="trailing" constant="25" id="XAj-ty-7XZ"/>
<constraint firstAttribute="trailing" secondItem="DCC-ij-T4b" secondAttribute="trailing" constant="25" id="ZuZ-js-ppd"/>
<constraint firstAttribute="width" secondItem="X4l-xG-txc" secondAttribute="height" multiplier="333:224" id="hk2-q0-gtZ"/>
<constraint firstItem="H14-N5-30v" firstAttribute="leading" secondItem="X4l-xG-txc" secondAttribute="leading" constant="25" id="qbV-n7-MW1"/>
<constraint firstItem="4cJ-8f-ous" firstAttribute="leading" secondItem="X4l-xG-txc" secondAttribute="leading" constant="25" id="wiO-Rv-0iV"/>
<constraint firstItem="DCC-ij-T4b" firstAttribute="top" secondItem="X4l-xG-txc" secondAttribute="top" constant="21" id="x1L-js-Ng9"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="X4l-xG-txc" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="GF0-9M-xaY"/>
<constraint firstAttribute="trailing" secondItem="X4l-xG-txc" secondAttribute="trailing" constant="21" id="cHn-a8-aIa"/>
<constraint firstItem="X4l-xG-txc" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" constant="93" id="iUe-sO-LRg"/>
<constraint firstItem="X4l-xG-txc" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="21" id="tGT-nH-dst"/>
</constraints>
<point key="canvasLocation" x="458.5" y="363.5"/>
</view>
</objects>
</document>
@@ -0,0 +1,34 @@
//
// XWCountryCodeController.h
// XWCountryCodeDemo
//
// Created by 邱学伟 on 16/4/19.
// Copyright © 2016年 邱学伟. All rights reserved.
// 国家代码选择界面
#import <UIKit/UIKit.h>
//1.代理传值
@protocol XWCountryCodeControllerDelegate <NSObject>
@optional
-(void)returnCountryCode:(NSString *)countryCode;
@end
//2.block传值 typedef void(^returnBlock)(NSString *showText);
typedef void(^returnCountryCodeBlock) (NSString *countryCodeStr);
@interface XWCountryCodeController : UIViewController
//代理
@property (nonatomic, assign) id<XWCountryCodeControllerDelegate> deleagete;
//block
//block声明属性
@property (nonatomic, copy) returnCountryCodeBlock returnCountryCodeBlock;
//block声明方法
-(void)toReturnCountryCode:(returnCountryCodeBlock)block;
@end
@@ -0,0 +1,238 @@
//
// XWCountryCodeController.m
// XWCountryCodeDemo
//
// Created by 邱学伟 on 16/4/19.
// Copyright © 2016年 邱学伟. All rights reserved.
//
#import "XWCountryCodeController.h"
//判断系统语言
#define CURR_LANG ([[NSLocale preferredLanguages] objectAtIndex:0])
#define LanguageIsEnglish ([CURR_LANG isEqualToString:@"en-US"] || [CURR_LANG isEqualToString:@"en-CA"] || [CURR_LANG isEqualToString:@"en-GB"] || [CURR_LANG isEqualToString:@"en-CN"] || [CURR_LANG isEqualToString:@"en"])
@interface XWCountryCodeController()<UITableViewDataSource,UITableViewDelegate,UISearchBarDelegate,UISearchDisplayDelegate>{
//国际代码主tableview
UITableView *countryCodeTableView;
//搜索
UISearchDisplayController *searchController;
// UISearchController *searchController;
UISearchBar *searchBar;
//代码字典
NSDictionary *sortedNameDict; //代码字典
NSArray *indexArray;
NSMutableArray *searchResultValuesArray;
}
@end
@interface XWCountryCodeController ()
@end
@implementation XWCountryCodeController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
//背景
[self.view setBackgroundColor:[UIColor whiteColor]];
//顶部标题
[self.navigationItem setTitle:@"国家代码"];
//创建子视图
[self creatSubviews];
}
//创建子视图
-(void)creatSubviews{
searchResultValuesArray = [[NSMutableArray alloc] init];
countryCodeTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, self.view.bounds.size.height-20) style:UITableViewStylePlain];
[self.view addSubview:countryCodeTableView];
//自动调整自己的宽度,保证与superView左边和右边的距离不变。
[countryCodeTableView setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[countryCodeTableView setDataSource:self];
[countryCodeTableView setDelegate:self];
[countryCodeTableView setSectionIndexBackgroundColor:[UIColor clearColor]];
searchBar = [[UISearchBar alloc] init];
[searchBar sizeToFit];
[searchBar setDelegate:self];
//关闭系统自动联想和首字母大写功能
[searchBar setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[countryCodeTableView setTableHeaderView:searchBar];
searchController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self];
[searchController setDelegate:self];
searchController.searchResultsDataSource = self;
searchController.searchResultsDelegate = self;
NSString *plistPathCH = [[NSBundle mainBundle] pathForResource:@"sortedChnames" ofType:@"plist"];
NSString *plistPathEN = [[NSBundle mainBundle] pathForResource:@"sortedEnames" ofType:@"plist"];
//判断当前系统语言
if (LanguageIsEnglish) {
sortedNameDict = [NSDictionary dictionaryWithContentsOfFile:plistPathEN];
}else{
sortedNameDict = [NSDictionary dictionaryWithContentsOfFile:plistPathCH];
}
indexArray = [sortedNameDict allKeys];
indexArray = [indexArray sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
return [obj1 compare:obj2];
}];
NSLog(@"sortedChnamesDict %@",sortedNameDict);
}
//搜索
-(void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
NSLog(@"%s",__FUNCTION__);
[searchResultValuesArray removeAllObjects];
for (NSArray *array in [sortedNameDict allValues]) {
for (NSString *value in array) {
if ([value containsString:searchBar.text]) {
[searchResultValuesArray addObject:value];
}
}
}
[searchController.searchResultsTableView reloadData];
}
#pragma mark - UITableView
//section
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
if (tableView == countryCodeTableView) {
return [sortedNameDict allKeys].count;
}else{
return 1;
}
}
//row
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
if (tableView == countryCodeTableView) {
NSArray *array = [sortedNameDict objectForKey:[indexArray objectAtIndex:section]];
return array.count;
}else{
return [searchResultValuesArray count];
}
}
//height
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 44;
}
//初始化cell
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (tableView == countryCodeTableView) {
static NSString *ID1 = @"cellIdentifier1";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID1];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID1];
}
//初始化cell数据!
NSInteger section = indexPath.section;
NSInteger row = indexPath.row;
cell.textLabel.text = [[sortedNameDict objectForKey:[indexArray objectAtIndex:section]] objectAtIndex:row];
[cell.textLabel setFont:[UIFont systemFontOfSize:16]];
return cell;
}else{
static NSString *ID2 = @"cellIdentifier2";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID2];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID2];
}
if ([searchResultValuesArray count] > 0) {
cell.textLabel.text = [searchResultValuesArray objectAtIndex:indexPath.row];
}
return cell;
}
}
//indexTitle
-(NSArray<NSString *> *)sectionIndexTitlesForTableView:(UITableView *)tableView{
if (tableView == countryCodeTableView) {
return indexArray;
}else{
return nil;
}
}
//
-(NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index{
if (tableView == countryCodeTableView) {
return index;
}else{
return 0;
}
}
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (tableView == countryCodeTableView) {
if (section == 0) {
return 0;
}
return 30;
}else {
return 0;
}
}
- (NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [indexArray objectAtIndex:section];
}
#pragma mark - 选择国际获取代码
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
NSLog(@"选择相应国家,输出:%@",cell.textLabel.text);
// //1.代理传值
// if (self.deleagete && [self.deleagete respondsToSelector:@selector(returnCountryCode:)]) {
// [self.deleagete returnCountryCode:cell.textLabel.text];
// }
// [self dismissViewControllerAnimated:YES completion:nil];
//2.block传值
if (self.returnCountryCodeBlock != nil) {
self.returnCountryCodeBlock(cell.textLabel.text);
}
[self dismissViewControllerAnimated:YES completion:nil];
}
-(void)toReturnCountryCode:(returnCountryCodeBlock)block{
self.returnCountryCodeBlock = block;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// 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.
}
*/
@end