Skip to content

Commit

Permalink
master:合并dev,修改密码功能完成
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyufeng1991 committed Nov 17, 2015
2 parents 1f7b711 + 016777b commit eca477b
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 5 deletions.
6 changes: 6 additions & 0 deletions Oncenote.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
719AF3BD1BFB10CD009D602D /* SettingList.m in Sources */ = {isa = PBXBuildFile; fileRef = 719AF3BC1BFB10CD009D602D /* SettingList.m */; settings = {ASSET_TAGS = (); }; };
719AF3C01BFB18DE009D602D /* NicknameViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 719AF3BF1BFB18DE009D602D /* NicknameViewController.m */; settings = {ASSET_TAGS = (); }; };
719AF3C31BFB5973009D602D /* AboutAppViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 719AF3C21BFB5973009D602D /* AboutAppViewController.m */; settings = {ASSET_TAGS = (); }; };
719AF3C61BFB5E21009D602D /* UpdatePasswordViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 719AF3C51BFB5E21009D602D /* UpdatePasswordViewController.m */; settings = {ASSET_TAGS = (); }; };
71A793751BF5B5F000410FFC /* LoginViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 71A793741BF5B5F000410FFC /* LoginViewController.m */; settings = {ASSET_TAGS = (); }; };
71A793781BF5CDCA00410FFC /* RegisterViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 71A793771BF5CDCA00410FFC /* RegisterViewController.m */; settings = {ASSET_TAGS = (); }; };
71A7937C1BF5E75600410FFC /* BmobOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 71A7937B1BF5E75600410FFC /* BmobOperation.m */; settings = {ASSET_TAGS = (); }; };
Expand Down Expand Up @@ -167,6 +168,8 @@
719AF3BF1BFB18DE009D602D /* NicknameViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NicknameViewController.m; sourceTree = "<group>"; };
719AF3C11BFB5973009D602D /* AboutAppViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AboutAppViewController.h; sourceTree = "<group>"; };
719AF3C21BFB5973009D602D /* AboutAppViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AboutAppViewController.m; sourceTree = "<group>"; };
719AF3C41BFB5E21009D602D /* UpdatePasswordViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UpdatePasswordViewController.h; sourceTree = "<group>"; };
719AF3C51BFB5E21009D602D /* UpdatePasswordViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UpdatePasswordViewController.m; sourceTree = "<group>"; };
71A793731BF5B5F000410FFC /* LoginViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginViewController.h; sourceTree = "<group>"; };
71A793741BF5B5F000410FFC /* LoginViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginViewController.m; sourceTree = "<group>"; };
71A793761BF5CDCA00410FFC /* RegisterViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterViewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -407,6 +410,8 @@
719AF3BF1BFB18DE009D602D /* NicknameViewController.m */,
719AF3C11BFB5973009D602D /* AboutAppViewController.h */,
719AF3C21BFB5973009D602D /* AboutAppViewController.m */,
719AF3C41BFB5E21009D602D /* UpdatePasswordViewController.h */,
719AF3C51BFB5E21009D602D /* UpdatePasswordViewController.m */,
);
name = ViewController;
sourceTree = "<group>";
Expand Down Expand Up @@ -709,6 +714,7 @@
71A793781BF5CDCA00410FFC /* RegisterViewController.m in Sources */,
718FF3A31BF623B7009A3F6D /* AddNoteViewController.m in Sources */,
719AF3BD1BFB10CD009D602D /* SettingList.m in Sources */,
719AF3C61BFB5E21009D602D /* UpdatePasswordViewController.m in Sources */,
71A7937C1BF5E75600410FFC /* BmobOperation.m in Sources */,
71BEC27E1BF717190003F173 /* Notes.m in Sources */,
71A793751BF5B5F000410FFC /* LoginViewController.m in Sources */,
Expand Down
93 changes: 90 additions & 3 deletions Oncenote/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
<color key="backgroundColor" red="0.89019607840000003" green="0.89019607840000003" blue="0.89019607840000003" alpha="1" colorSpace="calibratedRGB"/>
</view>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="50" sectionHeaderHeight="28" sectionFooterHeight="28" id="40P-a1-PyT">
<rect key="frame" x="0.0" y="66" width="320" height="150"/>
<rect key="frame" x="0.0" y="66" width="320" height="200"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
Expand Down Expand Up @@ -304,6 +304,93 @@
</objects>
<point key="canvasLocation" x="1760" y="878"/>
</scene>
<!--Update Password View Controller-->
<scene sceneID="4G1-ik-Vna">
<objects>
<viewController storyboardIdentifier="UpdatePasswordViewController" useStoryboardIdentifierAsRestorationIdentifier="YES" id="Feb-9a-9W1" customClass="UpdatePasswordViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="h8n-48-cLs">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" id="HpI-3X-rQ5">
<rect key="frame" x="0.0" y="0.0" width="320" height="65"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="Tsy-Tr-LhS">
<rect key="frame" x="13" y="25" width="40" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="取消">
<color key="titleColor" red="0.0" green="0.52941176469999995" blue="0.25882352939999997" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="naviCancelButtonPressed:" destination="Feb-9a-9W1" eventType="touchUpInside" id="6MP-g7-NdV"/>
<action selector="naviCancelButtonPressed:" destination="xNu-qL-Wmw" eventType="touchUpInside" id="FP1-6o-YgM"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="修改密码" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="GWl-5Z-s6C">
<rect key="frame" x="120" y="29" width="80" height="24"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="20"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="brO-aF-cb8">
<rect key="frame" x="264" y="25" width="32" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="完成">
<color key="titleColor" red="0.0" green="0.52941176469999995" blue="0.25882352939999997" alpha="1" colorSpace="calibratedRGB"/>
</state>
<connections>
<action selector="naviDoneButtonPressed:" destination="xNu-qL-Wmw" eventType="touchUpInside" id="DYC-2K-yAY"/>
<action selector="naviDoneButtonPressed:" destination="Feb-9a-9W1" eventType="touchUpInside" id="eZS-zk-Boo"/>
<action selector="naviLogoutButtonPressed:" destination="uPh-2i-OcR" eventType="touchUpInside" id="09h-rg-poK"/>
<action selector="naviStoreButtonPressed:" destination="TeH-OH-vUw" eventType="touchUpInside" id="aUy-TX-afL"/>
</connections>
</button>
</subviews>
<animations/>
<color key="backgroundColor" red="0.93725490199999995" green="0.93725490199999995" blue="0.95686274510000002" alpha="1" colorSpace="calibratedRGB"/>
</view>
<view contentMode="scaleToFill" id="afm-js-AeY">
<rect key="frame" x="-326" y="65" width="1000" height="1"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<color key="backgroundColor" red="0.89019607840000003" green="0.89019607840000003" blue="0.89019607840000003" alpha="1" colorSpace="calibratedRGB"/>
</view>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="输入原密码" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" id="1m7-3u-APy">
<rect key="frame" x="25" y="100" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<color key="backgroundColor" red="0.38823529410000002" green="0.76078431369999999" blue="0.47843137250000001" alpha="0.80133551520000001" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no"/>
</textField>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="输入新密码" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" id="Ak3-18-G9A">
<rect key="frame" x="25" y="148" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<color key="backgroundColor" red="0.38823529410000002" green="0.76078431369999999" blue="0.47843137250000001" alpha="0.80133551520000001" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<textInputTraits key="textInputTraits" autocorrectionType="no" spellCheckingType="no"/>
</textField>
</subviews>
<animations/>
<color key="backgroundColor" red="0.27058823529411763" green="0.69019607843137254" blue="0.38039215686274508" alpha="1" colorSpace="calibratedRGB"/>
</view>
<connections>
<outlet property="nowPasswordTextField" destination="Ak3-18-G9A" id="V8h-aa-r50"/>
<outlet property="oldPasswordTextField" destination="1m7-3u-APy" id="lXd-r0-mV9"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="tL2-rD-LL2" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2266" y="1266"/>
</scene>
<!--About App View Controller-->
<scene sceneID="70c-Dg-Mpd">
<objects>
Expand Down Expand Up @@ -407,7 +494,7 @@
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="h39-3o-fRo" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2266" y="1278"/>
<point key="canvasLocation" x="2272" y="2050"/>
</scene>
<!--Nickname View Controller-->
<scene sceneID="T6s-sg-zZ9">
Expand Down Expand Up @@ -466,7 +553,7 @@
<color key="backgroundColor" red="0.89019607840000003" green="0.89019607840000003" blue="0.89019607840000003" alpha="1" colorSpace="calibratedRGB"/>
</view>
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="输入你的昵称" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" id="A2m-Iy-sUK">
<rect key="frame" x="20" y="88" width="280" height="40"/>
<rect key="frame" x="20" y="100" width="280" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<animations/>
<color key="backgroundColor" red="0.38823529410000002" green="0.76078431369999999" blue="0.47843137250000001" alpha="0.80133551520000001" colorSpace="calibratedRGB"/>
Expand Down
2 changes: 1 addition & 1 deletion Oncenote/SettingList.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ - (instancetype)init
{
self = [super init];
if (self) {
self.settingListArray = [[NSArray alloc] initWithObjects:@"个人资料",@"应用官网",@"关于", nil];
self.settingListArray = [[NSArray alloc] initWithObjects:@"个人资料",@"修改密码",@"应用官网",@"关于", nil];
}
return self;
}
Expand Down
10 changes: 9 additions & 1 deletion Oncenote/SettingViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,23 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
}
break;


case 1:{
//修改密码;
[AllUtils jumpToViewController:@"UpdatePasswordViewController" contextViewController:self handler:nil];

}
break;

case 2:{

//从safari打开网页;
[[UIApplication sharedApplication] openURL:[[NSURL alloc] initWithString:@"http://oncenote.bmob.cn/"]];

}
break;

case 2:{
case 3:{

[AllUtils jumpToViewController:@"AboutAppViewController" contextViewController:self handler:nil];
}
Expand Down
13 changes: 13 additions & 0 deletions Oncenote/UpdatePasswordViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// UpdatePasswordViewController.h
// Oncenote
//
// Created by chenyufeng on 15/11/17.
// Copyright © 2015年 chenyufengweb. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UpdatePasswordViewController : UIViewController

@end
104 changes: 104 additions & 0 deletions Oncenote/UpdatePasswordViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@

//
// UpdatePasswordViewController.m
// Oncenote
//
// Created by chenyufeng on 15/11/17.
// Copyright © 2015年 chenyufengweb. All rights reserved.
//

#import "UpdatePasswordViewController.h"
#import "AllUtils.h"
#import <BmobSDK/Bmob.h>
#import "Constant.h"
#import "AppDelegate.h"

@interface UpdatePasswordViewController ()

@property (weak, nonatomic) IBOutlet UITextField *oldPasswordTextField;
@property (weak, nonatomic) IBOutlet UITextField *nowPasswordTextField;

@end

@implementation UpdatePasswordViewController

- (void)viewDidLoad {
[super viewDidLoad];


}

#pragma mark - 所有按钮的点击事件

- (IBAction)naviCancelButtonPressed:(id)sender {

[AllUtils jumpToViewController:@"SettingViewController" contextViewController:self handler:nil];

}



- (IBAction)naviDoneButtonPressed:(id)sender {

AppDelegate *app = [[UIApplication sharedApplication] delegate];
[self isOldPasswordRight:USER_TABLE userId:app.GLOBAL_USERID oldPassword:self.oldPasswordTextField.text];

}


#pragma mark - 判断原密码是否正确
- (void)isOldPasswordRight:(NSString*)tableName userId:(NSString*)userId oldPassword:(NSString*)oldPassword{

AppDelegate *app = [[UIApplication sharedApplication] delegate];
[BmobUser loginWithUsernameInBackground:app.GLOBAL_USERNAME password:oldPassword block:^(BmobUser *user, NSError *error) {
if (error) {
[AllUtils showPromptDialog:@"提示" andMessage:@"您输入的原密码错误,请确认后再修改密码" OKButton:@"确定" OKButtonAction:nil cancelButton:@"" cancelButtonAction:nil contextViewController:self];
}else{
//原密码正确,可以修改密码;
if ([self.nowPasswordTextField.text isEqualToString:@""]) {
[AllUtils showPromptDialog:@"提示" andMessage:@"新密码不能为空!" OKButton:@"确定" OKButtonAction:nil cancelButton:@"" cancelButtonAction:nil contextViewController:self];
}else{
//正式修改;
[AllUtils showPromptDialog:@"提示" andMessage:@"修改密码后将重新登录,确认修改吗?" OKButton:@"确定" OKButtonAction:^(UIAlertAction *action) {
[self updatePassword:USER_TABLE userId:app.GLOBAL_USERID nowPassword:self.nowPasswordTextField.text];
} cancelButton:@"取消" cancelButtonAction:nil contextViewController:self];
}
}
}];

}

#pragma mark - 修改新密码
- (void)updatePassword:(NSString*)tableName userId:(NSString*)userId nowPassword:(NSString*)nowPassword{

BmobQuery *update = [BmobQuery queryWithClassName:tableName];
[update getObjectInBackgroundWithId:userId block:^(BmobObject *object, NSError *error) {

if (!error) {
if (object) {
[object setObject:nowPassword forKey:@"password"];
[object updateInBackgroundWithResultBlock:^(BOOL isSuccessful, NSError *error) {
if (isSuccessful) {
//跳转到登录界面;
[AllUtils jumpToViewController:@"LoginViewController" contextViewController:self handler:nil];
} else {
[AllUtils showPromptDialog:@"提示" andMessage:@"网络异常,修改密码失败!" OKButton:@"确定" OKButtonAction:nil cancelButton:@"" cancelButtonAction:nil contextViewController:self];
}
}];
}
}else{
//错误处理
}

}];

}


@end






0 comments on commit eca477b

Please sign in to comment.