个人信息修改
This commit is contained in:
@@ -131,4 +131,10 @@ typedef void (^GiGaRequestResultBlock)(GiGaAPIResult *result);
|
||||
//+ (NSString *)resizeImageUrl:(NSString *)originImageUrl
|
||||
// size:(CGSize)size;
|
||||
|
||||
|
||||
+(void)userTokenTimeOutGologinFromVC:(UIViewController *)vc;
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#import "GiGaServerConfig.h"
|
||||
#import <JSONModel/JSONModel.h>
|
||||
#import "GiGaNetManager.h"
|
||||
#import "GiGaUserLoginVC.h"
|
||||
|
||||
@implementation GiGaBaseAPiRequest
|
||||
|
||||
@@ -159,4 +160,13 @@
|
||||
|
||||
}
|
||||
|
||||
+(void)userTokenTimeOutGologinFromVC:(UIViewController *)vc{
|
||||
|
||||
GiGaUserLoginVC *userlogInVC= [[GiGaUserLoginVC alloc] init];
|
||||
GiGaBaseNavViewController *baseNav = [[GiGaBaseNavViewController alloc] initWithRootViewController:userlogInVC];
|
||||
[vc presentViewController:baseNav animated:YES completion:nil];
|
||||
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -19,9 +19,13 @@ typedef void (^responseBlock)(NSDictionary *responseDict, NSDictionary *response
|
||||
success:(void (^)(id response))success
|
||||
failure:(void (^)(NSError *err))failure;
|
||||
|
||||
// 测试题 , 登录
|
||||
// 测试题 , 登录 body 传参
|
||||
+(void)userbodyRequest:(NSString *)url params:(NSDictionary *)param completionHandler:(nullable void (^)(NSURLResponse *response, NSDictionary *resDic, NSError * _Nullable error))completionHandler;
|
||||
|
||||
|
||||
//上传图片
|
||||
+(void)uploadImage:(NSString *)url
|
||||
imgData:(NSData *)imgData
|
||||
parms:(NSDictionary *)parms
|
||||
responseBlock:(responseBlock)block;
|
||||
|
||||
@end
|
||||
|
||||
@@ -131,7 +131,57 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
+(void)uploadImage:(NSString *)url
|
||||
imgData:(NSData *)imgData
|
||||
parms:(NSDictionary *)parms
|
||||
responseBlock:(responseBlock)block{
|
||||
|
||||
AFHTTPSessionManager*manager=[[AFHTTPSessionManager alloc] init];
|
||||
manager.responseSerializer=[AFHTTPResponseSerializer serializer];
|
||||
NSString *token = [GiGaUserDefault getCurentToken];
|
||||
if (token) {
|
||||
[manager.requestSerializer setValue:token forHTTPHeaderField:@"token"];
|
||||
}
|
||||
|
||||
[manager POST:url parameters:parms constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
|
||||
|
||||
//上传时使用当前的系统事件作为文件名
|
||||
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
|
||||
|
||||
formatter.dateFormat = @"yyyyMMddHHmmss";
|
||||
|
||||
NSString *str = [formatter stringFromDate:[NSDate date]];
|
||||
|
||||
NSString *fileName = [NSString stringWithFormat:@"%@.jpg", str];
|
||||
//服务器上传文件的字段和类型
|
||||
|
||||
[formData appendPartWithFileData:imgData name:@"file" fileName:fileName mimeType:@"image/jpeg"];
|
||||
NSString *userId = [GiGaUserDefault getCurentUserId];
|
||||
if (!userId) {
|
||||
userId = @"avator123";
|
||||
}
|
||||
|
||||
[formData appendPartWithFormData:imgData name:userId];
|
||||
|
||||
} progress:^(NSProgress * _Nonnull uploadProgress) {
|
||||
|
||||
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
|
||||
|
||||
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
|
||||
NSLog(@"%@", dict);
|
||||
NSDictionary *headerFields = [(NSHTTPURLResponse *)task.response allHeaderFields];
|
||||
if (block) {
|
||||
block(dict, headerFields, nil);
|
||||
}
|
||||
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
NSDictionary *headerFields = [(NSHTTPURLResponse *)task.response allHeaderFields];
|
||||
if (block) {
|
||||
block(nil, headerFields, error);
|
||||
}
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user