Commit b109bbab by Sweet Zhang

问卷感谢页增加二维码

parent 448d231c
# Editor configuration, see https://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc
# Only exists if Bazel was run
/bazel-out
# dependencies
/node_modules
# profiling files
chrome-profiler-events.json
speed-measure-plugin.json
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db
# Questionnair
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.3.8.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"questionnair": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/questionnaire",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
],
"scripts": [],
"es5BrowserSupport": true,
"baseHref": "/questionnaire/",
"deployUrl": "/questionnaire/"
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"dev": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
},
"stage": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.stage.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "questionnair:build"
},
"configurations": {
"production": {
"browserTarget": "questionnair:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "questionnair:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
],
"scripts": [],
"assets": [
"src/favicon.ico",
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"questionnair-e2e": {
"root": "e2e/",
"projectType": "application",
"prefix": "",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "questionnair:serve"
},
"configurations": {
"production": {
"devServerTarget": "questionnair:serve:production"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "questionnair"
}
\ No newline at end of file
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
\ No newline at end of file
import { AppPage } from './app.po';
import { browser, logging } from 'protractor';
describe('workspace-project App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', () => {
page.navigateTo();
expect(page.getTitleText()).toEqual('Welcome to questionnair!');
});
afterEach(async () => {
// Assert that there are no errors emitted from the browser
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
expect(logs).not.toContain(jasmine.objectContaining({
level: logging.Level.SEVERE,
} as logging.Entry));
});
});
import { browser, by, element } from 'protractor';
export class AppPage {
navigateTo() {
return browser.get(browser.baseUrl) as Promise<any>;
}
getTitleText() {
return element(by.css('app-root h1')).getText() as Promise<string>;
}
}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "commonjs",
"target": "es5",
"types": [
"jasmine",
"jasminewd2",
"node"
]
}
}
\ No newline at end of file
{
"name": "questionnair",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~7.2.0",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"angular-in-memory-web-api": "^0.8.0",
"bootstrap": "^3.4.1",
"core-js": "^2.5.4",
"ngx-bootstrap": "^4.1.1",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.13.9",
"@angular/cli": "~7.3.8",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "~7.2.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2"
}
}
import { NgModule } from '@angular/core'
import { CommonModule } from '@angular/common'
import { RouterModule, Routes } from '@angular/router'
import { AskComponent } from './ask/ask.component'
const routes: Routes = [
{
path: '',
redirectTo: '/index',
pathMatch: 'full'
},
{
path: 'index',
component: AskComponent
}
]
@NgModule({
declarations: [],
imports: [CommonModule, RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule {}
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
}).compileComponents();
}));
it('should create the app', () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
});
it(`should have as title 'questionnair'`, () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('questionnair');
});
it('should render title in a h1 tag', () => {
const fixture = TestBed.createComponent(AppComponent);
fixture.detectChanges();
const compiled = fixture.debugElement.nativeElement;
expect(compiled.querySelector('h1').textContent).toContain('Welcome to questionnair!');
});
});
import { Component } from '@angular/core';
import { CommonService} from './common.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor(
private commonService:CommonService,
) {
}
}
import { BrowserModule } from '@angular/platform-browser'
import { NgModule } from '@angular/core'
import { AppComponent } from './app.component'
import { AskComponent } from './ask/ask.component'
import { AppRoutingModule } from './app-routing.module'
import { HttpClientModule } from '@angular/common/http'
import { CommonService } from './common.service'
import { LocalStorage } from './local.storage'
import { Page1Component } from './page1/page1.component'
import { Page2Component } from './page2/page2.component'
import { Page3Component } from './page3/page3.component'
import { Page4Component } from './page4/page4.component'
import { Page5Component } from './page5/page5.component'
import { Page6Component } from './page6/page6.component'
import { Page7Component } from './page7/page7.component'
import { Page8Component } from './page8/page8.component'
import { Page9Component } from './page9/page9.component'
import { Page10Component } from './page10/page10.component'
import { Page11Component } from './page11/page11.component'
import { Page12Component } from './page12/page12.component'
import { Page13Component } from './page13/page13.component'
import { Page14Component } from './page14/page14.component'
import { Page15Component } from './page15/page15.component'
import { Page16Component } from './page16/page16.component'
import { Page17Component } from './page17/page17.component'
import {HashLocationStrategy, LocationStrategy} from '@angular/common';
@NgModule({
declarations: [
AppComponent,
AskComponent,
Page1Component,
Page2Component,
Page3Component,
Page4Component,
Page5Component,
Page6Component,
Page7Component,
Page8Component,
Page9Component,
Page10Component,
Page11Component,
Page12Component,
Page13Component,
Page14Component,
Page15Component,
Page16Component,
Page17Component
],
imports: [BrowserModule, AppRoutingModule, HttpClientModule],
providers: [CommonService, LocalStorage,{provide: LocationStrategy, useClass: HashLocationStrategy}],
bootstrap: [AppComponent]
})
export class AppModule {}
<div class="container">
<div class="wrapper layout">
<!-- {{curPage}} -->
<app-page1 [curPageData]="curPageData" *ngIf="curPage == 0"></app-page1>
<app-page2
[curPageData]="curPageData"
*ngIf="curPage == 1"
(getAllAnswer)="getAllAnswer($event)"
></app-page2>
<app-page3
[curPageData]="curPageData"
*ngIf="curPage == 2"
(getAllAnswer)="getAllAnswer($event)"
[isShowChildAgeBtn]="isShowChildAgeBtn"
></app-page3>
<app-page4
[curPageData]="curPageData"
*ngIf="curPage == 3"
(getAllAnswer)="getAllAnswer($event)"
></app-page4>
<app-page5
[curPageData]="curPageData"
*ngIf="curPage == 4"
(getAllAnswer)="getAllAnswer($event)"
></app-page5>
<!--过渡页-->
<app-page6 [curPageData]="curPageData" *ngIf="curPage == 5"> </app-page6>
<app-page7
[curPageData]="curPageData"
*ngIf="curPage == 6"
(getAllAnswer)="getAllAnswer($event)"
[hasMate]="hasMate"
></app-page7>
<app-page8
[curPageData]="curPageData"
*ngIf="curPage == 7"
(getAllAnswer)="getAllAnswer($event)"
></app-page8>
<app-page9
[curPageData]="curPageData"
*ngIf="curPage == 8"
(getAllAnswer)="getAllAnswer($event)"
[hasMate]="hasMate"
></app-page9>
<app-page10 [curPageData]="curPageData" *ngIf="curPage == 9"></app-page10>
<app-page11
[curPageData]="curPageData"
*ngIf="curPage == 10"
(getAllAnswer)="getAllAnswer($event)"
></app-page11>
<app-page12
[curPageData]="curPageData"
*ngIf="curPage == 11"
(getAllAnswer)="getAllAnswer($event)"
></app-page12>
<app-page13
[curPageData]="curPageData"
*ngIf="curPage == 12"
(getAllAnswer)="getAllAnswer($event)"
></app-page13>
<app-page14
[curPageData]="curPageData"
*ngIf="curPage == 13"
(getAllAnswer)="getAllAnswer($event)"
></app-page14>
<app-page15
[curPageData]="curPageData"
*ngIf="curPage == 14"
(getAllAnswer)="getAllAnswer($event)"
></app-page15>
<app-page16
[curPageData]="curPageData"
*ngIf="curPage == 15"
(getAllAnswer)="getAllAnswer($event)"
[provinceList] = "provinceList"
></app-page16>
<app-page17 [curPageData]="curPageData" *ngIf="curPage == 16"></app-page17>
<div class="footer" *ngIf="curPage == 0" (click)="addPage()">
<div>获取家庭分析报告</div>
</div>
<div class="content_footer" *ngIf="curPage != 0 && curPage!=16">
<div (click)="reducePage()" style="color: #8a8a8a;">&lt;</div>
<div
(click)="addPage()"
[ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }"
>下一步</div>
</div>
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AskComponent } from './ask.component';
describe('AskComponent', () => {
let component: AskComponent;
let fixture: ComponentFixture<AskComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AskComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AskComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core'
import { CommonService } from '../common.service'
import { Options } from 'selenium-webdriver/chrome'
@Component({
selector: 'app-ask',
templateUrl: './ask.component.html',
styleUrls: ['./ask.component.css']
})
export class AskComponent implements OnInit {
allQues: Array<any>;
curPage: number;
totalPage: number;
curQues: string;
curPageData: Object;
allAnswers: Array<any>;
isShowChildAgeBtn: boolean;
hasMate: boolean;
//获取省份
provinceList: Array<any>;
nextBtn:boolean;
// 暂存问题也信息
questionInfo:any;
constructor(private commonService: CommonService) {}
ngOnInit() {
this.curPage = 0
this.totalPage = 17
this.curPageData = []
this.allAnswers = []
this.isShowChildAgeBtn = true
this.hasMate = true
this.surveyInfo()
}
surveyInfo() {
this.commonService.surveyInfo().then(res => {
if (res['success']) {
this.allQues = res['data']['survey'].pages
this.curPageData = this.allQues[this.curPage]
}
})
this.commonService.provinceqry({ insurerId: 11 }).then(res => {
if (res['success']) {
this.provinceList = res['data'].provinceList
}
})
}
reducePage() {
if (this.curPage > 0) {
const page2Answer = this.allAnswers[1]
if(page2Answer){
const optionId = page2Answer.questions[0].options[0].optionId
if (this.curPage == 5 || this.curPage == 6) {
if (optionId == 1 || optionId == 3) {
this.curPage = this.curPage - 2
this.setCurPageData()
return
}
}
if (this.curPage == 13) {
if (optionId == 1) {
this.curPage = this.curPage - 3
this.setCurPageData()
return
}
if (optionId == 2) {
this.curPage = this.curPage - 2
this.setCurPageData()
return
}
}
if (this.curPage == 12) {
if (optionId == 3) {
this.curPage = this.curPage - 2
this.setCurPageData()
return
}
}
}
this.curPage--;
this.setCurPageData()
} else {
return
}
}
filterItems() {
return this.allAnswers.filter(item => {
return item != null
})
}
addPage() {
if(this.nextBtn===false){
return;
}
if(this.questionInfo){
this.allAnswers[this.curPage] = this.questionInfo;
this.questionInfo = null
}
if (this.curPage < 16) {
//判断当前页是否有答案
if (
this.curPage == 0 ||
this.allAnswers[this.curPage] ||
this.curPage == 5 ||
this.curPage == 9
) {
this.curPage++
this.setCurPageData()
}
} else {
this.curPage = 0
return
}
const answerParam = {
survey: {
customerId: this.commonService.getQueryString('customerId'),
orderId: this.commonService.getQueryString('orderId'),
pages: this.filterItems()
}
}
if (this.curPage == 16) {
this.commonService.saveCustomerAnwers(answerParam).then(res => {
})
}
}
getAllAnswer(e) {
this.questionInfo = e;
// console.log(e)
// debugger;
const page2Answer = this.allAnswers[1]
//判断当前问题长度和当前回答长度
if(this.curPageData['questions'].length == e['questions'].length){
for(let i=0;i<e['questions'].length;i++){
if(e['questions'][i]['options'].length>0){
if(this.curPage==15){
this.nextBtn = true
}else{
for(let j=0;j<e['questions'][i]['options'].length;j++){
if(!e['questions'][i]['options'][j]['optionId']){
this.nextBtn = false
}else{
this.nextBtn = true
}
}
}
}
}
}else{
//如果问题长度和答案长度不一样时判断问题页中是否配偶问题不显示
if(this.curPage == 6 || this.curPage == 8){
const optionId = page2Answer.questions[0].options[0].optionId
if(optionId==1 || optionId==3){
if(e['questions'].length>0){
this.nextBtn = true
}
}
}else{
this.nextBtn = false;
}
}
}
setCurPageData() {
const thePateData = this.allQues[this.curPage]
this.curPageData = thePateData
const page2Answer = this.allAnswers[1]
if (this.curPage == 2) {
this.filterPage2(
page2Answer.questions[0].options[0].optionId,
thePateData
)
}
//第4页
if (this.curPage == 4) {
this.filterPage5(
page2Answer.questions[0].options[0].optionId,
thePateData
)
}
if (this.curPage == 11) {
this.filterPage12(
page2Answer.questions[0].options[0].optionId,
thePateData
)
}
if (this.curPage == 12) {
this.filterPage13(
page2Answer.questions[0].options[0].optionId,
thePateData
)
}
if (this.curPage == 13) {
this.filterPage14(
page2Answer.questions[0].options[0].optionId,
this.allQues[this.curPage]
)
}
if (this.curPage == 14) {
this.filterPage15(
page2Answer.questions[0].options[0].optionId,
this.allQues[this.curPage]
)
}
if (this.curPage < 16) {
//判断当前页是否有答案
if (
this.curPage == 0 ||
this.allAnswers[this.curPage] ||
this.curPage == 5 ||
this.curPage == 9
) {
this.nextBtn = true;
}else{
this.nextBtn = false;
}
}
}
filterPage2(optionId, thePateData) {
//判断第二页选择家庭1单身2二人3独立带娃4多口
if (optionId == 1 || optionId == 2) {
this.isShowChildAgeBtn = false
} else {
this.isShowChildAgeBtn = true
}
//判断页面是否有配偶选项
if (optionId == 1 || optionId == 3) {
this.hasMate = false
} else {
this.hasMate = true
}
//单身贵族->您的年龄
if (optionId == 1) {
this.curPageData = {
...thePateData,
questions: thePateData.questions.filter(question => {
return question.questionId == 2
})
}
return
}
//二人世界->您的年龄&配偶年龄
if (optionId == 2) {
this.curPageData = {
...thePateData,
questions: thePateData.questions.filter(question => {
return question.questionId <= 3
})
}
return
}
//单亲->您的年龄&孩子年龄
if (optionId == 3) {
this.curPageData = {
...thePateData,
questions: thePateData.questions.filter(question => {
return question.questionId == 2 || question.questionId == 4
})
}
}
}
filterPage5(optionId, thePateData) {
//page5判断是否显示配偶工作页
//1单身 3单亲
if (optionId == 1 || optionId == 3) {
this.curPage++
this.curPageData = this.allQues[this.curPage]
}
}
//pege12判断是否显示配偶健康
filterPage12(optionId, thePateData) {
if (optionId == 1 || optionId == 3) {
this.curPage++
this.curPageData = this.allQues[this.curPage]
}
}
//page13判断是否显示孩子健康
filterPage13(optionId, thePateData) {
//单身或二人世界
if (optionId == 1 || optionId == 2) {
this.curPage++
}
}
//page14判断是否住院option内容
filterPage14(optionId, thePateData) {
//如果单身或者单亲选择相中没有配偶选项
//传一个optionType告诉子页面是单选还是多选1表示单选2表示多选
if (optionId == 1) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
optionType: 1,
options: thePateData.questions[0]['options'].filter(option => {
return option.optionId == 106 || option.optionId == 107
})
}
]
}
}
if (optionId == 2) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
optionType: 2,
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 108 ||
option.optionId == 109 ||
option.optionId == 111
)
})
}
]
}
}
if (optionId == 3) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
optionType: 2,
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 108 ||
option.optionId == 110 ||
option.optionId == 111
)
})
}
]
}
}
if (optionId == 4) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
optionType: 2,
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 108 ||
option.optionId == 109 ||
option.optionId == 110 ||
option.optionId == 111
)
})
}
]
}
}
}
//判断是否吸烟option内容
filterPage15(optionId, thePateData) {
//如果单身或者单亲选择相中没有配偶选项
//传一个optionType告诉子页面是单选还是多选1表示单选2表示多选
if (optionId == 1) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
optionType: 1,
options: thePateData.questions[0]['options'].filter(option => {
return option.optionId == 112 || option.optionId == 113
})
}
]
}
}
if (optionId == 2) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
optionType: 2,
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 114 ||
option.optionId == 115 ||
option.optionId == 117
)
})
}
]
}
}
if (optionId == 3) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
optionType: 2,
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 114 ||
option.optionId == 116 ||
option.optionId == 117
)
})
}
]
}
}
if (optionId == 4) {
this.curPageData = {
...thePateData,
questions: [
{
...thePateData.questions[0],
optionType: 2,
options: thePateData.questions[0]['options'].filter(option => {
return (
option.optionId == 114 ||
option.optionId == 115 ||
option.optionId == 116 ||
option.optionId == 117
)
})
}
]
}
}
}
}
import { TestBed } from '@angular/core/testing';
import { CommonService } from './common.service';
describe('CommonService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: CommonService = TestBed.get(CommonService);
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import {environment} from './../environments/environment';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {LocalStorage} from './local.storage';
@Injectable({
providedIn: 'root'
})
export class CommonService {
private USER_API_URL = '';
private httpOptions;
constructor(private http: HttpClient,
private ls: LocalStorage
) {
this.USER_API_URL = environment.apiUrl;
this.httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'X-Authorization': ''
})
};
}
async surveyInfo() {
const url = this.USER_API_URL + '/survey/surveyInfo';
const res = await this.obtainToken();
this.httpOptions.headers = this.httpOptions.headers.set('X-Authorization', res['data']['token']);
return this.http
.post(url, JSON.stringify({}),this.httpOptions).toPromise().then(response => {
return response;
});
}
async saveCustomerAnwers(objParam){
const url = this.USER_API_URL + '/survey/saveCustomerAnwers';
const res = await this.obtainToken();
this.httpOptions.headers = this.httpOptions.headers.set('X-Authorization', res['data']['token']);
return this.http
.post(url, JSON.stringify(objParam),this.httpOptions).toPromise().then(response => {
return response;
});
}
/**
* 获取TOKEN
*/
obtainToken() {
const url = this.USER_API_URL + '/authorize/obtainToken';
const ticketObj = {
ticket: 'questionnair'
};
return this.http.post(url, JSON.stringify(ticketObj), this.httpOptions).toPromise();
}
async provinceqry(objParam){
const url = this.USER_API_URL + '/partner/provinceqry';
const res = await this.obtainToken();
this.httpOptions.headers = this.httpOptions.headers.set('X-Authorization', res['data']['token']);
return this.http.post(url,JSON.stringify(objParam),this.httpOptions).toPromise().then(res => {
return res;
})
}
async getCityqry(objParam){
const url = this.USER_API_URL + '/partner/cityqry';
const res = await this.obtainToken();
this.httpOptions.headers = this.httpOptions.headers.set('X-Authorization', res['data']['token']);
return this.http
.post(url,JSON.stringify(objParam),this.httpOptions)
.toPromise().then(res => {
return res;
})
}
getQueryString(name) {
const after = window.location.hash.split('?')[1];
if (after) {
const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
const r = after.match(reg);
if (r != null) {
return decodeURIComponent(r[2]);
} else {
return null;
}
}
}
}
import { TestBed } from '@angular/core/testing';
import { DataService } from './data.service';
describe('DataService', () => {
beforeEach(() => TestBed.configureTestingModule({}));
it('should be created', () => {
const service: DataService = TestBed.get(DataService);
expect(service).toBeTruthy();
});
});
import { Injectable } from '@angular/core';
import {Subject} from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class DataService {
private dataSource = new Subject<any>();
answerList$ = this.dataSource.asObservable();
answerList: Array<any> = []; // 选择结果列表
pageId:number;
constructor() { }
// 添加answer
addAnswer(todo) {
if (this.answerList.length > 0) {
this.pageId = this.answerList[this.answerList.length - 1].id;
} else {
this.pageId = 0;
}
if (!todo.id) {
todo.id = ++this.pageId;
}
this.answerList.push(todo);
this.dataSource.next(this.answerList);
return this;
}
getAnswer() {
return this.answerList;
}
}
/**
* Created by Jerold Chen on 2018/4/13.
*/
export class LocalStorage {
public localStorage: any;
constructor() {
if (!localStorage) {
throw new Error('Current browser does not support Local Storage');
}
this.localStorage = localStorage;
}
public set(key: string, value: string): void {
this.localStorage[key] = value;
}
public get(key: string): string {
return this.localStorage[key] || false;
}
public setObject(key: string, value: any): void {
this.localStorage[key] = JSON.stringify(value);
}
public getObject(key: string): any {
return JSON.parse(this.localStorage[key] || '{}');
}
public remove(key: string): any {
this.localStorage.removeItem(key);
}
}
<div class="limbo">
<div class="title">
<img src="assets/images/bg_1.png" />
</div>
<div class="tips">
<span style="color:red;">*</span>
<span>本测试大约需要1分钟</span>
</div>
<!-- <div class="footer" routerLink="/question1">
<div>获取家庭分析报告</div>
</div> -->
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page1Component } from './page1.component';
describe('Page1Component', () => {
let component: Page1Component;
let fixture: ComponentFixture<Page1Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page1Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page1Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input } from '@angular/core'
@Component({
selector: 'app-page1',
templateUrl: './page1.component.html',
styleUrls: ['./page1.component.css']
})
export class Page1Component implements OnInit {
@Input() curPageData: Array<any>
constructor() {}
ngOnInit() {}
}
<div class="limbo">
<div class="title">
<img src="assets/images/bg_10.png" />
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page10Component } from './page10.component';
describe('Page10Component', () => {
let component: Page10Component;
let fixture: ComponentFixture<Page10Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page10Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page10Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input } from '@angular/core'
@Component({
selector: 'app-page10',
templateUrl: './page10.component.html',
styleUrls: ['./page10.component.css']
})
export class Page10Component implements OnInit {
@Input() curPageData: Array<any>
constructor() {}
ngOnInit() {
}
}
<div class="container">
<div class="layout">
<div class="content">
<div class="questionTitle">
{{ this.curPageData['questions'][0]['questionName'] }}
</div>
<ul class="jobContent">
<li
*ngFor="let options of this.curPageData['questions'][0]['options']"
[ngClass]="{ selected: options['selected'] == true }"
(click)="getAnswer(options)"
>
{{ options.optionName }}
</li>
</ul>
</div>
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page11Component } from './page11.component';
describe('Page11Component', () => {
let component: Page11Component;
let fixture: ComponentFixture<Page11Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page11Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page11Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
@Component({
selector: 'app-page11',
templateUrl: './page11.component.html',
styleUrls: ['./page11.component.css']
})
export class Page11Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
// allOption: object
allOptions: Array<any>
constructor() {}
ngOnInit() {
// this.allOption = {}
this.allOptions = []
// console.log(this.curPageData)
this.getAlloptions()
}
getAnswer(options) {
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
// 更改问题状态,防止重复往数组push
if (options['optionId'] == this.allOptions[i]['optionId']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
}
}
this.allOptions.push(options)
for (let i = 0; i < this.allOptions.length; i++) {
let index;
// 当选中无疾病时
if(options['optionId']==67 && options['selected']==true){
index = this.allOptions.indexOf(options);
this.allOptions[i]['selected'] = false;
if(index > -1){
this.allOptions[index]['selected'] = true;
}
}else{
// 选中其他疾病时,无疾病状态改为false
if(this.allOptions[i]['optionId']==67){
this.allOptions[i]['selected'] = false;
}
}
}
const ret = {
// ...this.curPageData,
pageId: this.curPageData['pageId'],
questions: [
{
...this.curPageData['questions'][0],
questionId: this.curPageData['questions'][0].questionId,
options: this.filterItems()
}
]
}
this.getAllAnswer.emit(ret)
}
filterItems() {
return this.allOptions.filter(item=> {
return item['selected']==true;
})
}
getAlloptions(){
const questions = this.curPageData['questions']
if(!questions){
return
}
questions[0]['options'].forEach(option => {
if(option['selected']){
this.allOptions.push(option);
const ret = {
// ...this.curPageData,
pageId: this.curPageData['pageId'],
questions: [
{
...this.curPageData['questions'][0],
questionId: this.curPageData['questions'][0].questionId,
options: this.filterItems()
}
]
}
this.getAllAnswer.emit(ret)
}
});
}
}
<div class="container">
<div class="layout">
<div class="content">
<div class="questionTitle">
{{ this.curPageData['questions'][0]['questionName'].substring(0, 1) }}
<span>
{{
this.curPageData['questions'][0]['questionName'].substring(1, 3)
}}</span
>
{{ this.curPageData['questions'][0]['questionName'].substring(3, 8) }}
</div>
<ul class="jobContent">
<li
*ngFor="let options of this.curPageData['questions'][0]['options']"
[ngClass]="{ selected: options['selected'] == true }"
(click)="getAnswer(options)"
>
{{ options.optionName }}
</li>
</ul>
</div>
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page12Component } from './page12.component';
describe('Page12Component', () => {
let component: Page12Component;
let fixture: ComponentFixture<Page12Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page12Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page12Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
@Component({
selector: 'app-page12',
templateUrl: './page12.component.html',
styleUrls: ['./page12.component.css']
})
export class Page12Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
allOptions: Array<any>
constructor() {}
ngOnInit() {
this.allOptions = []
this.getAlloptions()
}
getAnswer(options) {
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
// 更改问题状态,防止重复往数组push
if (options['optionId'] == this.allOptions[i]['optionId']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
}
}
this.allOptions.push(options)
for (let i = 0; i < this.allOptions.length; i++) {
let index;
// 当选中无疾病时
if(options['optionId']==83 && options['selected']==true){
index = this.allOptions.indexOf(options);
this.allOptions[i]['selected'] = false;
if(index > -1){
this.allOptions[index]['selected'] = true;
}
}else{
// 选中其他疾病时,无疾病状态改为false
if(this.allOptions[i]['optionId']==83){
this.allOptions[i]['selected'] = false;
}
}
}
const ret = {
// ...this.curPageData,
pageId: this.curPageData['pageId'],
questions: [
{
...this.curPageData['questions'][0],
questionId: this.curPageData['questions'][0].questionId,
options: this.filterItems()
}
]
}
this.getAllAnswer.emit(ret)
}
filterItems() {
return this.allOptions.filter(item=> {
return item['selected']==true;
})
}
getAlloptions(){
const questions = this.curPageData['questions']
if(!questions){
return
}
questions[0]['options'].forEach(option => {
if(option['selected']){
this.allOptions.push(option);
const ret = {
// ...this.curPageData,
pageId: this.curPageData['pageId'],
questions: [
{
...this.curPageData['questions'][0],
questionId: this.curPageData['questions'][0].questionId,
options: this.filterItems()
}
]
}
this.getAllAnswer.emit(ret)
}
});
}
}
<div class="container">
<div class="layout">
<div class="content">
<div class="questionTitle">
{{ this.curPageData['questions'][0]['questionName'] }}
</div>
<ul class="jobContent">
<li
class="selected"
*ngFor="let options of this.curPageData['questions'][0]['options']"
[ngClass]="{ selected: options['selected'] == true }"
(click)="getAnswer(options)"
>
{{ options.optionName }}
</li>
</ul>
</div>
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page13Component } from './page13.component';
describe('Page13Component', () => {
let component: Page13Component;
let fixture: ComponentFixture<Page13Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page13Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page13Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
@Component({
selector: 'app-page13',
templateUrl: './page13.component.html',
styleUrls: ['./page13.component.css']
})
export class Page13Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
allOptions: Array<any>
constructor() {}
ngOnInit() {
this.allOptions = []
this.getAlloptions()
}
getAnswer(options) {
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
// 更改问题状态,防止重复往数组push
if (options['optionId'] == this.allOptions[i]['optionId']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
}
}
this.allOptions.push(options)
for (let i = 0; i < this.allOptions.length; i++) {
let index;
// 当选中无疾病时
if(options['optionId']==99 && options['selected']==true){
index = this.allOptions.indexOf(options);
this.allOptions[i]['selected'] = false;
if(index > -1){
this.allOptions[index]['selected'] = true;
}
}else{
// 选中其他疾病时,无疾病状态改为false
if(this.allOptions[i]['optionId']==99){
this.allOptions[i]['selected'] = false;
}
}
}
const ret = {
// ...this.curPageData,
pageId: this.curPageData['pageId'],
questions: [
{
...this.curPageData['questions'][0],
questionId: this.curPageData['questions'][0].questionId,
options: this.filterItems()
}
]
}
this.getAllAnswer.emit(ret)
}
filterItems() {
return this.allOptions.filter(item=> {
return item['selected']==true;
})
}
getAlloptions(){
const questions = this.curPageData['questions']
if(!questions){
return
}
questions[0]['options'].forEach(option => {
if(option['selected']){
this.allOptions.push(option);
const ret = {
// ...this.curPageData,
pageId: this.curPageData['pageId'],
questions: [
{
...this.curPageData['questions'][0],
questionId: this.curPageData['questions'][0].questionId,
options: this.filterItems()
}
]
}
this.getAllAnswer.emit(ret)
}
});
}
}
<div class="container">
<div class="layout">
<div class="content">
<div class="questionTitle hospitalTitle">
{{ this.curPageData['pageName'] }}
</div>
<ul class="jobContent">
<li
*ngFor="let options of this.curPageData['questions'][0]['options']"
[ngClass]="{ selected: options['selected'] == true }"
(click)="checkFun(options)"
>
{{ options.optionName }}
</li>
</ul>
</div>
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page14Component } from './page14.component';
describe('Page14Component', () => {
let component: Page14Component;
let fixture: ComponentFixture<Page14Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page14Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page14Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit ,Input, Output, EventEmitter} from '@angular/core';
@Component({
selector: 'app-page14',
templateUrl: './page14.component.html',
styleUrls: ['./page14.component.css']
})
export class Page14Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
selectedObj:Object;
allOptions: Array<any>
optionType:number
constructor() { }
ngOnInit() {
// console.log(this.curPageData)
//拿到数据中是多选还是单选2表示多选1表示单选
this.optionType = this.curPageData['questions'][0].optionType
// console.log(this.optionType)
if(this.optionType==1){
this.selectedObj = {}
this.setOptionSelected()
}
if(this.optionType==2){
this.allOptions = []
this.getAlloptions()
}
}
getManyAnswer(options) {
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
// 更改问题状态,防止重复往数组push
if (options['optionId'] == this.allOptions[i]['optionId']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
}
}
this.allOptions.push(options)
for (let i = 0; i < this.allOptions.length; i++) {
let index;
// 当选中无疾病时
if(options['optionId']==111 && options['selected']==true){
index = this.allOptions.indexOf(options);
this.allOptions[i]['selected'] = false;
if(index > -1){
this.allOptions[index]['selected'] = true;
}
}else{
// 选中其他疾病时,无疾病状态改为false
if(this.allOptions[i]['optionId']==111){
this.allOptions[i]['selected'] = false;
}
}
}
const ret = {
// ...this.curPageData,
pageId: this.curPageData['pageId'],
questions: [
{
...this.curPageData['questions'][0],
questionId: this.curPageData['questions'][0].questionId,
options: this.filterItems()
}
]
}
this.getAllAnswer.emit(ret)
}
filterItems() {
return this.allOptions.filter(item=> {
return item['selected']==true;
})
}
//单选调用的方法
getAnswer(options) {
if(!this.selectedObj['selected']){
this.selectedObj = options
options['selected'] = true;
}else{
if(this.selectedObj['optionId']!=options.optionId){
this.selectedObj['selected'] = false;
options['selected'] = true;
this.selectedObj = options
}
}
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
questionId: this.curPageData['questions'][0].questionId,
options: [options]
}
]
}
this.getAllAnswer.emit(ret)
}
setOptionSelected() {
const options = this.curPageData['questions'][0].options
if (!options) {
return
}
options.forEach(option => {
if (option['selected']) {
this.selectedObj = option;
this.getAnswer(this.selectedObj);
}
})
}
//判断用哪个方法
checkFun(options){
if(this.optionType==1){
this.getAnswer(options)
}
if(this.optionType==2){
this.getManyAnswer(options)
}
}
getAlloptions(){
const questions = this.curPageData['questions']
if(!questions){
return
}
questions[0]['options'].forEach(option => {
if(option['selected']){
this.allOptions.push(option)
}
});
}
}
<div class="container">
<div class="layout">
<div class="content">
<div class="questionTitle smokeTitle">
{{ this.curPageData['pageName'] }}
</div>
<ul class="jobContent">
<li
*ngFor="let options of this.curPageData['questions'][0]['options']"
[ngClass]="{ selected: options['selected'] == true }"
(click)="checkFun(options)"
>
{{ options.optionName }}
</li>
</ul>
</div>
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page15Component } from './page15.component';
describe('Page15Component', () => {
let component: Page15Component;
let fixture: ComponentFixture<Page15Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page15Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page15Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit,Input, Output, EventEmitter} from '@angular/core';
@Component({
selector: 'app-page15',
templateUrl: './page15.component.html',
styleUrls: ['./page15.component.css']
})
export class Page15Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
curQues: Object
curAllQues: Object
optionType:number
selectedObj:Object;
allOptions: Array<any>
constructor() { }
ngOnInit() {
// console.log(this.curPageData)
//拿到数据中是多选还是单选2表示多选1表示单选
this.optionType = this.curPageData['questions'][0].optionType
// console.log(this.optionType)
if(this.optionType==1){
this.selectedObj = {}
this.setOptionSelected()
}
if(this.optionType==2){
this.allOptions = []
this.getAlloptions()
}
}
getManyAnswer(options) {
// console.log(options)
options['selected'] = !options['selected']
for (let i = 0; i < this.allOptions.length; i++) {
// 更改问题状态,防止重复往数组push
if (options['optionId'] == this.allOptions[i]['optionId']) {
let index = this.allOptions.indexOf(this.allOptions[i])
if (index > -1) {
this.allOptions.splice(index, 1)
}
}
}
this.allOptions.push(options)
for (let i = 0; i < this.allOptions.length; i++) {
let index;
// 当选中无疾病时
if(options['optionId']==117 && options['selected']==true){
index = this.allOptions.indexOf(options);
this.allOptions[i]['selected'] = false;
if(index > -1){
this.allOptions[index]['selected'] = true;
}
}else{
// 选中其他疾病时,无疾病状态改为false
if(this.allOptions[i]['optionId']==117){
this.allOptions[i]['selected'] = false;
}
}
}
const ret = {
// ...this.curPageData,
pageId: this.curPageData['pageId'],
questions: [
{
...this.curPageData['questions'][0],
questionId: this.curPageData['questions'][0].questionId,
options: this.filterItems()
}
]
}
this.getAllAnswer.emit(ret)
}
filterItems() {
return this.allOptions.filter(item=> {
return item['selected']==true;
})
}
//单选调用的方法
getAnswer(options) {
if(!this.selectedObj['selected']){
this.selectedObj = options
options['selected'] = true;
}else{
if(this.selectedObj['optionId']!=options.optionId){
this.selectedObj['selected'] = false;
options['selected'] = true;
this.selectedObj = options
}
}
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
questionId: this.curPageData['questions'][0].questionId,
options: [options]
}
]
}
this.getAllAnswer.emit(ret)
}
setOptionSelected() {
const options = this.curPageData['questions'][0].options
// console.log(this.curPageData['questions'][0])
if (!options) {
return
}
options.forEach(option => {
if (option['selected']) {
this.selectedObj = option;
this.getAnswer(this.selectedObj);
}
})
}
//判断用哪个方法
checkFun(options){
if(this.optionType==1){
this.getAnswer(options)
}
if(this.optionType==2){
this.getManyAnswer(options)
}
}
getAlloptions(){
const questions = this.curPageData['questions']
if(!questions){
return
}
questions[0]['options'].forEach(option => {
if(option['selected']){
this.allOptions.push(option)
}
});
}
}
<div class="container">
<div class="layout ">
<div class="content">
<div class="questionTitle">
{{ this.curPageData['questions'][0]['questionName'] }}
</div>
<ul class="cityContent">
<li
*ngFor="let provinces of this.provinceList"
[ngClass]="{ selected: provinces['selected'] == true }"
(click)="showToast(); selectProvince(provinces)"
>
{{ provinces.provinceAbbr }}
</li>
</ul>
<div class="address" *ngIf="this.showAddress">
{{ this.strAddress }}
</div>
</div>
</div>
<div class="toastWrapper toast" *ngIf="isShow" (click)="closeToast();">
</div>
<div class="toastContent city" *ngIf="isShow">
<div class="live">所在地区</div>
<div class="province">
<span>{{ this.provinceName }}</span>
</div>
<ul class="city">
<li
*ngFor="let city of this.cityList"
(click)="closeToast(); selectCity(city); getAnswer(city)"
>
{{ city.cityName }}
</li>
</ul>
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page16Component } from './page16.component';
describe('Page16Component', () => {
let component: Page16Component;
let fixture: ComponentFixture<Page16Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page16Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page16Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
import { CommonService } from '../common.service'
@Component({
selector: 'app-page16',
templateUrl: './page16.component.html',
styleUrls: ['./page16.component.css']
})
export class Page16Component implements OnInit {
@Input() curPageData: Array<any>
//获取省份
@Input() provinceList: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
isShow: boolean
cityList: Array<any>
provinceId: number
provinceName: string
//具体地址显示
showAddress: boolean
address: Object
selectedProvinceObj: Object
selectedCityObj: Object
strAddress: string
constructor(private commonService: CommonService) {}
ngOnInit() {
this.selectedProvinceObj = {}
this.selectedCityObj = {}
// console.log(this.curPageData)
this.showAddress = false
this.setOptionSelected()
}
showToast() {
this.isShow = true
}
selectProvince(option) {
if (!this.selectedProvinceObj['selected']) {
this.selectedProvinceObj = option
option['selected'] = true
} else {
if (this.selectedProvinceObj['provinceId'] != option.provinceId) {
this.selectedProvinceObj['selected'] = false
option['selected'] = true
this.selectedProvinceObj = option
}
}
// console.log(this.selectedProvinceObj)
this.provinceName = option.provinceName
this.provinceId = option.provinceId
this.getCityqry()
}
closeToast() {
this.isShow = false
}
getCityqry() {
const param = {
insurerId: 11,
provinceId: this.provinceId
}
this.commonService.getCityqry(param).then(res => {
if (res['success']) {
this.cityList = res['data'].cityList
// console.log(this.cityList)
}
})
}
selectCity(e) {
this.showAddress = true
this.strAddress = this.provinceName + e.cityName
this.address = {
customerInput: this.provinceName + ',' + e.cityName
}
}
getAnswer(option) {
if (!this.selectedCityObj['selected']) {
this.selectedCityObj = option
option['selected'] = true
} else {
if (this.selectedCityObj['optionId'] != option.optionId) {
this.selectedCityObj['selected'] = false
option['selected'] = true
this.selectedCityObj = option
}
}
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
...this.curPageData['questions'][0],
questionId: this.curPageData['questions'][0].questionId,
options: [this.address]
}
]
}
this.getAllAnswer.emit(ret)
console.log(ret)
}
setOptionSelected() {
const options = this.provinceList
// console.log(options)
if (!options) {
return
}
options.forEach(option => {
if (option['selected']) {
this.selectedProvinceObj = option;
this.getAnswer(this.selectedProvinceObj);
}
})
console.log(this.selectedProvinceObj)
}
}
<div class="limbo">
<div class="title">
<img src="assets/images/bg_17.png" />
</div>
<div class="footer" style="margin-top: 10%;" (click)="getHref()">
<div>我知道了</div>
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page17Component } from './page17.component';
describe('Page17Component', () => {
let component: Page17Component;
let fixture: ComponentFixture<Page17Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page17Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page17Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input } from '@angular/core'
@Component({
selector: 'app-page17',
templateUrl: './page17.component.html',
styleUrls: ['./page17.component.css']
})
export class Page17Component implements OnInit {
@Input() curPageData: Array<any>
constructor() {}
ngOnInit() {
// console.log(this.curPageData)
}
getHref(){
window.location.href = 'https://' + window.location.host+ '/member'
}
}
.option_item {
display: flex;
flex-wrap: wrap;
}
.option_item li {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex: 0 0 50%;
margin-bottom: 20%;
}
.option_item li img {
max-width: 55%;
}
.option_item li img.selected {
border: 1px solid #ff0000;
border-radius: 50%;
}
<div class="layout">
<div class="content">
<div class="questionTitle">{{ this.curPageData['pageName'] }}</div>
<ul class="option_item" style="margin-top: 20%;">
<li
*ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(options)"
>
<img
[ngClass]="{ selected: options['selected'] == true }"
src="assets/images/icon{{ options.optionId }}.png"
alt="{{ options.optionName }}"
/>
<span>{{ options.optionName }}</span>
</li>
</ul>
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page2Component } from './page2.component';
describe('Page2Component', () => {
let component: Page2Component;
let fixture: ComponentFixture<Page2Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page2Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page2Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
@Component({
selector: 'app-page2',
templateUrl: './page2.component.html',
styleUrls: ['./page2.component.css']
})
export class Page2Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
selectedObj:Object;
constructor() {}
ngOnInit() {
this.selectedObj = {}
this.setOptionSelected()
}
getAnswer(option) {
if(!this.selectedObj['selected']){
this.selectedObj = option
option['selected'] = true;
}else{
if(this.selectedObj['optionId']!=option.optionId){
this.selectedObj['selected'] = false;
option['selected'] = true;
this.selectedObj = option
}
}
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
questionId: this.curPageData['questions'][0].questionId,
questionName: this.curPageData['questions'][0].questionName,
options: [option]
}
]
}
// console.log(this.curPageData['questions']);
// console.log(ret.questions)
this.getAllAnswer.emit(ret);
console.log(ret)
// console.log(ret)
}
setOptionSelected() {
const options = this.curPageData['questions'][0].options
if (!options) {
return
}
options.forEach(option => {
if (option['selected']) {
this.selectedObj = option;
this.getAnswer(this.selectedObj)
}
})
}
}
.ageContent {
display: flex;
flex-wrap: wrap;
}
.ageContent li {
width: 100%;
height: 60px;
line-height: 60px;
border-bottom: 1px solid #dcdcdc;
display: flex;
justify-content: space-between;
}
.ageContent li span b {
margin-left: 10px;
}
.addChild {
/* display: flex;
justify-content: space-around;
align-items: center; */
width: 72%;
margin: 10% auto 0 auto;
text-align: center;
height: 70px;
line-height: 70px;
border: 1px #ff0000 solid;
border-radius: 40px;
position: relative;
}
.addChild div {
float: left;
color: #ec2d37;
font-size: 22px;
}
.addChild div.icon {
font-weight: bold;
width: 50px;
height: 50px;
border: 2px #ec2d37 solid;
border-radius: 50%;
font-size: 45px;
line-height: 38px;
margin: 3% 10% 0 10%;
}
<div class="layout">
<div class="content">
<div class="questionTitle">{{ this.curPageData['pageName'] }}</div>
<ul class="ageContent">
<li *ngFor="let optionsList of this.curPageData['questions']; index as i">
<div>{{ optionsList.questionName }}</div>
<b (click)="showToast(optionsList, i)" style="width:35%;text-align: center;float: right">
<span style="width:20%;text-align: center;">{{ optionsList.name }}</span
>
<span style="width:10%;text-align: center;float: right">&gt;</span>
</b>
</li>
</ul>
</div>
<!-- <div class="addChild" *ngIf="isShowChildAgeBtn" (click)="addChild()">
<div class="icon">+</div>
<div data-toggle="modal">增加孩子年龄</div>
</div> -->
<div class="toastWrapper toast" *ngIf="isShow" (click)="closeToast()">
</div>
</div>
<div class="toastContent" *ngIf="isShow">
<ul>
<li
[ngClass]="{ selected: this.curQuestionSelecte === options.optionName}"
*ngFor="let options of curQues.options"
(click)="
closeToast();
getAnswer(options);
changeStyle(options, options.optionId)
"
>
{{ options.optionName }}
</li>
</ul>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page3Component } from './page3.component';
describe('Page3Component', () => {
let component: Page3Component;
let fixture: ComponentFixture<Page3Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page3Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page3Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import {Component, OnInit, Input, Output, EventEmitter} from '@angular/core'
@Component({
selector: 'app-page3',
templateUrl: './page3.component.html',
styleUrls: ['./page3.component.css']
})
export class Page3Component implements OnInit {
@Input() curPageData: Array<any>
@Input() isShowChildAgeBtn: boolean
@Output() getAllAnswer = new EventEmitter<any>()
isShow: boolean;
curQues: Object;
curAllQues: Object;
selectedNum: number;
options: Array<any>;
curQuesIndex: number;
//当前问题长度
curQuesLen: number;
//增加孩子点击次数
addChildCount: number;
curQuestionSelecte: string;
questions: Array<any>;
selectedObj: Object;
constructor() {
this.questions = [];
}
ngOnInit() {
this.curQues = {};
this.curAllQues = {};
this.curQuesLen = this.curPageData['questions'].length;
//初始化增加孩子按钮可以点2次
this.addChildCount = 2;
this.selectedOptions();
// console.log(this.curPageData)
}
showToast(question, idx) {
this.isShow = true
this.curQues = question
this.curQuesIndex = idx
this.curQuestionSelecte = question.name
}
closeToast() {
this.isShow = false
}
getAnswer(option) {
const questionId = this.curQues['questionId']
this.curAllQues[questionId] = option
const questions = Object.keys(this.curAllQues).map(questionId => {
return {questionId, options: [this.curAllQues[questionId]]}
});
for (let j = 0; j < this.questions.length; j++) {
for (let i = 0; i < questions.length; i++) {
if (questions[i]['questionId'] != this.questions[j]['questionId']) {
questions.push(this.questions[j]);
break;
}
break;
}
}
const ret = {
pageId: 3,
questions
};
console.log(ret)
this.getAllAnswer.emit(ret);
}
changeStyle(options, optionId) {
//当前选中项
this.curPageData['questions'][this.curQuesIndex]['name'] =
options.optionName
this.curPageData['questions'][this.curQuesIndex]['optionId'] =
options.optionId
}
// 保存用户选择的信息
selectedOptions() {
if (this.curPageData['questions'].length > 0) {
for (let i = 0; i < this.curPageData['questions'].length; i++) {
if (!this.curPageData['questions'][i]['name']) {
break
}
let option = {};
let question = {
questionId: '',
options: []
};
question.questionId = this.curPageData['questions'][i].questionId;
option = {
customerInput: null,
optionId: this.curPageData['questions'][i]['optionId'],
optionName: this.curPageData['questions'][i]['name'],
optionOrder: 2,
selected: true
};
question.options.push(option);
this.questions.push(question);
}
}
const ret = {
pageId: 3,
questions: this.questions
};
this.getAllAnswer.emit(ret);
}
addChild() {
// this.addChildCount--
// if (this.addChildCount >= 0) {
// this.curPageData['questions'][this.curQuesLen++] = {
// questionId: 4,
// questionName: `孩子${this.addChildCount == 1 ? '1' : '2'}年龄`,
// optionType: 1,
// questionOrder: 4,
// options: [
// {
// optionId: 22,
// optionName: '95后',
// optionOrder: 1,
// customerInput: null
// },
// {
// optionId: 23,
// optionName: '90后',
// optionOrder: 2,
// customerInput: null
// },
// {
// optionId: 24,
// optionName: '85后',
// optionOrder: 3,
// customerInput: null
// },
// {
// optionId: 25,
// optionName: '80后',
// optionOrder: 4,
// customerInput: null
// },
// {
// optionId: 26,
// optionName: '75后',
// optionOrder: 5,
// customerInput: null
// },
// {
// optionId: 27,
// optionName: '70后',
// optionOrder: 6,
// customerInput: null
// },
// {
// optionId: 28,
// optionName: '65后',
// optionOrder: 7,
// customerInput: null
// },
// {
// optionId: 29,
// optionName: '60后',
// optionOrder: 8,
// customerInput: null
// }
// ]
// }
// }
}
}
<div class="container">
<div class="layout">
<div class="content">
<div class="questionTitle">{{ this.curPageData['pageName'] }}</div>
<ul class="jobContent">
<li
[ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData['questions'][0].options"
(click)="getAnswer(options)"
>
{{ options.optionName }}
</li>
</ul>
</div>
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page4Component } from './page4.component';
describe('Page4Component', () => {
let component: Page4Component;
let fixture: ComponentFixture<Page4Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page4Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page4Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
@Component({
selector: 'app-page4',
templateUrl: './page4.component.html',
styleUrls: ['./page4.component.css']
})
export class Page4Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
selectedObj: Object
constructor() {}
ngOnInit() {
this.selectedObj = {}
this.setOptionSelected()
}
getAnswer(option) {
if (!this.selectedObj['selected']) {
this.selectedObj = option
option['selected'] = true
} else {
if (this.selectedObj['optionId'] != option.optionId) {
this.selectedObj['selected'] = false
option['selected'] = true
this.selectedObj = option
}
}
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
questionId: this.curPageData['questions'][0].questionId,
questionName:this.curPageData['questions'][0].questionName,
options: [option]
}
]
}
this.getAllAnswer.emit(ret)
}
setOptionSelected() {
const options = this.curPageData['questions'][0].options
if (!options) {
return
}
options.forEach(option => {
if (option['selected']) {
this.selectedObj = option;
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
questionId: this.curPageData['questions'][0].questionId,
options: [this.selectedObj]
}
]
}
this.getAllAnswer.emit(ret);
}
})
}
}
<div class="container">
<div class="layout">
<div class="content">
<div class="questionTitle">
{{ this.curPageData['pageName'].substring(0, 1) }}
<span>{{ this.curPageData['pageName'].substring(1, 3) }}</span>
{{ this.curPageData['pageName'].substring(3, 10) }}
</div>
<ul class="jobContent">
<li
[ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(options)"
>
{{ options.optionName }}
</li>
</ul>
</div>
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page5Component } from './page5.component';
describe('Page5Component', () => {
let component: Page5Component;
let fixture: ComponentFixture<Page5Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page5Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page5Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
@Component({
selector: 'app-page5',
templateUrl: './page5.component.html',
styleUrls: ['./page5.component.css']
})
export class Page5Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
selectedObj: Object
constructor() {}
ngOnInit() {
this.selectedObj = {}
this.setOptionSelected()
}
getAnswer(option) {
if (!this.selectedObj['selected']) {
this.selectedObj = option
option['selected'] = true
} else {
if (this.selectedObj['optionId'] != option.optionId) {
this.selectedObj['selected'] = false
option['selected'] = true
this.selectedObj = option
}
}
const ret = {
pageId: this.curPageData['pageId'],
questions: [
{
questionId: this.curPageData['questions'][0].questionId,
questionName:this.curPageData['questions'][0].questionName,
options: [option]
}
]
}
this.getAllAnswer.emit(ret)
}
setOptionSelected() {
const options = this.curPageData['questions'][0].options
if (!options) {
return
}
options.forEach(option => {
if (option['selected']) {
this.selectedObj = option;
this.getAnswer(this.selectedObj)
}
})
}
}
<div class="limbo">
<div class="title">
<img src="assets/images/bg_6.png" />
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page6Component } from './page6.component';
describe('Page6Component', () => {
let component: Page6Component;
let fixture: ComponentFixture<Page6Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page6Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page6Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input } from '@angular/core'
@Component({
selector: 'app-page6',
templateUrl: './page6.component.html',
styleUrls: ['./page6.component.css']
})
export class Page6Component implements OnInit {
@Input() curPageData: Array<any>
constructor() {}
ngOnInit() {
// console.log(this.curPageData)
}
}
<div class="container">
<div class="layout">
<div class="content">
<div class="twoContent">
<div class="questionTitle">
{{ this.curPageData['questions'][0]['questionName'] }}
</div>
<ul class="income">
<li
[ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData['questions'][0].options"
(click)="getAnswer(this.curPageData['questions'][0], options)"
>
{{ options.optionName }}
</li>
</ul>
<div class="questionTitle" *ngIf="hasMate">
{{ this.curPageData['questions'][1]['questionName']}}
</div>
<ul class="income" *ngIf="hasMate">
<li
[ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData['questions'][1]['options']"
(click)="getAnswer(this.curPageData['questions'][1], options)"
>
{{ options.optionName }}
</li>
</ul>
</div>
</div>
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page7Component } from './page7.component';
describe('Page7Component', () => {
let component: Page7Component;
let fixture: ComponentFixture<Page7Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page7Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page7Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
@Component({
selector: 'app-page7',
templateUrl: './page7.component.html',
styleUrls: ['./page7.component.css']
})
export class Page7Component implements OnInit {
@Input() curPageData: Array<any>
@Input() hasMate: boolean
@Output() getAllAnswer = new EventEmitter<any>()
curAllQues: Object
selectedObj: Object
questions: Array<any>;
constructor() {}
ngOnInit() {
this.curAllQues = {}
this.selectedObj = {}
this.questions = []
this.setOptionSelected()
}
getAnswer(question, options) {
debugger;
//获取当前页面问题id
const questionId = question['questionId']
if (!this.selectedObj[questionId]) {
this.selectedObj[questionId] = options
options['selected'] = true
} else {
if (this.selectedObj[questionId].optionId != options.optionId) {
this.selectedObj[questionId]['selected'] = false
options['selected'] = true
this.selectedObj[questionId] = options
}
}
this.curAllQues[questionId] = options
const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId,
options: [this.curAllQues[questionId]]
}
})
for (let j = 0; j < this.questions.length; j++) {
for (let i = 0; i < questions.length; i++) {
if (questions[i]['questionId'] != this.questions[j]['questionId']) {
questions.push(this.questions[j]);
break;
}
break;
}
}
const ret = {
pageId: 7,
questions
}
// console.log(ret)
this.getAllAnswer.emit(ret)
}
setOptionSelected() {
const questions2 = this.curPageData['questions']
// console.log(questions)
if (!questions2) {
return
}
questions2.map(question => {
question['options'].forEach(option => {
if (option['selected']) {
this.selectedObj[question['questionId']] = option
}
})
})
const questions = Object.keys(this.selectedObj).map(questionId => {
return { questionId, options: [this.selectedObj[questionId]] }
})
this.questions = questions
const ret = {
pageId: 7,
questions
}
this.getAllAnswer.emit(ret)
}
}
<div class="container">
<div class="layout">
<div class="content">
<div class="questionTitle">
{{ this.curPageData['questions'][0]['questionName'] }}
</div>
<ul class="income">
<li
[ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(this.curPageData['questions'][0], options)"
>
{{ options.optionName }}
</li>
</ul>
<div class="questionTitle">
{{ this.curPageData['questions'][1]['questionName'] }}
</div>
<ul class="income">
<li
[ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData['questions'][1]['options']"
(click)="getAnswer(this.curPageData['questions'][1], options)"
>
{{ options.optionName }}
</li>
</ul>
</div>
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page8Component } from './page8.component';
describe('Page8Component', () => {
let component: Page8Component;
let fixture: ComponentFixture<Page8Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page8Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page8Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
@Component({
selector: 'app-page8',
templateUrl: './page8.component.html',
styleUrls: ['./page8.component.css']
})
export class Page8Component implements OnInit {
@Input() curPageData: Array<any>
@Output() getAllAnswer = new EventEmitter<any>()
curAllQues: Object
selectedObj: Object
questions: Array<any>;
constructor() {}
ngOnInit() {
this.questions = [];
this.curAllQues = {}
this.selectedObj = {}
this.setOptionSelected()
// console.log(this.curPageData)
}
getAnswer(question, options) {
const questionId = question['questionId']
if (!this.selectedObj[questionId]) {
this.selectedObj[questionId] = options
options['selected'] = true
} else {
if (this.selectedObj[questionId].optionId != options.optionId) {
this.selectedObj[questionId]['selected'] = false
options['selected'] = true
this.selectedObj[questionId] = options
}
}
this.curAllQues[questionId] = options
const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId, options: [this.curAllQues[questionId]] }
})
for (let j = 0; j < this.questions.length; j++) {
for (let i = 0; i < questions.length; i++) {
if (questions[i]['questionId'] != this.questions[j]['questionId']) {
questions.push(this.questions[j]);
break;
}
break;
}
}
const ret = {
pageId: 8,
questions
}
// console.log(this.curPageData['questions']);
this.getAllAnswer.emit(ret)
}
setOptionSelected() {
const questions2 = this.curPageData['questions']
if (!questions2) {
return
}
questions2.map(question => {
question['options'].forEach(option => {
if (option['selected']) {
this.selectedObj[question['questionId']] = option
}
})
})
const questions = Object.keys(this.selectedObj).map(questionId => {
return { questionId, options: [this.selectedObj[questionId]] }
})
this.questions = questions
const ret = {
pageId: 8,
questions
}
this.getAllAnswer.emit(ret)
}
}
<div class="container">
<div class="layout">
<div class="content">
<div class="questionTitle">
{{ this.curPageData['questions'][0]['questionName'] }}
</div>
<ul class="jobContent">
<li
[ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData['questions'][0]['options']"
(click)="getAnswer(this.curPageData['questions'][0], options)"
>
{{ options.optionName }}
</li>
</ul>
<div class="questionTitle" *ngIf="hasMate">
{{ this.curPageData['questions'][1]['questionName'] }}
</div>
<ul class="jobContent" *ngIf="hasMate">
<li
[ngClass]="{ selected: options['selected'] == true }"
*ngFor="let options of this.curPageData['questions'][1]['options']"
(click)="getAnswer(this.curPageData['questions'][1], options)"
>
{{ options.optionName }}
</li>
</ul>
</div>
</div>
</div>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Page9Component } from './page9.component';
describe('Page9Component', () => {
let component: Page9Component;
let fixture: ComponentFixture<Page9Component>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ Page9Component ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Page9Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'
@Component({
selector: 'app-page9',
templateUrl: './page9.component.html',
styleUrls: ['./page9.component.css']
})
export class Page9Component implements OnInit {
@Input() curPageData: Array<any>
@Input() hasMate: boolean
@Output() getAllAnswer = new EventEmitter<any>()
curAllQues: Object
selectedObj: Object
questions: Array<any>;
constructor() {}
ngOnInit() {
this.curAllQues = {}
this.selectedObj = {}
this.questions = [];
this.setOptionSelected()
}
getAnswer(question, options) {
const questionId = question['questionId']
// console.log('select', this.selectedObj, options)
if (!this.selectedObj[questionId]) {
this.selectedObj[questionId] = options
options['selected'] = true
} else {
if (this.selectedObj[questionId].optionId != options.optionId) {
this.selectedObj[questionId]['selected'] = false
options['selected'] = true
this.selectedObj[questionId] = options
}
}
this.curAllQues[questionId] = options
const questions = Object.keys(this.curAllQues).map(questionId => {
return { questionId, options: [this.curAllQues[questionId]] }
})
for (let j = 0; j < this.questions.length; j++) {
for (let i = 0; i < questions.length; i++) {
if (questions[i]['questionId'] != this.questions[j]['questionId']) {
questions.push(this.questions[j]);
break;
}
break;
}
}
const ret = {
pageId: 9,
questions
}
this.getAllAnswer.emit(ret)
}
setOptionSelected() {
const questions2 = this.curPageData['questions']
if (!questions2) {
return
}
questions2.map(question => {
question['options'].forEach(option => {
if (option['selected']) {
this.selectedObj[question['questionId']] = option
}
})
})
const questions = Object.keys(this.selectedObj).map(questionId => {
return { questionId, options: [this.selectedObj[questionId]] }
})
this.questions = questions
const ret = {
pageId: 9,
questions
}
this.getAllAnswer.emit(ret)
}
}
# This file is currently used by autoprefixer to adjust CSS to support the below specified browsers
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
#
# For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed
> 0.5%
last 2 versions
Firefox ESR
not dead
not IE 9-11
\ No newline at end of file
export const environment = {
production: true,
apiUrl: 'https://m.zuihuibi.cn/api'
};
/**
* Created by Sweet on 2019/3/22.
*/
export const environment = {
production: false,
apiUrl: 'https://mstage.zuihuibi.cn/api'
};
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
export const environment = {
production: false,
apiUrl: 'https://mdev.zuihuibi.cn/api'
};
/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>银盾保险在线</title>
<base href="/">
<link rel="shortcut icon" href="https://www.ydinsurance.cn/wp-content/uploads/2018/04/favicon.gif">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
</head>
<body>
<app-root></app-root>
</body>
<script>
var _hmt = _hmt || [];
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?36b1eb7eec3b5dac9f97d887092b5b27";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</html>
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage/questionnair'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/guide/browser-support
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.
/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
* because those flags need to be set before `zone.js` being loaded, and webpack
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags.ts';
*
* The flags allowed in zone-flags.ts are listed here.
*
* The following flags will work for all browsers.
*
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
* (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*
* (window as any).__Zone_enable_cross_context_check = true;
*
*/
/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/
/* You can add global styles to this file, and also import other style files */
*{
margin: 0;padding:0;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
html, body {
position: relative;
height:100%;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif,
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
/* overflow: hidden; */
}
img{
max-width: 100%;
}
ul li,ol li{
list-style: none;
}
.container{
padding: 0;
height: 100%;
}
.wrapper{
display: flex;
flex-direction: column;
}
.layout{
display: flex;
flex-direction: column;
padding:0 10px;
height:100%;
}
.layout.wrapper{
padding:0;
}
.tips{
display: flex;
justify-content: center;
align-items: center;
padding:20px 0px;
}
.footer{
display: flex;
justify-content: center;
align-items: center;
font-size: 20px;
padding: 20px 0;
width: 90%;
margin: 0 auto;
background: #ec2d37;
color: #fff;
border-radius: 10px;
box-shadow: 0px 15px 16px -8px #f4bbbe;
}
/* .layout.cityLayout{
padding:10px 0;
} */
.content{
/* max-height: 525px; */
overflow: auto;
-webkit-overflow-scrolling: touch;
padding-bottom: 75px;
}
/* .layout.cityLayout .questionTitle{
margin:0 10px;
} */
.questionTitle{
color:#ec2d37;
font-size: 22px;
height: 60px;
line-height: 60px;
width: 100%;
display: flex;
}
.questionTitle span{
color: rgba(3,177, 153)
}
.questionTitle.hospitalTitle{
line-height: unset;
margin: 25px auto 15px auto;
}
.questionTitle.smokeTitle{
line-height: unset;
margin: 25px auto 55px auto;
}
.content_footer{
display: flex;
width: 100%;
position: fixed;
bottom: 0;
background-color: #fff;
padding-bottom:15px;
}
.content_footer div{
text-align: center;
color: #ec2d37;
font-size: 20px;
height: 60px;
line-height: 60px;
font-weight: bold;
}
.content_footer div.next{
color: #8a8a8a;
}
.content_footer div:nth-child(1){
font-size: 20px;
width: 10%;
}
.content_footer div:nth-child(2){
font-weight: 500;
width: 50%;
margin-left:15%;
}
.twoContent{
height: 100%;
}
.jobContent,.income,.cityContent{
width: 100%;
}
.jobContent li,.income li,.cityContent li{
width: 100%;
height: 55px;
line-height: 55px;
border: 1px #8a8a8a solid;
margin-bottom: 15px;
border-radius: 4px;
box-sizing: border-box;
padding-left: 5%;
}
.jobContent li.selected,.income li.selected{
border: 2px #ff0000 solid;
}
.cityContent{
display: flex;
flex-wrap: wrap;
margin-top: 10%;
margin-bottom: 0px;
}
.income{
display: flex;
flex-wrap: wrap;
margin-bottom: 0;
}
.income li{
width: 49%;
float: left;
margin-right: 2%;
text-align: center;
padding-left: 0;
}
.income li:nth-child(2),.income li:nth-child(4),.income li:nth-child(6){
margin-right: 0;
}
.cityContent li{
width:12%;
height: 46px;
line-height: 46px;
text-align: center;
padding-left: 0;
margin-left: 1%;
margin-right: 1%;
border:none;
-moz-box-shadow:0px 3px 7px rgb(206, 208, 210);
-webkit-box-shadow:0px 3px 7px rgb(206, 208, 210);
box-shadow:0px 3px 7px rgb(206, 208, 210);
}
.cityContent li:nth-child(7),.cityContent li:nth-child(14),.cityContent li:nth-child(21),.cityContent li:nth-child(28){
margin-right: 0;
}
.cityContent li.selected{
background: rgba(148,209, 204)
}
.toastWrapper{
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
top: 0;
}
.toast{
position: fixed;
left: 0;
right: 0;
min-width: 320px;
max-width: 640px;
width: 100%;
margin: 0 auto;
z-index: 1;
}
.toastContent{
position: fixed;
bottom: 0;
width: 100%;
height: 50%;
background-color: #fff;
z-index: 20;
}
.toastContent.city{
margin: 0;
}
.toastContent .live{
display: flex;
height: 40px;
line-height: 40px;
text-align: center;
justify-content: center;
border-bottom: 1px rgb(220, 220, 220) solid;
font-size: 16px;
}
.toastContent .province{
display: flex;
height: 40px;
line-height:40px;
}
.toastContent .province span{
width: 45%;
font-size:16px;
text-align: center;
}
/* .toastContent .province span.selected{
border-bottom:2px solid #ff0000;
} */
.toastContent ul{
width: 100%;
margin: 5% 0%;
}
.toastContent ul li{
width: 46%;
float: left;
text-align: center;
margin: 2%;
border: 1px #8a8a8a solid;
border-radius: 4px;
box-sizing: border-box;
height: 40px;
line-height: 40px;
}
.toastContent ul li.selected{
border: 1px #ff0000 solid;
}
.toastContent ul.city {
margin: 0;
overflow: scroll;
max-height: 240px;
-webkit-overflow-scrolling: touch;
}
.toastContent ul.city li{
width: 100%;
border:none;
border-bottom: 1px rgb(220, 220, 220) solid;
border-radius: 0;
margin: 0;
height:35px;
line-height:35px;
}
.address{
width: 80%;
margin:15% auto;
text-align: center;
}
\ No newline at end of file
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/dist/zone-testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting
} from '@angular/platform-browser-dynamic/testing';
declare const require: any;
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(
BrowserDynamicTestingModule,
platformBrowserDynamicTesting()
);
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"types": []
},
"exclude": [
"test.ts",
"**/*.spec.ts"
]
}
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"types": [
"jasmine",
"node"
]
},
"files": [
"test.ts",
"polyfills.ts"
],
"include": [
"**/*.spec.ts",
"**/*.d.ts"
]
}
{
"extends": "../tslint.json",
"rules": {
"directive-selector": [
true,
"attribute",
"app",
"camelCase"
],
"component-selector": [
true,
"element",
"app",
"kebab-case"
]
}
}
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
}
}
{
"extends": "tslint:recommended",
"rulesDirectory": [
"codelyzer"
],
"rules": {
"array-type": false,
"arrow-parens": false,
"deprecation": {
"severity": "warn"
},
"import-blacklist": [
true,
"rxjs/Rx"
],
"interface-name": false,
"max-classes-per-file": false,
"max-line-length": [
true,
140
],
"member-access": false,
"member-ordering": [
true,
{
"order": [
"static-field",
"instance-field",
"static-method",
"instance-method"
]
}
],
"no-consecutive-blank-lines": false,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-empty": false,
"no-inferrable-types": [
true,
"ignore-params"
],
"no-non-null-assertion": true,
"no-redundant-jsdoc": true,
"no-switch-case-fall-through": true,
"no-use-before-declare": true,
"no-var-requires": false,
"object-literal-key-quotes": [
true,
"as-needed"
],
"object-literal-sort-keys": false,
"ordered-imports": false,
"quotemark": [
true,
"single"
],
"trailing-comma": false,
"no-output-on-prefix": true,
"use-input-property-decorator": true,
"use-output-property-decorator": true,
"use-host-property-decorator": true,
"no-input-rename": true,
"no-output-rename": true,
"use-life-cycle-interface": true,
"use-pipe-transform-interface": true,
"component-class-suffix": true,
"directive-class-suffix": true
}
}
.ydCodeContainer {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
letter-spacing: 2px;
}
.ydCodeContainer > img {
width: 180px;
max-width: 100%;
height: auto;
}
<div class="limbo"> <div class="limbo">
<div class="title"> <div class="title">
<img src="assets/images/bg_17.png" /> <img src="assets/images/bg_17.png"/>
</div>
<div class="ydCodeContainer">
<img src="assets/images/yd.jpg" alt="银盾在线">
<p>请关注我们的公众号查询你的方案</p>
</div> </div>
<div class="footer" style="margin-top: 10%;" (click)="getHref()"> <div class="footer" style="margin-top: 10%;" (click)="getHref()">
<div (click)="getHref()">我知道了</div> <div (click)="getHref()">我知道了</div>
......
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