1
This commit is contained in:
@@ -43,6 +43,11 @@
|
||||
if (identityToken.length) params[@"identityToken"] = identityToken;
|
||||
if (authorizationCode.length) params[@"accessCode"] = authorizationCode; // 仅供后端需要时使用
|
||||
if (cred.user.length) params[@"userID"] = cred.user; // 可选
|
||||
// 如有本地缓存的性别(首次进入首页时选择),一并上传给后端
|
||||
NSNumber *genderNumber = [self kb_localGenderParamIfAvailable];
|
||||
if (genderNumber != nil) {
|
||||
params[@"gender"] = genderNumber;
|
||||
}
|
||||
[KBHUD show];
|
||||
// 向服务端发起校验
|
||||
[[KBNetworkManager shared] POST:API_APPLE_LOGIN jsonBody:params headers:nil completion:^(NSDictionary * _Nullable jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
@@ -77,6 +82,11 @@
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
if (email.length) params[@"email"] = email;
|
||||
if (password.length) params[@"password"] = password;
|
||||
// 如有本地缓存的性别(首次进入首页时选择),一并上传给后端
|
||||
NSNumber *genderNumber = [self kb_localGenderParamIfAvailable];
|
||||
if (genderNumber != nil) {
|
||||
params[@"gender"] = genderNumber;
|
||||
}
|
||||
// 向服务端发起校验
|
||||
[[KBNetworkManager shared] POST:API_EMAIL_LOGIN jsonBody:params headers:nil completion:^(NSDictionary * _Nullable jsonOrData, NSURLResponse * _Nullable response, NSError * _Nullable error) {
|
||||
[KBHUD dismiss];
|
||||
@@ -127,4 +137,21 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
/// 读取本地缓存的性别枚举值,用于登录接口上传到后端。
|
||||
/// - 用户在首次进入首页的性别选择页或个人资料页中选择后,会持久化到 NSUserDefaults。
|
||||
- (nullable NSNumber *)kb_localGenderParamIfAvailable {
|
||||
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
|
||||
// 只有在用户真正看过性别选择页后,才认为本地的性别有效
|
||||
BOOL hasShownSexVC = [ud boolForKey:KBSexSelectShownKey];
|
||||
if (!hasShownSexVC) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSInteger value = [ud integerForKey:KBSexSelectedGenderKey];
|
||||
if (value < UserSexMan || value > UserSexTwoSex) {
|
||||
return nil;
|
||||
}
|
||||
return @(value);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user