Commit f4410e73 by Chao Sun
parents afd125a8 6a733dcd
...@@ -20,6 +20,8 @@ export class ChildrenHealthComponent implements OnInit { ...@@ -20,6 +20,8 @@ export class ChildrenHealthComponent implements OnInit {
questions: Array<any> = []; questions: Array<any> = [];
// 总共有几个孩子 // 总共有几个孩子
childTotalCount: any; childTotalCount: any;
// 暂存多个孩子的答案
childTotalQuestions: Array<any> = [];
constructor(private commonService: CommonService, constructor(private commonService: CommonService,
private router: Router, private router: Router,
...@@ -50,16 +52,26 @@ export class ChildrenHealthComponent implements OnInit { ...@@ -50,16 +52,26 @@ export class ChildrenHealthComponent implements OnInit {
// 选择健康情况(多选) // 选择健康情况(多选)
selectedHealth(option) { selectedHealth(option) {
this.id = this.route.snapshot.params['childId'];
option['selected'] = !option['selected']; option['selected'] = !option['selected'];
this.questions = []; this.questions = [];
this.getOptions(99, option); this.getOptions(99, option);
const questions = {
questionId: this.curPageData['questions']['0']['questionId'],
questionName: '孩子' + this.id + '的健康状态',
childId: this.id,
options: this.questions
};
for (let i = 0; i < this.childTotalQuestions.length; i++) {
if (this.childTotalQuestions[i].childId == questions.childId) {
this.childTotalQuestions.splice(this.childTotalQuestions.indexOf(this.childTotalQuestions[i]), 1);
break;
}
}
this.childTotalQuestions.push(questions);
this.pageAnswers = { this.pageAnswers = {
pageId: this.curPageData['pageId'], pageId: this.curPageData['pageId'],
questions: [{ questions: this.childTotalQuestions,
questionId: this.curPageData['questions']['0']['questionId'],
questionName: this.curPageData['questions']['0']['questionName'],
options: this.questions
}],
}; };
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
} }
......
...@@ -7,19 +7,19 @@ ...@@ -7,19 +7,19 @@
</div> </div>
<ul class="income"> <ul class="income">
<li <li
[ngClass]="{ selected: selectedOptionId == options.optionId }" [ngClass]="{ selected: options['selected'] }"
*ngFor="let options of this.curPageData?.questions[0].options" *ngFor="let options of this.curPageData?.questions[0].options"
(click)="selectedIncome(this.curPageData?.questions[0],options)" (click)="selectedIncome(this.curPageData?.questions[0],options)"
> >
{{ options.optionName }} {{ options.optionName }}
</li> </li>
</ul> </ul>
<div class="questionTitle" *ngIf="hasMate"> <div class="questionTitle" *ngIf="this.type == 2 || this.type == 4">
{{ this.curPageData?.questions[1]['questionName']}} {{ this.curPageData?.questions[1]['questionName']}}
</div> </div>
<ul class="income" *ngIf="hasMate"> <ul class="income" *ngIf="this.type == 2 || this.type == 4">
<li <li
[ngClass]="{ selected: selectedOptionId == options.optionId}" [ngClass]="{ selected: options['selected']}"
*ngFor="let options of this.curPageData?.questions[1]['options']" *ngFor="let options of this.curPageData?.questions[1]['options']"
(click)="selectedIncome(this.curPageData?.questions[1],options)" (click)="selectedIncome(this.curPageData?.questions[1],options)"
> >
......
...@@ -8,13 +8,11 @@ import {ActivatedRoute, Router} from "@angular/router"; ...@@ -8,13 +8,11 @@ import {ActivatedRoute, Router} from "@angular/router";
styleUrls: ['./income.component.css'] styleUrls: ['./income.component.css']
}) })
export class IncomeComponent implements OnInit { export class IncomeComponent implements OnInit {
hasMate: boolean;
curPageData: Array<any>; curPageData: Array<any>;
pageAnswers: any; pageAnswers: any;
// 家庭结构 // 家庭结构
type: any; type: any;
selectedOptionId: any; nextBtn: boolean;
nextBtn:boolean;
constructor(private commonService: CommonService, constructor(private commonService: CommonService,
private router: Router, private router: Router,
...@@ -34,34 +32,43 @@ export class IncomeComponent implements OnInit { ...@@ -34,34 +32,43 @@ export class IncomeComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.surveyInfo() this.surveyInfo();
//判断家庭决定是否显示配偶
if(this.type==2 || this.type == 4){
this.hasMate = true;
}else{
this.hasMate = false;
}
this.nextBtn = false; this.nextBtn = false;
} }
surveyInfo() { surveyInfo() {
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
if (res['success']) { if (res['success']) {
this.curPageData = res['data']['survey'].pages['6'] this.curPageData = res['data']['survey'].pages['6'];
console.log(this.curPageData) // console.log(this.curPageData)
this.pageAnswers.pageId = this.curPageData['pageId']; this.pageAnswers.pageId = this.curPageData['pageId'];
} }
}) })
} }
selectedIncome(question, option) { selectedIncome(question, option) {
this.selectedOptionId = option.optionId; option.selected = !option.selected;
option.selected = true;
const questions = { const questions = {
questionId: question.questionId, questionId: question.questionId,
questionName: question.questionName, questionName: question.questionName,
options: [option] options: []
}; };
// 将选择的状态改为true,其他的改为false;
if (question['options'].length > 0) {
for (let j = 0; j < question['options'].length; j++) {
if (question['options'][j].optionId == option.optionId) {
question['options'][j].selected = true;
} else {
question['options'][j].selected = false;
}
// 拿到所有selected为true的选项
if (question['options'][j]['selected']) {
questions.options.push(question['options'][j]);
}
}
}
// console.log(questions)
// 同一个问题更改答案
for (let i = 0; i < this.pageAnswers.questions.length; i++) { for (let i = 0; i < this.pageAnswers.questions.length; i++) {
if (this.pageAnswers.questions[i].questionId == question.questionId) { if (this.pageAnswers.questions[i].questionId == question.questionId) {
const index = this.pageAnswers.questions.indexOf(this.pageAnswers.questions[i]); const index = this.pageAnswers.questions.indexOf(this.pageAnswers.questions[i]);
...@@ -70,28 +77,27 @@ export class IncomeComponent implements OnInit { ...@@ -70,28 +77,27 @@ export class IncomeComponent implements OnInit {
} }
this.pageAnswers.questions.push(questions); this.pageAnswers.questions.push(questions);
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
console.log(questions) // console.log(this.pageAnswers)
console.log(this.pageAnswers) // 判断页面需要几个问题
//判断页面需要几个问题 if (this.type == 2 || this.type == 4) {
if(this.type==2 || this.type == 4){ if (this.curPageData['questions'].length == this.pageAnswers['questions'].length) {
if(this.curPageData['questions'].length == this.pageAnswers['questions'].length){
this.nextBtn = true; this.nextBtn = true;
}else{ } else {
this.nextBtn = false; this.nextBtn = false;
} }
}else{ } else {
if(this.pageAnswers['questions'].length>0){ if (this.pageAnswers['questions'].length > 0) {
this.nextBtn = true; this.nextBtn = true;
}else{ } else {
this.nextBtn = false; this.nextBtn = false;
} }
} }
} }
next(){ next() {
if(this.nextBtn == true){ if (this.nextBtn == true) {
this.router.navigate(['/loan'],{queryParams:{type:this.type}}) this.router.navigate(['/loan'], {queryParams: {type: this.type}})
}else{ } else {
return; return;
} }
} }
......
...@@ -11,12 +11,13 @@ export class JobComponent implements OnInit { ...@@ -11,12 +11,13 @@ export class JobComponent implements OnInit {
pageAnswers: any; pageAnswers: any;
selectedOptionId: any; selectedOptionId: any;
type: any; type: any;
id:any; id: any;
nextBtn:boolean; nextBtn: boolean;
constructor(private commonService: CommonService,
private router: Router, constructor(private commonService: CommonService,
private route: ActivatedRoute) { private router: Router,
/** private route: ActivatedRoute) {
/**
* 1:单身贵族 * 1:单身贵族
* 2:二人世界 * 2:二人世界
* 3:独立带娃 * 3:独立带娃
...@@ -49,7 +50,7 @@ export class JobComponent implements OnInit { ...@@ -49,7 +50,7 @@ export class JobComponent implements OnInit {
this.curPageData = res['data'].survey.pages['3']; this.curPageData = res['data'].survey.pages['3'];
} else { } else {
this.curPageData = res['data'].survey.pages['4']; this.curPageData = res['data'].survey.pages['4'];
} }
console.log(this.curPageData) console.log(this.curPageData)
} }
...@@ -71,32 +72,32 @@ export class JobComponent implements OnInit { ...@@ -71,32 +72,32 @@ export class JobComponent implements OnInit {
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
console.log(this.pageAnswers) console.log(this.pageAnswers)
console.log(this.commonService.todos) 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 {
this.nextBtn = false; this.nextBtn = false;
} }
} }
// 下一步 // 下一步
next() { next() {
//先判断下一步能不能点 // 先判断下一步能不能点
//如果是二人世界或是多口之家跳转到配偶页 // 如果是二人世界或是多口之家跳转到配偶页
//先判断当前页是您的页还是配偶页 // 先判断当前页是您的页还是配偶页
if(this.nextBtn ==true){ if (this.nextBtn == true) {
if(this.id == 1){ if (this.id == 1) {
if(this.type ==2 || this.type==4){ if (this.type == 2 || this.type == 4) {
this.router.navigate(['/spouse_job'],{queryParams:{type:this.type}}) this.router.navigate(['/spouse_job'], {queryParams: {type: this.type}})
}else{ } else {
this.router.navigate(['/transit1'],{queryParams:{type:this.type}}) this.router.navigate(['/transit1'], {queryParams: {type: this.type}})
} }
}else{ } else {
this.router.navigate(['/transit1'],{queryParams:{type:this.type}}) this.router.navigate(['/transit1'], {queryParams: {type: this.type}})
} }
}else{ } else {
return; return;
} }
} }
} }
...@@ -8,17 +8,16 @@ import {ActivatedRoute, Router} from "@angular/router"; ...@@ -8,17 +8,16 @@ import {ActivatedRoute, Router} from "@angular/router";
styleUrls: ['./loan.component.css'] styleUrls: ['./loan.component.css']
}) })
export class LoanComponent implements OnInit { export class LoanComponent implements OnInit {
curPageData:Array<any>; curPageData: Array<any>;
//家庭结构 // 家庭结构
type:any; type: any;
pageAnswers: any; pageAnswers: any;
selectedOptionId: any; nextBtn: boolean;
nextBtn:boolean;
constructor(private commonService: CommonService, constructor(private commonService: CommonService,
private router: Router, private router: Router,
private route: ActivatedRoute private route: ActivatedRoute) {
) { /**
/**
* 1:单身贵族 * 1:单身贵族
* 2:二人世界 * 2:二人世界
* 3:独立带娃 * 3:独立带娃
...@@ -47,15 +46,26 @@ export class LoanComponent implements OnInit { ...@@ -47,15 +46,26 @@ export class LoanComponent implements OnInit {
}) })
} }
selectedLoan(question,option){ selectedLoan(question, option) {
this.selectedOptionId = option.optionId; option.selected = !option.selected;
option.selected = true;
const questions = { const questions = {
questionId: question.questionId, questionId: question.questionId,
questionName: question.questionName, questionName: question.questionName,
options: [option] options: []
}; };
if (question['options'].length > 0) {
for (let j = 0; j < question['options'].length; j++) {
if (question['options'][j].optionId == option.optionId) {
question['options'][j].selected = true;
} else {
question['options'][j].selected = false;
}
// 拿到所有selected为true的选项
if (question['options'][j]['selected']) {
questions.options.push(question['options'][j]);
}
}
}
for (let i = 0; i < this.pageAnswers.questions.length; i++) { for (let i = 0; i < this.pageAnswers.questions.length; i++) {
if (this.pageAnswers.questions[i].questionId == question.questionId) { if (this.pageAnswers.questions[i].questionId == question.questionId) {
const index = this.pageAnswers.questions.indexOf(this.pageAnswers.questions[i]); const index = this.pageAnswers.questions.indexOf(this.pageAnswers.questions[i]);
...@@ -64,20 +74,19 @@ export class LoanComponent implements OnInit { ...@@ -64,20 +74,19 @@ export class LoanComponent implements OnInit {
} }
this.pageAnswers.questions.push(questions); this.pageAnswers.questions.push(questions);
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
console.log(questions) // console.log(this.pageAnswers)
console.log(this.pageAnswers) if (this.curPageData['questions'].length == this.pageAnswers['questions'].length) {
if(this.curPageData['questions'].length == this.pageAnswers['questions'].length){
this.nextBtn = true; this.nextBtn = true;
}else{ } else {
this.nextBtn = false; this.nextBtn = false;
} }
} }
next(){ next() {
if(this.nextBtn == true){ if (this.nextBtn == true) {
this.router.navigate(['/social'],{queryParams:{type:this.type}}) this.router.navigate(['/social'], {queryParams: {type: this.type}})
}else{ } else {
return return;
} }
} }
} }
import { Component, OnInit } from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {CommonService} from '../common.service'; import {CommonService} from '../common.service';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
...@@ -8,17 +8,17 @@ import {ActivatedRoute, Router} from "@angular/router"; ...@@ -8,17 +8,17 @@ import {ActivatedRoute, Router} from "@angular/router";
styleUrls: ['./social-security.component.css'] styleUrls: ['./social-security.component.css']
}) })
export class SocialSecurityComponent implements OnInit { export class SocialSecurityComponent implements OnInit {
curPageData:Array<any>; curPageData: Array<any>;
hasMate:boolean; hasMate: boolean;
//家庭结构 // 家庭结构
type:any; type: any;
nextBtn:boolean; nextBtn: boolean;
pageAnswers: any; pageAnswers: any;
selectedOptionId: any;
constructor(private commonService: CommonService, constructor(private commonService: CommonService,
private router: Router, private router: Router,
private route: ActivatedRoute) { private route: ActivatedRoute) {
/** /**
* 1:单身贵族 * 1:单身贵族
* 2:二人世界 * 2:二人世界
* 3:独立带娃 * 3:独立带娃
...@@ -34,31 +34,46 @@ export class SocialSecurityComponent implements OnInit { ...@@ -34,31 +34,46 @@ export class SocialSecurityComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.surveyInfo() this.surveyInfo()
//判断家庭决定是否显示配偶 // 判断家庭决定是否显示配偶
if(this.type==2 || this.type == 4){ if (this.type == 2 || this.type == 4) {
this.hasMate = true; this.hasMate = true;
}else{ } else {
this.hasMate = false; this.hasMate = false;
} }
this.nextBtn = false; this.nextBtn = false;
} }
surveyInfo() { surveyInfo() {
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
if (res['success']) { if (res['success']) {
this.curPageData = res['data']['survey'].pages['8'] this.curPageData = res['data']['survey'].pages['8'];
this.pageAnswers.pageId = this.curPageData['pageId'];
console.log(this.curPageData) console.log(this.curPageData)
} }
}) })
} }
selectedSocial(question,option){ selectedSocial(question, option) {
this.selectedOptionId = option.optionId; option.selected = !option.selected;
option.selected = true;
const questions = { const questions = {
questionId: question.questionId, questionId: question.questionId,
questionName: question.questionName, questionName: question.questionName,
options: [option] options: []
}; };
console.log(questions)
if (question['options'].length > 0) {
for (let j = 0; j < question['options'].length; j++) {
if (question['options'][j].optionId == option.optionId) {
question['options'][j].selected = true;
} else {
question['options'][j].selected = false;
}
// 拿到所有selected为true的选项
if (question['options'][j]['selected']) {
questions.options.push(question['options'][j]);
}
}
}
for (let i = 0; i < this.pageAnswers.questions.length; i++) { for (let i = 0; i < this.pageAnswers.questions.length; i++) {
if (this.pageAnswers.questions[i].questionId == question.questionId) { if (this.pageAnswers.questions[i].questionId == question.questionId) {
const index = this.pageAnswers.questions.indexOf(this.pageAnswers.questions[i]); const index = this.pageAnswers.questions.indexOf(this.pageAnswers.questions[i]);
...@@ -66,27 +81,28 @@ export class SocialSecurityComponent implements OnInit { ...@@ -66,27 +81,28 @@ export class SocialSecurityComponent implements OnInit {
} }
} }
this.pageAnswers.questions.push(questions); this.pageAnswers.questions.push(questions);
// console.log(this.pageAnswers)
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
//判断页面需要几个问题 // 判断页面需要几个问题
if(this.type==2 || this.type == 4){ if (this.type == 2 || this.type == 4) {
if(this.curPageData['questions'].length == this.pageAnswers['questions'].length){ if (this.curPageData['questions'].length == this.pageAnswers['questions'].length) {
this.nextBtn = true; this.nextBtn = true;
}else{ } else {
this.nextBtn = false; this.nextBtn = false;
} }
}else{ } else {
if(this.pageAnswers['questions'].length>0){ if (this.pageAnswers['questions'].length > 0) {
this.nextBtn = true; this.nextBtn = true;
}else{ } else {
this.nextBtn = false; this.nextBtn = false;
} }
} }
} }
next(){ next() {
if(this.nextBtn == true){ if (this.nextBtn == true) {
this.router.navigate(['/transit2'],{queryParams:{type:this.type}}) this.router.navigate(['/transit2'], {queryParams: {type: this.type}})
}else{ } else {
return; return;
} }
} }
......
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