This commit is contained in:
lianxiang
2018-09-29 20:12:56 +08:00
parent cb0accdb66
commit fc47921130
99 changed files with 1635 additions and 563 deletions
@@ -87,9 +87,11 @@
titleLabel.font = [UIFont fontWithName:GIGA_FONTBOLD size:16];
titleLabel.textColor = GIGARGB(63, 63, 63, 1);
titleLabel.numberOfLines = 2;
//titleLabel.backgroundColor = [UIColor redColor];
self.questionlabel = titleLabel;
[titleLabel sizeToFit];
//[titleLabel sizeToFit];
[self.view addSubview:titleLabel];
UILabel *descLabel = [[UILabel alloc] init];
descLabel.text = @"精准的选择,让小优更好的为您挑选最符合您的肤质的面膜";
@@ -113,7 +115,8 @@
make.left.mas_equalTo(numberBtn.mas_right).offset(12);
make.centerY.mas_equalTo(numberBtn.mas_centerY);
make.right.mas_equalTo(self.view.mas_right).offset(-20);
make.height.mas_equalTo(40);
}];
@@ -139,9 +142,13 @@
[self.view addSubview:nextBtn];
[nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view.mas_top).offset(529 -navH);
if (self.view.frame.size.height <=504) {
make.top.mas_equalTo(self.view.mas_top).offset(504 - navH);
}else{
make.top.mas_equalTo(self.view.mas_top).offset(529 - navH);
}
make.size.mas_equalTo(CGSizeMake(126, 40));
make.left.mas_equalTo(self.view.mas_left).offset(self.view.frame.size.width /2 - 126 /2);
make.left.mas_equalTo(self.view.mas_centerX).offset(- 126 /2);
}];
@@ -159,15 +166,23 @@
[self.view addSubview:self.preBtn];
[self.preBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.view.mas_left).offset(69);
make.top.mas_equalTo(self.view.mas_top).offset(529 - navH);
make.size.mas_equalTo(CGSizeMake(97, 40));
if (self.view.frame.size.height <=504) {
make.top.mas_equalTo(self.view.mas_top).offset(504 - navH);
}else{
make.top.mas_equalTo(self.view.mas_top).offset(529 - navH);
}
make.size.mas_equalTo(CGSizeMake(97, 40));
make.left.mas_equalTo(self.view.mas_centerX).offset(-10-97);
}];
if (_page == 1) {
self.preBtn.hidden = YES;
}
[self reloadViews];
}
-(void)creatQustionView{
@@ -247,8 +262,8 @@
}else{
model.defaultFlag = 0;
}
}];
}
-(void)loadRequestQuestions{
@@ -262,6 +277,10 @@
NSLog(@"result:%@",result.dic);
NSArray *list = result.dic[@"list"];
if (list.count==0 || [list isKindOfClass: [NSNull class]]) {
GIGA_ShowToast(@"");
return ;
}
for (NSDictionary *answerDic in list) {
ExercisesModel *model = [[ExercisesModel alloc] initWithDictionary:answerDic error:nil];
model.slidervalue = 0;
@@ -290,8 +309,8 @@
[self.questonArray addObject:model];
}
self.currentModel = self.questonArray[0];
self.currentModel = self.questonArray[0];
[self initUI];
}
}];
@@ -303,6 +322,7 @@
_currentModel = _questonArray[_page - 1];
[self reloadViews];
}
#pragma mark 刷新题目
@@ -310,11 +330,20 @@
-(void)reloadViews{
//刷新问题相关数据
// NSAttributedString *numbertitle = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%ld",(long)_page] attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
//
// [_numberBtn setAttributedTitle:numbertitle forState:UIControlStateNormal];
if (_page == self.questonArray.count) {
NSAttributedString *nextTitle = [[NSAttributedString alloc] initWithString:@"完成" attributes:@{NSFontAttributeName:[UIFont fontWithName:GIGA_FONTBOLD size:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
[_nextBtn setAttributedTitle:nextTitle forState:UIControlStateNormal];
}else{
NSAttributedString *nextTitle = [[NSAttributedString alloc] initWithString:@"下一题" attributes:@{NSFontAttributeName:[UIFont fontWithName:GIGA_FONTBOLD size:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
[_nextBtn setAttributedTitle:nextTitle forState:UIControlStateNormal];
}
self.questionlabel.text = [NSString stringWithFormat:@"%@",_currentModel.question];
self.descLabel.text = _currentModel.remark;
//
@@ -325,19 +354,35 @@
if (_page > 1) {
self.preBtn.hidden = NO;
[self.nextBtn mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view.mas_top).offset(529 -SAFE_NAV_HEIGHT);
make.size.mas_equalTo(CGSizeMake(126, 40));
make.left.mas_equalTo(self.view.mas_left).offset(self.view.frame.size.width /2 + 10);
if (self.view.frame.size.height <= 504) {
[self.nextBtn mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view.mas_top).offset(504 -SAFE_NAV_HEIGHT);
make.size.mas_equalTo(CGSizeMake(126, 40));
make.left.mas_equalTo(self.view.mas_centerX).offset(10);
}];
}];
}else{
[self.nextBtn mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view.mas_top).offset(529 -SAFE_NAV_HEIGHT);
make.size.mas_equalTo(CGSizeMake(126, 40));
make.left.mas_equalTo(self.view.mas_centerX).offset(10);
}];
}
}else{
[self.nextBtn mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.view.mas_top).offset(529 -SAFE_NAV_HEIGHT);
if (self.view.frame.size.height <= 504) {
make.top.mas_equalTo(self.view.mas_top).offset(504 -SAFE_NAV_HEIGHT);
}else{
make.top.mas_equalTo(self.view.mas_top).offset(529 -SAFE_NAV_HEIGHT);
}
make.size.mas_equalTo(CGSizeMake(126, 40));
make.left.mas_equalTo(self.view.mas_left).offset(self.view.frame.size.width /2 - 126 /2);
make.left.mas_equalTo(self.view.mas_centerX).offset(-63);
}];
self.preBtn.hidden = YES;
}
@@ -349,6 +394,7 @@
[self saveProgress];
if (_page == self.questonArray.count ) {
//GIGA_ShowToast(@"没有了");
[self submitAnswer];
return;
}
@@ -363,7 +409,7 @@
-(void)submitAnswer{
[self userTestEnd];
}
@@ -397,10 +443,12 @@
//获取结果
-(void)getTestResult{
self.nextBtn.userInteractionEnabled = NO;
NSDictionary *params = @{@"singleChoiceList":self.answerArray};
[self.view makeToastActivity:CSToastPositionCenter];
NSString *url = [NSString stringWithFormat:@"%@%@",[GiGaServerConfig getMainUrl],kAiSkinTestResult];
[GiGaNetManager userbodyRequest:url params:params completionHandler:^(NSURLResponse *response, NSDictionary *resDic, NSError * _Nullable error) {
self.nextBtn.userInteractionEnabled = YES;
[self.view hideToastActivity];
GiGaAPIResult *result = [[GiGaAPIResult alloc] initWithDictionary:resDic];
if (result.success) {
@@ -423,6 +471,7 @@
// MaskTestResult *model =[[MaskTestResult alloc] initWithDictionary:dic error:nil];
MaskTestResultVC *resultVC = [[MaskTestResultVC alloc] init];
resultVC.model = mode;
resultVC.isfromshouYE = YES;
[self.navigationController pushViewController:resultVC animated:YES];
}else{
@@ -11,6 +11,7 @@
@interface MaskTestResultVC : GiGaBaseViewController
@property (nonatomic,strong) MaskTestResult *model;
@property (nonatomic) BOOL isfromshouYE;
@end
@@ -17,17 +17,22 @@
#import <WXApi.h>
#import "MaskTestResult.h"
#import "MaskTestNODataViewCell.h"
#import "UIButton+WebCache.h"
#import "UIImageView+WebCache.h"
@interface MaskTestResultVC ()
@property (nonatomic,strong) UIView *tabheader;
//@property (nonatomic,strong) UIImageView *qrimageView;
@end
@implementation MaskTestResultVC
- (void)viewDidLoad {
[super viewDidLoad];
[self addNavTitile:@"测试结果"];
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.view addSubview:self.tableView];
self.tableView.delegate = self;
@@ -37,26 +42,160 @@
self.tableView.sectionFooterHeight = 0;
self.tableView.estimatedSectionFooterHeight= 0;
self.tableView.estimatedSectionHeaderHeight = 0;
//self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,self.view.frame.size.width, 30)];
self.tableView.frame = CGRectMake(0,0,KMainW, self.view.frame.size.height);
//分享用默认隐藏
UIView *holdView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,self.view.frame.size.width, SAFE_NAV_HEIGHT)];
holdView.backgroundColor = [UIColor whiteColor];
UIView *tabheader = [[UIView alloc] initWithFrame:holdView.bounds];
tabheader.backgroundColor = GIGA_MAIN_BGCOLOR;
[holdView addSubview:tabheader];
UILabel *reslabel = [[UILabel alloc] init];
reslabel.text = @"我的皮肤测试结果:";
reslabel.textColor = [UIColor whiteColor];
reslabel.font = GIGA_TEXTFONTBOLD(20);
[tabheader addSubview:reslabel];
[reslabel sizeToFit];
[reslabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(tabheader.mas_left).offset(18);
make.centerY.mas_equalTo(tabheader.mas_centerY);
}];
UIImageView *shareUserImageView = [[UIImageView alloc] init];
BOOL isUserLogin = [GiGaUserDefault isUserLogin];
if (isUserLogin) {
GiGaUser *user = [[GiGaUserManager shareUser] getCurrentUser];
if (user) {
if (user.headImgUrl && ![user.headImgUrl isKindOfClass:[NSNull class]]) {
NSURL *url = [NSURL URLWithString:user.headImgUrl];
[shareUserImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"nav_circle_avatar"]];
}
}
}
[tabheader addSubview:shareUserImageView];
[shareUserImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(tabheader.mas_right).offset(-18);
make.size.mas_equalTo(CGSizeMake(34, 34));
make.centerY.mas_equalTo(tabheader.mas_centerY);
}];
shareUserImageView.layer.masksToBounds = YES;
shareUserImageView.layer.cornerRadius = 17;
tabheader.hidden = YES;
self.tabheader = tabheader;
self.tableView.tableHeaderView = holdView;
self.tableView.frame = CGRectMake(0,-SAFE_NAV_HEIGHT,KMainW,KMainH);
[self.tableView registerClass:[MaskResultPercentCell class] forCellReuseIdentifier:@"MaskResultPercentCell"];
[self.tableView registerClass:[MaskResultMinViewCell class] forCellReuseIdentifier:@"MaskResultMinViewCell"];
[self.tableView registerClass:[MaskResultShareViewCell class] forCellReuseIdentifier:@"MaskResultShareViewCell"];
// if (@available(iOS 11.0, *)) {
// self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
//
//
// } else {
//
// self.automaticallyAdjustsScrollViewInsets = NO;
// }
if (!self.model) {
[self addNavTitile:@"历史测试"];
[self requstLatestTestData];
}else{
[self addNavTitile:@"测试结果"];
}
NC_ADD_TARGET_NAME_OBJECT(self, @selector(usershareSuccessNoti), NC_UseShareSuccessNoti, nil);
[self initUserAvator];
//重写返回按钮
UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
backBtn.frame = CGRectMake(0, 0, 40, 40);
[backBtn setImage:[UIImage imageNamed:@"btn_moment_back"] forState:UIControlStateNormal];
[backBtn setImageEdgeInsets:UIEdgeInsetsMake(0,-14, 0, 14)];
//backBtn.backgroundColor = [UIColor redColor];
[backBtn addTarget:self action:@selector(backItemAction) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
self.navigationItem.leftBarButtonItem = backItem;
}
//重写返回事件
- (void)backItemAction{
if (_isfromshouYE) {
[self.navigationController popToRootViewControllerAnimated:YES];
}else{
[self.navigationController popViewControllerAnimated:YES];
}
}
- (void)viewDidAppear:(BOOL)animated{
[super viewDidAppear:animated];
if (_isfromshouYE) {
if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
}
}
- (void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
if (_isfromshouYE) {
if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}
}
}
-(void)dealloc{
NC_REMOVE_NAME(self, NC_UseShareSuccessNoti, nil);
}
-(void)initUserAvator{
//rightItem
UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
rightBtn.frame = CGRectMake(0, 0, 40, 40);
rightBtn.layer.masksToBounds = YES;
rightBtn.layer.cornerRadius = 20;
[rightBtn setImage:[UIImage imageNamed:@"nav_circle_avatar"] forState:UIControlStateNormal];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 11.0) {
[rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(40, 40));
}];
}
BOOL isUserLogin = [GiGaUserDefault isUserLogin];
if (isUserLogin) {
GiGaUser *user = [[GiGaUserManager shareUser] getCurrentUser];
if (user) {
if (user.headImgUrl && ![user.headImgUrl isKindOfClass:[NSNull class]]) {
NSURL *url = [NSURL URLWithString:user.headImgUrl];
[rightBtn sd_setImageWithURL:url forState:UIControlStateNormal];
}
}
}
}
-(void)requstLatestTestData{
[self.view makeToastActivity:CSToastPositionCenter];
@@ -139,8 +278,11 @@
if (self.model == nil) {
return 255;
}
CGFloat viewH = KMainH - SAFE_NAV_HEIGHT;
CGFloat cellH = viewH / 3 ;
if (KMainW < 375) {
return 201;
}
CGFloat viewH = self.view.frame.size.height - SAFE_NAV_HEIGHT;
CGFloat cellH = viewH / 3;
return cellH;
}
@@ -160,16 +302,17 @@
GIGA_ShowToast(@"未安装微信");
return;
}
UIImage *image = [UIImage saveLongImage:self.tableView];
[self showFinalShareView];
UIImage *image = [UIImage saveNavsuitImage:self.tableView];
//[[GiGaFileNanager shareInstance] saveImaeToAlBum:image];
[self jxt_showActionSheetWithTitle:@"分享微信" message:@"" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
[self jxt_showActionSheetWithTitle:@"分享微信" message:@"" appearanceProcess:^(JXTAlertController * _Nonnull alertMaker) {
alertMaker.addActionDefaultTitle(@"");
alertMaker.addActionDefaultTitle(@"微信好");
alertMaker.addActionDefaultTitle(@"朋友圈");
alertMaker.addActionCancelTitle(@"取消");
} actionsBlock:^(NSInteger buttonIndex, UIAlertAction * _Nonnull action, JXTAlertController * _Nonnull alertSelf) {
[self hidSomeViews];
if (buttonIndex==0) {
//好友
[self shareImagToWX:image scene:WXSceneSession];
@@ -178,9 +321,30 @@
}else if (buttonIndex==1){
// 朋友圈
[self shareImagToWX:image scene:WXSceneTimeline];
}else{
GILog(@"取消");
}
}];
}
-(void)hidSomeViews{
MaskResultShareViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]];
cell.qrcodeImage.hidden = YES;
cell.shareBtn.hidden = NO;
cell.lastLabe.text = @"让更多的朋友一起加入面膜时间吧!";
self.tabheader.hidden = YES;
}
-(void)showFinalShareView{
MaskResultShareViewCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]];
cell.qrcodeImage.hidden = NO;
cell.shareBtn.hidden = YES;
cell.lastLabe.text = @"长按扫描二维码,测试你的肤质";
self.tabheader.hidden = NO;
}
-(void)shareImagToWX:(UIImage *)image scene:(int)scene{
WXMediaMessage *msg = [WXMediaMessage message];
@@ -207,15 +371,20 @@
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//分享成功
-(void)usershareSuccessNoti{
//GIGA_ShowToast(@"分享成功");
if (_isfromshouYE) {
[self.navigationController popToRootViewControllerAnimated:YES];
}
}
-(void)testBtnAction{
[self.navigationController popToRootViewControllerAnimated:YES];
}
@end