Commit e91e49df by Chao Sun

删除多个问题初始化

parent fb98e718
...@@ -46,10 +46,6 @@ export class AskComponent implements OnInit { ...@@ -46,10 +46,6 @@ export class AskComponent implements OnInit {
}) })
} }
reducePage() { reducePage() {
if(this.questionInfo){
this.allAnswers[this.curPage] = this.questionInfo;
this.questionInfo = null
}
if (this.curPage > 0) { if (this.curPage > 0) {
const page2Answer = this.allAnswers[1] const page2Answer = this.allAnswers[1]
if(page2Answer){ if(page2Answer){
...@@ -88,24 +84,6 @@ export class AskComponent implements OnInit { ...@@ -88,24 +84,6 @@ export class AskComponent implements OnInit {
} else { } else {
return return
} }
// if(this.curPage == 6 || this.curPage == 8){
// const page2Answer = this.allAnswers[1]
// const optionId = page2Answer.questions[0].options[0].optionId
// if(optionId==1 || optionId==3){
// if(this.questionInfo['questions'].length>0){
// this.nextBtn = true
// }
// }
// }
// if(this.curPageData['questions'].length == this.questionInfo['questions'].length){
// this.nextBtn = true
// }
console.log(this.questionInfo)
// if(){
// }
} }
filterItems() { filterItems() {
return this.allAnswers.filter(item => { return this.allAnswers.filter(item => {
...@@ -143,10 +121,10 @@ export class AskComponent implements OnInit { ...@@ -143,10 +121,10 @@ export class AskComponent implements OnInit {
pages: this.filterItems() pages: this.filterItems()
} }
} }
console.log(answerParam)
if (this.curPage == 16) { if (this.curPage == 16) {
this.commonService.saveCustomerAnwers(answerParam).then(res => { this.commonService.saveCustomerAnwers(answerParam).then(res => {
// console.log(res)
}) })
} }
} }
...@@ -219,7 +197,6 @@ export class AskComponent implements OnInit { ...@@ -219,7 +197,6 @@ export class AskComponent implements OnInit {
this.nextBtn = false; this.nextBtn = false;
} }
} }
// console.log('thePateData------', this.curPage, thePateData)
} }
filterPage2(optionId, thePateData) { filterPage2(optionId, thePateData) {
...@@ -271,7 +248,6 @@ export class AskComponent implements OnInit { ...@@ -271,7 +248,6 @@ export class AskComponent implements OnInit {
//1单身 3单亲 //1单身 3单亲
if (optionId == 1 || optionId == 3) { if (optionId == 1 || optionId == 3) {
this.curPage++ this.curPage++
// console.log('page5', this.curPage, this.curPageData)
this.curPageData = this.allQues[this.curPage] this.curPageData = this.allQues[this.curPage]
} }
} }
......
...@@ -36,6 +36,7 @@ export class Page3Component implements OnInit { ...@@ -36,6 +36,7 @@ export class Page3Component implements OnInit {
this.curQuesIndex = idx this.curQuesIndex = idx
// console.log(question) // console.log(question)
this.curQuestionSelecte = question.name this.curQuestionSelecte = question.name
} }
closeToast() { closeToast() {
this.isShow = false this.isShow = false
...@@ -43,9 +44,11 @@ export class Page3Component implements OnInit { ...@@ -43,9 +44,11 @@ export class Page3Component implements OnInit {
getAnswer(option) { getAnswer(option) {
const questionId = this.curQues['questionId'] const questionId = this.curQues['questionId']
this.curAllQues[questionId] = option this.curAllQues[questionId] = option
console.log(this.curAllQues)
const questions = Object.keys(this.curAllQues).map(questionId => { const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId, options: [this.curAllQues[questionId]] } return { questionId, options: [this.curAllQues[questionId]] }
}) })
const ret = { const ret = {
pageId: 3, pageId: 3,
questions questions
...@@ -57,9 +60,9 @@ export class Page3Component implements OnInit { ...@@ -57,9 +60,9 @@ export class Page3Component implements OnInit {
//当前选中项 //当前选中项
this.curPageData['questions'][this.curQuesIndex]['name'] = this.curPageData['questions'][this.curQuesIndex]['name'] =
options.optionName options.optionName
} }
addChild() { addChild() {
// this.addChildCount-- // this.addChildCount--
// if (this.addChildCount >= 0) { // if (this.addChildCount >= 0) {
......
...@@ -45,6 +45,7 @@ export class Page5Component implements OnInit { ...@@ -45,6 +45,7 @@ export class Page5Component implements OnInit {
options.forEach(option => { options.forEach(option => {
if (option['selected']) { if (option['selected']) {
this.selectedObj = option; this.selectedObj = option;
console.log(this.selectedObj)
this.getAnswer(this.selectedObj) this.getAnswer(this.selectedObj)
} }
}) })
......
...@@ -11,14 +11,17 @@ export class Page7Component implements OnInit { ...@@ -11,14 +11,17 @@ export class Page7Component implements OnInit {
@Output() getAllAnswer = new EventEmitter<any>() @Output() getAllAnswer = new EventEmitter<any>()
curAllQues: Object curAllQues: Object
selectedObj: Object selectedObj: Object
selectedObj1:Object
constructor() {} constructor() {}
ngOnInit() { ngOnInit() {
this.curAllQues = {} this.curAllQues = {}
this.selectedObj = {} this.selectedObj = {}
this.selectedObj1 = {}
this.setOptionSelected() this.setOptionSelected()
} }
getAnswer(question, options) { getAnswer(question, options) {
console.log(question,options)
//获取当前页面问题id //获取当前页面问题id
const questionId = question['questionId'] const questionId = question['questionId']
if (!this.selectedObj[questionId]) { if (!this.selectedObj[questionId]) {
...@@ -53,14 +56,6 @@ export class Page7Component implements OnInit { ...@@ -53,14 +56,6 @@ export class Page7Component implements OnInit {
if (option['selected']) { if (option['selected']) {
// console.log(this.selectedObj) // console.log(this.selectedObj)
this.selectedObj[question['questionId']] = option this.selectedObj[question['questionId']] = option
const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId, options: [this.curAllQues[questionId]] }
})
const ret = {
pageId: 7,
questions
}
this.getAllAnswer.emit(ret)
} }
}) })
}) })
......
...@@ -53,14 +53,6 @@ export class Page8Component implements OnInit { ...@@ -53,14 +53,6 @@ export class Page8Component implements OnInit {
question['options'].forEach(option => { question['options'].forEach(option => {
if (option['selected']) { if (option['selected']) {
this.selectedObj[question['questionId']] = option this.selectedObj[question['questionId']] = option
const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId, options: [this.curAllQues[questionId]] }
})
const ret = {
pageId: 8,
questions
}
this.getAllAnswer.emit(ret)
} }
}) })
}) })
......
...@@ -50,14 +50,6 @@ export class Page9Component implements OnInit { ...@@ -50,14 +50,6 @@ export class Page9Component implements OnInit {
question['options'].forEach(option => { question['options'].forEach(option => {
if (option['selected']) { if (option['selected']) {
this.selectedObj[question['questionId']] = option this.selectedObj[question['questionId']] = option
const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId, options: [this.curAllQues[questionId]] }
})
const ret = {
pageId: 9,
questions
}
this.getAllAnswer.emit(ret)
} }
}) })
}) })
......
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