Commit 3fba7ea1 by Chao Sun

checked

parent 2a793f2b
......@@ -48,9 +48,21 @@
*ngIf="curPage == 10"
(getAllAnswer)="getAllAnswer($event)"
></app-page11>
<app-page12 [curPageData]="curPageData" *ngIf="curPage == 11"></app-page12>
<app-page13 [curPageData]="curPageData" *ngIf="curPage == 12"></app-page13>
<app-page14 [curPageData]="curPageData" *ngIf="curPage == 13"></app-page14>
<app-page12
[curPageData]="curPageData"
*ngIf="curPage == 11"
(getAllAnswer)="getAllAnswer($event)"
></app-page12>
<app-page13
[curPageData]="curPageData"
*ngIf="curPage == 12"
(getAllAnswer)="getAllAnswer($event)"
></app-page13>
<app-page14
[curPageData]="curPageData"
*ngIf="curPage == 13"
(getAllAnswer)="getAllAnswer($event)"
></app-page14>
<app-page15 [curPageData]="curPageData" *ngIf="curPage == 14"></app-page15>
<app-page16 [curPageData]="curPageData" *ngIf="curPage == 15"></app-page16>
<app-page17 [curPageData]="curPageData" *ngIf="curPage == 16"></app-page17>
......
......@@ -67,23 +67,40 @@ export class AskComponent implements OnInit {
setCurPageData() {
const thePateData = this.allQues[this.curPage]
console.log('thePateData------', this.curPage, thePateData)
this.curPageData = thePateData
this.curPageData = thePateData
const page2Answer = this.allAnswers[1]
if (this.curPage == 2) {
const page2Answer = this.allAnswers[1]
this.filterPage2(
page2Answer.questions[0].options[0].optionId,
thePateData
)
}
if (this.curPage == 4) {
const page2Answerswer = this.allAnswers[1]
console.log(page2Answerswer)
this.filterPage5(
page2Answerswer.questions[0].options[0].optionId,
page2Answer.questions[0].options[0].optionId,
thePateData
)
}
if(this.curPage == 11){
this.filterPage12(
page2Answer.questions[0].options[0].optionId,
thePateData
)
}
if(this.curPage == 12){
this.filterPage13(
page2Answer.questions[0].options[0].optionId,
thePateData
)
}
if(this.curPage ==14){
this.filterPage15(
page2Answer.questions[0].options[0].optionId,
thePateData
)
}
}
filterPage2(optionId, thePateData) {
//判断第二页选择家庭1单身2二人3独立带娃4多口
if (optionId == 1 || optionId == 2) {
......@@ -91,6 +108,7 @@ export class AskComponent implements OnInit {
} else {
this.isShowChildAgeBtn = true
}
//判断页面是否有配偶选项
if (optionId == 1 || optionId == 3) {
this.hasMate = false
} else {
......@@ -128,13 +146,52 @@ export class AskComponent implements OnInit {
}
filterPage5(optionId, thePateData) {
//判断是否显示配偶工作页
//page5判断是否显示配偶工作页
//1单身 3单亲
if (optionId == 1 || optionId == 3) {
this.curPage++
console.log('page5', this.curPage, this.curPageData)
this.curPageData = this.allQues[this.curPage]
}
}
//pege12判断是否显示配偶健康
filterPage12(optionId, thePateData){
if (optionId == 1 || optionId == 3) {
this.curPage++
console.log('page12', this.curPage, this.curPageData)
this.curPageData = this.allQues[this.curPage]
}
}
//page13判断是否显示孩子健康
filterPage13(optionId, thePateData){
//单身或二人世界
if (optionId == 1 || optionId ==2) {
this.curPage++
console.log('page13', this.curPage, this.curPageData)
this.curPageData = this.allQues[this.curPage]
}
}
//page15判断option内容
filterPage15(optionId,thePateData){
//如果单身或者单亲选择相中没有配偶选项
if(optionId == 1 || optionId == 3){
this.curPageData = {
...thePateData,
questions:thePateData.questions[0]['options'].filter(option=>{
return option.optionId == 108 || option.optionId==109
})
}
}
if(optionId==2 || optionId==4){
this.curPageData = {
...thePateData,
questions:thePateData.questions[0]['options'].filter(option=>{
return option.optionId == 110 || option.optionId == 111 || option.optionId == 112
})
}
}
}
}
......@@ -2,14 +2,13 @@
<div class="layout">
<div class="content">
<div class="questionTitle">
{{ this.curPageData.questions[0].questionName }}
{{ this.curPageData['questions'][0]['questionName'] }}
</div>
<ul class="jobContent">
<li
class="selected"
*ngFor="let options of this.curPageData.questions[0].options"
(click)="getAnswer(options)"
>
*ngFor="let options of this.curPageData['questions'][0]['options']"
[ngClass]="{'selected':options['selected']==true}"
(click)="getAnswer(options);changeStyle(options.optionId)">
{{ options.optionName }}
</li>
</ul>
......
......@@ -9,39 +9,67 @@ export class Page11Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
allOption: object
selectedNum:number;
allOptions:Array<any>;
constructor() {}
ngOnInit() {
this.allOption = {}
this.allOption = {};
this.allOptions = [];
console.log(this.curPageData)
}
getAnswer(options) {
console.log(options)
if (!this.allOption[options['optionId']]) {
this.allOption[options['optionId']] = {}
}
this.allOption[options['optionId']] = {
selected: !this.allOption[options['optionId']]['selected'],
options
}
const options_ret = Object.keys(this.allOption)
.filter(item => {
return this.allOption[item]['selected']
})
.map(questionId => {
return {
options: this.allOption[questionId]
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)
}
})
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
questionId: this.curPageData['questions'][0].questionId,
options: options_ret
}
}
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)
}
]
}
}
this.getAllAnswer.emit(ret)
console.log(this.allOptions)
// if (!this.allOption[options['optionId']]) {
// this.allOption[options['optionId']] = {}
// }
// console.log(this.allOption)
// this.allOption[options['optionId']] = {
// selected: !this.allOption[options['optionId']]['selected'],
// options
// }
// const options_ret = Object.keys(this.allOption)
// .filter(item => {
// return this.allOption[item]['selected']
// })
// .map(questionId => {
// return {
// options: this.allOption[questionId]
// }
// })
// const ret = {
// pageId: this.curPageData['pageId'],
// questions: [
// {
// questionId: this.curPageData['questions'][0].questionId,
// options: options_ret
// }
// ]
// }
// this.getAllAnswer.emit(ret)
}
changeStyle(optionId){
this.selectedNum = optionId
}
}
......@@ -2,16 +2,17 @@
<div class="layout">
<div class="content">
<div class="questionTitle">
{{ this.curPageData.questions[0].questionName.substring(0, 1) }}
{{ this.curPageData['questions'][0]['questionName'].substring(0, 1) }}
<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>
<ul class="jobContent">
<li
class="selected"
*ngFor="let options of this.curPageData.questions[0].options"
*ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(options)"
>
{{ options.optionName }}
</li>
......
import { Component, OnInit, Input } from '@angular/core'
import { Component, OnInit, Input , Output, EventEmitter} from '@angular/core'
@Component({
selector: 'app-page12',
......@@ -7,9 +7,22 @@ import { Component, OnInit, Input } from '@angular/core'
})
export class Page12Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
constructor() {}
ngOnInit() {
console.log(this.curPageData)
}
getAnswer(option) {
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
questionId: this.curPageData['questions'][0].questionId,
option: [option]
}
]
}
this.getAllAnswer.emit(ret)
}
}
......@@ -2,12 +2,13 @@
<div class="layout">
<div class="content">
<div class="questionTitle">
{{ this.curPageData.questions[0].questionName }}
{{ this.curPageData['questions'][0]['questionName'] }}
</div>
<ul class="jobContent">
<li
class="selected"
*ngFor="let options of this.curPageData.questions[0].options"
*ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(options)"
>
{{ options.optionName }}
</li>
......
import { Component, OnInit, Input } from '@angular/core'
import { Component, OnInit, Input, Output, EventEmitter} from '@angular/core'
@Component({
selector: 'app-page13',
templateUrl: './page13.component.html',
......@@ -6,10 +6,22 @@ import { Component, OnInit, Input } from '@angular/core'
})
export class Page13Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
constructor() {}
ngOnInit() {
console.log(this.curPageData)
}
getAnswer(option) {
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
questionId: this.curPageData['questions'][0].questionId,
option: [option]
}
]
}
this.getAllAnswer.emit(ret)
}
}
......@@ -2,12 +2,13 @@
<div class="layout">
<div class="content">
<div class="questionTitle hospitalTitle">
{{ this.curPageData.questions[0].questionName }}
{{ this.curPageData['pageName'] }}
</div>
<ul class="jobContent">
<li
class="selected"
*ngFor="let options of this.curPageData.questions[0].options"
*ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(options)"
>
{{ options.optionName }}
</li>
......
import { Component, OnInit ,Input} from '@angular/core';
import { Component, OnInit ,Input, Output, EventEmitter} from '@angular/core';
@Component({
selector: 'app-page14',
......@@ -7,10 +7,23 @@ import { Component, OnInit ,Input} from '@angular/core';
})
export class Page14Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
constructor() { }
ngOnInit() {
console.log(this.curPageData)
}
getAnswer(option) {
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
questionId: this.curPageData['questions'][0].questionId,
option: [option]
}
]
}
this.getAllAnswer.emit(ret)
}
}
......@@ -2,12 +2,13 @@
<div class="layout">
<div class="content">
<div class="questionTitle smokeTitle">
{{ this.curPageData.questions[0].questionName }}
{{ this.curPageData['questions'][0]['questionName'] }}
</div>
<ul class="jobContent">
<li
class="selected"
*ngFor="let options of this.curPageData.questions[0].options"
*ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(options)"
>
{{ options.optionName }}
</li>
......
import { Component, OnInit,Input } from '@angular/core';
import { Component, OnInit,Input, Output, EventEmitter} from '@angular/core';
@Component({
selector: 'app-page15',
......@@ -7,10 +7,25 @@ import { Component, OnInit,Input } from '@angular/core';
})
export class Page15Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
curQues: Object
curAllQues: Object
constructor() { }
ngOnInit() {
console.log(this.curPageData)
}
getAnswer(option){
const questionId = this.curQues['questionId']
this.curAllQues[questionId] = option
const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId, options: this.curAllQues[questionId] }
})
const ret = {
pageId: 15,
questions
}
this.getAllAnswer.emit(ret)
}
}
......@@ -2,7 +2,7 @@
<div class="layout ">
<div class="content">
<div class="questionTitle">
{{ this.curPageData.questions[0].questionName }}
{{ this.curPageData['questions'][0]['questionName'] }}
</div>
<ul class="cityContent">
<li *ngFor="let provinces of this.provinceList" (click)="showToast()">
......
......@@ -3,11 +3,12 @@
<div class="questionTitle">{{ this.curPageData['pageName'] }}</div>
<ul class="option_item">
<li
*ngFor="let options of this.curPageData.questions[0].options"
*ngFor="let options of this.curPageData['questions'][0].options"
(click)="getAnswer(options)"
>
<img
class="selected"
[ngClass]="{'selected':this.selectedNum === options.optionId}"
(click)="changeStyle(options.optionId)"
src="assets/images/icon{{ options.optionId }}.png"
alt="{{ options.optionName }}"
/>
......
......@@ -8,6 +8,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
export class Page2Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
selectedNum:number;
constructor() {}
ngOnInit() {
......@@ -25,4 +26,9 @@ export class Page2Component implements OnInit {
}
this.getAllAnswer.emit(ret)
}
changeStyle(optionId){
//当前选中项
this.selectedNum = optionId
}
}
......@@ -2,13 +2,15 @@
<div class="content">
<div class="questionTitle">{{ this.curPageData['pageName'] }}</div>
<ul class="ageContent">
<li *ngFor="let optionsList of this.curPageData.questions">
<li *ngFor="let optionsList of this.curPageData['questions'];index as i">
<div>{{ optionsList.questionName }}</div>
<b (click)="showToast(optionsList)">&gt;</b>
<b (click)="showToast(optionsList)">
<span>{{optionsList.name}}</span>&gt;
</b>
</li>
</ul>
</div>
<div class="addChild" *ngIf="isShowChildAgeBtn">
<div class="addChild" *ngIf="isShowChildAgeBtn" (click)="addChild()">
<div class="icon">+</div>
<div data-toggle="modal">增加孩子年龄</div>
</div>
......@@ -16,10 +18,10 @@
<div class="toastContent">
<ul>
<li
class="selected"
[ngClass]="{'selected':this.selectedNum === options.optionId}"
*ngFor="let options of curQues.options"
(click)="closeToast(); getAnswer(options)"
>
(click)="closeToast(); getAnswer(options);changeStyle(options,options.optionId)"
>
{{ options.optionName }}
</li>
</ul>
......
......@@ -13,18 +13,19 @@ export class Page3Component implements OnInit {
isShow: boolean
curQues: Object
curAllQues: Object
selectedNum:number;
options:Array<any>;
curQuesLen:number;
constructor() {}
ngOnInit() {
this.curQues = {}
this.curAllQues = {}
console.log(this.curPageData)
this.curQuesLen = this.curPageData['questions'].length;
}
showToast(question) {
this.isShow = true
this.curQues = question
console.log(this.curQues)
}
closeToast() {
this.isShow = false
......@@ -41,4 +42,40 @@ export class Page3Component implements OnInit {
}
this.getAllAnswer.emit(ret)
}
changeStyle(options,optionId){
//当前选中项
this.selectedNum = optionId
for(let i=0;i<this.curPageData['questions'].length;i++){
for(let j=0;j<this.curPageData['questions'][i]['options'].length;j++){
if(options.optionId==this.curPageData['questions'][i].options[j].optionId){
this.curPageData['questions'].optionName = options.optionName;
this.curPageData['questions'][i]['name'] = this.curPageData['questions'][i].options[j].optionName
}
}
}
}
addChild(){
this.curQuesLen++;
if(this.curQuesLen<5){
this.curPageData['questions'][this.curQuesLen-1] = {
questionId: 4,
questionName: "孩子"+(this.curQuesLen-1)+"年龄",
optionType: 1,
questionOrder: 4,
options: [
{optionId: 22, optionName: "95后", optionOrder: 1, 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}
]
}
}
console.log(this.curPageData['questions'])
}
}
......@@ -4,9 +4,9 @@
<div class="questionTitle">{{ this.curPageData['pageName'] }}</div>
<ul class="jobContent">
<li
class="selected"
*ngFor="let options of this.curPageData.questions[0].options"
(click)="getAnswer(options)"
[ngClass]="{'selected':this.selectedNum === options.optionId}"
*ngFor="let options of this.curPageData['questions'][0].options"
(click)="getAnswer(options);changeStyle(options.optionId)"
>
{{ options.optionName }}
</li>
......
......@@ -8,6 +8,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
export class Page4Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
selectedNum:number;
constructor() {}
ngOnInit() {
......@@ -25,4 +26,8 @@ export class Page4Component implements OnInit {
}
this.getAllAnswer.emit(ret)
}
changeStyle(optionId){
//当前选中项
this.selectedNum = optionId
}
}
......@@ -8,9 +8,9 @@
</div>
<ul class="jobContent">
<li
class="selected"
*ngFor="let options of this.curPageData.questions[0].options"
(click)="getAnswer(options)"
[ngClass]="{'selected':this.selectedNum === options.optionId}"
*ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(options);changeStyle(options.optionId)"
>
{{ options.optionName }}
</li>
......
......@@ -8,6 +8,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
export class Page5Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
selectedNum:number;
constructor() {}
ngOnInit() {
......@@ -25,4 +26,8 @@ export class Page5Component implements OnInit {
}
this.getAllAnswer.emit(ret)
}
changeStyle(optionId){
//当前选中项
this.selectedNum = optionId
}
}
......@@ -2,25 +2,27 @@
<div class="layout">
<div class="content">
<div class="questionTitle">
{{ this.curPageData.questions[0].questionName }}
{{ this.curPageData['questions'][0]['questionName'] }}
</div>
<ul class="income">
<li
class="selected"
*ngFor="let options of this.curPageData.questions[0].options"
(click)="getAnswer(this.curPageData.questions[0], options)"
[ngClass]="{'selected':this.selectedNum === options.optionId}"
*ngFor="let options of this.curPageData['questions'][0].options"
(click)="getAnswer(this.curPageData['questions'][0], options);
changeStyle(options.optionId)"
>
{{ options.optionName }}
</li>
</ul>
<div class="questionTitle" *ngIf="hasMate">
{{ this.curPageData.questions[1].questionName }}
{{ this.curPageData['questions'][1]['questionName']}}
</div>
<ul class="income" *ngIf="hasMate">
<li
class="selected"
*ngFor="let options of this.curPageData.questions[1].options"
(click)="getAnswer(this.curPageData.questions[1], options)"
[ngClass]="{'selected':this.selectedTwo === options.optionId}"
*ngFor="let options of this.curPageData['questions'][1]['options']"
(click)="getAnswer(this.curPageData['questions'][1], options);
changeStyle2(options.optionId)"
>
{{ options.optionName }}
</li>
......
......@@ -10,6 +10,9 @@ export class Page7Component implements OnInit {
@Input() hasMate: boolean
@Output() getAllAnswer = new EventEmitter<any>()
curAllQues: Object
selectedNum:number;
//第二个问题的选择
selectedTwo:number;
constructor() {}
ngOnInit() {
......@@ -30,4 +33,10 @@ export class Page7Component implements OnInit {
}
this.getAllAnswer.emit(ret)
}
changeStyle(optionId){
this.selectedNum = optionId
}
changeStyle2(optionId){
this.selectedTwo = optionId
}
}
......@@ -2,25 +2,27 @@
<div class="layout">
<div class="content">
<div class="questionTitle">
{{ this.curPageData.questions[0].questionName }}
{{ this.curPageData['questions'][0]['questionName'] }}
</div>
<ul class="income">
<li
class="selected"
*ngFor="let options of this.curPageData.questions[0].options"
(click)="getAnswer(this.curPageData.questions[0], options)"
[ngClass]="{'selected':this.selectedNum === options.optionId}"
*ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(this.curPageData['questions'][0], options);
changeStyle(options.optionId)"
>
{{ options.optionName }}
</li>
</ul>
<div class="questionTitle">
{{ this.curPageData.questions[1].questionName }}
{{ this.curPageData['questions'][1]['questionName'] }}
</div>
<ul class="income">
<li
class="selected"
*ngFor="let options of this.curPageData.questions[1].options"
(click)="getAnswer(this.curPageData.questions[1], options)"
<li
[ngClass]="{'selected':this.selectedTwo === options.optionId}"
*ngFor="let options of this.curPageData['questions'][1]['options']"
(click)="getAnswer(this.curPageData['questions'][1], options);
changeStyle2(options.optionId)"
>
{{ options.optionName }}
</li>
......
......@@ -9,6 +9,8 @@ export class Page8Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
curAllQues: Object
selectedNum:number;
selectedTwo:number;
constructor() {}
ngOnInit() {
......@@ -28,4 +30,11 @@ export class Page8Component implements OnInit {
}
this.getAllAnswer.emit(ret)
}
changeStyle(optionId){
this.selectedNum = optionId
}
changeStyle2(optionId){
this.selectedTwo = optionId
}
}
......@@ -2,25 +2,27 @@
<div class="layout">
<div class="content">
<div class="questionTitle">
{{ this.curPageData.questions[0].questionName }}
{{ this.curPageData['questions'][0]['questionName'] }}
</div>
<ul class="jobContent">
<li
class="selected"
*ngFor="let options of this.curPageData.questions[0].options"
(click)="getAnswer(this.curPageData.questions[0], options)"
[ngClass]="{'selected':this.selectedNum === options.optionId}"
*ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(this.curPageData['questions'][0], options);
changeStyle(options.optionId)"
>
{{ options.optionName }}
</li>
</ul>
<div class="questionTitle" *ngIf="hasMate">
{{ this.curPageData.questions[1].questionName }}
{{ this.curPageData['questions'][1]['questionName'] }}
</div>
<ul class="jobContent" *ngIf="hasMate">
<li
class="selected"
*ngFor="let options of this.curPageData.questions[1].options"
(click)="getAnswer(this.curPageData.questions[1], options)"
[ngClass]="{'selected':this.selectedTwo === options.optionId}"
*ngFor="let options of this.curPageData['questions'][1]['options']"
(click)="getAnswer(this.curPageData['questions'][1], options);
changeStyle2(options.optionId)"
>
{{ options.optionName }}
</li>
......
......@@ -10,6 +10,8 @@ export class Page9Component implements OnInit {
@Input() hasMate: boolean
@Output() getAllAnswer = new EventEmitter<any>()
curAllQues: Object
selectedNum:number;
selectedTwo:number;
constructor() {}
ngOnInit() {
......@@ -29,4 +31,10 @@ export class Page9Component implements OnInit {
}
this.getAllAnswer.emit(ret)
}
changeStyle(optionId){
this.selectedNum = optionId
}
changeStyle2(optionId){
this.selectedTwo = optionId
}
}
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