Commit e2a5c230 by Sweet Zhang

格式化代码

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