fix 首页
This commit is contained in:
@@ -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{
|
||||
|
||||
@@ -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];
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user