Commit 9391fe3e by Chao Sun

fix: many bug

parent 3fba7ea1
import { Component, OnInit } from '@angular/core' import { Component, OnInit } from '@angular/core'
import { CommonService } from '../common.service' import { CommonService } from '../common.service'
import { Options } from 'selenium-webdriver/chrome'
@Component({ @Component({
selector: 'app-ask', selector: 'app-ask',
templateUrl: './ask.component.html', templateUrl: './ask.component.html',
...@@ -17,7 +18,7 @@ export class AskComponent implements OnInit { ...@@ -17,7 +18,7 @@ export class AskComponent implements OnInit {
constructor(private commonService: CommonService) {} constructor(private commonService: CommonService) {}
ngOnInit() { ngOnInit() {
this.curPage = 10 this.curPage = 0
this.totalPage = 17 this.totalPage = 17
this.curPageData = [] this.curPageData = []
this.allAnswers = [] this.allAnswers = []
...@@ -67,8 +68,8 @@ export class AskComponent implements OnInit { ...@@ -67,8 +68,8 @@ export class AskComponent implements OnInit {
setCurPageData() { setCurPageData() {
const thePateData = this.allQues[this.curPage] const thePateData = this.allQues[this.curPage]
console.log('thePateData------', this.curPage, thePateData) console.log('thePateData------', this.curPage, thePateData)
this.curPageData = thePateData this.curPageData = thePateData
const page2Answer = this.allAnswers[1] const page2Answer = this.allAnswers[1]
if (this.curPage == 2) { if (this.curPage == 2) {
this.filterPage2( this.filterPage2(
page2Answer.questions[0].options[0].optionId, page2Answer.questions[0].options[0].optionId,
...@@ -81,22 +82,24 @@ export class AskComponent implements OnInit { ...@@ -81,22 +82,24 @@ export class AskComponent implements OnInit {
thePateData thePateData
) )
} }
if(this.curPage == 11){ if (this.curPage == 11) {
this.filterPage12( this.filterPage12(
page2Answer.questions[0].options[0].optionId, page2Answer.questions[0].options[0].optionId,
thePateData thePateData
) )
} }
if(this.curPage == 12){ if (this.curPage == 12) {
this.filterPage13( this.filterPage13(
page2Answer.questions[0].options[0].optionId, page2Answer.questions[0].options[0].optionId,
thePateData thePateData
) )
} }
if(this.curPage ==14){ console.log('page start', this.curPage)
this.filterPage15( if (this.curPage == 13) {
console.log('page end', this.curPage)
this.filterPage14(
page2Answer.questions[0].options[0].optionId, page2Answer.questions[0].options[0].optionId,
thePateData this.allQues[this.curPage]
) )
} }
} }
...@@ -156,41 +159,87 @@ export class AskComponent implements OnInit { ...@@ -156,41 +159,87 @@ export class AskComponent implements OnInit {
} }
//pege12判断是否显示配偶健康 //pege12判断是否显示配偶健康
filterPage12(optionId, thePateData){ filterPage12(optionId, thePateData) {
if (optionId == 1 || optionId == 3) { if (optionId == 1 || optionId == 3) {
this.curPage++ this.curPage++
console.log('page12', this.curPage, this.curPageData)
this.curPageData = this.allQues[this.curPage] this.curPageData = this.allQues[this.curPage]
} }
} }
//page13判断是否显示孩子健康 //page13判断是否显示孩子健康
filterPage13(optionId, thePateData){ filterPage13(optionId, thePateData) {
//单身或二人世界 //单身或二人世界
if (optionId == 1 || optionId ==2) { if (optionId == 1 || optionId == 2) {
this.curPage++ this.curPage++
console.log('page13', this.curPage, this.curPageData)
this.curPageData = this.allQues[this.curPage]
} }
} }
//page15判断option内容 //page14判断option内容
filterPage15(optionId,thePateData){ filterPage14(optionId, thePateData) {
//如果单身或者单亲选择相中没有配偶选项 //如果单身或者单亲选择相中没有配偶选项
if(optionId == 1 || optionId == 3){ if (optionId == 1) {
this.curPageData = { this.curPageData = {
...thePateData, ...thePateData,
questions:thePateData.questions[0]['options'].filter(option=>{ questions: [
return option.optionId == 108 || option.optionId==109 {
}) ...thePateData.questions[0],
options: thePateData.questions[0]['options'].filter(option => {
return option.optionId == 106 || option.optionId == 107
})
}
]
} }
} }
if(optionId==2 || optionId==4){ if (optionId == 2) {
this.curPageData = { this.curPageData = {
...thePateData, ...thePateData,
questions:thePateData.questions[0]['options'].filter(option=>{ questions: [
return option.optionId == 110 || option.optionId == 111 || option.optionId == 112 {
}) ...thePateData.questions[0],
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 108 ||
option.optionId == 109 ||
option.optionId == 111
)
})
}
]
}
}
if (optionId == 3) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 108 ||
option.optionId == 110 ||
option.optionId == 111
)
})
}
]
}
}
if (optionId == 4) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 108 ||
option.optionId == 109 ||
option.optionId == 110 ||
option.optionId == 111
)
})
}
]
} }
} }
} }
......
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
<ul class="jobContent"> <ul class="jobContent">
<li <li
*ngFor="let options of this.curPageData['questions'][0]['options']" *ngFor="let options of this.curPageData['questions'][0]['options']"
[ngClass]="{'selected':options['selected']==true}" [ngClass]="{ selected: options['selected'] == true }"
(click)="getAnswer(options);changeStyle(options.optionId)"> (click)="getAnswer(options)"
>
{{ options.optionName }} {{ options.optionName }}
</li> </li>
</ul> </ul>
......
...@@ -8,36 +8,35 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core' ...@@ -8,36 +8,35 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
export class Page11Component implements OnInit { export class Page11Component implements OnInit {
@Input() curPageData: Array<any> @Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>() @Output() getAllAnswer = new EventEmitter<any>()
allOption: object // allOption: object
selectedNum:number; allOptions: Array<any>
allOptions:Array<any>;
constructor() {} constructor() {}
ngOnInit() { ngOnInit() {
this.allOption = {}; // this.allOption = {}
this.allOptions = []; this.allOptions = []
console.log(this.curPageData) console.log(this.curPageData)
} }
getAnswer(options) { getAnswer(options) {
options['selected'] = !options['selected']; options['selected'] = !options['selected']
for(let i=0;i<this.allOptions.length;i++){ for (let i = 0; i < this.allOptions.length; i++) {
if(options['optionId'] == this.allOptions[i]['optionId']){ if (options['optionId'] == this.allOptions[i]['optionId']) {
let index = this.allOptions.indexOf(this.allOptions[i]); let index = this.allOptions.indexOf(this.allOptions[i])
if(index>-1){ if (index > -1) {
this.allOptions.splice(index,1) this.allOptions.splice(index, 1)
} }
} }
} }
this.allOptions.push(options); this.allOptions.push(options)
for(let i=0;i<this.allOptions.length;i++){ for (let i = 0; i < this.allOptions.length; i++) {
if(!this.allOptions[i]['selected']){ if (!this.allOptions[i]['selected']) {
let index = this.allOptions.indexOf(this.allOptions[i]); let index = this.allOptions.indexOf(this.allOptions[i])
if(index>-1){ if (index > -1) {
this.allOptions.splice(index,1) this.allOptions.splice(index, 1)
} }
} }
} }
console.log(this.allOptions) console.log(this.allOptions)
// if (!this.allOption[options['optionId']]) { // if (!this.allOption[options['optionId']]) {
...@@ -57,19 +56,15 @@ export class Page11Component implements OnInit { ...@@ -57,19 +56,15 @@ export class Page11Component implements OnInit {
// options: this.allOption[questionId] // options: this.allOption[questionId]
// } // }
// }) // })
// const ret = { const ret = {
// pageId: this.curPageData['pageId'], pageId: this.curPageData['pageId'],
// questions: [ questions: [
// { {
// questionId: this.curPageData['questions'][0].questionId, questionId: this.curPageData['questions'][0].questionId,
// options: options_ret options: this.allOptions
// } }
// ] ]
// } }
// this.getAllAnswer.emit(ret) this.getAllAnswer.emit(ret)
}
changeStyle(optionId){
this.selectedNum = optionId
} }
} }
...@@ -4,14 +4,16 @@ ...@@ -4,14 +4,16 @@
<div class="questionTitle"> <div class="questionTitle">
{{ this.curPageData['questions'][0]['questionName'].substring(0, 1) }} {{ this.curPageData['questions'][0]['questionName'].substring(0, 1) }}
<span> <span>
{{ this.curPageData['questions'][0]['questionName'].substring(1, 3) }}</span {{
this.curPageData['questions'][0]['questionName'].substring(1, 3)
}}</span
> >
{{ this.curPageData['questions'][0]['questionName'].substring(3, 8) }} {{ this.curPageData['questions'][0]['questionName'].substring(3, 8) }}
</div> </div>
<ul class="jobContent"> <ul class="jobContent">
<li <li
class="selected"
*ngFor="let options of this.curPageData['questions'][0]['options']" *ngFor="let options of this.curPageData['questions'][0]['options']"
[ngClass]="{ selected: options['selected'] == true }"
(click)="getAnswer(options)" (click)="getAnswer(options)"
> >
{{ options.optionName }} {{ options.optionName }}
......
import { Component, OnInit, Input , Output, EventEmitter} from '@angular/core' import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
@Component({ @Component({
selector: 'app-page12', selector: 'app-page12',
...@@ -8,18 +8,39 @@ import { Component, OnInit, Input , Output, EventEmitter} from '@angular/core' ...@@ -8,18 +8,39 @@ import { Component, OnInit, Input , Output, EventEmitter} from '@angular/core'
export class Page12Component implements OnInit { export class Page12Component implements OnInit {
@Input() curPageData: Array<any> @Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>() @Output() getAllAnswer = new EventEmitter<any>()
allOptions: Array<any>
constructor() {} constructor() {}
ngOnInit() { ngOnInit() {
this.allOptions = []
console.log(this.curPageData) console.log(this.curPageData)
} }
getAnswer(option) { getAnswer(options) {
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
if (options['optionId'] == this.allOptions[i]['optionId']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
}
}
this.allOptions.push(options)
for (let i = 0; i < this.allOptions.length; i++) {
if (!this.allOptions[i]['selected']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
}
}
console.log(this.allOptions)
const ret = { const ret = {
pageId: this.curPageData['pageId'], pageId: this.curPageData['pageId'],
questions: [ questions: [
{ {
questionId: this.curPageData['questions'][0].questionId, questionId: this.curPageData['questions'][0].questionId,
option: [option] options: this.allOptions
} }
] ]
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<li <li
class="selected" class="selected"
*ngFor="let options of this.curPageData['questions'][0]['options']" *ngFor="let options of this.curPageData['questions'][0]['options']"
[ngClass]="{ selected: options['selected'] == true }"
(click)="getAnswer(options)" (click)="getAnswer(options)"
> >
{{ options.optionName }} {{ options.optionName }}
......
import { Component, OnInit, Input, Output, EventEmitter} from '@angular/core' import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
@Component({ @Component({
selector: 'app-page13', selector: 'app-page13',
templateUrl: './page13.component.html', templateUrl: './page13.component.html',
...@@ -7,18 +7,39 @@ import { Component, OnInit, Input, Output, EventEmitter} from '@angular/core' ...@@ -7,18 +7,39 @@ import { Component, OnInit, Input, Output, EventEmitter} from '@angular/core'
export class Page13Component implements OnInit { export class Page13Component implements OnInit {
@Input() curPageData: Array<any> @Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>() @Output() getAllAnswer = new EventEmitter<any>()
allOptions: Array<any>
constructor() {} constructor() {}
ngOnInit() { ngOnInit() {
this.allOptions = []
console.log(this.curPageData) console.log(this.curPageData)
} }
getAnswer(option) { getAnswer(options) {
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
if (options['optionId'] == this.allOptions[i]['optionId']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
}
}
this.allOptions.push(options)
for (let i = 0; i < this.allOptions.length; i++) {
if (!this.allOptions[i]['selected']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
}
}
console.log(this.allOptions)
const ret = { const ret = {
pageId: this.curPageData['pageId'], pageId: this.curPageData['pageId'],
questions: [ questions: [
{ {
questionId: this.curPageData['questions'][0].questionId, questionId: this.curPageData['questions'][0].questionId,
option: [option] options: this.allOptions
} }
] ]
} }
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
<div class="content"> <div class="content">
<div class="questionTitle">{{ this.curPageData['pageName'] }}</div> <div class="questionTitle">{{ this.curPageData['pageName'] }}</div>
<ul class="ageContent"> <ul class="ageContent">
<li *ngFor="let optionsList of this.curPageData['questions'];index as i"> <li *ngFor="let optionsList of this.curPageData['questions']; index as i">
<div>{{ optionsList.questionName }}</div> <div>{{ optionsList.questionName }}</div>
<b (click)="showToast(optionsList)"> <b (click)="showToast(optionsList, i)">
<span>{{optionsList.name}}</span>&gt; <span>{{ optionsList.name }}</span
>&gt;
</b> </b>
</li> </li>
</ul> </ul>
...@@ -18,10 +19,14 @@ ...@@ -18,10 +19,14 @@
<div class="toastContent"> <div class="toastContent">
<ul> <ul>
<li <li
[ngClass]="{'selected':this.selectedNum === options.optionId}" [ngClass]="{ selected: this.selectedNum === options.optionId }"
*ngFor="let options of curQues.options" *ngFor="let options of curQues.options"
(click)="closeToast(); getAnswer(options);changeStyle(options,options.optionId)" (click)="
> closeToast();
getAnswer(options);
changeStyle(options, options.optionId)
"
>
{{ options.optionName }} {{ options.optionName }}
</li> </li>
</ul> </ul>
......
...@@ -13,19 +13,27 @@ export class Page3Component implements OnInit { ...@@ -13,19 +13,27 @@ export class Page3Component implements OnInit {
isShow: boolean isShow: boolean
curQues: Object curQues: Object
curAllQues: Object curAllQues: Object
selectedNum:number; selectedNum: number
options:Array<any>; options: Array<any>
curQuesLen:number; curQuesIndex: number
//当前问题长度
curQuesLen: number
//增加孩子点击次数
addChildCount: number
constructor() {} constructor() {}
ngOnInit() { ngOnInit() {
this.curQues = {} this.curQues = {}
this.curAllQues = {} this.curAllQues = {}
this.curQuesLen = this.curPageData['questions'].length; this.curQuesLen = this.curPageData['questions'].length
//初始化增加孩子按钮可以点2次
this.addChildCount = 2
} }
showToast(question) { showToast(question, idx) {
this.isShow = true this.isShow = true
this.curQues = question this.curQues = question
this.curQuesIndex = idx
} }
closeToast() { closeToast() {
this.isShow = false this.isShow = false
...@@ -42,37 +50,88 @@ export class Page3Component implements OnInit { ...@@ -42,37 +50,88 @@ export class Page3Component implements OnInit {
} }
this.getAllAnswer.emit(ret) this.getAllAnswer.emit(ret)
} }
changeStyle(options,optionId){ changeStyle(options, optionId) {
//当前选中项 //当前选中项
this.curPageData['questions'][this.curQuesIndex]['name'] =
options.optionName
this.selectedNum = optionId this.selectedNum = optionId
for(let i=0;i<this.curPageData['questions'].length;i++){ // for (let i = 0; i < this.curQuesLen; i++) {
for(let j=0;j<this.curPageData['questions'][i]['options'].length;j++){ // for (
if(options.optionId==this.curPageData['questions'][i].options[j].optionId){ // let j = 0;
this.curPageData['questions'].optionName = options.optionName; // j < this.curPageData['questions'][i]['options'].length;
this.curPageData['questions'][i]['name'] = this.curPageData['questions'][i].options[j].optionName // j++
} // ) {
} // if (
} // options.optionId ==
// this.curPageData['questions'][i].options[j].optionId
// ) {
// this.curPageData['questions'][i]['name'] = this.curPageData[
// 'questions'
// ][i].options[j].optionName
// }
// }
// }
} }
addChild(){ addChild() {
this.curQuesLen++; this.addChildCount--
if(this.curQuesLen<5){ if (this.addChildCount >= 0) {
this.curPageData['questions'][this.curQuesLen-1] = { this.curPageData['questions'][this.curQuesLen++] = {
questionId: 4, questionId: 4,
questionName: "孩子"+(this.curQuesLen-1)+"年龄", questionName: `孩子${this.addChildCount == 1 ? '1' : '2'}年龄`,
optionType: 1, optionType: 1,
questionOrder: 4, questionOrder: 4,
options: [ options: [
{optionId: 22, optionName: "95后", optionOrder: 1, customerInput: null}, {
{optionId: 23, optionName: "90后", optionOrder: 2, customerInput: null}, optionId: 22,
{optionId: 24, optionName: "85后", optionOrder: 3, customerInput: null}, optionName: '95后',
{optionId: 25, optionName: "80后", optionOrder: 4, customerInput: null}, optionOrder: 1,
{optionId: 26, optionName: "75后", optionOrder: 5, customerInput: null}, customerInput: null
{optionId: 27, optionName: "70后", optionOrder: 6, customerInput: null}, },
{optionId: 28, optionName: "65后", optionOrder: 7, customerInput: null}, {
{optionId: 29, optionName: "60后", optionOrder: 8, customerInput: null} optionId: 23,
optionName: '90后',
optionOrder: 2,
customerInput: null
},
{
optionId: 24,
optionName: '85后',
optionOrder: 3,
customerInput: null
},
{
optionId: 25,
optionName: '80后',
optionOrder: 4,
customerInput: null
},
{
optionId: 26,
optionName: '75后',
optionOrder: 5,
customerInput: null
},
{
optionId: 27,
optionName: '70后',
optionOrder: 6,
customerInput: null
},
{
optionId: 28,
optionName: '65后',
optionOrder: 7,
customerInput: null
},
{
optionId: 29,
optionName: '60后',
optionOrder: 8,
customerInput: null
}
] ]
} }
} }
......
...@@ -6,10 +6,9 @@ ...@@ -6,10 +6,9 @@
</div> </div>
<ul class="jobContent"> <ul class="jobContent">
<li <li
[ngClass]="{'selected':this.selectedNum === options.optionId}" [ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData['questions'][0]['options']" *ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(this.curPageData['questions'][0], options); (click)="getAnswer(this.curPageData['questions'][0], options)"
changeStyle(options.optionId)"
> >
{{ options.optionName }} {{ options.optionName }}
</li> </li>
...@@ -19,10 +18,9 @@ ...@@ -19,10 +18,9 @@
</div> </div>
<ul class="jobContent" *ngIf="hasMate"> <ul class="jobContent" *ngIf="hasMate">
<li <li
[ngClass]="{'selected':this.selectedTwo === options.optionId}" [ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData['questions'][1]['options']" *ngFor="let options of this.curPageData['questions'][1]['options']"
(click)="getAnswer(this.curPageData['questions'][1], options); (click)="getAnswer(this.curPageData['questions'][1], options)"
changeStyle2(options.optionId)"
> >
{{ options.optionName }} {{ options.optionName }}
</li> </li>
......
...@@ -10,17 +10,27 @@ export class Page9Component implements OnInit { ...@@ -10,17 +10,27 @@ export class Page9Component implements OnInit {
@Input() hasMate: boolean @Input() hasMate: boolean
@Output() getAllAnswer = new EventEmitter<any>() @Output() getAllAnswer = new EventEmitter<any>()
curAllQues: Object curAllQues: Object
selectedNum:number; selectedObj: Object
selectedTwo:number;
constructor() {} constructor() {}
ngOnInit() { ngOnInit() {
this.curAllQues = {} this.curAllQues = {}
console.log(this.curPageData) this.selectedObj = {}
this.setOptionSelected()
} }
getAnswer(question, options) { getAnswer(question, options) {
console.log('page9', question, options)
const questionId = question['questionId'] const questionId = question['questionId']
console.log('select', this.selectedObj, options)
if (!this.selectedObj[questionId]) {
this.selectedObj[questionId] = options
options['selected'] = true
} else {
if (this.selectedObj[questionId].optionId != options.optionId) {
this.selectedObj[questionId]['selected'] = false
options['selected'] = true
this.selectedObj[questionId] = options
}
}
this.curAllQues[questionId] = options this.curAllQues[questionId] = options
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] }
...@@ -31,10 +41,17 @@ export class Page9Component implements OnInit { ...@@ -31,10 +41,17 @@ export class Page9Component implements OnInit {
} }
this.getAllAnswer.emit(ret) this.getAllAnswer.emit(ret)
} }
changeStyle(optionId){ setOptionSelected() {
this.selectedNum = optionId const questions = this.curPageData['questions']
} if (!questions) {
changeStyle2(optionId){ return
this.selectedTwo = optionId }
questions.map(question => {
question['options'].forEach(option => {
if (option['selected']) {
this.selectedObj[question['questionId']] = option
}
})
})
} }
} }
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