Commit 0d0616de by Sweet Zhang

健康

parent ffb5a675
...@@ -16,7 +16,7 @@ import {Transit1Component} from './transit1/transit1.component'; ...@@ -16,7 +16,7 @@ import {Transit1Component} from './transit1/transit1.component';
import {Transit2Component} from './transit2/transit2.component'; import {Transit2Component} from './transit2/transit2.component';
import {Transit3Component} from './transit3/transit3.component'; import {Transit3Component} from './transit3/transit3.component';
import { CommonModule } from '@angular/common'; import {CommonModule} from '@angular/common';
const routes: Routes = [ const routes: Routes = [
{ {
...@@ -52,17 +52,14 @@ const routes: Routes = [ ...@@ -52,17 +52,14 @@ const routes: Routes = [
component: SocialSecurityComponent component: SocialSecurityComponent
}, { }, {
path: 'health', path: 'health',
component: HealthComponent
}, {
path: 'health',
component: HealthComponent, component: HealthComponent,
data: [{type: 1}] data: [{id: 1}]
}, { }, {
path: 'spouse_health', path: 'spouse_health',
component: HealthComponent, component: HealthComponent,
data: [{type: 2}] data: [{id: 2}]
}, { }, {
path: 'children_health', path: 'children_health/:childId',
component: ChildrenHealthComponent, component: ChildrenHealthComponent,
}, { }, {
path: 'disease', path: 'disease',
...@@ -73,15 +70,15 @@ const routes: Routes = [ ...@@ -73,15 +70,15 @@ const routes: Routes = [
}, { }, {
path: 'live', path: 'live',
component: LiveComponent component: LiveComponent
},{ }, {
path:'transit1', path: 'transit1',
component:Transit1Component component: Transit1Component
},{ }, {
path:'transit2', path: 'transit2',
component:Transit2Component component: Transit2Component
},{ }, {
path:'transit3', path: 'transit3',
component:Transit3Component component: Transit3Component
}, },
// { // {
// path: '*', // path: '*',
...@@ -90,7 +87,7 @@ const routes: Routes = [ ...@@ -90,7 +87,7 @@ const routes: Routes = [
]; ];
@NgModule({ @NgModule({
imports: [CommonModule,RouterModule.forRoot(routes)], imports: [CommonModule, RouterModule.forRoot(routes)],
exports: [RouterModule] exports: [RouterModule]
}) })
export class AppRoutingModule { export class AppRoutingModule {
......
...@@ -8,15 +8,14 @@ ...@@ -8,15 +8,14 @@
<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 }" [ngClass]="{ selected: options['selected'] == true }" (click)="selectedHealth(options)">
>
{{ options.optionName }} {{ options.optionName }}
</li> </li>
</ul> </ul>
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <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> </div>
</div> </div>
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";
@Component({ @Component({
selector: 'app-children-health', selector: 'app-children-health',
...@@ -7,14 +8,82 @@ import {CommonService} from '../common.service'; ...@@ -7,14 +8,82 @@ import {CommonService} from '../common.service';
styleUrls: ['./children-health.component.css'] styleUrls: ['./children-health.component.css']
}) })
export class ChildrenHealthComponent implements OnInit { export class ChildrenHealthComponent implements OnInit {
curPageData:Array<any>; // 问题数据
constructor( curPageData: Array<any>;
private commonService: CommonService // 获取是第几个孩子的健康状况
) { } id: any;
// 获取家庭结构
type: any;
// 本页面答案
pageAnswers: any;
// 暂存健康状况
questions: Array<any> = [];
// 总共有几个孩子
childTotalCount: 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.id = this.route.snapshot.params['childId'];
this.childTotalCount = this.route.snapshot.queryParams['childTotalCount'];
this.pageAnswers = {
pageId: '',
questions: [{
questionId: '',
questionName: '',
options: [{optionId: '', optionName: '', optionOrder: '', selected: ''}]
}],
};
}
ngOnInit() { ngOnInit() {
this.surveyInfo() this.surveyInfo()
} }
// 选择健康情况(多选)
selectedHealth(option) {
option['selected'] = !option['selected'];
this.questions = [];
this.getOptions(99, option);
this.pageAnswers = {
pageId: this.curPageData['pageId'],
questions: [{
questionId: this.curPageData['questions']['0']['questionId'],
questionName: this.curPageData['questions']['0']['questionName'],
options: this.questions
}],
};
this.commonService.addAnswer(this.pageAnswers);
}
// 获取所有用户选择的健康选项
getOptions(nonDiseaseOptionId, option) {
for (let i = 0; i < this.curPageData['questions'][0]['options'].length; i++) {
if (option.optionId == nonDiseaseOptionId && option['selected']) {
this.curPageData['questions'][0]['options'][i]['selected'] = false;
if (this.curPageData['questions'][0]['options'][i]['optionId'] == nonDiseaseOptionId) {
this.curPageData['questions'][0]['options'][i]['selected'] = true;
}
} else {
if (this.curPageData['questions'][0]['options'][i]['optionId'] == nonDiseaseOptionId) {
this.curPageData['questions'][0]['options'][i]['selected'] = false;
}
}
// 拿到所有selected为true的选项
if (this.curPageData['questions'][0]['options'][i]['selected']) {
this.questions.push(this.curPageData['questions'][0]['options'][i]);
}
}
}
surveyInfo() { surveyInfo() {
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
if (res['success']) { if (res['success']) {
...@@ -23,4 +92,28 @@ export class ChildrenHealthComponent implements OnInit { ...@@ -23,4 +92,28 @@ export class ChildrenHealthComponent implements OnInit {
} }
}) })
} }
// 下一步
next() {
if (this.pageAnswers.questions[0].options.every((item) => {
return item.selected;
})) {
this.id = this.route.snapshot.params['childId'];
// 查看有几个孩子,一个直接跳到疾病页,多个跳多个孩子页
if (this.id < this.childTotalCount) {
this.router.navigate(['/children_health', parseInt(this.id, 0) + 1], {
queryParams: {
type: this.type,
childTotalCount: this.childTotalCount
}
});
this.surveyInfo();
} else {
this.router.navigate(['/disease'], {queryParams: {type: this.type}});
}
} else {
return;
}
}
} }
...@@ -47,6 +47,6 @@ export class FamilyComponent implements OnInit { ...@@ -47,6 +47,6 @@ export class FamilyComponent implements OnInit {
// 下一步 // 下一步
next() { next() {
this.router.navigate(['/job'], {queryParams: {type: this.selectedOptionId}}); this.router.navigate(['/age'], {queryParams: {type: this.selectedOptionId}});
} }
} }
...@@ -5,17 +5,16 @@ ...@@ -5,17 +5,16 @@
{{ this.curPageData?.questions[0]['questionName'] }} {{ this.curPageData?.questions[0]['questionName'] }}
</div> </div>
<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)="selectedHealth(options)">
>
{{ options.optionName }} {{ options.optionName }}
</li> </li>
</ul> </ul>
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;">&lt;</div> <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> </div>
</div> </div>
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";
@Component({ @Component({
selector: 'app-health', selector: 'app-health',
...@@ -7,19 +8,123 @@ import {CommonService} from '../common.service'; ...@@ -7,19 +8,123 @@ import {CommonService} from '../common.service';
styleUrls: ['./health.component.css'] styleUrls: ['./health.component.css']
}) })
export class HealthComponent implements OnInit { export class HealthComponent implements OnInit {
curPageData:Array<any>; // 问题数据
constructor(private commonService: CommonService) { } curPageData: Array<any>;
// 获取是您的健康情况还是配偶的健康情况
id: any;
// 获取家庭结构
type: any;
// 本页面答案
pageAnswers: any;
// 暂存健康状况
questions: Array<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.id = this.route.snapshot['data']['0']['id'];
this.pageAnswers = {
pageId: '',
questions: [{
questionId: '',
questionName: '',
options: [{optionId: '', optionName: '', optionOrder: '', selected: ''}]
}],
};
}
ngOnInit() { ngOnInit() {
this.surveyInfo() this.surveyInfo();
} }
surveyInfo() { surveyInfo() {
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
if (res['success']) { if (res['success']) {
this.curPageData = res['data']['survey'].pages['10'] if (this.id == 1) {
this.curPageData = res['data'].survey.pages['10'];
} else {
this.curPageData = res['data'].survey.pages['11'];
}
console.log(this.curPageData) console.log(this.curPageData)
} }
}) })
} }
// 选择健康情况(多选)
selectedHealth(option) {
option['selected'] = !option['selected'];
this.questions = [];
if (this.id == 1) {
this.getOptions(67, option);
} else if (this.id == 2) {
this.getOptions(83, option);
}
this.pageAnswers = {
pageId: this.curPageData['pageId'],
questions: [{
questionId: this.curPageData['questions']['0']['questionId'],
questionName: this.curPageData['questions']['0']['questionName'],
options: this.questions
}],
};
this.commonService.addAnswer(this.pageAnswers);
}
// 获取所有用户选择的健康选项
getOptions(nonDiseaseOptionId, option) {
for (let i = 0; i < this.curPageData['questions'][0]['options'].length; i++) {
if (option.optionId == nonDiseaseOptionId && option['selected']) {
this.curPageData['questions'][0]['options'][i]['selected'] = false;
if (this.curPageData['questions'][0]['options'][i]['optionId'] == nonDiseaseOptionId) {
this.curPageData['questions'][0]['options'][i]['selected'] = true;
}
} else {
if (this.curPageData['questions'][0]['options'][i]['optionId'] == nonDiseaseOptionId) {
this.curPageData['questions'][0]['options'][i]['selected'] = false;
}
}
// 拿到所有selected为true的选项
if (this.curPageData['questions'][0]['options'][i]['selected']) {
this.questions.push(this.curPageData['questions'][0]['options'][i]);
}
}
}
// 下一步
next() {
if (this.pageAnswers.questions[0].options.every((item) => {
return item.selected;
})) {
// 如果是二人世界或是多口之家跳转到配偶页
// 先判断当前页是您的页还是配偶页
if (this.id == 1) {
if (this.type == 2 || this.type == 4) {
this.router.navigate(['/spouse_health'], {queryParams: {type: this.type}});
} else if (this.type == 3) {
this.router.navigate(['/children_health', 1], {queryParams: {type: this.type}});
} else if (this.type == 1) {
this.router.navigate(['/disease'], {queryParams: {type: this.type}});
}
} else {
if (this.type == 1 || this.type == 2) {
this.router.navigate(['/disease'], {queryParams: {type: this.type}});
} else if (this.type == 3 || this.type == 4) {
this.router.navigate(['/children_health', 1], {queryParams: {type: this.type}});
} else {
this.router.navigate(['/disease'], {queryParams: {type: this.type}});
}
}
} else {
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,16 @@ import {ActivatedRoute, Router} from "@angular/router"; ...@@ -8,17 +8,16 @@ 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; hasMate: boolean;
curPageData:Array<any>; curPageData: Array<any>;
pageAnswers: any; pageAnswers: any;
// 家庭结构 // 家庭结构
type: any; type: any;
selectedOptionId: 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:二人世界
...@@ -37,12 +36,13 @@ export class IncomeComponent implements OnInit { ...@@ -37,12 +36,13 @@ export class IncomeComponent implements OnInit {
this.surveyInfo() this.surveyInfo()
this.hasMate = true; this.hasMate = true;
//判断家庭决定是否显示配偶 //判断家庭决定是否显示配偶
if(this.type==2 || this.type == 4){ if (this.type == 2 || this.type == 4) {
} else {
}else{
} }
} }
surveyInfo() { surveyInfo() {
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
if (res['success']) { if (res['success']) {
...@@ -54,10 +54,10 @@ export class IncomeComponent implements OnInit { ...@@ -54,10 +54,10 @@ export class IncomeComponent implements OnInit {
}) })
} }
selectedIncome(question,option){ selectedIncome(question, option) {
this.selectedOptionId = option.optionId; this.selectedOptionId = option.optionId;
option.selected = true; option.selected = true;
const questions = { const questions = {
questionId: question.questionId, questionId: question.questionId,
questionName: question.questionName, questionName: question.questionName,
......
import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {CommonService} from '../common.service'; import {CommonService} from '../common.service';
import {Router,ActivatedRoute} from "@angular/router"; import {Router, ActivatedRoute} from "@angular/router";
@Component({ @Component({
selector: 'app-job', selector: 'app-job',
templateUrl: './job.component.html', templateUrl: './job.component.html',
...@@ -11,11 +11,12 @@ export class JobComponent implements OnInit { ...@@ -11,11 +11,12 @@ export class JobComponent implements OnInit {
pageAnswers: any; pageAnswers: any;
selectedOptionId: any; selectedOptionId: any;
type: any; type: any;
id:any; id: any;
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:独立带娃
...@@ -26,7 +27,7 @@ export class JobComponent implements OnInit { ...@@ -26,7 +27,7 @@ export class JobComponent implements OnInit {
* 1:您的工作 * 1:您的工作
* 2: 配偶的工作 * 2: 配偶的工作
* @id * @id
* */ * */
this.type = this.route.snapshot.queryParams['type']; this.type = this.route.snapshot.queryParams['type'];
this.id = this.route.snapshot['data']['0']['id']; this.id = this.route.snapshot['data']['0']['id'];
console.log(this.id) console.log(this.id)
...@@ -43,17 +44,17 @@ export class JobComponent implements OnInit { ...@@ -43,17 +44,17 @@ export class JobComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
if (res['success']) { if (res['success']) {
if(this.id==1){ if (this.id == 1) {
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)
} }
}); });
} }
selectedJob(option){ selectedJob(option) {
console.log(this.curPageData['pageId']) console.log(this.curPageData['pageId'])
this.selectedOptionId = option.optionId; this.selectedOptionId = option.optionId;
option.selected = true; option.selected = true;
...@@ -69,19 +70,20 @@ export class JobComponent implements OnInit { ...@@ -69,19 +70,20 @@ export class JobComponent implements OnInit {
console.log(this.pageAnswers) console.log(this.pageAnswers)
console.log(this.commonService.todos) console.log(this.commonService.todos)
} }
// 下一步 // 下一步
next() { next() {
//如果是二人世界或是多口之家跳转到配偶页 //如果是二人世界或是多口之家跳转到配偶页
//先判断当前页是您的页还是配偶页 //先判断当前页是您的页还是配偶页
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}})
} }
} }
} }
import { Component, OnInit } from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {CommonService} from '../common.service'; import {CommonService} from '../common.service';
@Component({ @Component({
...@@ -7,14 +7,17 @@ import {CommonService} from '../common.service'; ...@@ -7,14 +7,17 @@ import {CommonService} from '../common.service';
styleUrls: ['./loan.component.css'] styleUrls: ['./loan.component.css']
}) })
export class LoanComponent implements OnInit { export class LoanComponent implements OnInit {
curPageData:Array<any>; curPageData: Array<any>;
hasMate:boolean; hasMate: boolean;
constructor(private commonService: CommonService) { }
constructor(private commonService: CommonService) {
}
ngOnInit() { ngOnInit() {
this.surveyInfo() this.surveyInfo()
this.hasMate = true; this.hasMate = true;
} }
surveyInfo() { surveyInfo() {
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
if (res['success']) { if (res['success']) {
......
import { Component, OnInit } from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {Router,ActivatedRoute} from '@angular/router'; import {Router, ActivatedRoute} from '@angular/router';
@Component({ @Component({
selector: 'app-transit1', selector: 'app-transit1',
templateUrl: './transit1.component.html', templateUrl: './transit1.component.html',
styleUrls: ['./transit1.component.css'] styleUrls: ['./transit1.component.css']
}) })
export class Transit1Component implements OnInit { export class Transit1Component implements OnInit {
type:any; type: any;
constructor(
private router: Router, constructor(private router: Router,
private route: ActivatedRoute) { private route: ActivatedRoute) {
/** /**
* 1:单身贵族 * 1:单身贵族
* 2:二人世界 * 2:二人世界
...@@ -23,7 +23,7 @@ export class Transit1Component implements OnInit { ...@@ -23,7 +23,7 @@ export class Transit1Component implements OnInit {
ngOnInit() { ngOnInit() {
} }
next(){ next() {
this.router.navigate(['/income'],{queryParams:{type:this.type}}) this.router.navigate(['/income'], {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