Commit 20edb27f by Chao Sun

疾病

parent ffb5a675
......@@ -6,8 +6,9 @@
</div>
<ul class="jobContent">
<li
*ngFor="let options of this.curPageData?.questions[0]['options']"
[ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.options"
[ngClass]="{ selected: selectedOptionId == options.optionId }"
(click)="getAnswer(options)"
>
{{ options.optionName }}
</li>
......@@ -15,7 +16,8 @@
</div>
<div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"> 下一步 </div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"
(click)="next()"> 下一步 </div>
</div>
</div>
</div>
import { Component, OnInit } from '@angular/core';
import {CommonService} from '../common.service';
import {ActivatedRoute, Router} from "@angular/router";
@Component({
selector: 'app-disease',
......@@ -8,19 +9,94 @@ import {CommonService} from '../common.service';
})
export class DiseaseComponent implements OnInit {
curPageData:Array<any>;
type:any;
pageAnswers:any;
nextBtn:boolean;
options:Array<any>;
selectedOptionId:any;
constructor(
private commonService: CommonService
) { }
private commonService: CommonService,
private router: Router,
private route: ActivatedRoute
) {
this.type = this.route.snapshot.queryParams['type'];
this.pageAnswers = {
pageId: '',
questions: [{
questionId: '',
questionName: '',
options: [{optionId: '', optionName: '', optionOrder: '', selected: ''}]
}],
};
}
ngOnInit() {
this.nextBtn = false;
this.surveyInfo()
}
surveyInfo() {
this.commonService.surveyInfo().then(res => {
if (res['success']) {
this.curPageData = res['data']['survey'].pages['13']
console.log(this.curPageData)
/**
* 1:单身贵族
* 2:二人世界
* 3:独立带娃
* 4:多口之家
* @type {any}
*/
//过滤选项
if(this.type == 1){
this.options = this.curPageData['questions']['0']['options']
this.options = this.options.filter(option=>{
return option.optionId == 106 || option.optionId == 107
})
}
if(this.type == 2){
this.options = this.curPageData['questions']['0']['options']
this.options = this.options.filter(option=>{
return option.optionId == 108 || option.optionId == 109 || option.optionId == 111
})
}
if(this.type == 3){
this.options = this.curPageData['questions']['0']['options']
this.options = this.options.filter(option=>{
return option.optionId == 108 || option.optionId == 110 || option.optionId == 111
})
}
if(this.type == 4){
this.options = this.curPageData['questions']['0']['options']
this.options = this.options.filter(option=>{
return option.optionId == 108 || option.optionId == 109 || option.optionId == 110 || option.optionId == 111
})
}
}
})
}
getAnswer(option){
// console.log(options)
this.selectedOptionId = option.optionId;
this.pageAnswers = {
pageId : this.curPageData['pageId'],
questions:[{
questionId: this.curPageData['questions']['0']['questionId'],
questionName: this.curPageData['questions']['0']['questionName'],
options:[option]
}]
}
this.commonService.addAnswer(this.pageAnswers)
console.log(this.pageAnswers)
if(this.pageAnswers['questions'].length>0){
this.nextBtn = true
}else{
this.nextBtn = false
}
}
next(){
if(this.nextBtn == true){
this.router.navigate(['/smoke'],{queryParams:{type:this.type}})
}
}
}
......@@ -14,6 +14,7 @@ export class IncomeComponent implements OnInit {
// 家庭结构
type: any;
selectedOptionId: any;
nextBtn:boolean;
constructor(
private commonService: CommonService,
private router: Router,
......@@ -35,13 +36,13 @@ export class IncomeComponent implements OnInit {
ngOnInit() {
this.surveyInfo()
this.hasMate = true;
//判断家庭决定是否显示配偶
if(this.type==2 || this.type == 4){
this.hasMate = true;
}else{
this.hasMate = false;
}
this.nextBtn = false;
}
surveyInfo() {
this.commonService.surveyInfo().then(res => {
......@@ -49,7 +50,6 @@ export class IncomeComponent implements OnInit {
this.curPageData = res['data']['survey'].pages['6']
console.log(this.curPageData)
this.pageAnswers.pageId = this.curPageData['pageId'];
}
})
}
......@@ -57,7 +57,6 @@ export class IncomeComponent implements OnInit {
selectedIncome(question,option){
this.selectedOptionId = option.optionId;
option.selected = true;
const questions = {
questionId: question.questionId,
questionName: question.questionName,
......@@ -71,9 +70,29 @@ export class IncomeComponent implements OnInit {
}
this.pageAnswers.questions.push(questions);
this.commonService.addAnswer(this.pageAnswers);
console.log(question)
console.log(option)
console.log(questions)
console.log(this.pageAnswers)
//判断页面需要几个问题
if(this.type==2 || this.type == 4){
if(this.curPageData['questions'].length == this.pageAnswers['questions'].length){
this.nextBtn = true;
}else{
this.nextBtn = false;
}
}else{
if(this.pageAnswers['questions'].length>0){
this.nextBtn = true;
}else{
this.nextBtn = false;
}
}
}
next(){
if(this.nextBtn == true){
this.router.navigate(['/loan'],{queryParams:{type:this.type}})
}else{
return;
}
}
}
......@@ -12,6 +12,7 @@ export class JobComponent implements OnInit {
selectedOptionId: any;
type: any;
id:any;
nextBtn:boolean;
constructor(private commonService: CommonService,
private router: Router,
private route: ActivatedRoute) {
......@@ -41,12 +42,14 @@ export class JobComponent implements OnInit {
}
ngOnInit() {
this.nextBtn = false;
this.commonService.surveyInfo().then(res => {
if (res['success']) {
if(this.id==1){
this.curPageData = res['data'].survey.pages['3'];
}else{
this.curPageData = res['data'].survey.pages['4'];
}
console.log(this.curPageData)
}
......@@ -68,20 +71,31 @@ 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{
this.nextBtn = false;
}
}
// 下一步
next() {
//先判断下一步能不能点
//如果是二人世界或是多口之家跳转到配偶页
//先判断当前页是您的页还是配偶页
if(this.id == 1){
if(this.type ==2 || this.type==4){
this.router.navigate(['/spouse_job'],{queryParams:{type:this.type}})
if(this.nextBtn ==true){
if(this.id == 1){
if(this.type ==2 || this.type==4){
this.router.navigate(['/spouse_job'],{queryParams:{type:this.type}})
}else{
this.router.navigate(['/transit1'],{queryParams:{type:this.type}})
}
}else{
this.router.navigate(['/transit1'],{queryParams:{type:this.type}})
}
}else{
this.router.navigate(['/transit1'],{queryParams:{type:this.type}})
return;
}
}
}
......@@ -8,7 +8,8 @@
<li
[ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData?.questions[0]['options']"
>
(click)="selectedLoan(this.curPageData?.questions[0],options)"
>
{{ options.optionName }}
</li>
</ul>
......@@ -19,14 +20,17 @@
<li
[ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData?.questions[1]['options']"
>
(click)="selectedLoan(this.curPageData?.questions[1],options)"
>
{{ options.optionName }}
</li>
</ul>
</div>
<div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"> 下一步 </div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"
(click)="next()"
> 下一步 </div>
</div>
</div>
</div>
import { Component, OnInit } from '@angular/core';
import {CommonService} from '../common.service';
import {ActivatedRoute, Router} from "@angular/router";
@Component({
selector: 'app-loan',
......@@ -8,19 +9,74 @@ import {CommonService} from '../common.service';
})
export class LoanComponent implements OnInit {
curPageData:Array<any>;
hasMate:boolean;
constructor(private commonService: CommonService) { }
//家庭结构
type:any;
pageAnswers: any;
selectedOptionId: any;
nextBtn:boolean;
constructor(private commonService: CommonService,
private router: Router,
private route: ActivatedRoute
) {
/**
* 1:单身贵族
* 2:二人世界
* 3:独立带娃
* 4:多口之家
* @type {any}
*/
this.type = this.route.snapshot.queryParams['type'];
this.pageAnswers = {
pageId: '',
questions: [],
};
}
ngOnInit() {
this.nextBtn = false;
this.surveyInfo()
this.hasMate = true;
}
surveyInfo() {
this.commonService.surveyInfo().then(res => {
if (res['success']) {
this.curPageData = res['data']['survey'].pages['7']
this.pageAnswers.pageId = this.curPageData['pageId'];
console.log(this.curPageData)
}
})
}
selectedLoan(question,option){
this.selectedOptionId = option.optionId;
option.selected = true;
const questions = {
questionId: question.questionId,
questionName: question.questionName,
options: [option]
};
for (let i = 0; i < this.pageAnswers.questions.length; i++) {
if (this.pageAnswers.questions[i].questionId == question.questionId) {
const index = this.pageAnswers.questions.indexOf(this.pageAnswers.questions[i]);
this.pageAnswers.questions.splice(index, 1);
}
}
this.pageAnswers.questions.push(questions);
this.commonService.addAnswer(this.pageAnswers);
console.log(questions)
console.log(this.pageAnswers)
if(this.curPageData['questions'].length == this.pageAnswers['questions'].length){
this.nextBtn = true;
}else{
this.nextBtn = false;
}
}
next(){
if(this.nextBtn == true){
this.router.navigate(['/social'],{queryParams:{type:this.type}})
}else{
return
}
}
}
......@@ -8,7 +8,8 @@
<li
[ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData?.questions[0]['options']"
>
(click)=selectedSocial(this.curPageData?.questions[0],options)
>
{{ options.optionName }}
</li>
</ul>
......@@ -19,14 +20,17 @@
<li
[ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData?.questions[1]['options']"
>
(click)=selectedSocial(this.curPageData?.questions[1],options)
>
{{ options.optionName }}
</li>
</ul>
</div>
<div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"> 下一步 </div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"
(click)="next()"
> 下一步 </div>
</div>
</div>
</div>
import { Component, OnInit } from '@angular/core';
import {CommonService} from '../common.service';
import {ActivatedRoute, Router} from "@angular/router";
@Component({
selector: 'app-social-security',
......@@ -9,11 +10,37 @@ import {CommonService} from '../common.service';
export class SocialSecurityComponent implements OnInit {
curPageData:Array<any>;
hasMate:boolean;
constructor(private commonService: CommonService) { }
//家庭结构
type:any;
nextBtn:boolean;
pageAnswers: any;
selectedOptionId: any;
constructor(private commonService: CommonService,
private router: Router,
private route: ActivatedRoute) {
/**
* 1:单身贵族
* 2:二人世界
* 3:独立带娃
* 4:多口之家
* @type {any}
*/
this.type = this.route.snapshot.queryParams['type'];
this.pageAnswers = {
pageId: '',
questions: [],
};
}
ngOnInit() {
this.surveyInfo()
this.hasMate = true;
//判断家庭决定是否显示配偶
if(this.type==2 || this.type == 4){
this.hasMate = true;
}else{
this.hasMate = false;
}
this.nextBtn = false;
}
surveyInfo() {
this.commonService.surveyInfo().then(res => {
......@@ -23,4 +50,44 @@ export class SocialSecurityComponent implements OnInit {
}
})
}
selectedSocial(question,option){
this.selectedOptionId = option.optionId;
option.selected = true;
const questions = {
questionId: question.questionId,
questionName: question.questionName,
options: [option]
};
for (let i = 0; i < this.pageAnswers.questions.length; i++) {
if (this.pageAnswers.questions[i].questionId == question.questionId) {
const index = this.pageAnswers.questions.indexOf(this.pageAnswers.questions[i]);
this.pageAnswers.questions.splice(index, 1);
}
}
this.pageAnswers.questions.push(questions);
this.commonService.addAnswer(this.pageAnswers);
//判断页面需要几个问题
if(this.type==2 || this.type == 4){
if(this.curPageData['questions'].length == this.pageAnswers['questions'].length){
this.nextBtn = true;
}else{
this.nextBtn = false;
}
}else{
if(this.pageAnswers['questions'].length>0){
this.nextBtn = true;
}else{
this.nextBtn = false;
}
}
}
next(){
if(this.nextBtn == true){
this.router.navigate(['/transit2'],{queryParams:{type:this.type}})
}else{
return;
}
}
}
......@@ -4,6 +4,8 @@
</div>
<div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"> 下一步 </div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"
(click)="next()"
> 下一步 </div>
</div>
</div>
import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router";
@Component({
selector: 'app-transit2',
......@@ -6,10 +7,18 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./transit2.component.css']
})
export class Transit2Component implements OnInit {
constructor() { }
//家庭结构
type:any;
constructor(
private router: Router,
private route: ActivatedRoute) {
this.type = this.route.snapshot.queryParams['type'];
}
ngOnInit() {
}
next(){
this.router.navigate(['/health'],{queryParams:{type:this.type}})
}
}
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