Commit a308ae59 by Sweet Zhang

年龄

parent 4d4267d2
...@@ -23,6 +23,7 @@ export class AgeComponent implements OnInit { ...@@ -23,6 +23,7 @@ export class AgeComponent implements OnInit {
lastQuestions: Array<any>; lastQuestions: Array<any>;
nextBtn: boolean = false; nextBtn: boolean = false;
targetObj: any = {}; targetObj: any = {};
constructor(private commonService: CommonService, private router: Router, private route: ActivatedRoute) { constructor(private commonService: CommonService, private router: Router, private route: ActivatedRoute) {
/** /**
* 1:单身贵族 * 1:单身贵族
...@@ -42,7 +43,6 @@ export class AgeComponent implements OnInit { ...@@ -42,7 +43,6 @@ export class AgeComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 3).pop(); this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 3).pop();
console.log(this.lastQuestions)
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
this.curPageData = res['data']['survey']['pages'].filter(item => item.pageId === 3).pop(); this.curPageData = res['data']['survey']['pages'].filter(item => item.pageId === 3).pop();
this.pageAnswers.pageId = this.curPageData['pageId']; this.pageAnswers.pageId = this.curPageData['pageId'];
...@@ -56,25 +56,32 @@ export class AgeComponent implements OnInit { ...@@ -56,25 +56,32 @@ export class AgeComponent implements OnInit {
this.handleData([]); this.handleData([]);
} }
if (this.lastQuestions) { if (this.lastQuestions) {
// 检测增加了几个孩子
const childLength = this.lastQuestions['questions'].filter(item => item.questionSubId).length;
if (childLength > 0) {
for (let i = 0; i < childLength; i++) {
this.addChild();
}
}
for (let i = 0; i < this.lastQuestions['questions'].length; i++) { for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
for (let j = 0; j < this.curPageData['questions'].length; j++) { for (let j = 0; j < this.curPageData['questions'].length; j++) {
if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) { if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) {
this.lastQuestions['questions'][i]['options'].forEach(option => { if (this.lastQuestions['questions'][i]['questionSubId'] == this.curPageData['questions'][j]['questionSubId']) {
if (Object.keys(option).indexOf('optionId') > -1) { this.lastQuestions['questions'][i]['options'].forEach(option => {
this.targetObj = option; if (Object.keys(option).indexOf('optionId') > -1) {
} this.targetObj = option;
// console.log(this.targetObj) }
this.showToast(this.curPageData['questions'][j]) this.showToast(this.curPageData['questions'][j])
this.selectedAge(this.targetObj); this.selectedAge(this.targetObj);
}); });
}
} }
} }
} }
}else{ } else {
return return;
} }
// console.log(this.curPageData) console.log(this.curPageData);
}); });
} }
......
...@@ -14,7 +14,8 @@ export class JobComponent implements OnInit { ...@@ -14,7 +14,8 @@ export class JobComponent implements OnInit {
id: any; id: any;
nextBtn: boolean; nextBtn: boolean;
lastQuestions: Array<any>; lastQuestions: Array<any>;
targetObj:Object = {} targetObj: Object = {}
constructor(private commonService: CommonService, constructor(private commonService: CommonService,
private router: Router, private router: Router,
private route: ActivatedRoute) { private route: ActivatedRoute) {
...@@ -49,46 +50,44 @@ export class JobComponent implements OnInit { ...@@ -49,46 +50,44 @@ export class JobComponent implements OnInit {
if (this.id == 1) { if (this.id == 1) {
this.curPageData = res['data'].survey.pages['3']; this.curPageData = res['data'].survey.pages['3'];
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 4).pop(); this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 4).pop();
console.log(this.lastQuestions) if (this.lastQuestions) {
if(this.lastQuestions){
for (let i = 0; i < this.lastQuestions['questions'].length; i++) { for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
for (let j = 0; j < this.curPageData['questions'].length; j++) { for (let j = 0; j < this.curPageData['questions'].length; j++) {
if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) { if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) {
this.lastQuestions['questions'][i]['options'].forEach(option => { this.lastQuestions['questions'][i]['options'].forEach(option => {
if(Object.keys(option).indexOf('optionId')>-1){ if (Object.keys(option).indexOf('optionId') > -1) {
this.targetObj = option this.targetObj = option
} }
this.selectedJob(this.targetObj); this.selectedJob(this.targetObj);
}); });
} }
} }
} }
}else{ } else {
return return;
} }
} else { } else {
this.curPageData = res['data'].survey.pages['4']; this.curPageData = res['data'].survey.pages['4'];
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 5).pop(); this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 5).pop();
if(this.lastQuestions){ if (this.lastQuestions) {
for (let i = 0; i < this.lastQuestions['questions'].length; i++) { for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
for (let j = 0; j < this.curPageData['questions'].length; j++) { for (let j = 0; j < this.curPageData['questions'].length; j++) {
if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) { if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) {
this.lastQuestions['questions'][i]['options'].forEach(option => { this.lastQuestions['questions'][i]['options'].forEach(option => {
if(Object.keys(option).indexOf('optionId')>-1){ if (Object.keys(option).indexOf('optionId') > -1) {
this.targetObj = option this.targetObj = option;
} }
this.selectedJob(this.targetObj); this.selectedJob(this.targetObj);
}); });
} }
} }
} }
}else{ } else {
return return;
} }
} }
console.log(this.curPageData)
} }
}); });
} }
...@@ -111,8 +110,6 @@ export class JobComponent implements OnInit { ...@@ -111,8 +110,6 @@ export class JobComponent implements OnInit {
}], }],
}; };
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
console.log(this.pageAnswers)
console.log(this.commonService.todos)
if (this.pageAnswers['questions'].length > 0) { if (this.pageAnswers['questions'].length > 0) {
this.nextBtn = true; this.nextBtn = true;
} else { } else {
...@@ -139,6 +136,7 @@ export class JobComponent implements OnInit { ...@@ -139,6 +136,7 @@ export class JobComponent implements OnInit {
return; return;
} }
} }
// 上一步 // 上一步
before() { before() {
this.commonService.before(); this.commonService.before();
......
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