Commit 10bbd770 by Chao Sun

过渡页公用

parent aea78dc9
...@@ -34,6 +34,7 @@ export class EventBusService { ...@@ -34,6 +34,7 @@ export class EventBusService {
async userPractitionerQuery(userPractitioner) { async userPractitionerQuery(userPractitioner) {
const url = this.USER_API_URL + '/user/userPractitionerQuery'; const url = this.USER_API_URL + '/user/userPractitionerQuery';
const res = await this.obtainToken(); const res = await this.obtainToken();
console.log(res)
this.httpOptions.headers = this.httpOptions.headers.set('X-Authorization', res['data']['token']); this.httpOptions.headers = this.httpOptions.headers.set('X-Authorization', res['data']['token']);
return this.http.post(url, JSON.stringify(userPractitioner), this.httpOptions) return this.http.post(url, JSON.stringify(userPractitioner), this.httpOptions)
.toPromise().then(response => { .toPromise().then(response => {
......
...@@ -122,6 +122,7 @@ ...@@ -122,6 +122,7 @@
"tsConfig": "src/tsconfig.spec.json", "tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js", "karmaConfig": "src/karma.conf.js",
"styles": [ "styles": [
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"src/styles.css" "src/styles.css"
], ],
"scripts": [], "scripts": [],
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
"@angular/platform-browser": "~7.2.0", "@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0", "@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~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", "core-js": "^2.5.4",
"rxjs": "~6.3.3", "rxjs": "~6.3.3",
"tslib": "^1.9.0", "tslib": "^1.9.0",
......
...@@ -5,15 +5,25 @@ import {AskComponent} from './ask/ask.component'; ...@@ -5,15 +5,25 @@ import {AskComponent} from './ask/ask.component';
import {AskdetailComponent} from './askdetail/askdetail.component'; import {AskdetailComponent} from './askdetail/askdetail.component';
import {PageTwoComponent} from './page-two/page-two.component'; import {PageTwoComponent} from './page-two/page-two.component';
import {PageThreeComponent} from './page-three/page-three.component'; import {PageThreeComponent} from './page-three/page-three.component';
import {PageFourComponent} from './page-four/page-four.component';
const routes: Routes = [ const routes: Routes = [
{ {
path: '', redirectTo: '/index', pathMatch: 'full' path: '', redirectTo: '/index', pathMatch: 'full'
}, },
{path: 'index', component: AskComponent}, {path:'index', component: AskComponent,
{path: 'askdetail/:id',component: AskdetailComponent }, data: {
{path:'pageTwo',component:PageTwoComponent}, limbo: '1',
{path:'pageThree',component:PageThreeComponent} }
},
{path:'question1',component: AskdetailComponent },
{path:'question2',component:PageTwoComponent},
{path:'question3',component:PageThreeComponent},
{path:'question4',component:PageFourComponent},
{path:'index', component: AskComponent,
data: {
limbo: '2',
}
},
]; ];
@NgModule({ @NgModule({
declarations: [], declarations: [],
......
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { CommonService} from './common.service';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
templateUrl: './app.component.html', templateUrl: './app.component.html',
styleUrls: ['./app.component.css'] styleUrls: ['./app.component.css']
}) })
export class AppComponent { export class AppComponent {
title = 'questionnair'; constructor(
private commonService:CommonService,
) {
}
} }
...@@ -7,20 +7,25 @@ import { AppRoutingModule } from './app-routing.module'; ...@@ -7,20 +7,25 @@ import { AppRoutingModule } from './app-routing.module';
import { AskdetailComponent } from './askdetail/askdetail.component'; import { AskdetailComponent } from './askdetail/askdetail.component';
import { PageTwoComponent } from './page-two/page-two.component'; import { PageTwoComponent } from './page-two/page-two.component';
import { PageThreeComponent } from './page-three/page-three.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({ @NgModule({
declarations: [ declarations: [
AppComponent, AppComponent,
AskComponent, AskComponent,
AskdetailComponent, AskdetailComponent,
PageTwoComponent, PageTwoComponent,
PageThreeComponent PageThreeComponent,
PageFourComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,
AppRoutingModule AppRoutingModule,
HttpClientModule
], ],
providers: [], providers: [CommonService,LocalStorage],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
export class AppModule { } export class AppModule { }
<div class="wrapper"> <div class="container">
<div class="title"> <div class="wrapper layout">
<img src="assets/images/bg_1.png" alt=""> <div class="title">
</div> <img src="assets/images/bg_1.png">
<div class="tips"> {{this.picNum}}
<span style="color:red;">*</span> </div>
<span>本测试仅需三分钟</span> <div class="tips">
</div> <span style="color:red;">*</span>
<div class="footer" (click)="viewDetail(1)"> <span>本测试仅需三分钟</span>
<div>获取家庭分析报告</div> </div>
<div class="footer" routerLink="/question1">
<div>获取家庭分析报告</div>
</div>
</div> </div>
</div> </div>
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {Router} from '@angular/router'; import {Router} from '@angular/router';
import {CommonService} from '../common.service';
import {LocalStorage} from '../local.storage';
@Component({ @Component({
selector: 'app-ask', selector: 'app-ask',
templateUrl: './ask.component.html', templateUrl: './ask.component.html',
...@@ -7,22 +9,20 @@ import {Router} from '@angular/router'; ...@@ -7,22 +9,20 @@ import {Router} from '@angular/router';
}) })
export class AskComponent implements OnInit { export class AskComponent implements OnInit {
questionList:Array<any>; questionList:Array<any>;
questionPageList = []; //分页后前台显示数据 picNum:number;
pageNo = 1; //当前页码 constructor(private router: Router,
preShow = false; //上一页 private ls: LocalStorage,
nextShow = true; //下一页 private commonService:CommonService
pageSize = 1; //单页显示数 ) {
totalCount = 0; //总页数
pageSizes = [5, 10, 15];
curPage = 1; //当前页
constructor(private router: Router) {
} }
ngOnInit() { ngOnInit() {
} this.commonService.getAllInfo();
viewDetail(id){ setTimeout(()=>{
this.router.navigate(['askdetail',id]) this.commonService.questionList.forEach(item=>{
})
},100)
} }
} }
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div routerLink="/index">&lt;</div> <div routerLink="/index">&lt;</div>
<div routerLink="/pageTwo" class="next">下一步</div> <div routerLink="/question2" class="next">下一步</div>
</div> </div>
</div> </div>
...@@ -9,14 +9,15 @@ import {CommonService} from '../common.service'; ...@@ -9,14 +9,15 @@ import {CommonService} from '../common.service';
export class AskdetailComponent implements OnInit { export class AskdetailComponent implements OnInit {
list:Array<any>; list:Array<any>;
constructor( constructor(
private commservice:CommonService, private commonService:CommonService,
) { ) {
} }
ngOnInit() { ngOnInit() {
this.list =this.commservice.questionList.filter(item=> // this.list =this.commservice.questionList.filter(item=>
item.pageId=='1' // item.pageId=='1'
).pop().questions // ).pop().questions
console.log(this.commonService.questionList)
} }
} }
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import {environment} from './../environments/environment';
import {HttpClient, HttpHeaders} from '@angular/common/http';
import {LocalStorage} from './local.storage';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class CommonService { export class CommonService {
questionList:Array<any> private USER_API_URL = '';
constructor() { private httpOptions;
this.questionList = [ questionList:Array<any>;
{ constructor(private http: HttpClient,
"pageId": "1", private ls: LocalStorage
"pageName": "了解一下您的家庭情况,以便分析您的家庭风险", ) {
"pageOrder": "1", this.USER_API_URL = environment.apiUrl;
"questions": this.httpOptions = {
[ headers: new HttpHeaders({
{ 'Content-Type': 'application/json',
"questionId": "1", 'X-Authorization': ''
"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": ""
}
]
}
]
}
]
} }
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="container">
<div class="content"> <div class="layout">
<div class="questionTitle">您从事哪种职业</div> <div class="content">
<ul class="jobContent"> <div class="questionTitle">您从事哪种职业</div>
<li class="selected"> <ul class="jobContent">
室内轻体力(办公室人员、教师、医生等) <li class="selected">
</li> 室内轻体力(办公室人员、教师、医生等)
<li> </li>
室内重体力(经常加班,程序员等) <li>
</li> 室内重体力(经常加班,程序员等)
<li> </li>
室内复杂作业(装修类,生产线作业等) <li>
</li> 室内复杂作业(装修类,生产线作业等)
<li> </li>
户外简单工作(经常出差、销售、司机、导游等) <li>
</li> 户外简单工作(经常出差、销售、司机、导游等)
<li> </li>
户外复杂工作(施工工程师,建筑工人等) <li>
</li> 户外复杂工作(施工工程师,建筑工人等)
<li> </li>
家庭主妇/家庭主夫 <li>
</li> 家庭主妇/家庭主夫
</ul> </li>
</ul>
</div>
<div class="content_footer">
<div routerLink="/question2">&lt;</div>
<div routerLink="/question4" class="next">下一步</div>
</div>
</div> </div>
</div>
<div class="content_footer"> \ No newline at end of file
<div routerLink="/pageTwo">&lt;</div>
<div routerLink="/pageThree" class="next">下一步</div>
</div>
</div>
\ No newline at end of file
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<div>增加孩子年龄</div> <div>增加孩子年龄</div>
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div routerLink="/askdetail/1">&lt;</div> <div routerLink="/question1">&lt;</div>
<div routerLink="/pageThree" class="next">下一步</div> <div routerLink="/question3" class="next">下一步</div>
</div> </div>
</div> </div>
...@@ -21,6 +21,9 @@ ul li,ol li{ ...@@ -21,6 +21,9 @@ ul li,ol li{
overflow: hidden; overflow: hidden;
padding:10px; padding:10px;
} }
.layout.wrapper{
padding:0;
}
.content{ .content{
height: 100%; height: 100%;
} }
...@@ -51,4 +54,20 @@ ul li,ol li{ ...@@ -51,4 +54,20 @@ ul li,ol li{
.content_footer div:nth-child(2){ .content_footer div:nth-child(2){
flex: 0 0 60%; flex: 0 0 60%;
font-weight: 500; 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