Commit e2a5c230 by Sweet Zhang

格式化代码

parent f4410e73
...@@ -51,7 +51,7 @@ export class AgeComponent implements OnInit { ...@@ -51,7 +51,7 @@ export class AgeComponent implements OnInit {
} else { } else {
this.handleData([]); this.handleData([]);
} }
console.log(this.curPageData) // console.log(this.curPageData)
}); });
} }
......
...@@ -129,20 +129,4 @@ export class CommonService { ...@@ -129,20 +129,4 @@ export class CommonService {
return this; return this;
} }
// 更新一个答案
updateTodoById(pageId: number, values: Object = {}) {
const todo = this.todos.filter(todo => todo.pageId == pageId).pop();
if (!todo) {
return null;
}
Object.assign(todo, values); // 将更新的values对象的属性值赋给todo对象
this.todosSource.next(this.todos);
return todo;
}
// 获取所有答案
getTodos() {
return this.todos;
}
} }
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,18 +8,16 @@ import {ActivatedRoute, Router} from "@angular/router"; ...@@ -8,18 +8,16 @@ 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:Array<any>; curPageData: Array<any>;
type:any; type: any;
pageAnswers:any; pageAnswers: any;
nextBtn:boolean; nextBtn: boolean;
options:Array<any>; options: Array<any>;
selectedOptionId:any; questions: Array<any> = [];
questions:Array<any> = [];
constructor( constructor(private commonService: CommonService,
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: '',
...@@ -35,6 +33,7 @@ export class DiseaseComponent implements OnInit { ...@@ -35,6 +33,7 @@ export class DiseaseComponent implements OnInit {
this.nextBtn = false; this.nextBtn = false;
this.surveyInfo() this.surveyInfo()
} }
surveyInfo() { surveyInfo() {
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
if (res['success']) { if (res['success']) {
...@@ -46,28 +45,28 @@ export class DiseaseComponent implements OnInit { ...@@ -46,28 +45,28 @@ export class DiseaseComponent implements OnInit {
* 4:多口之家 * 4:多口之家
* @type {any} * @type {any}
*/ */
//过滤选项 // 过滤选项
if(this.type == 1){ if (this.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(this.type == 2){ if (this.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(this.type == 3){ if (this.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(this.type == 4){ if (this.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
}) })
} }
...@@ -75,31 +74,32 @@ export class DiseaseComponent implements OnInit { ...@@ -75,31 +74,32 @@ export class DiseaseComponent implements OnInit {
}) })
} }
getOneAnswer(option){ getOneAnswer(option) {
for(let i=0;i<this.options.length;i++){ for (let i = 0; i < this.options.length; i++) {
if(option['optionId']==this.options[i]['optionId']){ if (option['optionId'] == this.options[i]['optionId']) {
this.options[i]['selected'] = true; this.options[i]['selected'] = true;
}else{ } else {
this.options[i]['selected'] = false; this.options[i]['selected'] = false;
} }
} }
this.pageAnswers = { this.pageAnswers = {
pageId : this.curPageData['pageId'], pageId: this.curPageData['pageId'],
questions:[{ questions: [{
questionId: this.curPageData['questions']['0']['questionId'], questionId: this.curPageData['questions']['0']['questionId'],
questionName: this.curPageData['questions']['0']['questionName'], questionName: this.curPageData['questions']['0']['questionName'],
options:[option] options: [option]
}] }]
} }
this.commonService.addAnswer(this.pageAnswers) this.commonService.addAnswer(this.pageAnswers)
console.log(this.pageAnswers) // console.log(this.pageAnswers)
if(this.pageAnswers['questions'].length>0){ if (this.pageAnswers['questions'].length > 0) {
this.nextBtn = true this.nextBtn = true
}else{ } else {
this.nextBtn = false this.nextBtn = false
} }
} }
getManyAnswer(option){
getManyAnswer(option) {
option['selected'] = !option['selected']; option['selected'] = !option['selected'];
this.questions = []; this.questions = [];
for (let i = 0; i < this.curPageData['questions'][0]['options'].length; i++) { for (let i = 0; i < this.curPageData['questions'][0]['options'].length; i++) {
...@@ -126,26 +126,28 @@ export class DiseaseComponent implements OnInit { ...@@ -126,26 +126,28 @@ export class DiseaseComponent implements OnInit {
options: this.questions options: this.questions
}], }],
}; };
if(this.pageAnswers['questions'].length>0){ if (this.pageAnswers['questions'].length > 0) {
this.nextBtn = true this.nextBtn = true
}else{ } else {
this.nextBtn = false this.nextBtn = false
} }
console.log(this.pageAnswers) // console.log(this.pageAnswers)
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
} }
//根据type区分单选多选
checkFun(option){ // 根据type区分单选多选
if(this.type==1){ checkFun(option) {
if (this.type == 1) {
this.getOneAnswer(option) this.getOneAnswer(option)
}else{ } else {
this.getManyAnswer(option) this.getManyAnswer(option)
} }
} }
next(){
if(this.nextBtn == true){ next() {
this.router.navigate(['/smoke'],{queryParams:{type:this.type}}) if (this.nextBtn == true) {
}else{ this.router.navigate(['/smoke'], {queryParams: {type: this.type}})
} else {
return return
} }
} }
......
...@@ -42,7 +42,7 @@ export class FamilyComponent implements OnInit { ...@@ -42,7 +42,7 @@ export class FamilyComponent implements OnInit {
}], }],
}; };
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
console.log(this.pageAnswers) // console.log(this.pageAnswers)
} }
// 下一步 // 下一步
......
...@@ -53,7 +53,7 @@ export class HealthComponent implements OnInit { ...@@ -53,7 +53,7 @@ export class HealthComponent implements OnInit {
} else { } else {
this.curPageData = res['data'].survey.pages['11']; this.curPageData = res['data'].survey.pages['11'];
} }
console.log(this.curPageData) // console.log(this.curPageData)
} }
}) })
} }
......
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({
...@@ -8,26 +8,25 @@ import {ActivatedRoute, Router} from "@angular/router"; ...@@ -8,26 +8,25 @@ 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: Array<any> curPageData: Array<any>;
provinceList: Array<any> provinceList: Array<any>;
isShow: boolean isShow: boolean;
provinceId: number provinceId: number;
provinceName: string provinceName: string;
cityList: Array<any> cityList: Array<any>;
//页面是否显示地址 // 页面是否显示地址
showAddress: boolean showAddress: boolean;
//入参地址 // 入参地址
address: Object address: any;
//页面地址 // 页面地址
strAddress: string strAddress: string;
pageAnswers: any; pageAnswers: any;
type:any; type: any;
nextBtn:boolean; nextBtn: 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: '',
...@@ -44,17 +43,18 @@ export class LiveComponent implements OnInit { ...@@ -44,17 +43,18 @@ export class LiveComponent implements OnInit {
this.nextBtn = false; this.nextBtn = false;
this.showAddress = false; this.showAddress = false;
} }
surveyInfo() { surveyInfo() {
//获取问题 // 获取问题
this.commonService.surveyInfo().then(res => { this.commonService.surveyInfo().then(res => {
if (res['success']) { if (res['success']) {
this.curPageData = res['data']['survey'].pages['15'] this.curPageData = res['data']['survey'].pages['15'];
} }
}) })
//获取省份 // 获取省份
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;
} }
}) })
} }
...@@ -65,19 +65,20 @@ export class LiveComponent implements OnInit { ...@@ -65,19 +65,20 @@ export class LiveComponent implements OnInit {
selectProvince(option) { selectProvince(option) {
// console.log(this.selectedProvinceObj) // 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++) {
if(option['provinceId']==this.provinceList[i]['provinceId']){ if (option['provinceId'] == this.provinceList[i]['provinceId']) {
this.provinceList[i]['selected'] = true; this.provinceList[i]['selected'] = true;
}else{ } else {
this.provinceList[i]['selected'] = false; this.provinceList[i]['selected'] = false;
} }
} }
this.getCityqry() this.getCityqry();
} }
closeToast() { closeToast() {
this.isShow = false this.isShow = false;
} }
getCityqry() { getCityqry() {
...@@ -87,18 +88,18 @@ export class LiveComponent implements OnInit { ...@@ -87,18 +88,18 @@ export class LiveComponent implements OnInit {
} }
this.commonService.getCityqry(param).then(res => { this.commonService.getCityqry(param).then(res => {
if (res['success']) { if (res['success']) {
this.cityList = res['data'].cityList this.cityList = res['data'].cityList;
// console.log(this.cityList) // console.log(this.cityList)
} }
}) })
} }
selectCity(e) { selectCity(e) {
this.showAddress = true this.showAddress = true;
this.strAddress = this.provinceName + e.cityName this.strAddress = this.provinceName + e.cityName;
this.address = { this.address = {
customerInput: this.provinceName + ',' + e.cityName customerInput: this.provinceName + ',' + e.cityName
} };
this.pageAnswers = { this.pageAnswers = {
pageId: this.curPageData['pageId'], pageId: this.curPageData['pageId'],
questions: [{ questions: [{
...@@ -107,19 +108,19 @@ export class LiveComponent implements OnInit { ...@@ -107,19 +108,19 @@ export class LiveComponent implements OnInit {
options: [this.address] options: [this.address]
}], }],
}; };
this.commonService.addAnswer(this.pageAnswers) this.commonService.addAnswer(this.pageAnswers);
if(this.pageAnswers['questions'].length>0){ if (this.pageAnswers['questions'].length > 0) {
this.nextBtn = true this.nextBtn = true;
}else{ } else {
this.nextBtn = false this.nextBtn = false;
} }
console.log(this.pageAnswers) // console.log(this.pageAnswers);
} }
next(){ next() {
if(this.nextBtn == true){ if (this.nextBtn == true) {
this.router.navigate(['/transit3']) this.router.navigate(['/transit3']);
}else{ } else {
return; return;
} }
} }
......
...@@ -33,15 +33,15 @@ export class LoanComponent implements OnInit { ...@@ -33,15 +33,15 @@ export class LoanComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.nextBtn = false; this.nextBtn = false;
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['7'] this.curPageData = res['data']['survey'].pages['7'];
this.pageAnswers.pageId = this.curPageData['pageId']; this.pageAnswers.pageId = this.curPageData['pageId'];
console.log(this.curPageData) // console.log(this.curPageData);
} }
}) })
} }
......
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,18 +8,16 @@ import {ActivatedRoute, Router} from "@angular/router"; ...@@ -8,18 +8,16 @@ 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:Array<any>; curPageData: Array<any>;
type:any; type: any;
nextBtn:boolean; nextBtn: boolean;
pageAnswers:any; pageAnswers: any;
options:Array<any>; options: Array<any>;
questions:Array<any> = []; questions: Array<any> = [];
constructor( constructor(private commonService: CommonService,
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: '',
...@@ -33,12 +31,13 @@ export class SmokingComponent implements OnInit { ...@@ -33,12 +31,13 @@ export class SmokingComponent implements OnInit {
ngOnInit() { ngOnInit() {
this.nextBtn = false; this.nextBtn = false;
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['14'] this.curPageData = res['data']['survey'].pages['14'];
/** /**
* 1:单身贵族 * 1:单身贵族
* 2:二人世界 * 2:二人世界
...@@ -47,60 +46,60 @@ export class SmokingComponent implements OnInit { ...@@ -47,60 +46,60 @@ export class SmokingComponent implements OnInit {
* @type {any} * @type {any}
*/ */
//过滤选项 //过滤选项
if(this.type == 1){ if (this.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;
}) })
} }
if(this.type == 2){ if (this.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 == 114 || option.optionId == 115 || option.optionId == 117 return option.optionId == 114 || option.optionId == 115 || option.optionId == 117;
}) })
} }
if(this.type == 3){ if (this.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 == 114 || option.optionId == 116 || option.optionId == 117 return option.optionId == 114 || option.optionId == 116 || option.optionId == 117;
}) })
} }
if(this.type == 4){ if (this.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 == 114 || option.optionId == 115 || option.optionId == 116 || option.optionId == 117 return option.optionId == 114 || option.optionId == 115 || option.optionId == 116 || option.optionId == 117;
}) })
} }
} }
}) })
} }
getOneAnswer(option){ getOneAnswer(option) {
for(let i=0;i<this.options.length;i++){ for (let i = 0; i < this.options.length; i++) {
if(option['optionId']==this.options[i]['optionId']){ if (option['optionId'] == this.options[i]['optionId']) {
this.options[i]['selected'] = true; this.options[i]['selected'] = true;
}else{ } else {
this.options[i]['selected'] = false; this.options[i]['selected'] = false;
} }
} }
this.pageAnswers = { this.pageAnswers = {
pageId : this.curPageData['pageId'], pageId: this.curPageData['pageId'],
questions:[{ questions: [{
questionId: this.curPageData['questions']['0']['questionId'], questionId: this.curPageData['questions']['0']['questionId'],
questionName: this.curPageData['questions']['0']['questionName'], questionName: this.curPageData['questions']['0']['questionName'],
options:[option] options: [option]
}] }]
} }
this.commonService.addAnswer(this.pageAnswers) this.commonService.addAnswer(this.pageAnswers);
console.log(this.pageAnswers) // console.log(this.pageAnswers);
if(this.pageAnswers['questions'].length>0){ if (this.pageAnswers['questions'].length > 0) {
this.nextBtn = true this.nextBtn = true;
}else{ } else {
this.nextBtn = false this.nextBtn = false;
} }
} }
getManyAnswer(option){ getManyAnswer(option) {
option['selected'] = !option['selected']; option['selected'] = !option['selected'];
this.questions = []; this.questions = [];
for (let i = 0; i < this.curPageData['questions'][0]['options'].length; i++) { for (let i = 0; i < this.curPageData['questions'][0]['options'].length; i++) {
...@@ -127,27 +126,27 @@ export class SmokingComponent implements OnInit { ...@@ -127,27 +126,27 @@ export class SmokingComponent implements OnInit {
options: this.questions options: this.questions
}], }],
}; };
if(this.pageAnswers['questions'].length>0){ if (this.pageAnswers['questions'].length > 0) {
this.nextBtn = true this.nextBtn = true;
}else{ } else {
this.nextBtn = false this.nextBtn = false;
} }
console.log(this.pageAnswers) // console.log(this.pageAnswers);
this.commonService.addAnswer(this.pageAnswers); this.commonService.addAnswer(this.pageAnswers);
} }
checkFun(option){ checkFun(option) {
if(this.type==1){ if (this.type == 1) {
this.getOneAnswer(option) this.getOneAnswer(option);
}else{ } else {
this.getManyAnswer(option) this.getManyAnswer(option);
} }
} }
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;
} }
} }
......
...@@ -33,7 +33,7 @@ export class SocialSecurityComponent implements OnInit { ...@@ -33,7 +33,7 @@ export class SocialSecurityComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
this.surveyInfo() this.surveyInfo();
// 判断家庭决定是否显示配偶 // 判断家庭决定是否显示配偶
if (this.type == 2 || this.type == 4) { if (this.type == 2 || this.type == 4) {
this.hasMate = true; this.hasMate = true;
...@@ -48,7 +48,7 @@ export class SocialSecurityComponent implements OnInit { ...@@ -48,7 +48,7 @@ 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'];
console.log(this.curPageData) // console.log(this.curPageData)
} }
}) })
} }
...@@ -60,7 +60,6 @@ export class SocialSecurityComponent implements OnInit { ...@@ -60,7 +60,6 @@ export class SocialSecurityComponent implements OnInit {
questionName: question.questionName, questionName: question.questionName,
options: [] options: []
}; };
console.log(questions)
if (question['options'].length > 0) { if (question['options'].length > 0) {
for (let j = 0; j < question['options'].length; j++) { for (let j = 0; j < question['options'].length; j++) {
if (question['options'][j].optionId == option.optionId) { if (question['options'][j].optionId == option.optionId) {
......
import { Component, OnInit } from '@angular/core'; import {Component, OnInit} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
@Component({ @Component({
...@@ -7,18 +7,18 @@ import {ActivatedRoute, Router} from "@angular/router"; ...@@ -7,18 +7,18 @@ import {ActivatedRoute, Router} from "@angular/router";
styleUrls: ['./transit2.component.css'] styleUrls: ['./transit2.component.css']
}) })
export class Transit2Component implements OnInit { export class Transit2Component implements OnInit {
//家庭结构 // 家庭结构
type:any; type: any;
constructor(
private router: Router, constructor(private router: Router,
private route: ActivatedRoute) { private route: ActivatedRoute) {
this.type = this.route.snapshot.queryParams['type']; this.type = this.route.snapshot.queryParams['type'];
} }
ngOnInit() { ngOnInit() {
} }
next(){ next() {
this.router.navigate(['/health'],{queryParams:{type:this.type}}) this.router.navigate(['/health'], {queryParams: {type: this.type}});
} }
} }
import { Component, OnInit } from '@angular/core'; import {Component, OnInit} from '@angular/core';
@Component({ @Component({
selector: 'app-transit3', selector: 'app-transit3',
...@@ -7,11 +7,13 @@ import { Component, OnInit } from '@angular/core'; ...@@ -7,11 +7,13 @@ import { Component, OnInit } from '@angular/core';
}) })
export class Transit3Component implements OnInit { export class Transit3Component implements OnInit {
constructor() { } constructor() {
}
ngOnInit() { ngOnInit() {
} }
getHref(){
window.location.href = 'https://' + window.location.host+ '/member' getHref() {
window.location.href = 'https://' + window.location.host + '/member';
} }
} }
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