项目中 登录注册逻辑判断
来源:互联网 发布:淘宝数据分析网站 编辑:程序博客网 时间:2024/06/06 19:53
在项目中用的 是三方服务器。做的demo 短信验证 。记录逻辑实现 比较简单 在button的点击事件中进行判断
- (void)buttonAction:(UIButton *)buttonAction {
/*** 首先 进入注册后 . 进入后台服务器 查找用户名信息是否含有 如果有提示 : 已注册过可直接登录 直接return 返回结束事件
* 其次 没有注册过 . sdk 发送短信验证 没上线登记 每日限20条 。如果发送成功 跳转到下级页面 进行验证 成功后模态回个人界面
* 手机 格式不对 提示 手机格式不正确
*/
BmobQuery *bquery = [BmobQuery queryWithClassName:@"_User"];
// 表的数据
[bquery findObjectsInBackgroundWithBlock:^(NSArray *array, NSError *error) {
for (BmobObject *obj in array) {
//打印Name
// NSLog(@"obj.playerName = %@", [obj objectForKey:@"username"]);
// 老用户
if ([[obj objectForKey:@"username"] isEqualToString:_userName.text]) {
UIAlertController *hyAlert = [UIAlertController alertControllerWithTitle:@"提示" message:@"该账户注册过,可直接登录" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *alertAc = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// 方法回调
}];
[hyAlert addAction:alertAc];
[self presentViewController:hyAlert animated:YES completion:nil];
return;
}
}
// 新用户
/**
* @from v1.1.1
* @brief 获取验证码(Get verification code)
*
* @param method 获取验证码的方法(The method of getting verificationCode)
* @param phoneNumber 电话号码(The phone number)
* @param zone 区域号,不要加"+"号(Area code)
* @param customIdentifier 自定义短信模板标识 该标识需从官网http://www.mob.com上申请,审核通过后获得。(Custom model of SMS. The identifier can get it from http://www.mob.com when the application had approved)
* @param result 请求结果回调(Results of the request)
*/
[SMSSDK getVerificationCodeByMethod:SMSGetCodeMethodSMS phoneNumber:_userName.text zone:@"86" customIdentifier:nil result:^(NSError *error){
if (!error) {
NSLog(@"获取验证码成功");
MessageViewController *vc = [MessageViewController new];
vc.string = _userName.text;
[self.navigationController pushViewController:vc animated:YES];
// 在手机号正确的前提下 bmob 中插入一条数据 插入用户名密码进来.
BmobObject *userScore = [BmobObject objectWithoutDatatWithClassName:@"_User" objectId:_userName.text];
[userScore setObject:_userName.text forKey:@"username"];
[userScore setObject:_passWord.text forKey:@"password"];
[userScore saveInBackgroundWithResultBlock:^(BOOL isSuccessful, NSError *error) {
//进行操作
}];
} else {
NSLog(@"错误信息:%@",error);
UIAlertController *errorAlert = [UIAlertController alertControllerWithTitle:@"提示" message:@"请输正确手机号" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
// 方法回调
}];
[errorAlert addAction:alertAction];
[self presentViewController:errorAlert animated:YES completion:nil];
}
}];
}];
}
0 0
- 项目中 登录注册逻辑判断
- 项目实战:Android中登录&注册二三事
- [py]登录注册逻辑设置
- 登录注册常用JQuery逻辑
- unity项目中使用到的登陆注册逻辑备注
- 项目 功能: > 注册 > 登录
- 毕业设计(九)---注册和登录逻辑
- ecshop 会员登录注册业务逻辑实现
- 微信授权、登录、注册逻辑
- 登录注册判断密码再次输入
- 注册登录流程逻辑以及cookie的总结
- 项目登录、注册页面的收获
- 【JavaSE_项目练习】用户登录注册
- Android开发中单用户登录的逻辑
- 登录逻辑
- 用户登录流程中,记住密码和自动登录逻辑。
- 在Ant中使用逻辑判断 Condition
- shell 中目录切换、逻辑判断
- ROS学习(二)server和client的编写总结
- UVA - 10305 Ordering Tasks(拓扑排序)
- GitHub 的协同开发
- 初识mybatis
- 网络流24题之十三 星际转移 分层图网络流
- 项目中 登录注册逻辑判断
- 生成唯一id号解决方法
- 第5周项目1:三角形类雏形(4)
- Android中常见的异常
- 第五周项目二------游戏角色
- 33 继承(五)
- Activity本身作为事件监听器类
- 第四次上机实践项目-项目4-长方柱
- java--多线程