Commit 10bbd770 by Chao Sun

过渡页公用

parent aea78dc9
......@@ -34,6 +34,7 @@ export class EventBusService {
async userPractitionerQuery(userPractitioner) {
const url = this.USER_API_URL + '/user/userPractitionerQuery';
const res = await this.obtainToken();
console.log(res)
this.httpOptions.headers = this.httpOptions.headers.set('X-Authorization', res['data']['token']);
return this.http.post(url, JSON.stringify(userPractitioner), this.httpOptions)
.toPromise().then(response => {
......
......@@ -122,6 +122,7 @@
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css"
],
"scripts": [],
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -19,6 +19,8 @@
"@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",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
......
......@@ -5,15 +5,25 @@ import {AskComponent} from './ask/ask.component';
import {AskdetailComponent} from './askdetail/askdetail.component';
import {PageTwoComponent} from './page-two/page-two.component';
import {PageThreeComponent} from './page-three/page-three.component';
import {PageFourComponent} from './page-four/page-four.component';
const routes: Routes = [
{
path: '', redirectTo: '/index', pathMatch: 'full'
},
{path: 'index', component: AskComponent},
{path: 'askdetail/:id',component: AskdetailComponent },
{path:'pageTwo',component:PageTwoComponent},
{path:'pageThree',component:PageThreeComponent}
{path:'index', component: AskComponent,
data: {
limbo: '1',
}
},
{path:'question1',component: AskdetailComponent },
{path:'question2',component:PageTwoComponent},
{path:'question3',component:PageThreeComponent},
{path:'question4',component:PageFourComponent},
{path:'index', component: AskComponent,
data: {
limbo: '2',
}
},
];
@NgModule({
declarations: [],
......
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 {
title = 'questionnair';
constructor(
private commonService:CommonService,
) {
}
}
......@@ -7,20 +7,25 @@ import { AppRoutingModule } from './app-routing.module';
import { AskdetailComponent } from './askdetail/askdetail.component';
import { PageTwoComponent } from './page-two/page-two.component';
import { PageThreeComponent } from './page-three/page-three.component';
import {HttpClientModule} from '@angular/common/http';
import {CommonService} from './common.service';
import { PageFourComponent } from './page-four/page-four.component';
import {LocalStorage} from './local.storage';
@NgModule({
declarations: [
AppComponent,
AskComponent,
AskdetailComponent,
PageTwoComponent,
PageThreeComponent
PageThreeComponent,
PageFourComponent
],
imports: [
BrowserModule,
AppRoutingModule
AppRoutingModule,
HttpClientModule
],
providers: [],
providers: [CommonService,LocalStorage],
bootstrap: [AppComponent]
})
export class AppModule { }
<div class="wrapper">
<div class="title">
<img src="assets/images/bg_1.png" alt="">
</div>
<div class="tips">
<span style="color:red;">*</span>
<span>本测试仅需三分钟</span>
</div>
<div class="footer" (click)="viewDetail(1)">
<div>获取家庭分析报告</div>
<div class="container">
<div class="wrapper layout">
<div class="title">
<img src="assets/images/bg_1.png">
{{this.picNum}}
</div>
<div class="tips">
<span style="color:red;">*</span>
<span>本测试仅需三分钟</span>
</div>
<div class="footer" routerLink="/question1">
<div>获取家庭分析报告</div>
</div>
</div>
</div>
import { Component, OnInit } from '@angular/core';
import {Router} from '@angular/router';
import {CommonService} from '../common.service';
import {LocalStorage} from '../local.storage';
@Component({
selector: 'app-ask',
templateUrl: './ask.component.html',
......@@ -7,22 +9,20 @@ import {Router} from '@angular/router';
})
export class AskComponent implements OnInit {
questionList:Array<any>;
questionPageList = []; //分页后前台显示数据
pageNo = 1; //当前页码
preShow = false; //上一页
nextShow = true; //下一页
pageSize = 1; //单页显示数
totalCount = 0; //总页数
pageSizes = [5, 10, 15];
curPage = 1; //当前页
constructor(private router: Router) {
picNum:number;
constructor(private router: Router,
private ls: LocalStorage,
private commonService:CommonService
) {
}
ngOnInit() {
}
viewDetail(id){
this.router.navigate(['askdetail',id])
this.commonService.getAllInfo();
setTimeout(()=>{
this.commonService.questionList.forEach(item=>{
})
},100)
}
}
......@@ -36,7 +36,7 @@
</div>
<div class="content_footer">
<div routerLink="/index">&lt;</div>
<div routerLink="/pageTwo" class="next">下一步</div>
<div routerLink="/question2" class="next">下一步</div>
</div>
</div>
......@@ -9,14 +9,15 @@ import {CommonService} from '../common.service';
export class AskdetailComponent implements OnInit {
list:Array<any>;
constructor(
private commservice:CommonService,
private commonService:CommonService,
) {
}
ngOnInit() {
this.list =this.commservice.questionList.filter(item=>
item.pageId=='1'
).pop().questions
// this.list =this.commservice.questionList.filter(item=>
// item.pageId=='1'
// ).pop().questions
console.log(this.commonService.questionList)
}
}
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 {
questionList:Array<any>
constructor() {
this.questionList = [
{
"pageId": "1",
"pageName": "了解一下您的家庭情况,以便分析您的家庭风险",
"pageOrder": "1",
"questions":
[
{
"questionId": "1",
"questionName": "您的家庭结构",
"optionType": "1",
"questionOrder": "1",
"options":
[
{
"optionId": "1",
"optionName": "单身贵族",
"optionOrder": "1",
"optionIdSelected": "",
"customerInput": ""
},
{
"optionId": "2",
"optionName": "二人世界",
"optionOrder": "2",
"optionIdSelected": "",
"customerInput": ""
},
{
"optionId": "3",
"optionName": "独立带娃",
"optionOrder": "3",
"optionIdSelected": "",
"customerInput": ""
},
{
"optionId": "4",
"optionName": "多口之家",
"optionOrder": "4",
"optionIdSelected": "",
"customerInput": ""
}
]
},
{
"questionId": "2",
"questionName": "您的家庭成员年龄",
"optionType": "3",
"questionOrder": "2",
"options":
[
{
"optionId": "5",
"optionName": "您的年龄",
"optionOrder": "1",
"optionIdSelected": "",
"customerInput": ""
},
{
"optionId": "6",
"optionName": "配偶年龄",
"optionOrder": "2",
"optionIdSelected": "",
"customerInput": ""
},
{
"optionId": "7",
"optionName": "孩子年龄",
"optionOrder": "3",
"optionIdSelected": "",
"customerInput": ""
}
]
}
]
},
{
"pageId": "2",
"pageName": "了解一下您的家庭收入情况,以便定制适合的保险配置",
"pageOrder": "2",
"questions":
[
{
"questionId": "5",
"questionName": "您的年收入(税前) ?",
"optionType": "1",
"questionOrder": "1",
"options":
[
{
"optionId": "21",
"optionName": "10万以下",
"optionOrder": "1",
"optionIdSelected": "",
"customerInput": ""
},
{
"optionId": "22",
"optionName": "10~25",
"optionOrder": "2",
"optionIdSelected": "",
"customerInput": ""
},
{
"optionId": "23",
"optionName": "25~40",
"optionOrder": "3",
"optionIdSelected": "",
"customerInput": ""
},
{
"optionId": "24",
"optionName": "40~60",
"optionOrder": "4",
"optionIdSelected": "",
"customerInput": ""
},
{
"optionId": "25",
"optionName": "60万以上",
"optionOrder": "5",
"optionIdSelected": "",
"customerInput": ""
}
]
},
{
"questionId": "6",
"questionName": "您配偶的年收入(税前) ?",
"optionType": "1",
"questionOrder": "2",
"options":
[
{
"optionId": "26",
"optionName": "10万以下",
"optionOrder": "1",
"optionIdSelected": "",
"customerInput": ""
},
{
"optionId": "27",
"optionName": "10~25",
"optionOrder": "2",
"optionIdSelected": "",
"customerInput": ""
},
{
"optionId": "28",
"optionName": "25~40",
"optionOrder": "3",
"optionIdSelected": "",
"customerInput": ""
},
{
"optionId": "29",
"optionName": "40~60",
"optionOrder": "4",
"optionIdSelected": "",
"customerInput": ""
},
{
"optionId": "30",
"optionName": "60万以上",
"optionOrder": "5",
"optionIdSelected": "",
"customerInput": ""
}
]
}
]
}
]
private USER_API_URL = '';
private httpOptions;
questionList:Array<any>;
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()
}
async getAllInfo(){
const res = await this.surveyInfo()
if(res['success']){
this.questionList = res['data']['survey'].pages
}
}
/**
* 获取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();
}
}
/**
* 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="container">
<div class="layout">
<div class="content">
<div class="questionTitle">您的配偶从事哪种职业</div>
<ul class="jobContent">
<li class="selected">
室内轻体力(办公室人员、教师、医生等)
</li>
<li>
室内重体力(经常加班,程序员等)
</li>
<li>
室内复杂作业(装修类,生产线作业等)
</li>
<li>
户外简单工作(经常出差、销售、司机、导游等)
</li>
<li>
户外复杂工作(施工工程师,建筑工人等)
</li>
<li>
家庭主妇/家庭主夫
</li>
</ul>
</div>
<div class="content_footer">
<div routerLink="/question3">&lt;</div>
<div routerLink="/index" class="next">下一步</div>
</div>
</div>
</div>
\ No newline at end of file
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PageFourComponent } from './page-four.component';
describe('PageFourComponent', () => {
let component: PageFourComponent;
let fixture: ComponentFixture<PageFourComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PageFourComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PageFourComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-page-four',
templateUrl: './page-four.component.html',
styleUrls: ['./page-four.component.css']
})
export class PageFourComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
.jobContent{
width: 100%;
}
.jobContent li{
width: 100%;
height: 60px;
line-height: 60px;
border: 1px #8a8a8a solid;
margin-bottom: 10px;
border-radius: 4px;
box-sizing: border-box;
padding-left: 5%;
}
.jobContent li.selected{
border: 1px #ff0000 solid;
}
\ No newline at end of file
<div class="layout">
<div class="content">
<div class="questionTitle">您从事哪种职业</div>
<ul class="jobContent">
<li class="selected">
室内轻体力(办公室人员、教师、医生等)
</li>
<li>
室内重体力(经常加班,程序员等)
</li>
<li>
室内复杂作业(装修类,生产线作业等)
</li>
<li>
户外简单工作(经常出差、销售、司机、导游等)
</li>
<li>
户外复杂工作(施工工程师,建筑工人等)
</li>
<li>
家庭主妇/家庭主夫
</li>
</ul>
<div class="container">
<div class="layout">
<div class="content">
<div class="questionTitle">您从事哪种职业</div>
<ul class="jobContent">
<li class="selected">
室内轻体力(办公室人员、教师、医生等)
</li>
<li>
室内重体力(经常加班,程序员等)
</li>
<li>
室内复杂作业(装修类,生产线作业等)
</li>
<li>
户外简单工作(经常出差、销售、司机、导游等)
</li>
<li>
户外复杂工作(施工工程师,建筑工人等)
</li>
<li>
家庭主妇/家庭主夫
</li>
</ul>
</div>
<div class="content_footer">
<div routerLink="/question2">&lt;</div>
<div routerLink="/question4" class="next">下一步</div>
</div>
</div>
<div class="content_footer">
<div routerLink="/pageTwo">&lt;</div>
<div routerLink="/pageThree" class="next">下一步</div>
</div>
</div>
\ No newline at end of file
</div>
\ No newline at end of file
......@@ -27,7 +27,7 @@
<div>增加孩子年龄</div>
</div>
<div class="content_footer">
<div routerLink="/askdetail/1">&lt;</div>
<div routerLink="/pageThree" class="next">下一步</div>
<div routerLink="/question1">&lt;</div>
<div routerLink="/question3" class="next">下一步</div>
</div>
</div>
......@@ -21,6 +21,9 @@ ul li,ol li{
overflow: hidden;
padding:10px;
}
.layout.wrapper{
padding:0;
}
.content{
height: 100%;
}
......@@ -51,4 +54,20 @@ ul li,ol li{
.content_footer div:nth-child(2){
flex: 0 0 60%;
font-weight: 500;
}
.jobContent{
width: 100%;
}
.jobContent li{
width: 100%;
height: 60px;
line-height: 60px;
border: 1px #8a8a8a solid;
margin-bottom: 10px;
border-radius: 4px;
box-sizing: border-box;
padding-left: 5%;
}
.jobContent li.selected{
border: 1px #ff0000 solid;
}
\ No newline at end of file
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