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 { 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)
}
}
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