Commit 509df535 by Chao Sun

去除console

parent 527b795a
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";
@Component({ @Component({
selector: 'app-age', selector: 'app-age',
...@@ -119,7 +119,6 @@ export class AgeComponent implements OnInit { ...@@ -119,7 +119,6 @@ export class AgeComponent implements OnInit {
this.pageAnswers.questions.push(question); this.pageAnswers.questions.push(question);
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
this.closeToast(); this.closeToast();
// 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 {
...@@ -144,7 +143,7 @@ export class AgeComponent implements OnInit { ...@@ -144,7 +143,7 @@ export class AgeComponent implements OnInit {
this.isShow = false; this.isShow = false;
} }
// 增加孩子 // 增加孩子
addChild() { addChild() {
this.totalChildLimitCount--; this.totalChildLimitCount--;
if (this.totalChildLimitCount < 0) { if (this.totalChildLimitCount < 0) {
...@@ -163,7 +162,7 @@ export class AgeComponent implements OnInit { ...@@ -163,7 +162,7 @@ export class AgeComponent implements OnInit {
} }
} }
// 根据家庭结构处理展示数据 // 根据家庭结构处理展示数据
handleData(questionId) { handleData(questionId) {
for (let m = 0; m < this.curPageData['questions'].length; m++) { for (let m = 0; m < this.curPageData['questions'].length; m++) {
for (let n = 0; n < questionId.length; n++) { for (let n = 0; n < questionId.length; n++) {
...@@ -175,10 +174,10 @@ export class AgeComponent implements OnInit { ...@@ -175,10 +174,10 @@ export class AgeComponent implements OnInit {
} }
} }
// 下一步 // 下一步
next() { next() {
if (this.nextBtn) { if (this.nextBtn) {
this.router.navigate(['/job'], {queryParams: {type: this.type}}); this.router.navigate(['/job'], { 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";
@Component({ @Component({
selector: 'app-disease', selector: 'app-disease',
...@@ -8,7 +8,7 @@ import {ActivatedRoute, Router} from "@angular/router"; ...@@ -8,7 +8,7 @@ import {ActivatedRoute, Router} from "@angular/router";
styleUrls: ['./disease.component.css'] styleUrls: ['./disease.component.css']
}) })
export class DiseaseComponent implements OnInit { export class DiseaseComponent implements OnInit {
curPageData:any; curPageData: any;
type: any; type: any;
pageAnswers: any; pageAnswers: any;
nextBtn: boolean; nextBtn: boolean;
...@@ -16,22 +16,22 @@ export class DiseaseComponent implements OnInit { ...@@ -16,22 +16,22 @@ export class DiseaseComponent implements OnInit {
questions: Array<any> = []; questions: Array<any> = [];
lastQuestions: Array<any>; lastQuestions: Array<any>;
constructor(private commonService: CommonService, constructor(private commonService: CommonService,
private router: Router, private router: Router,
private route: ActivatedRoute) { private route: ActivatedRoute) {
this.type = this.route.snapshot.queryParams['type']; this.type = this.route.snapshot.queryParams['type'];
this.pageAnswers = { this.pageAnswers = {
pageId: '', pageId: '',
questions: [{ questions: [{
questionId: '', questionId: '',
questionName: '', questionName: '',
options: [{optionId: '', optionName: '', optionOrder: '', selected: ''}] options: [{ optionId: '', optionName: '', optionOrder: '', selected: '' }]
}], }],
}; };
} }
ngOnInit() { ngOnInit() {
this.nextBtn = false; this.nextBtn = false;
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 14).pop(); this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 14).pop();
this.surveyInfo(); this.surveyInfo();
} }
...@@ -41,7 +41,7 @@ export class DiseaseComponent implements OnInit { ...@@ -41,7 +41,7 @@ export class DiseaseComponent implements OnInit {
this.curPageData = res['data']['survey'].pages['13'] this.curPageData = res['data']['survey'].pages['13']
//过滤页面数据 //过滤页面数据
this.filterOptions(this.type) this.filterOptions(this.type)
if(this.lastQuestions){ if (this.lastQuestions) {
for (let i = 0; i < this.lastQuestions['questions'].length; i++) { for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
for (let j = 0; j < this.curPageData['questions'].length; j++) { for (let j = 0; j < this.curPageData['questions'].length; j++) {
if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) { if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) {
...@@ -53,14 +53,12 @@ export class DiseaseComponent implements OnInit { ...@@ -53,14 +53,12 @@ export class DiseaseComponent implements OnInit {
this.curPageData['questions'][j]['options'][this.curPageData['questions'][j]['options'].indexOf(option)] = targetObj; this.curPageData['questions'][j]['options'][this.curPageData['questions'][j]['options'].indexOf(option)] = targetObj;
// 过滤选项 // 过滤选项
this.filterOptions(this.type) this.filterOptions(this.type)
// console.log(targetObj)
} }
}); });
if (this.type == 1) { if (this.type == 1) {
this.getOneAnswer(targetObj) this.getOneAnswer(targetObj)
} else { } else {
console.log(targetObj) this.getManyAnswer(targetObj, true)
this.getManyAnswer(targetObj,true)
} }
} }
}); });
...@@ -89,7 +87,6 @@ export class DiseaseComponent implements OnInit { ...@@ -89,7 +87,6 @@ export class DiseaseComponent implements OnInit {
}] }]
} }
this.commonService.addAnswer(this.pageAnswers) this.commonService.addAnswer(this.pageAnswers)
// console.log(this.pageAnswers)
if (this.curPageData['questions'].length == this.pageAnswers.questions.length) { if (this.curPageData['questions'].length == this.pageAnswers.questions.length) {
if (this.pageAnswers.questions.every(item => item.options.length > 0)) { if (this.pageAnswers.questions.every(item => item.options.length > 0)) {
this.nextBtn = true; this.nextBtn = true;
...@@ -101,7 +98,7 @@ export class DiseaseComponent implements OnInit { ...@@ -101,7 +98,7 @@ export class DiseaseComponent implements OnInit {
} }
} }
getManyAnswer(option,lastFlag) { getManyAnswer(option, lastFlag) {
if (lastFlag === false) { if (lastFlag === false) {
option['selected'] = !option['selected']; option['selected'] = !option['selected'];
} }
...@@ -139,7 +136,6 @@ export class DiseaseComponent implements OnInit { ...@@ -139,7 +136,6 @@ export class DiseaseComponent implements OnInit {
} else { } else {
this.nextBtn = false; this.nextBtn = false;
} }
// console.log(this.pageAnswers)
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
} }
...@@ -148,44 +144,44 @@ export class DiseaseComponent implements OnInit { ...@@ -148,44 +144,44 @@ export class DiseaseComponent implements OnInit {
if (this.type == 1) { if (this.type == 1) {
this.getOneAnswer(option) this.getOneAnswer(option)
} else { } else {
this.getManyAnswer(option,false) this.getManyAnswer(option, false)
} }
} }
next() { next() {
if (this.nextBtn == true) { if (this.nextBtn == true) {
this.router.navigate(['/smoke'], {queryParams: {type: this.type}}) this.router.navigate(['/smoke'], { queryParams: { type: this.type } })
} else { } else {
return return
} }
} }
//过滤页面选项 //过滤页面选项
filterOptions(type){ filterOptions(type) {
if (type == 1) { if (type == 1) {
this.options = this.curPageData['questions']['0']['options'] this.options = this.curPageData['questions']['0']['options']
this.options = this.options.filter(option => { this.options = this.options.filter(option => {
return option.optionId == 106 || option.optionId == 107 return option.optionId == 106 || option.optionId == 107
}) })
} }
if (type == 2) { if (type == 2) {
this.options = this.curPageData['questions']['0']['options'] this.options = this.curPageData['questions']['0']['options']
this.options = this.options.filter(option => { this.options = this.options.filter(option => {
return option.optionId == 108 || option.optionId == 109 || option.optionId == 111 return option.optionId == 108 || option.optionId == 109 || option.optionId == 111
}) })
} }
if (type == 3) { if (type == 3) {
this.options = this.curPageData['questions']['0']['options'] this.options = this.curPageData['questions']['0']['options']
this.options = this.options.filter(option => { this.options = this.options.filter(option => {
return option.optionId == 108 || option.optionId == 110 || option.optionId == 111 return option.optionId == 108 || option.optionId == 110 || option.optionId == 111
}) })
} }
if (type == 4) { if (type == 4) {
this.options = this.curPageData['questions']['0']['options'] this.options = this.curPageData['questions']['0']['options']
this.options = this.options.filter(option => { this.options = this.options.filter(option => {
return option.optionId == 108 || option.optionId == 109 || option.optionId == 110 || option.optionId == 111 return option.optionId == 108 || option.optionId == 109 || option.optionId == 110 || option.optionId == 111
}) })
} }
} }
// 上一步 // 上一步
before() { before() {
......
import {Component, OnInit} from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {CommonService} from '../common.service'; import { CommonService } from '../common.service';
import {Router} from "@angular/router"; import { Router } from "@angular/router";
@Component({ @Component({
selector: 'app-family', selector: 'app-family',
templateUrl: './family.component.html', templateUrl: './family.component.html',
...@@ -24,7 +24,7 @@ export class FamilyComponent implements OnInit { ...@@ -24,7 +24,7 @@ export class FamilyComponent implements OnInit {
questions: [{ questions: [{
questionId: '', questionId: '',
questionName: '', questionName: '',
options: [{optionId: '', optionName: '', optionOrder: '', selected: ''}] options: [{ optionId: '', optionName: '', optionOrder: '', selected: '' }]
}], }],
}; };
} }
...@@ -33,7 +33,6 @@ export class FamilyComponent implements OnInit { ...@@ -33,7 +33,6 @@ export class FamilyComponent implements OnInit {
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 2).pop(); this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 2).pop();
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
this.curPageData = res['data']['survey']['pages'].filter(item => item.pageId === 2).pop(); this.curPageData = res['data']['survey']['pages'].filter(item => item.pageId === 2).pop();
console.log(this.curPageData)
if (this.lastQuestions) { if (this.lastQuestions) {
this.lastSelectedOptionId = this.lastQuestions['questions'][0]['options'][0]['optionId'] this.lastSelectedOptionId = this.lastQuestions['questions'][0]['options'][0]['optionId']
for (let i = 0; i < this.lastQuestions['questions'].length; i++) { for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
...@@ -53,7 +52,7 @@ export class FamilyComponent implements OnInit { ...@@ -53,7 +52,7 @@ export class FamilyComponent implements OnInit {
} }
// 选择家庭结构 // 选择家庭结构
selectedFamily(option) { selectedFamily(option) {
this.selectedOptionId = option.optionId; this.selectedOptionId = option.optionId;
// 如果选择的跟上一次的家庭结构不一样,那么将以前的答案清空 // 如果选择的跟上一次的家庭结构不一样,那么将以前的答案清空
...@@ -77,7 +76,6 @@ export class FamilyComponent implements OnInit { ...@@ -77,7 +76,6 @@ export class FamilyComponent implements OnInit {
}], }],
}; };
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(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 {
...@@ -85,16 +83,16 @@ export class FamilyComponent implements OnInit { ...@@ -85,16 +83,16 @@ export class FamilyComponent implements OnInit {
} }
} }
// 下一步 // 下一步
next() { next() {
if (this.nextBtn) { if (this.nextBtn) {
this.router.navigate(['/age'], {queryParams: {type: this.selectedOptionId}}); this.router.navigate(['/age'], { queryParams: { type: this.selectedOptionId } });
} else { } else {
return; return;
} }
} }
// 上一步 // 上一步
before() { before() {
this.commonService.before(); this.commonService.before();
} }
......
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";
@Component({ @Component({
selector: 'app-health', selector: 'app-health',
...@@ -9,7 +9,7 @@ import {ActivatedRoute, Router} from "@angular/router"; ...@@ -9,7 +9,7 @@ import {ActivatedRoute, Router} from "@angular/router";
}) })
export class HealthComponent implements OnInit { export class HealthComponent implements OnInit {
// 问题数据 // 问题数据
curPageData:any; curPageData: any;
// 获取是您的健康情况还是配偶的健康情况 // 获取是您的健康情况还是配偶的健康情况
id: any; id: any;
// 获取家庭结构 // 获取家庭结构
...@@ -22,8 +22,8 @@ export class HealthComponent implements OnInit { ...@@ -22,8 +22,8 @@ export class HealthComponent implements OnInit {
lastQuestions: Array<any>; lastQuestions: Array<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:二人世界
...@@ -38,7 +38,7 @@ export class HealthComponent implements OnInit { ...@@ -38,7 +38,7 @@ export class HealthComponent implements OnInit {
questions: [{ questions: [{
questionId: '', questionId: '',
questionName: '', questionName: '',
options: [{optionId: '', optionName: '', optionOrder: '', selected: ''}] options: [{ optionId: '', optionName: '', optionOrder: '', selected: '' }]
}], }],
}; };
} }
...@@ -62,8 +62,6 @@ export class HealthComponent implements OnInit { ...@@ -62,8 +62,6 @@ export class HealthComponent implements OnInit {
for (let i = 0; i < this.lastQuestions['questions'].length; i++) { for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
for (let j = 0; j < this.curPageData['questions'].length; j++) { for (let j = 0; j < this.curPageData['questions'].length; j++) {
if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) { if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) {
// console.log(this.lastQuestions)
// console.log(this.curPageData)
this.lastQuestions['questions'][i]['options'].forEach(option => { this.lastQuestions['questions'][i]['options'].forEach(option => {
if (Object.keys(option).indexOf('optionId') > -1) { if (Object.keys(option).indexOf('optionId') > -1) {
const targetObj = option; const targetObj = option;
...@@ -73,7 +71,6 @@ export class HealthComponent implements OnInit { ...@@ -73,7 +71,6 @@ export class HealthComponent implements OnInit {
} }
}); });
this.selectedHealth(targetObj, true); this.selectedHealth(targetObj, true);
// console.log(this.targetObj);
} }
}); });
} }
...@@ -87,8 +84,6 @@ export class HealthComponent implements OnInit { ...@@ -87,8 +84,6 @@ export class HealthComponent implements OnInit {
for (let i = 0; i < this.lastQuestions['questions'].length; i++) { for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
for (let j = 0; j < this.curPageData['questions'].length; j++) { for (let j = 0; j < this.curPageData['questions'].length; j++) {
if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) { if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) {
// console.log(this.lastQuestions)
// console.log(this.curPageData)
this.lastQuestions['questions'][i]['options'].forEach(option => { this.lastQuestions['questions'][i]['options'].forEach(option => {
if (Object.keys(option).indexOf('optionId') > -1) { if (Object.keys(option).indexOf('optionId') > -1) {
const targetObj = option; const targetObj = option;
...@@ -98,7 +93,6 @@ export class HealthComponent implements OnInit { ...@@ -98,7 +93,6 @@ export class HealthComponent implements OnInit {
} }
}); });
this.selectedHealth(targetObj, true); this.selectedHealth(targetObj, true);
// console.log(this.targetObj);
} }
}); });
} }
...@@ -169,7 +163,7 @@ export class HealthComponent implements OnInit { ...@@ -169,7 +163,7 @@ export class HealthComponent implements OnInit {
// 先判断当前页是您的页还是配偶页 // 先判断当前页是您的页还是配偶页
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_health'], {queryParams: {type: this.type}}); this.router.navigate(['/spouse_health'], { queryParams: { type: this.type } });
} else if (this.type == 3) { } else if (this.type == 3) {
this.router.navigate(['/children_health', 1], { this.router.navigate(['/children_health', 1], {
queryParams: { queryParams: {
...@@ -177,11 +171,11 @@ export class HealthComponent implements OnInit { ...@@ -177,11 +171,11 @@ export class HealthComponent implements OnInit {
} }
}); });
} else if (this.type == 1) { } else if (this.type == 1) {
this.router.navigate(['/disease'], {queryParams: {type: this.type}}); this.router.navigate(['/disease'], { queryParams: { type: this.type } });
} }
} else { } else {
if (this.type == 1 || this.type == 2) { if (this.type == 1 || this.type == 2) {
this.router.navigate(['/disease'], {queryParams: {type: this.type}}); this.router.navigate(['/disease'], { queryParams: { type: this.type } });
} else if (this.type == 3 || this.type == 4) { } else if (this.type == 3 || this.type == 4) {
this.router.navigate(['/children_health', 1], { this.router.navigate(['/children_health', 1], {
queryParams: { queryParams: {
...@@ -189,7 +183,7 @@ export class HealthComponent implements OnInit { ...@@ -189,7 +183,7 @@ export class HealthComponent implements OnInit {
} }
}); });
} else { } else {
this.router.navigate(['/disease'], {queryParams: {type: this.type}}); this.router.navigate(['/disease'], { queryParams: { type: this.type } });
} }
} }
} else { } else {
......
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";
@Component({ @Component({
selector: 'app-income', selector: 'app-income',
...@@ -8,16 +8,16 @@ import {ActivatedRoute, Router} from "@angular/router"; ...@@ -8,16 +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 {
curPageData:any; curPageData: any;
pageAnswers: any; pageAnswers: any;
// 家庭结构 // 家庭结构
type: any; type: any;
nextBtn: boolean; nextBtn: boolean;
lastQuestions: Array<any>; lastQuestions: Array<any>;
targetObj:Object = {} targetObj: Object = {}
constructor(private commonService: CommonService, constructor(private commonService: CommonService,
private router: Router, private router: Router,
private route: ActivatedRoute) { private route: ActivatedRoute) {
/** /**
* 1:单身贵族 * 1:单身贵族
* 2:二人世界 * 2:二人世界
...@@ -34,7 +34,7 @@ export class IncomeComponent implements OnInit { ...@@ -34,7 +34,7 @@ export class IncomeComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.nextBtn = false; this.nextBtn = false;
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 7).pop(); this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 7).pop();
this.surveyInfo(); this.surveyInfo();
} }
...@@ -42,22 +42,21 @@ export class IncomeComponent implements OnInit { ...@@ -42,22 +42,21 @@ export class IncomeComponent implements OnInit {
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)
this.pageAnswers.pageId = this.curPageData['pageId']; this.pageAnswers.pageId = this.curPageData['pageId'];
if(this.lastQuestions){ if (this.lastQuestions) {
for (let i = 0; i < this.lastQuestions['questions'].length; i++) { for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
for (let j = 0; j < this.curPageData['questions'].length; j++) { for (let j = 0; j < this.curPageData['questions'].length; j++) {
if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) { if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) {
this.lastQuestions['questions'][i]['options'].forEach(option => { this.lastQuestions['questions'][i]['options'].forEach(option => {
if(Object.keys(option).indexOf('optionId')>-1){ if (Object.keys(option).indexOf('optionId') > -1) {
this.targetObj = option this.targetObj = option
} }
this.selectedIncome(this.curPageData['questions'][j],this.targetObj); this.selectedIncome(this.curPageData['questions'][j], this.targetObj);
}); });
} }
} }
} }
}else{ } else {
return; return;
} }
} }
...@@ -85,7 +84,6 @@ export class IncomeComponent implements OnInit { ...@@ -85,7 +84,6 @@ export class IncomeComponent implements OnInit {
} }
} }
} }
// 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) {
...@@ -95,7 +93,6 @@ export class IncomeComponent implements OnInit { ...@@ -95,7 +93,6 @@ 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(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) {
...@@ -114,7 +111,7 @@ export class IncomeComponent implements OnInit { ...@@ -114,7 +111,7 @@ export class IncomeComponent implements OnInit {
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;
} }
......
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";
@Component({ @Component({
selector: 'app-live', selector: 'app-live',
...@@ -8,7 +8,7 @@ import {ActivatedRoute, Router} from "@angular/router"; ...@@ -8,7 +8,7 @@ import {ActivatedRoute, Router} from "@angular/router";
styleUrls: ['./live.component.css'] styleUrls: ['./live.component.css']
}) })
export class LiveComponent implements OnInit { export class LiveComponent implements OnInit {
curPageData:any; curPageData: any;
provinceList: Array<any>; provinceList: Array<any>;
isShow: boolean; isShow: boolean;
provinceId: number; provinceId: number;
...@@ -24,17 +24,17 @@ export class LiveComponent implements OnInit { ...@@ -24,17 +24,17 @@ export class LiveComponent implements OnInit {
type: any; type: any;
nextBtn: boolean; nextBtn: boolean;
lastQuestions: Array<any>; lastQuestions: Array<any>;
tipsFlag:boolean; tipsFlag: boolean;
constructor(private commonService: CommonService, constructor(private commonService: CommonService,
private router: Router, private router: Router,
private route: ActivatedRoute) { private route: ActivatedRoute) {
this.type = this.route.snapshot.queryParams['type']; this.type = this.route.snapshot.queryParams['type'];
this.pageAnswers = { this.pageAnswers = {
pageId: '', pageId: '',
questions: [{ questions: [{
questionId: '', questionId: '',
questionName: '', questionName: '',
options: [{optionId: '', optionName: '', optionOrder: '', selected: ''}] options: [{ optionId: '', optionName: '', optionOrder: '', selected: '' }]
}], }],
}; };
} }
...@@ -45,7 +45,7 @@ export class LiveComponent implements OnInit { ...@@ -45,7 +45,7 @@ export class LiveComponent implements OnInit {
this.tipsFlag = false; this.tipsFlag = false;
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 16).pop(); this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 16).pop();
// 获取省份 // 获取省份
this.commonService.provinceqry({insurerId: 11}).then(res => { this.commonService.provinceqry({ insurerId: 11 }).then(res => {
if (res['success']) { if (res['success']) {
this.provinceList = res['data'].provinceList; this.provinceList = res['data'].provinceList;
} }
...@@ -71,7 +71,6 @@ export class LiveComponent implements OnInit { ...@@ -71,7 +71,6 @@ export class LiveComponent implements OnInit {
if (this.provinceList.length > 0) { if (this.provinceList.length > 0) {
for (let i = 0; i < this.provinceList.length; i++) { for (let i = 0; i < this.provinceList.length; i++) {
if (this.provinceList[i].provinceName == left) { if (this.provinceList[i].provinceName == left) {
// console.log(this.provinceList[i])
this.selectProvince(this.provinceList[i]) this.selectProvince(this.provinceList[i])
} }
...@@ -97,7 +96,6 @@ export class LiveComponent implements OnInit { ...@@ -97,7 +96,6 @@ export class LiveComponent implements OnInit {
} }
selectProvince(option) { selectProvince(option) {
// console.log(this.selectedProvinceObj)
this.provinceName = option.provinceName; this.provinceName = option.provinceName;
this.provinceId = option.provinceId; this.provinceId = option.provinceId;
for (let i = 0; i < this.provinceList.length; i++) { for (let i = 0; i < this.provinceList.length; i++) {
...@@ -162,9 +160,9 @@ export class LiveComponent implements OnInit { ...@@ -162,9 +160,9 @@ export class LiveComponent implements OnInit {
this.router.navigate(['/transit3']); this.router.navigate(['/transit3']);
} else { } else {
this.tipsFlag = true; this.tipsFlag = true;
setTimeout(()=>{ setTimeout(() => {
this.tipsFlag = false; this.tipsFlag = false;
},2000) }, 2000)
} }
}); });
} else { } else {
......
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";
@Component({ @Component({
selector: 'app-loan', selector: 'app-loan',
...@@ -8,7 +8,7 @@ import {ActivatedRoute, Router} from "@angular/router"; ...@@ -8,7 +8,7 @@ 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:any; curPageData: any;
// 家庭结构 // 家庭结构
type: any; type: any;
pageAnswers: any; pageAnswers: any;
...@@ -17,8 +17,8 @@ export class LoanComponent implements OnInit { ...@@ -17,8 +17,8 @@ export class LoanComponent implements OnInit {
targetObj: Object = {} targetObj: Object = {}
constructor(private commonService: CommonService, constructor(private commonService: CommonService,
private router: Router, private router: Router,
private route: ActivatedRoute) { private route: ActivatedRoute) {
/** /**
* 1:单身贵族 * 1:单身贵族
* 2:二人世界 * 2:二人世界
...@@ -58,12 +58,10 @@ export class LoanComponent implements OnInit { ...@@ -58,12 +58,10 @@ export class LoanComponent implements OnInit {
} }
} }
} }
}else{ } else {
return; return;
} }
} }
// console.log(this.pageAnswers)
// console.log(this.commonService.todos)
}) })
} }
...@@ -95,7 +93,6 @@ export class LoanComponent implements OnInit { ...@@ -95,7 +93,6 @@ 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(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 {
...@@ -105,7 +102,7 @@ export class LoanComponent implements OnInit { ...@@ -105,7 +102,7 @@ export class LoanComponent implements OnInit {
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";
@Component({ @Component({
selector: 'app-smoking', selector: 'app-smoking',
...@@ -8,7 +8,7 @@ import {ActivatedRoute, Router} from "@angular/router"; ...@@ -8,7 +8,7 @@ import {ActivatedRoute, Router} from "@angular/router";
styleUrls: ['./smoking.component.css'] styleUrls: ['./smoking.component.css']
}) })
export class SmokingComponent implements OnInit { export class SmokingComponent implements OnInit {
curPageData:any; curPageData: any;
type: any; type: any;
nextBtn: boolean; nextBtn: boolean;
pageAnswers: any; pageAnswers: any;
...@@ -17,22 +17,22 @@ export class SmokingComponent implements OnInit { ...@@ -17,22 +17,22 @@ export class SmokingComponent implements OnInit {
lastQuestions: Array<any>; lastQuestions: Array<any>;
constructor(private commonService: CommonService, constructor(private commonService: CommonService,
private router: Router, private router: Router,
private route: ActivatedRoute) { private route: ActivatedRoute) {
this.type = this.route.snapshot.queryParams['type']; this.type = this.route.snapshot.queryParams['type'];
this.pageAnswers = { this.pageAnswers = {
pageId: '', pageId: '',
questions: [{ questions: [{
questionId: '', questionId: '',
questionName: '', questionName: '',
options: [{optionId: '', optionName: '', optionOrder: '', selected: ''}] options: [{ optionId: '', optionName: '', optionOrder: '', selected: '' }]
}], }],
}; };
} }
ngOnInit() { ngOnInit() {
this.nextBtn = false; this.nextBtn = false;
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 15).pop(); this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 15).pop();
this.surveyInfo(); this.surveyInfo();
} }
...@@ -41,7 +41,7 @@ export class SmokingComponent implements OnInit { ...@@ -41,7 +41,7 @@ export class SmokingComponent implements OnInit {
if (res['success']) { if (res['success']) {
this.curPageData = res['data']['survey'].pages['14']; this.curPageData = res['data']['survey'].pages['14'];
this.filterOptions(this.type) this.filterOptions(this.type)
if(this.lastQuestions){ if (this.lastQuestions) {
for (let i = 0; i < this.lastQuestions['questions'].length; i++) { for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
for (let j = 0; j < this.curPageData['questions'].length; j++) { for (let j = 0; j < this.curPageData['questions'].length; j++) {
if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) { if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) {
...@@ -53,13 +53,12 @@ export class SmokingComponent implements OnInit { ...@@ -53,13 +53,12 @@ export class SmokingComponent implements OnInit {
this.curPageData['questions'][j]['options'][this.curPageData['questions'][j]['options'].indexOf(option)] = targetObj; this.curPageData['questions'][j]['options'][this.curPageData['questions'][j]['options'].indexOf(option)] = targetObj;
// 过滤选项 // 过滤选项
this.filterOptions(this.type) this.filterOptions(this.type)
// console.log(targetObj)
} }
}); });
if (this.type == 1) { if (this.type == 1) {
this.getOneAnswer(targetObj) this.getOneAnswer(targetObj)
} else { } else {
this.getManyAnswer(targetObj,true) this.getManyAnswer(targetObj, true)
} }
} }
}); });
...@@ -88,7 +87,6 @@ export class SmokingComponent implements OnInit { ...@@ -88,7 +87,6 @@ export class SmokingComponent implements OnInit {
}] }]
} }
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
// console.log(this.pageAnswers);
if (this.curPageData['questions'].length == this.pageAnswers.questions.length) { if (this.curPageData['questions'].length == this.pageAnswers.questions.length) {
if (this.pageAnswers.questions.every(item => item.options.length > 0)) { if (this.pageAnswers.questions.every(item => item.options.length > 0)) {
this.nextBtn = true; this.nextBtn = true;
...@@ -100,7 +98,7 @@ export class SmokingComponent implements OnInit { ...@@ -100,7 +98,7 @@ export class SmokingComponent implements OnInit {
} }
} }
getManyAnswer(option,lastFlag) { getManyAnswer(option, lastFlag) {
if (lastFlag === false) { if (lastFlag === false) {
option['selected'] = !option['selected']; option['selected'] = !option['selected'];
} }
...@@ -138,7 +136,6 @@ export class SmokingComponent implements OnInit { ...@@ -138,7 +136,6 @@ export class SmokingComponent implements OnInit {
} else { } else {
this.nextBtn = false; this.nextBtn = false;
} }
// console.log(this.pageAnswers);
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
} }
...@@ -146,20 +143,20 @@ export class SmokingComponent implements OnInit { ...@@ -146,20 +143,20 @@ export class SmokingComponent implements OnInit {
if (this.type == 1) { if (this.type == 1) {
this.getOneAnswer(option); this.getOneAnswer(option);
} else { } else {
this.getManyAnswer(option,false); this.getManyAnswer(option, false);
} }
} }
next() { next() {
if (this.nextBtn == true) { if (this.nextBtn == true) {
this.router.navigate(['/live'], {queryParams: {type: this.type}}) this.router.navigate(['/live'], { queryParams: { type: this.type } })
} else { } else {
return; return;
} }
} }
filterOptions(type){ filterOptions(type) {
//过滤选项 //过滤选项
if (type == 1) { if (type == 1) {
this.options = this.curPageData['questions']['0']['options']; this.options = this.curPageData['questions']['0']['options'];
this.options = this.options.filter(option => { this.options = this.options.filter(option => {
return option.optionId == 112 || option.optionId == 113; return option.optionId == 112 || option.optionId == 113;
......
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";
@Component({ @Component({
selector: 'app-social-security', selector: 'app-social-security',
...@@ -8,16 +8,16 @@ import {ActivatedRoute, Router} from "@angular/router"; ...@@ -8,16 +8,16 @@ 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:any; curPageData: any;
// 家庭结构 // 家庭结构
type: any; type: any;
nextBtn: boolean; nextBtn: boolean;
pageAnswers: any; pageAnswers: any;
lastQuestions: Array<any>; lastQuestions: Array<any>;
targetObj:Object = {} targetObj: Object = {}
constructor(private commonService: CommonService, constructor(private commonService: CommonService,
private router: Router, private router: Router,
private route: ActivatedRoute) { private route: ActivatedRoute) {
/** /**
* 1:单身贵族 * 1:单身贵族
* 2:二人世界 * 2:二人世界
...@@ -34,7 +34,7 @@ export class SocialSecurityComponent implements OnInit { ...@@ -34,7 +34,7 @@ export class SocialSecurityComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.nextBtn = false; this.nextBtn = false;
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 9).pop(); this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 9).pop();
this.surveyInfo(); this.surveyInfo();
} }
...@@ -43,20 +43,20 @@ export class SocialSecurityComponent implements OnInit { ...@@ -43,20 +43,20 @@ export class SocialSecurityComponent implements OnInit {
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']; this.pageAnswers.pageId = this.curPageData['pageId'];
if(this.lastQuestions){ if (this.lastQuestions) {
for (let i = 0; i < this.lastQuestions['questions'].length; i++) { for (let i = 0; i < this.lastQuestions['questions'].length; i++) {
for (let j = 0; j < this.curPageData['questions'].length; j++) { for (let j = 0; j < this.curPageData['questions'].length; j++) {
if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) { if (this.lastQuestions['questions'][i].questionId == this.curPageData['questions'][j].questionId) {
this.lastQuestions['questions'][i]['options'].forEach(option => { this.lastQuestions['questions'][i]['options'].forEach(option => {
if(Object.keys(option).indexOf('optionId')>-1){ if (Object.keys(option).indexOf('optionId') > -1) {
this.targetObj = option this.targetObj = option
} }
this.selectedSocial(this.curPageData['questions'][j],this.targetObj); this.selectedSocial(this.curPageData['questions'][j], this.targetObj);
}); });
} }
} }
} }
}else{ } else {
return; return;
} }
} }
...@@ -90,7 +90,6 @@ export class SocialSecurityComponent implements OnInit { ...@@ -90,7 +90,6 @@ 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) {
...@@ -110,7 +109,7 @@ export class SocialSecurityComponent implements OnInit { ...@@ -110,7 +109,7 @@ export class SocialSecurityComponent implements OnInit {
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