fix 首页

This commit is contained in:
lianxiang 2018-09-13 23:42:18 +08:00
parent 7d0027f58d
commit fada68d22d
62 changed files with 860 additions and 158 deletions

View File

@ -93,6 +93,8 @@
838388D3212FB7D700D14C53 /* JXTAlertController.m in Sources */ = {isa = PBXBuildFile; fileRef = 838388CE212FB7D700D14C53 /* JXTAlertController.m */; };
838388D4212FB7D700D14C53 /* JXTAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 838388D2212FB7D700D14C53 /* JXTAlertView.m */; };
838388DA2130046D00D14C53 /* emojizone.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 838388D92130046D00D14C53 /* emojizone.mp4 */; };
8384643E214A484400F12B33 /* MaskTestResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 8384643D214A484400F12B33 /* MaskTestResult.m */; };
83846441214A4BFF00F12B33 /* MaskTestResultVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 83846440214A4BFF00F12B33 /* MaskTestResultVC.m */; };
838500DC2137F3F7003514A3 /* GiGaAttributedLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 838500DB2137F3F7003514A3 /* GiGaAttributedLabel.m */; };
83928FFA2134D8F60077D2E8 /* GiGaFlyingCommitInputView.m in Sources */ = {isa = PBXBuildFile; fileRef = 83928FF92134D8F60077D2E8 /* GiGaFlyingCommitInputView.m */; };
83928FFE2134F37D0077D2E8 /* GiGaSocketRocketUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = 83928FFD2134F37D0077D2E8 /* GiGaSocketRocketUtility.m */; };
@ -294,6 +296,10 @@
838388D1212FB7D700D14C53 /* JXTAlertView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JXTAlertView.h; sourceTree = "<group>"; };
838388D2212FB7D700D14C53 /* JXTAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JXTAlertView.m; sourceTree = "<group>"; };
838388D92130046D00D14C53 /* emojizone.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = emojizone.mp4; sourceTree = "<group>"; };
8384643C214A484400F12B33 /* MaskTestResult.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MaskTestResult.h; sourceTree = "<group>"; };
8384643D214A484400F12B33 /* MaskTestResult.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MaskTestResult.m; sourceTree = "<group>"; };
8384643F214A4BFF00F12B33 /* MaskTestResultVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MaskTestResultVC.h; sourceTree = "<group>"; };
83846440214A4BFF00F12B33 /* MaskTestResultVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MaskTestResultVC.m; sourceTree = "<group>"; };
838500DA2137F3F7003514A3 /* GiGaAttributedLabel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaAttributedLabel.h; sourceTree = "<group>"; };
838500DB2137F3F7003514A3 /* GiGaAttributedLabel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GiGaAttributedLabel.m; sourceTree = "<group>"; };
83928FF82134D8F60077D2E8 /* GiGaFlyingCommitInputView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GiGaFlyingCommitInputView.h; sourceTree = "<group>"; };
@ -863,6 +869,8 @@
children = (
83835BC1212E677C001480F2 /* GiGaQuestionVC.h */,
83835BC2212E677C001480F2 /* GiGaQuestionVC.m */,
8384643F214A4BFF00F12B33 /* MaskTestResultVC.h */,
83846440214A4BFF00F12B33 /* MaskTestResultVC.m */,
);
path = Controller;
sourceTree = "<group>";
@ -876,6 +884,8 @@
83773FBB214769230014EE4C /* ExercisesModel.m */,
83BC8A882148D28300820437 /* QustionAnswer.h */,
83BC8A892148D28300820437 /* QustionAnswer.m */,
8384643C214A484400F12B33 /* MaskTestResult.h */,
8384643D214A484400F12B33 /* MaskTestResult.m */,
);
path = Model;
sourceTree = "<group>";
@ -1278,6 +1288,7 @@
buildActionMask = 2147483647;
files = (
835060AD212D4D0C007E6220 /* GiGaFileNanager.m in Sources */,
83846441214A4BFF00F12B33 /* MaskTestResultVC.m in Sources */,
83346AC5212BBC8C0054D597 /* GiGaRegistViewController.m in Sources */,
83346AD7212C18F50054D597 /* GiGaAppGaurdVC.m in Sources */,
8349585C212511040064DB6C /* AppDelegate+ThirdParty.m in Sources */,
@ -1293,6 +1304,7 @@
8361B4382121847600238FEB /* UINavigationBar+Custom.m in Sources */,
83BFAE6C213CD0E3004EF801 /* GiGaMineInfoViewCell.m in Sources */,
83BC8A872148BE8A00820437 /* NYPopover.m in Sources */,
8384643E214A484400F12B33 /* MaskTestResult.m in Sources */,
83346AD4212BFF6E0054D597 /* UserGuardViewController.m in Sources */,
83BC8A8A2148D28300820437 /* QustionAnswer.m in Sources */,
8357ADC92123BFCA000816F2 /* GiGaUserManager.m in Sources */,

View File

@ -1,5 +1,9 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "ceshi_number@2x.png",

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "mask_img_hair.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "mask_img_hair@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "mask_img_hair@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "mask_img_head.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "mask_img_head@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "mask_img_head@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "mask_img_mask.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "mask_img_mask@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "mask_img_mask@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "masking_img_mask.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "masking_img_mask@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "masking_img_mask@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "nav_point_bg.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "user_history@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "user_history@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "user_indicator_right@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "user_indicator_right@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "user_indicator_white@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "user_indicator_white@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 612 B

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "user_setup@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "user_setup@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "user_test@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "user_test@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -229,12 +229,16 @@
return nil;
}
// 13.2.0 isoLatin1
//NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
NSData *jsonData = [jsonString dataUsingEncoding:NSISOLatin1StringEncoding];
NSError *err;
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData
options:NSJSONReadingMutableContainers
error:&err];
if(err)
{
NSLog(@"json解析失败%@",err);
@ -243,4 +247,11 @@
return dic;
}
+(NSString *)_859ToUTF8:(NSString *)oldStr
{
NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingISOLatin1);
return [NSString stringWithUTF8String:[oldStr cStringUsingEncoding:enc]];
}
@end

View File

@ -107,7 +107,7 @@
- (void)analyseResponseInfo:(NSDictionary *)responseData headerFileds:(NSDictionary *)headerFields error:(NSError *)error
{
self.responseHeaderFields = headerFields;
NSString *token = headerFields[@"access-token"];
NSString *token = headerFields[@"token"];
if (token && token.length > 0) {
//token
//[FFBMSConfig shareInstance].token = token;

View File

@ -9,6 +9,7 @@
#import "GiGaNetManager.h"
#import "AFNetworking.h"
#import "GiGaServerConfig.h"
#import "GiGaUserDefault.h"
@interface GiGaNetManager()
@ -23,7 +24,11 @@
// AFHTTPSessionManager*manager=[[AFHTTPSessionManager alloc] initWithBaseURL:baseUrl sessionConfiguration:configuration];
AFHTTPSessionManager*manager=[[AFHTTPSessionManager alloc] init];
manager.responseSerializer=[AFHTTPResponseSerializer serializer];
NSString *token = [GiGaUserDefault getCurentToken];
if (token) {
[manager.requestSerializer setValue:token forHTTPHeaderField:@"token"];
}
switch (requestMethod) {
case RequestGetMethod:

View File

@ -48,7 +48,7 @@ NSString *const kGiGaToken = @"GiGatoken";
+(BOOL)isUserLogin{
NSString *uid = UD_GET_VALUE(GIGADEFAULTKEY_USERID);
NSString *uid = UD_GET_VALUE(kGiGaToken);
return uid ? YES : NO;
}

View File

@ -57,10 +57,12 @@ const static NSInteger GIGADB_USER_VER = 0;//当前数据库版本号
self.user = user;
NSString *userTableId = [NSString stringWithFormat:@"%@",user.userId];
self.userTabId = userTableId;
//
NSDictionary *userDic = [user toDictionary];
[_userArr removeAllObjects];
[_userArr addObject:user];
[_userArr addObject:userDic];
[_store putObject:_userArr withId:userTableId intoTable:GIGA_USER_TABLE];
[GiGaUserDefault saveUserId:userTableId];
@ -72,7 +74,10 @@ 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];
//self.user = usrA[0];
NSDictionary *userdic = usrA[0];
GiGaUser *user = [[GiGaUser alloc] initWithDictionary:userdic error:nil];;
self.user = user;
}
return self.user;
}

View File

@ -78,7 +78,6 @@
-(void)textFieldUI{
UIView *acountView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
UIImageView *acountViewIcon = [[UIImageView alloc] initWithFrame:CGRectMake(15,9, 12, 22)];
acountViewIcon.image = [UIImage imageNamed:@"ic_number"];
@ -283,25 +282,19 @@
NSString *url = [NSString stringWithFormat:@"%@sys/v1/wechatlogin",[GiGaServerConfig getMainUrl]];
[GiGaNetManager requestMethod:RequestPostMethod Url:url params:weiXinUserinfo responseBlock:^(NSDictionary *responseDict, NSDictionary *responseHeaderFields, NSError *error) {
[self.view hideToastActivity];
if (!error) {
if ([responseDict[@"code"] integerValue] == 0) {
//[self userloginSussecess:responseDict];
[self.view makeToast:responseDict[@"msg"] duration:2.0 position:CSToastPositionCenter];
[self jxt_showAlertWithTitle:@"温馨提示" message:@"请先绑定或注册手机号" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"知道了");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
}];
[self userloginSussecess:responseDict];
}else if([responseDict[@"code"] integerValue] == 500){
//
// [self.view makeToast:responseDict[@"msg"] duration:2.0 position:CSToastPositionCenter];
// [self jxt_showAlertWithTitle:@"温馨提示" message:@"请绑定手机号" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
//
// } actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
//
// }];
[self.view makeToast:responseDict[@"msg"] duration:2.0 position:CSToastPositionCenter];
[self jxt_showAlertWithTitle:@"温馨提示" message:@"请绑定手机号" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
}];
}else{
@ -313,17 +306,18 @@
GILog(@"上传微信用户信息error:\n%@",error.localizedDescription);
}
}];
}
-(void)userloginSussecess:(NSDictionary *)resDic{
//token
//token
[GiGaUserDefault saveToken:resDic[@"token"]];
//
[MobClick endEvent:MobClick_UserLogin];
//123
[GiGaUserDefault saveUserId:@"123"];
// //123
// [GiGaUserDefault saveUserId:@"123"];
GIGA_WIndowTost(@"登录成功!");
[self dismissViewControllerAnimated:YES completion:nil];

View File

@ -36,6 +36,8 @@
@property(nonatomic,strong)MaskViewBootomWaringView *waringView;
@property(nonatomic,strong) UIImageView *maskImageView;
@property(nonatomic,strong) UIImageView *faceView;
@property (nonatomic,strong) UIImageView *hairImageView;
@property(nonatomic) CGPoint attachPoint;
@property(nonatomic,strong) MaskTimeCircularProgressView *cicleProgressView;
@property(nonatomic,strong) UIImageView *swipeGaurdimagView;
@ -53,7 +55,7 @@
_maskImageView = [[UIImageView alloc] init];
_maskImageView.userInteractionEnabled = YES;
//_maskImageView.backgroundColor = [UIColor purpleColor];
_maskImageView.image = [UIImage imageNamed:@"img_mask"];
_maskImageView.image = [UIImage imageNamed:@"mask_img_mask"];
UISwipeGestureRecognizer * upSwipeGesture = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(maskupSwipeGesture)];
[upSwipeGesture setDirection:(UISwipeGestureRecognizerDirectionUp)];
@ -65,6 +67,17 @@
}
return _maskImageView;
}
//
- (UIImageView *)hairImageView{
if (!_hairImageView) {
_hairImageView = [[UIImageView alloc] init];
_hairImageView.image = [UIImage imageNamed:@"mask_img_hair"];
}
return _hairImageView;
}
//
- (UIImageView *)faceView{
@ -72,16 +85,17 @@
_faceView = [[UIImageView alloc] init];
//_faceView.backgroundColor = [UIColor lightGrayColor];
_faceView.userInteractionEnabled = YES;
_faceView.image = [UIImage imageNamed:@"bg_img_face"];
_faceView.image = [UIImage imageNamed:@"mask_img_head"];
}
return _faceView;
}
//
- (MaskTimeCircularProgressView *)cicleProgressView{
if (!_cicleProgressView) {
_cicleProgressView = [[MaskTimeCircularProgressView alloc] initWithFrame:CGRectMake(100, 500, 136, 136) backColor:GIGARGB(88, 0, 2, 1) progressColor:[UIColor blueColor] lineWidth:10 timeinterval:10];
_cicleProgressView = [[MaskTimeCircularProgressView alloc] initWithFrame:CGRectMake(100, 251, 125, 125) backColor:GIGARGB(88, 0, 2, 1) progressColor:[UIColor blueColor] lineWidth:10 timeinterval:10];
_cicleProgressView.delegate = self;
_cicleProgressView.hidden = YES;
@ -168,6 +182,7 @@
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.navigationController.navigationBar setTranslucent:NO];
if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}
@ -199,7 +214,7 @@
[self animaMask];
}
#pragma mark -
#pragma mark -
-(void)animaMask{
@ -207,18 +222,51 @@
self.startMaskButton.hidden = YES;
[self.view layoutIfNeeded];
[UIView animateWithDuration:1.0 animations:^{
[self.maskImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.attachPoint.y - 87 + 4);
}];
[self.faceView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.attachPoint.y -124);
make.top.mas_equalTo(self.attachPoint.y -94);
}];
[self.hairImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.attachPoint.y - 94 - 34);
}];
[self.maskImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.attachPoint.y - 87);
}];
[self.maskImageView setImage:[UIImage imageNamed:@"masking_img_mask"]];
[self.view layoutIfNeeded];
} completion:^(BOOL finished) {
// self.cicleProgressView.hidden = NO;
// self.maskImageView.userInteractionEnabled = NO;
//
//[self startMaskTime];
[self updateMaskingView];
}];
}
#pragma mark
-(void)updateMaskingView{
[self.view layoutIfNeeded];
[UIView animateWithDuration:1.0 animations:^{
[self.faceView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(124 + PhoneX_TopMargin);
}];
[self.hairImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(90 + PhoneX_TopMargin);
}];
[self.maskImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view.mas_top).offset(90 + PhoneX_TopMargin +43);
}];
[self.view layoutIfNeeded];
} completion:^(BOOL finished) {
self.cicleProgressView.hidden = NO;
self.maskImageView.userInteractionEnabled = NO;
//
[self startMaskTime];
}];
}
@ -226,21 +274,29 @@
#pragma mark
-(void)endMaskAnimation{
[self.maskImageView setImage:[UIImage imageNamed:@"mask_img_mask"]];
self.cicleProgressView.hidden = YES;
self.swipeGaurdimagView.hidden = NO;
self.startMaskButton.hidden = NO;
[self.view layoutIfNeeded];
[UIView animateWithDuration:1.0 animations:^{
[self.faceView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(124 + PhoneX_TopMargin);
}];
[self.hairImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(90 + PhoneX_TopMargin);
}];
[self.maskImageView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(254 + PhoneX_TopMargin);
}];
[self.faceView mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(91 + PhoneX_TopMargin);
}];
[self.view layoutIfNeeded];
//[self.view layoutIfNeeded];
} completion:^(BOOL finished) {
self.maskImageView.userInteractionEnabled = YES;
@ -252,28 +308,47 @@
-(void)initUI{
self.view.backgroundColor = GIGA_MAIN_BGCOLOR;
[self.view addSubview:self.maskImageView];
[self.view addSubview:self.faceView];
[self.view bringSubviewToFront:self.maskImageView];
[self.view addSubview:self.maskImageView];
[self.view addSubview:self.hairImageView];
//[self.view bringSubviewToFront:self.maskImageView];
[self.view addSubview:self.swipeGaurdimagView];
[self.view addSubview:self.startMaskButton];
[self.view addSubview:self.startTestButton];
[self.view addSubview:self.cicleProgressView];
//face
[self.faceView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view.mas_top).offset(91 + PhoneX_TopMargin);
make.size.mas_equalTo(CGSizeMake(99, 124));
make.top.mas_equalTo(self.view.mas_top).offset(124 + PhoneX_TopMargin);
make.size.mas_equalTo(CGSizeMake(77, 94));
make.centerX.mas_equalTo(self.view.mas_centerX);
//make.left.mas_equalTo(self.view.mas_left).offset(153);
}];
//hair
[self.hairImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view.mas_top).offset(90 + PhoneX_TopMargin);
make.size.mas_equalTo(CGSizeMake(97, 109));
//make.centerX.mas_equalTo(self.view.mas_centerX);
make.left.mas_equalTo(self.faceView.mas_left).offset(-14);
}];
//mask
[self.maskImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view.mas_top).offset(254 + PhoneX_TopMargin);
make.size.mas_equalTo(CGSizeMake(72, 87));
//make.centerX.mas_equalTo(self.view.mas_centerX);
make.left.mas_equalTo(self.faceView.mas_left);
}];
//circle
[self.cicleProgressView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view.mas_top).offset(251 + PhoneX_TopMargin);
make.size.mas_equalTo(CGSizeMake(125, 125));
make.centerX.mas_equalTo(self.view.mas_centerX);
}];
@ -292,6 +367,7 @@
make.centerX.mas_equalTo(self.view.mas_centerX);
}];
//startTest
[self.startTestButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view.mas_top).offset(486 + PhoneX_TopMargin);
@ -415,11 +491,6 @@
GiGaQuestionVC *questionVC = [[GiGaQuestionVC alloc] init];
[self.navigationController pushViewController:questionVC animated:YES];
// }else{
// GiGaUserLoginVC *userlogInVC= [[GiGaUserLoginVC alloc] init];
// GiGaBaseNavViewController *baseNav = [[GiGaBaseNavViewController alloc] initWithRootViewController:userlogInVC];
// [self presentViewController:baseNav animated:YES completion:nil];
// }
}
-(void)addNotify{

View File

@ -15,12 +15,15 @@
#import "ExercisesModel.h"
#import "QustionAnswer.h"
#import "GiGaServerConfig.h"
#import "MaskTestResult.h"
#import "GiGaUserDefault.h"
#import "GiGaUserLoginVC.h"
#import "MaskTestResultVC.h"
@interface GiGaQuestionVC ()<QeustionViewDelegate>
@property (nonatomic,weak) MaskQuestionView *questionView;
@property (nonatomic,assign) NSInteger page;
@property (nonatomic,assign) NSInteger curentAnswerIdex;
@property (nonatomic,strong) NSMutableArray *questonArray;
@property (nonatomic,strong) NSMutableArray *answerArray;
@ -44,10 +47,6 @@
// self.title = @"测试肤质";
_page = 1;
//
_curentAnswerIdex = 0;
//
[self loadRequestQuestions];
}
@ -192,6 +191,7 @@
//[tit insertObject:mode.answer atIndex:0];
[tit addObject:mode.answer];
}
titles = tit;
if (self.questionView) {
[self.questionView removeFromSuperview];
@ -199,27 +199,48 @@
}
[self.view layoutIfNeeded];
MaskQuestionView *questionView = [[MaskQuestionView alloc] initQuestionView:CGRectMake(0,248, self.view.frame.size.width,212) style:style titles:titles];
questionView.answerList = _currentModel.answerList;
MaskQuestionView *questionView = [[MaskQuestionView alloc] initQuestionView:CGRectMake(0,248, self.view.frame.size.width,212) style:style titles:titles current:_currentModel];
NSLog(@"_currentModel--ID:%d",_currentModel.questionId);
questionView.delegate = self;
[self.view addSubview:questionView];
self.questionView = questionView;
}
- (void)sliderChangeValueShouldChoiceModelAt:(NSInteger)index
- (void)sliderChangeValueShouldChoiceModelAt:(int)index slider:(float)value
{
NSLog(@"答案下标:%ld",(long)index);
_curentAnswerIdex = index;
}
- (void)yesOrNoChoiceModelAt:(NSInteger)index{
if (index > _currentModel.answerList.count) {
return;
}
_curentAnswerIdex = index;
NSLog(@"答案下标:%d",index);
//
_currentModel.slidervalue = value;
[self changeAnswerDefaultflag:index];
}
- (void)yesOrNoChoiceModelAt:(int)index{
_currentModel.slidervalue = index;
[self changeAnswerDefaultflag:index];
}
-(void)changeAnswerDefaultflag:(int)index{
NSArray *temparr = [NSArray arrayWithArray:_currentModel.answerList];
[temparr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
QustionAnswer *model = obj;
if ((int)index == idx) {
model.defaultFlag = 1;
}else{
model.defaultFlag = 0;
}
}];
}
-(void)loadRequestQuestions{
NSDictionary *params = @{};
@ -227,16 +248,41 @@
[self.view makeToastActivity:CSToastPositionCenter];
[request requstDataWithResult:^(GiGaAPIResult *result) {
[self.view hideToastActivity];
if (result.success) {
[self.view hideToastActivity];
NSLog(@"result:%@",result.dic);
NSArray *list = result.dic[@"list"];
for (NSDictionary *answerDic in list) {
ExercisesModel *model = [[ExercisesModel alloc] initWithDictionary:answerDic error:nil];
model.slidervalue = 0;
if (model.optionsStyle == 2) {
//1 0
NSArray *answerlsit = [NSArray arrayWithArray:model.answerList];
[answerlsit enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
QustionAnswer *answer = obj;
if (answer.defaultFlag == 1) {
model.slidervalue = (float)idx;
}
}];
}else{
NSArray *answerlsit = [NSArray arrayWithArray:model.answerList];
[answerlsit enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
QustionAnswer *answer = obj;
if (answer.defaultFlag == 1) {
model.slidervalue = (answerlsit.count -1 -idx) / (answerlsit.count - 1);
//GILog(@"model.slidervalue%.2f",model.slidervalue);
}
}];
}
[self.questonArray addObject:model];
}
self.currentModel = self.questonArray[0];
[self initUI];
}
}];
@ -289,16 +335,14 @@
}
-(void)nextBtnAction{
[self saveProgress];
if (_page == self.questonArray.count ) {
GIGA_ShowToast(@"没有了");
[self submitAnswer];
return;
}
_page ++ ;
//
@ -317,11 +361,38 @@
[GiGaNetManager userbodyRequest:url params:params completionHandler:^(NSURLResponse *response, NSDictionary *resDic, NSError * _Nullable error) {
[self.view hideToastActivity];
GiGaAPIResult *result = [[GiGaAPIResult alloc] initWithDictionary:resDic];
GILog(@"**答案提交***\n code:%ld\n message:%@\n *******\n dic:%@",result.code,result.message,result.dic);
GILog(@"**测试结果***\n code:%ld\n message:%@\n *******\n dic:%@",result.code,result.message,result.dic);
[self userTestEnd];
}];
}
-(void)userTestEnd{
BOOL isUserLogin = [GiGaUserDefault isUserLogin];
if (isUserLogin) {
//
MaskTestResultVC *reusltVC = [[MaskTestResultVC alloc] init];
[self.navigationController pushViewController:reusltVC animated:YES];
}else{
[self jxt_showAlertWithTitle:@"对不起您还没有登录" message:@"请登录后查看肤质测试结果" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionCancelTitle(@"返回首页");
alertMaker.addActionDestructiveTitle(@"登录");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
if (buttonIndex == 0) {
[self.navigationController popViewControllerAnimated:YES];
}else{
GiGaUserLoginVC *userlogInVC= [[GiGaUserLoginVC alloc] init];
GiGaBaseNavViewController *baseNav = [[GiGaBaseNavViewController alloc] initWithRootViewController:userlogInVC];
[self presentViewController:baseNav animated:YES completion:nil];
}
}];
}
}
-(void)preBtnAction{
_page -- ;
@ -334,18 +405,28 @@
-(void)saveProgress{
int questionId = _currentModel.questionId;
QustionAnswer *curentAnswer = _currentModel.answerList[_curentAnswerIdex];
int answerid = curentAnswer.answer_id;
__block int answerid = 0;
NSArray *answerArr = [NSArray arrayWithArray:_currentModel.answerList];
[answerArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
QustionAnswer *model = obj;
if (model.defaultFlag == 1) {
answerid = model.answer_id;
}
}];
GILog(@"问题ID%d\n 角标id(答案号)%d\n 题号:%ld",questionId,answerid,(long)_page);
NSDictionary *answerDic = @{@"questionId":[NSString stringWithFormat:@"%d",questionId],@"answerId":[NSString stringWithFormat:@"%d",answerid]};
for (NSDictionary *dic in self.answerArray) {
//
if (questionId == [dic[@"questionId"] intValue]) {
//
NSArray *tempArr= [NSArray arrayWithArray:self.answerArray];
//
[tempArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSDictionary *dic = obj;
if ([dic[@"questionId"] intValue] == questionId) {
[self.answerArray removeObject:dic];
}
}
}];
[self.answerArray addObject:answerDic];

View File

@ -0,0 +1,13 @@
//
// MaskTestResultVC.h
// GIGA
//
// Created by lianxiang on 2018/9/13.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import "GiGaBaseViewController.h"
@interface MaskTestResultVC : GiGaBaseViewController
@end

View File

@ -0,0 +1,38 @@
//
// MaskTestResultVC.m
// GIGA
//
// Created by lianxiang on 2018/9/13.
// Copyright © 2018 com.giga.ios. All rights reserved.
//
#import "MaskTestResultVC.h"
@interface MaskTestResultVC ()
@end
@implementation MaskTestResultVC
- (void)viewDidLoad {
[super viewDidLoad];
[self addNavTitile:@"测试结果"];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end

View File

@ -23,6 +23,10 @@
//optionsStyle:样式(单选或滑动) 1滑动2单选 3滑动带指示 4滑动渐变,
@property (nonatomic,assign) int optionsStyle;
@property (nonatomic,assign) int questionId;
//用户选择的当前题目答案下标 未选择时为默认值
@property (nonatomic,assign) NSInteger answerIndex;
@property (nonatomic,assign) float slidervalue;
@end

View File

@ -0,0 +1,21 @@
//
// MaskTestResult.h
// GIGA
//
// Created by lianxiang on 2018/9/13.
// Copyright © 2018年 com.giga.ios. All rights reserved.
//
#import <JSONModel/JSONModel.h>
@interface MaskTestResult : JSONModel
@property(nonatomic,copy) NSString *dryness;
@property(nonatomic,copy) NSString *drynessPercent;
@property(nonatomic,copy) NSString *mask;
@property(nonatomic,copy) NSString *minute;
@property(nonatomic,copy) NSString *oiliness;
@property(nonatomic,copy) NSString *oilinessPercent;
@end

View File

@ -0,0 +1,13 @@
//
// MaskTestResult.m
// GIGA
//
// Created by lianxiang on 2018/9/13.
// Copyright © 2018 com.giga.ios. All rights reserved.
//
#import "MaskTestResult.h"
@implementation MaskTestResult
@end

View File

@ -15,5 +15,7 @@
@property (nonatomic,assign) int dryness;
@property (nonatomic,assign) int fx;
@property (nonatomic,assign) int answer_id;
//默认答案 1选中 0 非选中
@property (nonatomic,assign) int defaultFlag;
@end

View File

@ -23,7 +23,7 @@
self.minimumValue = 0.0;
self.maximumValue = 1.0;
self.value = 0.5;
[self creatSubView:type];
}
@ -77,7 +77,6 @@
self.minimumValue = 0.0;
self.maximumValue = 1.0;
self.value = 0.5;
self.minimumTrackTintColor = GIGARGB(216,216, 216, 1);
self.maximumTrackTintColor = GIGARGB(216,216, 216, 1);

View File

@ -7,6 +7,7 @@
//
#import <UIKit/UIKit.h>
#import "ExercisesModel.h"
typedef NS_ENUM(NSInteger,MaskQuetionViewStyle)
{
@ -19,8 +20,8 @@ typedef NS_ENUM(NSInteger,MaskQuetionViewStyle)
@protocol QeustionViewDelegate<NSObject>;
@optional
-(void)sliderChangeValueShouldChoiceModelAt:(NSInteger)index;
-(void)yesOrNoChoiceModelAt:(NSInteger)index;
-(void)sliderChangeValueShouldChoiceModelAt:(int)index slider:(float)value;
-(void)yesOrNoChoiceModelAt:(int)index;
@end
@interface MaskQuestionView : UIView
@ -28,7 +29,8 @@ typedef NS_ENUM(NSInteger,MaskQuetionViewStyle)
@property(nonatomic,assign) id<QeustionViewDelegate>delegate;
@property(nonatomic,assign) MaskQuetionViewStyle style;
@property(nonatomic,strong) NSArray *answerList;
@property(nonatomic,strong) ExercisesModel *currentModel;
-(instancetype)initQuestionView:(CGRect)frame style:(MaskQuetionViewStyle)style titles:(NSArray *)titles;
-(instancetype)initQuestionView:(CGRect)frame style:(MaskQuetionViewStyle)style titles:(NSArray *)titles current:(ExercisesModel *)currentModel;
@end

View File

@ -17,6 +17,8 @@
@property(nonatomic,strong) UITableView *tableView;
@property(nonatomic,strong) GIGaQuestionSlider *slider;
@property(nonatomic,strong) NYSliderPopover *poSlider;
@property(nonatomic,strong) UIButton *noBtn;
@property(nonatomic,strong) UIButton *yesBtn;
@end
@ -30,11 +32,13 @@
}
-(instancetype)initQuestionView:(CGRect)frame style:(MaskQuetionViewStyle)style titles:(NSArray *)titles{
-(instancetype)initQuestionView:(CGRect)frame style:(MaskQuetionViewStyle)style titles:(NSArray *)titles current:(ExercisesModel *)currentModel{
self = [super initWithFrame:frame];
if (self) {
self.dataArr = titles;
self.currentModel = currentModel;
self.answerList = currentModel.answerList;
self.style = style;
[self creatSubs:style titles:titles];
}
@ -81,6 +85,7 @@
[slider addTarget:self action:@selector(updateValue:) forControlEvents:UIControlEventValueChanged];
self.poSlider = slider;
[self addSubview:slider];
//self.poSlider.value = self.currentModel.slidervalue;
self.poSlider.transform = CGAffineTransformMakeRotation(- M_PI/2);
}
@ -94,6 +99,7 @@
GIGaQuestionSlider *slider = [[GIGaQuestionSlider alloc] initWithFrame:CGRectMake(0,self.frame.size.height,self.frame.size.height, 13) type:type];
[slider addTarget:self action:@selector(updateValue:) forControlEvents:UIControlEventValueChanged];
self.slider = slider;
[self.slider setValue:self.currentModel.slidervalue];
[self addSubview:slider];
self.slider.transform = CGAffineTransformMakeRotation(- M_PI/2);
}
@ -116,39 +122,72 @@
-(void)creatYseNoView{
UIButton *yesBtn = [UIButton buttonWithType:UIButtonTypeCustom];
yesBtn.backgroundColor = GIGARGB(181, 14, 14, 1);
yesBtn.frame = CGRectMake(self.center.x - 120/2, 40, 120, 34);
[yesBtn addTarget:self action:@selector(yesBtnAction) forControlEvents:UIControlEventTouchUpInside];
NSAttributedString *preTitle = [[NSAttributedString alloc] initWithString:@"是" attributes:@{NSFontAttributeName:[UIFont fontWithName:GIGA_FONTBOLD size:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
[yesBtn setAttributedTitle:preTitle forState:UIControlStateNormal];
[yesBtn addTarget:self action:@selector(yesBtnAction:) forControlEvents:UIControlEventTouchUpInside];
yesBtn.layer.borderWidth = 1;
yesBtn.layer.borderColor = GIGARGB(181, 14, 14, 1).CGColor;
yesBtn.layer.masksToBounds = YES;
yesBtn.layer.cornerRadius = 2;
self.yesBtn = yesBtn;
[self addSubview:yesBtn];
UIButton *noBtn = [UIButton buttonWithType:UIButtonTypeCustom];
noBtn.backgroundColor = [UIColor whiteColor];
noBtn.frame = CGRectMake(self.center.x - 120/2,CGRectGetMaxY(yesBtn.frame) + 31, 120, 34);
[noBtn addTarget:self action:@selector(noBtnAction) forControlEvents:UIControlEventTouchUpInside];
NSAttributedString *noBtnTitle = [[NSAttributedString alloc] initWithString:@"否" attributes:@{NSFontAttributeName:[UIFont fontWithName:GIGA_FONTBOLD size:18],NSForegroundColorAttributeName:GIGARGB(181, 14, 14, 1)}];
[noBtn setAttributedTitle:noBtnTitle forState:UIControlStateNormal];
[noBtn addTarget:self action:@selector(noBtnAction:) forControlEvents:UIControlEventTouchUpInside];
noBtn.layer.borderWidth = 1;
noBtn.layer.borderColor = GIGARGB(181, 14, 14, 1).CGColor;
noBtn.layer.masksToBounds = YES;
noBtn.layer.cornerRadius = 2;
self.noBtn = noBtn;
[self addSubview:noBtn];
//slidervalue
if (self.currentModel.slidervalue == 1 ) {
[self selectNOBtnState:self.noBtn];
}else{
[self selctYesBtnState:self.yesBtn];
}
}
#pragma mark
-(void)yesBtnAction{
-(void)yesBtnAction:(UIButton *)btn{
[self selctYesBtnState:btn];
if (self.delegate && [self.delegate performSelector:@selector(yesOrNoChoiceModelAt:)]) {
[self.delegate yesOrNoChoiceModelAt:0];
}
}
#pragma mark
-(void)noBtnAction{
[self.delegate yesOrNoChoiceModelAt:1];
-(void)noBtnAction:(UIButton *)btn{
[self selectNOBtnState:btn];
if (self.delegate && [self.delegate performSelector:@selector(yesOrNoChoiceModelAt:)]) {
[self.delegate yesOrNoChoiceModelAt:1];
}
}
//
-(void)selctYesBtnState:(UIButton *)btn{
NSAttributedString *preTitle = [[NSAttributedString alloc] initWithString:@"是" attributes:@{NSFontAttributeName:[UIFont fontWithName:GIGA_FONTBOLD size:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
[btn setAttributedTitle:preTitle forState:UIControlStateNormal];
btn.backgroundColor = GIGARGB(181, 14, 14, 1);
NSAttributedString *noBtnTitle = [[NSAttributedString alloc] initWithString:@"否" attributes:@{NSFontAttributeName:[UIFont fontWithName:GIGA_FONTBOLD size:18],NSForegroundColorAttributeName:GIGARGB(181, 14, 14, 1)}];
[self.noBtn setAttributedTitle:noBtnTitle forState:UIControlStateNormal];
self.noBtn.backgroundColor = [UIColor whiteColor];
}
-(void)selectNOBtnState:(UIButton *)btn{
NSAttributedString *preTitle = [[NSAttributedString alloc] initWithString:@"否" attributes:@{NSFontAttributeName:[UIFont fontWithName:GIGA_FONTBOLD size:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
[btn setAttributedTitle:preTitle forState:UIControlStateNormal];
btn.backgroundColor = GIGARGB(181, 14, 14, 1);
NSAttributedString *yesTitle = [[NSAttributedString alloc] initWithString:@"是" attributes:@{NSFontAttributeName:[UIFont fontWithName:GIGA_FONTBOLD size:18],NSForegroundColorAttributeName:GIGARGB(181, 14, 14, 1)}];
[self.yesBtn setAttributedTitle:yesTitle forState:UIControlStateNormal];
self.yesBtn.backgroundColor = [UIColor whiteColor];
}
-(void)updateValue:(UISlider *)slider{
@ -163,24 +202,41 @@
if (_answerList.count <=2) {
return;
}
NSInteger totalCount = _answerList.count;
// 20 ~ 50
CGFloat sliderFormatValue = value*30 + 20;
if (self.poSlider) {
[self.poSlider showPopover];
self.poSlider.popover.textLabel.text = [NSString stringWithFormat:@"%.f",sliderFormatValue];
}
// 50 20
//
int powSize = 30 / (totalCount - 1);
//
NSInteger index = (sliderFormatValue - 20) / powSize;
// 20 ~ 60
NSString * valueF = [NSString stringWithFormat:@"%.2f",value];
CGFloat sliderFormatValue = [valueF floatValue]*40.f + 20.f;
if (sliderFormatValue == 20.f) {
self.poSlider.popover.textLabel.text = @"20-";
}else if (sliderFormatValue == 60.f){
self.poSlider.popover.textLabel.text = @"60+";
}else{
self.poSlider.popover.textLabel.text = [NSString stringWithFormat:@"%.f",sliderFormatValue];
}
if (self.delegate && [self.delegate performSelector:@selector(sliderChangeValueShouldChoiceModelAt:)]) {
[self.delegate sliderChangeValueShouldChoiceModelAt:index];
}
// 0 100
//
CGFloat powSize = 100.f / (totalCount -1);
//
CGFloat currentValue = value * 100.f;
// 1
int count = currentValue / powSize;
//
int index = 0 ;
index = (int)_answerList.count - 1 -count;
if (index < 0) {
index = 0;
}
if (self.delegate && [self.delegate performSelector:@selector(sliderChangeValueShouldChoiceModelAt: slider:)]) {
[self.delegate sliderChangeValueShouldChoiceModelAt:index slider:value];
}
}

View File

@ -149,7 +149,6 @@
self.minimumValue = 0.0;
self.maximumValue = 1.0;
self.value = 0.5;
self.minimumTrackTintColor = GIGARGB(216,216, 216, 1);
self.maximumTrackTintColor = GIGARGB(216,216, 216, 1);

View File

@ -13,8 +13,11 @@
#import "GiSysSettingsVC.h"
#import "GiMaskTimeHistoryVC.h"
#import "UINavigationBar+Custom.h"
#import "GiGaBaseAPiRequest.h"
#import "GiGaUserManager.h"
@interface GiGaMeViewController ()
@property (nonatomic,strong) GiGaUser *user;
@end
@ -28,14 +31,52 @@
[self.view addSubview:self.tableView];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.tableView.backgroundColor = [UIColor lightGrayColor];
self.tableView.backgroundColor = [UIColor whiteColor];
self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
self.tableView.sectionFooterHeight = 0;
self.tableView.estimatedSectionFooterHeight= 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.bounces = NO;
self.tableView.frame = CGRectMake(0, PhoneX_TopMargin + 1, KMainW,KMainH - PhoneX_BottomMargin);
[self loadUserInfo];
}
-(void)loadUserInfo{
GiGaUser *user = [[GiGaUserManager shareUser] getCurrentUser];
if (!user) {
[self requstUserinfo];
}else{
self.user = user;
}
}
-(void)requstUserinfo{
GiGaBaseAPiRequest *requst = [GiGaBaseAPiRequest initWithRequestPath:@"user/v1/info" method:RequestPostMethod parms:nil];
[self.view makeToastActivity:CSToastPositionCenter];
weakify(self);
[requst requstDataWithResult:^(GiGaAPIResult *result) {
[self.view hideToastActivity];
if (result.success) {
//
NSDictionary *userDic = result.dic[@"userInfo"];
GiGaUser *user = [[GiGaUser alloc] initWithDictionary:userDic error:nil];
weakSelf.user = user;
[[GiGaUserManager shareUser] saveUser:user];
NSIndexSet *set = [NSIndexSet indexSetWithIndex:0];
[self.tableView reloadSections:set withRowAnimation:UITableViewRowAnimationNone];
NSLog(@"user dic ***\n%@",result.dic);
}
}];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
@ -45,7 +86,7 @@
if (section == 0){
return 1;
}
return 2;
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
@ -55,6 +96,10 @@
cell = [[[NSBundle mainBundle] loadNibNamed:@"GiGaMineUserViewCell" owner:self options:nil] lastObject];
}
if (self.user) {
[cell loadUserinfoWith:self.user];
}
return cell;
}
GiGaMineInfoViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GiGaMineInfoViewCell"];
@ -83,21 +128,20 @@
GiMaskTimeHistoryVC *historyVC= [[GiMaskTimeHistoryVC alloc] init];
[self.navigationController pushViewController:historyVC animated:YES];
}else if (indexPath.section == 1 && indexPath.row == 1){
}else{
//
GiSysSettingsVC*settingsVC= [[GiSysSettingsVC alloc] init];
[self.navigationController pushViewController:settingsVC animated:YES];
}
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if(indexPath.section==0){
return 180;
return 139;
}else {
return 54;
}
@ -109,11 +153,20 @@
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if (section == 1){
return 20;
return 6;
}
return 0.1;
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
if (section == 1) {
UIView *view = [[UIView alloc] init];
view.backgroundColor = GIGARGB(222, 222, 222, 1);
return view;
}
return nil;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];

View File

@ -11,10 +11,24 @@
@interface GiGaUser : JSONModel
@property(nonatomic,copy) NSString *userId;
@property(nonatomic,copy) NSString *name;
@property(nonatomic,copy) NSString *avatar;//头像
@property(nonatomic,copy) NSString *tel;
@property(nonatomic,copy) NSString *token;
@property(nonatomic,copy) NSString *areaId;
@property(nonatomic,copy) NSString *areaName;
@property(nonatomic,copy) NSString *birthday;
@property(nonatomic,copy) NSString *cityId;
@property(nonatomic,copy) NSString *cityName;
@property(nonatomic,copy) NSString *headImgUrl;
@property(nonatomic,copy) NSString *mobileMask;
@property(nonatomic,assign) NSInteger mobileStatus;
@property(nonatomic,copy) NSString *mobileStatusName;
@property(nonatomic,copy) NSString *nickName;
@property(nonatomic,copy) NSString *occupationCode;
@property(nonatomic,copy) NSString *provinceId;
@property(nonatomic,copy) NSString *provinceName;
@property(nonatomic,copy) NSString *sexCode;
@property(nonatomic,copy) NSString *sexName;
@property(nonatomic,copy) NSString *weixin;
@end

View File

@ -10,4 +10,9 @@
@implementation GiGaUser
+ (BOOL)propertyIsOptional:(NSString *)propertyName{
return YES;
}
@end

View File

@ -17,15 +17,13 @@
- (void)loadCellData:(NSIndexPath *)indexPath{
if(indexPath.section == 1 && indexPath.row == 0){
self.listImageView.image = [UIImage imageNamed:@""];
self.descLabel.text = @"历史记录";
}else{
self.listImageView.image = [UIImage imageNamed:@""];
self.descLabel.text = @"系统设置";
}
NSArray *arr =@[@"历史记录",@"历史测试",@"系统设置"];
NSArray *imageName = @[@"user_history",@"user_test",@"user_setup"];
self.descLabel.text = arr[indexPath.row];
self.listImageView.image = [UIImage imageNamed:imageName[indexPath.row]];
}

View File

@ -12,43 +12,51 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="GiGaMineInfoViewCell" id="KGk-i7-Jjw" customClass="GiGaMineInfoViewCell">
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="GiGaMineInfoViewCell" id="KGk-i7-Jjw" customClass="GiGaMineInfoViewCell">
<rect key="frame" x="0.0" y="0.0" width="375" height="54"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="341" height="53.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="53.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="uc2-z4-fOE">
<rect key="frame" x="16" y="11" width="35" height="32"/>
<color key="backgroundColor" red="0.19215686269999999" green="0.81960784310000001" blue="0.76470588240000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="uc2-z4-fOE">
<rect key="frame" x="16" y="15" width="22.5" height="23"/>
<constraints>
<constraint firstAttribute="width" constant="35" id="7VO-cv-XQj"/>
<constraint firstAttribute="height" constant="32" id="zDE-yt-1Bb"/>
<constraint firstAttribute="width" constant="22.5" id="7VO-cv-XQj"/>
<constraint firstAttribute="height" constant="23" id="zDE-yt-1Bb"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="uAa-YI-Wvr">
<rect key="frame" x="71" y="16" width="26" height="21"/>
<rect key="frame" x="53" y="16.5" width="25.5" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="wKB-tA-m3l"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="15"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="14"/>
<color key="textColor" red="0.21568627450980393" green="0.21568627450980393" blue="0.21568627450980393" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="O4K-t3-KxB">
<rect key="frame" x="0.0" y="53" width="375" height="1"/>
<rect key="frame" x="0.0" y="53" width="409" height="1"/>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.94901960780000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="lgP-Cy-DDC"/>
</constraints>
</view>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="user_indicator_right" translatesAutoresizingMaskIntoConstraints="NO" id="zO5-UY-SQP">
<rect key="frame" x="343" y="20" width="8.5" height="14"/>
<constraints>
<constraint firstAttribute="width" constant="8.5" id="84f-qF-Loo"/>
<constraint firstAttribute="height" constant="14" id="D5i-qd-Y9A"/>
</constraints>
</imageView>
</subviews>
<constraints>
<constraint firstItem="O4K-t3-KxB" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="4HX-Qq-cv3"/>
<constraint firstItem="uc2-z4-fOE" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="5qg-HZ-06o"/>
<constraint firstAttribute="trailing" secondItem="O4K-t3-KxB" secondAttribute="trailing" constant="-34" id="Nad-rR-L6i"/>
<constraint firstItem="uAa-YI-Wvr" firstAttribute="leading" secondItem="uc2-z4-fOE" secondAttribute="trailing" constant="20" id="PO3-lw-pzh"/>
<constraint firstItem="uAa-YI-Wvr" firstAttribute="leading" secondItem="uc2-z4-fOE" secondAttribute="trailing" constant="14.5" id="PO3-lw-pzh"/>
<constraint firstItem="zO5-UY-SQP" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" constant="0.25" id="ZCK-2M-1bz"/>
<constraint firstAttribute="trailing" secondItem="zO5-UY-SQP" secondAttribute="trailing" constant="23.5" id="b2w-5h-Oei"/>
<constraint firstAttribute="bottom" secondItem="O4K-t3-KxB" secondAttribute="bottom" constant="-0.5" id="kHp-np-2YA"/>
<constraint firstItem="uAa-YI-Wvr" firstAttribute="centerY" secondItem="uc2-z4-fOE" secondAttribute="centerY" id="sn9-aQ-jMo"/>
<constraint firstItem="uc2-z4-fOE" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="16" id="ugC-g4-MrU"/>
@ -62,4 +70,7 @@
<point key="canvasLocation" x="33.5" y="75"/>
</tableViewCell>
</objects>
<resources>
<image name="user_indicator_right" width="9" height="14"/>
</resources>
</document>

View File

@ -7,7 +7,13 @@
//
#import <UIKit/UIKit.h>
#import "GiGaUser.h"
@interface GiGaMineUserViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIImageView *userAvator;
@property (weak, nonatomic) IBOutlet UILabel *userName;
@property (weak, nonatomic) IBOutlet UIButton *vipLabe;
-(void)loadUserinfoWith:(GiGaUser *)user;
@end

View File

@ -8,12 +8,34 @@
// - cell
#import "GiGaMineUserViewCell.h"
#import "UIImageView+WebCache.h"
@implementation GiGaMineUserViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
self.vipLabe.layer.masksToBounds = YES;
self.vipLabe.layer.cornerRadius = self.vipLabe.frame.size.height /2;
self.vipLabe.layer.borderWidth = 1;
self.vipLabe.layer.borderColor = [UIColor whiteColor].CGColor;
self.userAvator.layer.masksToBounds = YES;
self.userAvator.layer.cornerRadius = self.userAvator.frame.size.height /2 ;
}
-(void)loadUserinfoWith:(GiGaUser *)user{
if (user.headImgUrl && ![user.nickName isKindOfClass:[NSNull class]]) {
[self.userAvator sd_setImageWithURL:[NSURL URLWithString:user.headImgUrl]];
}
if (!user.nickName && ![user.nickName isKindOfClass:[NSNull class]]) {
self.userName.text = user.nickName;
}else{
self.userName.text = @"GIGAUser666";
}
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {

View File

@ -12,35 +12,69 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="GiGaMineUserViewCell" id="KGk-i7-Jjw" customClass="GiGaMineUserViewCell">
<rect key="frame" x="0.0" y="0.0" width="375" height="180"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="GiGaMineUserViewCell" id="KGk-i7-Jjw" customClass="GiGaMineUserViewCell">
<rect key="frame" x="0.0" y="0.0" width="375" height="139"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="341" height="179.5"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="138.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="enF-Ff-Ve5">
<rect key="frame" x="16" y="32" width="78" height="83"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="1" green="0.34901960780000002" blue="0.094117647060000004" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="img_circle_avatar" translatesAutoresizingMaskIntoConstraints="NO" id="enF-Ff-Ve5">
<rect key="frame" x="21" y="33.5" width="72" height="72"/>
<constraints>
<constraint firstAttribute="width" constant="72" id="0cV-T2-hjs"/>
<constraint firstAttribute="height" constant="72" id="Jry-ab-5Rb"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="用户名" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ljK-NJ-5JM">
<rect key="frame" x="115" y="45" width="52" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="用户名" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ljK-NJ-5JM">
<rect key="frame" x="108" y="45" width="36" height="17"/>
<constraints>
<constraint firstAttribute="height" constant="17" id="WSz-1q-Smh"/>
</constraints>
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="12"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8KQ-fZ-Z5e">
<rect key="frame" x="115" y="85" width="80" height="30"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8KQ-fZ-Z5e">
<rect key="frame" x="108" y="70" width="54" height="20"/>
<constraints>
<constraint firstAttribute="width" constant="54" id="PMb-11-KnL"/>
<constraint firstAttribute="height" constant="20" id="wk4-Kh-bq7"/>
</constraints>
<fontDescription key="fontDescription" name="PingFangSC-Medium" family="PingFang SC" pointSize="10"/>
<state key="normal" title="VIP会员"/>
</button>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="user_indicator_white" translatesAutoresizingMaskIntoConstraints="NO" id="Cuw-j9-gym">
<rect key="frame" x="343" y="62" width="8.5" height="14"/>
<constraints>
<constraint firstAttribute="height" constant="14" id="P9r-33-wNp"/>
<constraint firstAttribute="width" constant="8.5" id="lm3-q9-BlG"/>
</constraints>
</imageView>
</subviews>
<constraints>
<constraint firstItem="ljK-NJ-5JM" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="45" id="7kC-vE-DJc"/>
<constraint firstAttribute="trailing" secondItem="Cuw-j9-gym" secondAttribute="trailing" constant="23.5" id="8Ul-7Z-RhI"/>
<constraint firstItem="8KQ-fZ-Z5e" firstAttribute="leading" secondItem="enF-Ff-Ve5" secondAttribute="trailing" constant="15" id="Kc6-B5-AxT"/>
<constraint firstItem="enF-Ff-Ve5" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="21" id="Ktw-Wr-D0J"/>
<constraint firstItem="8KQ-fZ-Z5e" firstAttribute="top" secondItem="ljK-NJ-5JM" secondAttribute="bottom" constant="8" id="X7c-Mw-8Kp"/>
<constraint firstItem="Cuw-j9-gym" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" constant="-0.25" id="sd7-cN-yU2"/>
<constraint firstItem="ljK-NJ-5JM" firstAttribute="leading" secondItem="enF-Ff-Ve5" secondAttribute="trailing" constant="15" id="ut9-G8-edt"/>
<constraint firstItem="enF-Ff-Ve5" firstAttribute="centerY" secondItem="H2p-sc-9uM" secondAttribute="centerY" id="yPC-Eg-YqT"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" white="0.33333333329999998" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="backgroundColor" red="0.51372549019607838" green="0.039215686274509803" blue="0.039215686274509803" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="aW0-zy-SZf"/>
<point key="canvasLocation" x="33.5" y="75"/>
<connections>
<outlet property="userAvator" destination="enF-Ff-Ve5" id="Uf2-hS-TtN"/>
<outlet property="userName" destination="ljK-NJ-5JM" id="p0c-zb-CTC"/>
<outlet property="vipLabe" destination="8KQ-fZ-Z5e" id="lf1-k7-E7T"/>
</connections>
<point key="canvasLocation" x="33.5" y="74.5"/>
</tableViewCell>
</objects>
<resources>
<image name="img_circle_avatar" width="114" height="114"/>
<image name="user_indicator_white" width="9" height="14"/>
</resources>
</document>