个人信息修改
This commit is contained in:
@@ -32,4 +32,5 @@
|
||||
title:(NSString *)aTitle;
|
||||
+ (void)messageAddto:(UIView *)aView title:(NSString *)aTitle;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -65,5 +65,7 @@
|
||||
*/
|
||||
|
||||
+(BOOL)checkPassWord:(NSString *)pass;
|
||||
//
|
||||
+(int)convertToInt:(NSString*)strtemp;
|
||||
|
||||
@end
|
||||
|
||||
@@ -265,4 +265,21 @@
|
||||
return NO;
|
||||
}
|
||||
|
||||
//获取中英文字符长度
|
||||
+(int)convertToInt:(NSString*)strtemp
|
||||
{
|
||||
int strlength = 0;
|
||||
char* p = (char*)[strtemp cStringUsingEncoding:NSUnicodeStringEncoding];
|
||||
for (int i=0 ; i<[strtemp lengthOfBytesUsingEncoding:NSUnicodeStringEncoding] ;i++) {
|
||||
if (*p) {
|
||||
p++;
|
||||
strlength++;
|
||||
}
|
||||
else {
|
||||
p++;
|
||||
}
|
||||
|
||||
}
|
||||
return strlength;
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// GIGaFileManager.h
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/9/18.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface GIGaFileManager : NSObject
|
||||
+(void)savaUserAvatorWith:(NSString *)userId image:(UIImage *)image;
|
||||
+(UIImage *)getUserAvatorWith:(NSString *)userId;
|
||||
+ (UIImage *) scaleFromImage: (UIImage *) image toSize: (CGSize) size;
|
||||
+ (UIImage *)thumbnailWithImageWithoutScale:(UIImage *)image size:(CGSize)asize;
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,87 @@
|
||||
|
||||
//
|
||||
// GIGaFileManager.m
|
||||
// GIGA
|
||||
//
|
||||
// Created by lianxiang on 2018/9/18.
|
||||
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
||||
//
|
||||
|
||||
#import "GIGaFileManager.h"
|
||||
|
||||
@implementation GIGaFileManager
|
||||
|
||||
+(void)savaUserAvatorWith:(NSString *)userId image:(UIImage *)image{
|
||||
if (!userId) {
|
||||
GILog(@"userID nil !!!");
|
||||
return;
|
||||
}
|
||||
NSData*imageData=UIImageJPEGRepresentation(image,1.0f);
|
||||
NSString *fullPath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:userId];
|
||||
[imageData writeToFile:fullPath atomically:YES];
|
||||
|
||||
}
|
||||
|
||||
+ (UIImage *)getUserAvatorWith:(NSString *)userId{
|
||||
|
||||
if (!userId) {
|
||||
GILog(@"userID nil !!!");
|
||||
return nil;
|
||||
}
|
||||
NSString*fullpath=[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]stringByAppendingPathComponent:userId];
|
||||
UIImage*saveImage=[[UIImage alloc]initWithContentsOfFile:fullpath];
|
||||
if (!saveImage) {
|
||||
saveImage = [UIImage imageNamed:@"img_circle_avatar"];
|
||||
}
|
||||
return saveImage;
|
||||
|
||||
}
|
||||
|
||||
// 改变图像的尺寸,方便上传服务器
|
||||
+ (UIImage *) scaleFromImage: (UIImage *) image toSize: (CGSize) size
|
||||
{
|
||||
UIGraphicsBeginImageContext(size);
|
||||
[image drawInRect:CGRectMake(0, 0, size.width, size.height)];
|
||||
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
return newImage;
|
||||
}
|
||||
//保持原来的长宽比,生成一个缩略图
|
||||
+ (UIImage *)thumbnailWithImageWithoutScale:(UIImage *)image size:(CGSize)asize
|
||||
{
|
||||
UIImage *newimage;
|
||||
if (nil == image) {
|
||||
newimage = nil;
|
||||
}
|
||||
else{
|
||||
CGSize oldsize = image.size;
|
||||
CGRect rect;
|
||||
if (asize.width/asize.height > oldsize.width/oldsize.height) {
|
||||
rect.size.width = asize.width*oldsize.height/oldsize.width;
|
||||
// rect.size.height = asize.height*oldsize.height/oldsize.width;
|
||||
rect.size.height = asize.width*oldsize.height/oldsize.width;
|
||||
rect.origin.x = (asize.width - rect.size.width)/2;
|
||||
|
||||
rect.origin.y = 0;
|
||||
}
|
||||
else{
|
||||
//rect.size.width = asize.width;
|
||||
rect.size.width = asize.height*oldsize.width/oldsize.height;
|
||||
rect.size.height = asize.height*oldsize.width/oldsize.height;
|
||||
rect.origin.x = 0;
|
||||
rect.origin.y = (asize.height - rect.size.height)/2;
|
||||
|
||||
}
|
||||
UIGraphicsBeginImageContext(asize);
|
||||
CGContextRef context = UIGraphicsGetCurrentContext();
|
||||
CGContextSetFillColorWithColor(context, [[UIColor clearColor] CGColor]);
|
||||
UIRectFill(CGRectMake(0, 0, asize.width, asize.height));//clear background
|
||||
[image drawInRect:rect];
|
||||
newimage = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
}
|
||||
return newimage;
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -101,7 +101,7 @@ const static NSInteger GIGADB_USER_VER = 0;//当前数据库版本号
|
||||
NSString *useriD = [GiGaUserDefault getCurentUserId];
|
||||
NSArray *usrA= [_store getObjectById:useriD fromTable:GIGA_USER_TABLE];
|
||||
if (usrA && usrA.count > 0) {
|
||||
//self.user = usrA[0];
|
||||
|
||||
NSDictionary *userdic = usrA[0];
|
||||
GiGaUser *user = [[GiGaUser alloc] initWithDictionary:userdic error:nil];;
|
||||
self.user = user;
|
||||
|
||||
Reference in New Issue
Block a user