198 lines
6.5 KiB
Objective-C
198 lines
6.5 KiB
Objective-C
//
|
|
// GiGaQuestionVC.m
|
|
// GIGA
|
|
//
|
|
// Created by lianxiang on 2018/8/23.
|
|
// Copyright © 2018年 com.giga.ios. All rights reserved.
|
|
//
|
|
|
|
#import "GiGaQuestionVC.h"
|
|
#import "Masonry.h"
|
|
#import "GiGaBaseAPiRequest.h"
|
|
#import "GiGaNetManager.h"
|
|
#import "GIGaQuestionSlider.h"
|
|
#import "MaskQuestionView.h"
|
|
#import "ExercisesModel.h"
|
|
|
|
@interface GiGaQuestionVC ()
|
|
|
|
@property (nonatomic,weak) MaskQuestionView *questionView;
|
|
@property (nonatomic,assign) NSInteger page;
|
|
@property (nonatomic,strong) NSMutableArray *questonArray;
|
|
@property (nonatomic,strong) ExercisesModel *currentModel;
|
|
|
|
@property (nonatomic,strong) UILabel *questionlabel;
|
|
@property (nonatomic,strong) UIButton *nextBtn;
|
|
@property (nonatomic,strong) UIButton *preBtn;
|
|
|
|
@end
|
|
|
|
@implementation GiGaQuestionVC
|
|
|
|
- (void)viewDidLoad {
|
|
[self addNavTitile:@"测试肤质"];
|
|
[super viewDidLoad];
|
|
// self.title = @"测试肤质";
|
|
_page = 1;
|
|
//
|
|
[self loadRequestQuestions];
|
|
|
|
//[self initUI];
|
|
|
|
}
|
|
|
|
-(void)initUI{
|
|
|
|
UIButton *numberBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
[numberBtn setBackgroundImage:[UIImage imageNamed:@"ceshi_number"] forState:UIControlStateNormal];
|
|
NSAttributedString *numbertitle = [[NSAttributedString alloc] initWithString:@"1" attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
|
|
|
[numberBtn setAttributedTitle:numbertitle forState:UIControlStateNormal];
|
|
[self.view addSubview:numberBtn];
|
|
|
|
UILabel *titleLabel = [[UILabel alloc] init];
|
|
titleLabel.text = @"悄悄地告诉你小优的年龄区间是?";
|
|
titleLabel.font = [UIFont fontWithName:GIGA_FONTBOLD size:16];
|
|
titleLabel.textColor = GIGARGB(63, 63, 63, 1);
|
|
[self.view addSubview:titleLabel];
|
|
|
|
UILabel *descLabel = [[UILabel alloc] init];
|
|
descLabel.text = @"精准的选择,让小优更好的为您挑选最符合您的肤质的面膜";
|
|
descLabel.font = [UIFont fontWithName:GIGA_FONTNAME size:12];
|
|
descLabel.textColor = GIGARGB(208, 208, 208, 1);
|
|
descLabel.numberOfLines = 0;
|
|
descLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
|
[self.view addSubview:descLabel];
|
|
|
|
[numberBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(31, 31));
|
|
make.top.mas_equalTo(self.view.mas_top).offset(112 + PhoneX_TopMargin);
|
|
make.left.mas_equalTo(self.view.mas_left).offset(46);
|
|
|
|
}];
|
|
|
|
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
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(-53);
|
|
|
|
}];
|
|
|
|
[descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(numberBtn.mas_right).offset(12);
|
|
make.top.mas_equalTo(titleLabel.mas_bottom).offset(20);
|
|
make.right.mas_equalTo(self.view.mas_right).offset(-89);
|
|
|
|
}];
|
|
|
|
//选择题view
|
|
NSArray *titles = @[@"hahah",@"呵呵呵呵",@"哦哦",@"有有u哟哦",@"呵呵呵呵"];
|
|
NSMutableArray *tit = [NSMutableArray new];
|
|
ExercisesModel *model = self.questonArray[0];
|
|
NSArray *modeA = model.answerList;
|
|
for (NSDictionary *mode in modeA){
|
|
[tit addObject:mode[@"answer"]];
|
|
}
|
|
titles = tit;
|
|
MaskQuestionView *questionView = [[MaskQuestionView alloc] initQuestionView:CGRectMake(0,248, self.view.frame.size.width,212) style:MaskQuetionViewStleSliderNormal titles:titles];
|
|
|
|
questionView.backgroundColor = [UIColor redColor];
|
|
[self.view addSubview:questionView];
|
|
self.questionView = questionView;
|
|
|
|
|
|
}
|
|
|
|
-(void)updateValue:(UISlider *)slider{
|
|
NSLog(@"value%f",slider.value);
|
|
GILog(@"formatvalue:%.2f",slider.value*60);
|
|
|
|
}
|
|
|
|
-(NSMutableArray *)questonArray{
|
|
if (!_questonArray) {
|
|
_questonArray = [[NSMutableArray alloc] init];
|
|
}
|
|
return _questonArray;
|
|
}
|
|
|
|
-(void)loadRequestQuestions{
|
|
|
|
NSDictionary *params = @{};
|
|
GiGaBaseAPiRequest *request = [GiGaBaseAPiRequest initWithRequestPath:@"activity/maskquestion/v1/list" method:RequestPostMethod parms:params];
|
|
|
|
[request requstDataWithResult:^(GiGaAPIResult *result) {
|
|
if (result.success) {
|
|
NSLog(@"result:%@",result.dic);
|
|
NSArray *list = result.dic[@"list"];
|
|
NSDictionary *answer = list[0];
|
|
for (NSDictionary *answerDic in list) {
|
|
ExercisesModel *model = [[ExercisesModel alloc] initWithDictionary:answerDic error:nil];
|
|
[self.questonArray addObject:model];
|
|
|
|
}
|
|
[self initUI];
|
|
}
|
|
}];
|
|
|
|
}
|
|
|
|
#pragma mark 获取当前题目信息
|
|
-(void)getQuestionsInfo{
|
|
|
|
_currentModel = _questonArray[_page - 1];
|
|
[self reloadViews];
|
|
}
|
|
|
|
#pragma mark 刷新题目
|
|
-(void)reloadViews{
|
|
//刷新问题相关数据
|
|
// NSString *questionlabelText = [NSString stringWithFormat:@"%@.%@", _currentModel.questionid, _currentModel.question];
|
|
// NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
|
// [paragraphStyle setLineSpacing:4.0f];
|
|
// NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:questionlabelText];
|
|
// NSDictionary *attrs =@{NSFontAttributeName:[UIFont systemFontOfSize:18]};
|
|
// [attributedString setAttributes:attrs range:NSMakeRange(0, 2)];
|
|
//
|
|
// _questionlabel.attributedText = attributedString;
|
|
|
|
[self.view layoutIfNeeded];//必加
|
|
// //刷新答案相关数据
|
|
// [_questionView reloadViewWithFrame:CGRectMake(30, CGRectGetMaxY(_questionlabel.frame) + 15, KMainW - 30*2, 0) style:[_currentModel.questiontype intValue] - 1 answerArray:_currentModel.tkselect userAnswers:_currentModel.userAnswer];
|
|
|
|
}
|
|
|
|
|
|
-(void)nextBtnAction{
|
|
// if (_page == [_currentModel.totalCount integerValue] ) {
|
|
// GIGA_ShowToast(@"没有了");
|
|
// return;
|
|
// }
|
|
// [self saveProgress];
|
|
// _page ++ ;
|
|
// //获取题目信息
|
|
// [self getQuestionsInfo];
|
|
|
|
//self.nextBtn.enabled = _page == [_currentModel.totalCount integerValue] ? NO : YES;
|
|
|
|
}
|
|
|
|
#pragma mark -做题记录
|
|
-(void)saveProgress{
|
|
// NSString *answer = self.questionView.selectAnswer;
|
|
// NSString *anserNum = self.questionView.qrnum;
|
|
// NSString *anserid = _currentModel.questionid;
|
|
// GILog(@"选择答案:%@\n 角标:%@\n 题号:%@",answer,anserNum,anserid);
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
|
|
|
|
|
|
@end
|