Commit e2da9242 by Sweet Zhang

增加年龄的判断

parent aa75d93c
...@@ -21,6 +21,7 @@ export class AgeComponent implements OnInit { ...@@ -21,6 +21,7 @@ export class AgeComponent implements OnInit {
question: any; question: any;
// 上一次的答案 // 上一次的答案
lastQuestions: Array<any>; lastQuestions: Array<any>;
nextBtn: boolean = false;
constructor(private commonService: CommonService, private router: Router, private route: ActivatedRoute) { constructor(private commonService: CommonService, private router: Router, private route: ActivatedRoute) {
/** /**
...@@ -96,14 +97,18 @@ export class AgeComponent implements OnInit { ...@@ -96,14 +97,18 @@ export class AgeComponent implements OnInit {
// console.log(this.curPageData); // console.log(this.curPageData);
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
this.closeToast(); this.closeToast();
console.log(this.pageAnswers) console.log(this.pageAnswers);
if (this.curPageData['questions'].length == this.pageAnswers.questions.length) {
this.nextBtn = true;
} else {
this.nextBtn = false;
}
} }
showToast(question, idx) { showToast(question, idx) {
this.isShow = true; this.isShow = true;
this.curQues = question; this.curQues = question;
this.curQuesIndex = idx; this.curQuesIndex = idx;
console.log(question)
for (let i = 0; i < question['options'].length; i++) { for (let i = 0; i < question['options'].length; i++) {
if (question.optionName == question['options'][i].optionName) { if (question.optionName == question['options'][i].optionName) {
question['options'][i]['selected'] = true question['options'][i]['selected'] = true
...@@ -130,6 +135,11 @@ export class AgeComponent implements OnInit { ...@@ -130,6 +135,11 @@ export class AgeComponent implements OnInit {
this.question.optionName = null; this.question.optionName = null;
this.question.questionName = '孩子' + this.questionSubId + '年龄'; this.question.questionName = '孩子' + this.questionSubId + '年龄';
this.curPageData['questions'].push(this.question); this.curPageData['questions'].push(this.question);
if (this.curPageData['questions'].length == this.pageAnswers.questions.length) {
this.nextBtn = true;
} else {
this.nextBtn = false;
}
} }
// 根据家庭结构处理展示数据 // 根据家庭结构处理展示数据
...@@ -146,6 +156,11 @@ export class AgeComponent implements OnInit { ...@@ -146,6 +156,11 @@ export class AgeComponent implements OnInit {
// 下一步 // 下一步
next() { next() {
if (this.nextBtn) {
this.router.navigate(['/job'], {queryParams: {type: this.type}}); this.router.navigate(['/job'], {queryParams: {type: this.type}});
} else {
return;
}
} }
} }
...@@ -66,7 +66,7 @@ export class FamilyComponent implements OnInit { ...@@ -66,7 +66,7 @@ export class FamilyComponent implements OnInit {
}], }],
}; };
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
// console.log(this.pageAnswers) // console.log(this.pageAnswers);
if (this.pageAnswers.questions[0].options.every((item) => { if (this.pageAnswers.questions[0].options.every((item) => {
return item.selected; return item.selected;
})) { })) {
......
...@@ -108,9 +108,7 @@ export class HealthComponent implements OnInit { ...@@ -108,9 +108,7 @@ export class HealthComponent implements OnInit {
// 下一步 // 下一步
next() { next() {
if (this.pageAnswers.questions[0].options.every((item) => { if (this.nextBtn) {
return item.selected;
})) {
// 如果是二人世界或是多口之家跳转到配偶页 // 如果是二人世界或是多口之家跳转到配偶页
// 先判断当前页是您的页还是配偶页 // 先判断当前页是您的页还是配偶页
if (this.id == 1) { if (this.id == 1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment