Commit 509df535 by Chao Sun

去除console

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