Commit a308ae59 by Sweet Zhang

年龄

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