Commit 59f75a16 by Sweet Zhang

增加缓存

parent c6253af5
import { Component, OnInit } from '@angular/core'; import {Component, OnInit} from '@angular/core';
import { CommonService } from "./common.service"; import {CommonService} from "./common.service";
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
...@@ -12,7 +12,11 @@ export class AppComponent implements OnInit { ...@@ -12,7 +12,11 @@ export class AppComponent implements OnInit {
} }
ngOnInit() { ngOnInit() {
const customerId = this.commonService.getQueryString('customerId'); let customerId = this.commonService.getQueryString('customerId');
const double12_customerInfo = localStorage.getItem('double12_customerInfo') ? JSON.parse(localStorage.getItem('double12_customerInfo')) : null;
if (double12_customerInfo) {
customerId = double12_customerInfo.customerId;
}
const orderId = this.commonService.getQueryString('orderId'); const orderId = this.commonService.getQueryString('orderId');
if (customerId) { if (customerId) {
sessionStorage.setItem('customerId', customerId); sessionStorage.setItem('customerId', customerId);
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</div> </div>
<div class="content_footer"> <div class="content_footer">
<div style="color: #8a8a8a;" (click)="before()">&lt;</div> <div style="color: #8a8a8a;" (click)="before()">&lt;</div>
<div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next()"> 下一步</div> <div [ngStyle]="{ color: nextBtn == false ? '#8a8a8a' : '#ec2d37' }" (click)="next(null)"> 下一步</div>
</div> </div>
<div class="toastWrapper toast" *ngIf="isShow" (click)="closeToast();"> <div class="toastWrapper toast" *ngIf="isShow" (click)="closeToast();">
......
import { Component, OnInit } from '@angular/core'; import {Component, OnInit} from '@angular/core';
import { CommonService } from '../common.service' import {CommonService} from '../common.service'
import { ActivatedRoute, Router } from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
@Component({ @Component({
selector: 'app-live', selector: 'app-live',
...@@ -41,15 +41,15 @@ export class LiveComponent implements OnInit { ...@@ -41,15 +41,15 @@ export class LiveComponent implements OnInit {
childrenDisease: boolean = false; childrenDisease: boolean = false;
constructor(private commonService: CommonService, constructor(private commonService: CommonService,
private router: Router, private router: Router,
private route: ActivatedRoute) { private route: ActivatedRoute) {
this.type = this.route.snapshot.queryParams['type']; this.type = this.route.snapshot.queryParams['type'];
this.pageAnswers = { this.pageAnswers = {
pageId: '', pageId: '',
questions: [{ questions: [{
questionId: '', questionId: '',
questionName: '', questionName: '',
options: [{ optionId: '', optionName: '', optionOrder: '', selected: '' }] options: [{optionId: '', optionName: '', optionOrder: '', selected: ''}]
}], }],
}; };
this.loginData = { this.loginData = {
...@@ -65,7 +65,7 @@ export class LiveComponent implements OnInit { ...@@ -65,7 +65,7 @@ export class LiveComponent implements OnInit {
this.tipsFlag = false; this.tipsFlag = false;
this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 16).pop(); this.lastQuestions = this.commonService.todosCopy.filter(item => item.pageId == 16).pop();
// 获取省份 // 获取省份
this.commonService.provinceqry({ insurerId: 11 }).then(res => { this.commonService.provinceqry({insurerId: 11}).then(res => {
if (res['success']) { if (res['success']) {
this.provinceList = res['data'].provinceList; this.provinceList = res['data'].provinceList;
} }
...@@ -165,7 +165,7 @@ export class LiveComponent implements OnInit { ...@@ -165,7 +165,7 @@ export class LiveComponent implements OnInit {
} }
} }
next() { next(type) {
if (this.nextBtn == true) { if (this.nextBtn == true) {
const param = { const param = {
survey: { survey: {
...@@ -176,6 +176,22 @@ export class LiveComponent implements OnInit { ...@@ -176,6 +176,22 @@ export class LiveComponent implements OnInit {
}; };
// 有campaignInfo表示 自动评测 // 有campaignInfo表示 自动评测
if (sessionStorage.getItem('campaignInfo')) { if (sessionStorage.getItem('campaignInfo')) {
const double12_customerInfo = localStorage.getItem('double12_customerInfo') ? JSON.parse(localStorage.getItem('double12_customerInfo')) : null;
if (double12_customerInfo) {
param.survey.customerId = double12_customerInfo.customerId;
const orderIdParam = {
name: double12_customerInfo.customerName,
customerId: double12_customerInfo.customerId,
campaignInfo: {
"campaignCode": JSON.parse(sessionStorage.getItem('campaignInfo'))['campaignCode'],
"campaignTaskCode": JSON.parse(sessionStorage.getItem('campaignInfo'))['campaignTaskCode']
}
}
if (type !== 1) {
this.getOrderId(orderIdParam);
return;
}
}
if (!param || !param.survey.customerId || param.survey.customerId === 'null' || param.survey.customerId === 'undefined') { if (!param || !param.survey.customerId || param.survey.customerId === 'null' || param.survey.customerId === 'undefined') {
this.loginModalFlag = true; this.loginModalFlag = true;
return; return;
...@@ -232,7 +248,7 @@ export class LiveComponent implements OnInit { ...@@ -232,7 +248,7 @@ export class LiveComponent implements OnInit {
this.errorModal('手机号码输入有误'); this.errorModal('手机号码输入有误');
return; return;
} else if (this.loginData.mobileNo) { } else if (this.loginData.mobileNo) {
this.commonService.verificationCode({ mobileNo: this.loginData.mobileNo, type: '1' }).then(res => { this.commonService.verificationCode({mobileNo: this.loginData.mobileNo, type: '1'}).then(res => {
if (res['success']) { if (res['success']) {
this.sendBtnFlag = true; this.sendBtnFlag = true;
this.errorModal('发送成功'); this.errorModal('发送成功');
...@@ -276,15 +292,21 @@ export class LiveComponent implements OnInit { ...@@ -276,15 +292,21 @@ export class LiveComponent implements OnInit {
}).then(res => { }).then(res => {
if (res['success']) { if (res['success']) {
// 登录 // 登录
this.commonService.login({ 'mobileNo': this.loginData.mobileNo }).then(response => { this.commonService.login({'mobileNo': this.loginData.mobileNo}).then(response => {
if (response['success']) { if (response['success']) {
const double12_customerInfo = {
customerId: response['data']['customerId'],
customerName: this.loginData.name,
mobileNo: this.loginData.mobileNo
};
localStorage.setItem('double12_customerInfo', JSON.stringify(double12_customerInfo));
// 登录成功 // 登录成功
this.loginModalFlag = false; this.loginModalFlag = false;
//获取customerId后调用获取orderId接口 //获取customerId后调用获取orderId接口
if (response['data']['customerId']) { if (response['data']['customerId']) {
sessionStorage.setItem('customerId', response['data']['customerId']); sessionStorage.setItem('customerId', response['data']['customerId']);
} }
this.getOrderId(); this.getOrderId(null);
} else { } else {
// 登录失败 // 登录失败
this.errorModal(res['message']); this.errorModal(res['message']);
...@@ -297,20 +319,26 @@ export class LiveComponent implements OnInit { ...@@ -297,20 +319,26 @@ export class LiveComponent implements OnInit {
}) })
} }
//获取orderId后调用保存问卷 // 获取orderId后调用保存问卷
getOrderId() { getOrderId(obj) {
const orderIdParam = { let orderIdParam;
name: this.loginData.name, if (obj) {
customerId: sessionStorage.getItem('customerId'), orderIdParam = obj;
campaignInfo: { } else {
"campaignCode": JSON.parse(sessionStorage.getItem('campaignInfo'))['campaignCode'], orderIdParam = {
"campaignTaskCode": JSON.parse(sessionStorage.getItem('campaignInfo'))['campaignTaskCode'] name: this.loginData.name,
customerId: sessionStorage.getItem('customerId'),
campaignInfo: {
"campaignCode": JSON.parse(sessionStorage.getItem('campaignInfo'))['campaignCode'],
"campaignTaskCode": JSON.parse(sessionStorage.getItem('campaignInfo'))['campaignTaskCode']
}
} }
} }
this.commonService.createActivityOrder(orderIdParam).then(res => { this.commonService.createActivityOrder(orderIdParam).then(res => {
if (res['success']) { if (res['success']) {
sessionStorage.setItem('orderId', res['data']['orderId']); sessionStorage.setItem('orderId', res['data']['orderId']);
this.next(); this.next(1);
} else { } else {
this.errorModal(res['message']); this.errorModal(res['message']);
......
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