Commit b43aad5c by Chao Sun

合并

parents 20edb27f 0d0616de
......@@ -16,7 +16,7 @@ import {Transit1Component} from './transit1/transit1.component';
import {Transit2Component} from './transit2/transit2.component';
import {Transit3Component} from './transit3/transit3.component';
import { CommonModule } from '@angular/common';
import {CommonModule} from '@angular/common';
const routes: Routes = [
{
......@@ -52,17 +52,14 @@ const routes: Routes = [
component: SocialSecurityComponent
}, {
path: 'health',
component: HealthComponent
}, {
path: 'health',
component: HealthComponent,
data: [{type: 1}]
data: [{id: 1}]
}, {
path: 'spouse_health',
component: HealthComponent,
data: [{type: 2}]
data: [{id: 2}]
}, {
path: 'children_health',
path: 'children_health/:childId',
component: ChildrenHealthComponent,
}, {
path: 'disease',
......@@ -73,15 +70,15 @@ const routes: Routes = [
}, {
path: 'live',
component: LiveComponent
},{
path:'transit1',
component:Transit1Component
},{
path:'transit2',
component:Transit2Component
},{
path:'transit3',
component:Transit3Component
}, {
path: 'transit1',
component: Transit1Component
}, {
path: 'transit2',
component: Transit2Component
}, {
path: 'transit3',
component: Transit3Component
},
// {
// path: '*',
......@@ -90,7 +87,7 @@ const routes: Routes = [
];
@NgModule({
imports: [CommonModule,RouterModule.forRoot(routes)],
imports: [CommonModule, RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {
......
......@@ -8,15 +8,14 @@
<li
class="selected"
*ngFor="let options of this.curPageData?.questions[0]['options']"
[ngClass]="{ selected: options['selected'] == true }"
>
[ngClass]="{ selected: options['selected'] == true }" (click)="selectedHealth(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 {Component, OnInit} from '@angular/core';
import {CommonService} from '../common.service';
import {ActivatedRoute, Router} from "@angular/router";
@Component({
selector: 'app-children-health',
......@@ -7,14 +8,82 @@ import {CommonService} from '../common.service';
styleUrls: ['./children-health.component.css']
})
export class ChildrenHealthComponent implements OnInit {
curPageData:Array<any>;
constructor(
private commonService: CommonService
) { }
// 问题数据
curPageData: Array<any>;
// 获取是第几个孩子的健康状况
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() {
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() {
this.commonService.surveyInfo().then(res => {
if (res['success']) {
......@@ -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 {
// 下一步
next() {
this.router.navigate(['/job'], {queryParams: {type: this.selectedOptionId}});
this.router.navigate(['/age'], {queryParams: {type: this.selectedOptionId}});
}
}
......@@ -5,17 +5,16 @@
{{ this.curPageData?.questions[0]['questionName'] }}
</div>
<ul class="jobContent">
<li
*ngFor="let options of this.curPageData?.questions[0]['options']"
[ngClass]="{ selected: options['selected'] == true }"
>
<li *ngFor="let options of this.curPageData?.questions[0]['options']"
[ngClass]="{ selected: options['selected'] == true}"
(click)="selectedHealth(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 {Component, OnInit} from '@angular/core';
import {CommonService} from '../common.service';
import {ActivatedRoute, Router} from "@angular/router";
@Component({
selector: 'app-health',
......@@ -7,19 +8,123 @@ import {CommonService} from '../common.service';
styleUrls: ['./health.component.css']
})
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() {
this.surveyInfo()
this.surveyInfo();
}
surveyInfo() {
this.commonService.surveyInfo().then(res => {
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)
}
})
}
// 选择健康情况(多选)
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 {ActivatedRoute, Router} from "@angular/router";
......@@ -8,18 +8,17 @@ import {ActivatedRoute, Router} from "@angular/router";
styleUrls: ['./income.component.css']
})
export class IncomeComponent implements OnInit {
hasMate:boolean;
curPageData:Array<any>;
hasMate: boolean;
curPageData: Array<any>;
pageAnswers: any;
// 家庭结构
type: any;
selectedOptionId: any;
nextBtn:boolean;
constructor(
private commonService: CommonService,
private router: Router,
private route: ActivatedRoute
) {
constructor(private commonService: CommonService,
private router: Router,
private route: ActivatedRoute) {
/**
* 1:单身贵族
* 2:二人世界
......@@ -44,6 +43,7 @@ export class IncomeComponent implements OnInit {
}
this.nextBtn = false;
}
surveyInfo() {
this.commonService.surveyInfo().then(res => {
if (res['success']) {
......@@ -54,7 +54,7 @@ export class IncomeComponent implements OnInit {
})
}
selectedIncome(question,option){
selectedIncome(question, option) {
this.selectedOptionId = option.optionId;
option.selected = true;
const questions = {
......
import {Component, OnInit} from '@angular/core';
import {CommonService} from '../common.service';
import {Router,ActivatedRoute} from "@angular/router";
import {Router, ActivatedRoute} from "@angular/router";
@Component({
selector: 'app-job',
templateUrl: './job.component.html',
......@@ -27,7 +27,7 @@ export class JobComponent implements OnInit {
* 1:您的工作
* 2: 配偶的工作
* @id
* */
* */
this.type = this.route.snapshot.queryParams['type'];
this.id = this.route.snapshot['data']['0']['id'];
console.log(this.id)
......@@ -45,18 +45,18 @@ export class JobComponent implements OnInit {
this.nextBtn = false;
this.commonService.surveyInfo().then(res => {
if (res['success']) {
if(this.id==1){
if (this.id == 1) {
this.curPageData = res['data'].survey.pages['3'];
}else{
} else {
this.curPageData = res['data'].survey.pages['4'];
}
console.log(this.curPageData)
console.log(this.curPageData)
}
});
}
selectedJob(option){
selectedJob(option) {
console.log(this.curPageData['pageId'])
this.selectedOptionId = option.optionId;
option.selected = true;
......@@ -77,6 +77,7 @@ export class JobComponent implements OnInit {
this.nextBtn = false;
}
}
// 下一步
next() {
//先判断下一步能不能点
......
import { Component, OnInit } from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {CommonService} from '../common.service';
import {ActivatedRoute, Router} from "@angular/router";
......@@ -36,6 +36,7 @@ export class LoanComponent implements OnInit {
this.nextBtn = false;
this.surveyInfo()
}
surveyInfo() {
this.commonService.surveyInfo().then(res => {
if (res['success']) {
......
import { Component, OnInit } from '@angular/core';
import {Router,ActivatedRoute} from '@angular/router';
import {Component, OnInit} from '@angular/core';
import {Router, ActivatedRoute} from '@angular/router';
@Component({
selector: 'app-transit1',
templateUrl: './transit1.component.html',
styleUrls: ['./transit1.component.css']
})
export class Transit1Component implements OnInit {
type:any;
constructor(
private router: Router,
private route: ActivatedRoute) {
type: any;
constructor(private router: Router,
private route: ActivatedRoute) {
/**
* 1:单身贵族
* 2:二人世界
......@@ -23,7 +23,7 @@ export class Transit1Component implements OnInit {
ngOnInit() {
}
next(){
this.router.navigate(['/income'],{queryParams:{type:this.type}})
next() {
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