Commit 59f75a16 by Sweet Zhang

增加缓存

parent c6253af5
import { Component, OnInit } from '@angular/core';
import { CommonService } from "./common.service";
import {Component, OnInit} from '@angular/core';
import {CommonService} from "./common.service";
@Component({
selector: 'app-root',
......@@ -12,7 +12,11 @@ export class AppComponent implements OnInit {
}
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');
if (customerId) {
sessionStorage.setItem('customerId', customerId);
......
......@@ -17,7 +17,7 @@
</div>
<div class="content_footer">
<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 class="toastWrapper toast" *ngIf="isShow" (click)="closeToast();">
......
import { Component, OnInit } from '@angular/core';
import { CommonService } from '../common.service'
import { ActivatedRoute, Router } from "@angular/router";
import {Component, OnInit} from '@angular/core';
import {CommonService} from '../common.service'
import {ActivatedRoute, Router} from "@angular/router";
@Component({
selector: 'app-live',
......@@ -49,7 +49,7 @@ export class LiveComponent implements OnInit {
questions: [{
questionId: '',
questionName: '',
options: [{ optionId: '', optionName: '', optionOrder: '', selected: '' }]
options: [{optionId: '', optionName: '', optionOrder: '', selected: ''}]
}],
};
this.loginData = {
......@@ -65,7 +65,7 @@ export class LiveComponent implements OnInit {
this.tipsFlag = false;
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']) {
this.provinceList = res['data'].provinceList;
}
......@@ -165,7 +165,7 @@ export class LiveComponent implements OnInit {
}
}
next() {
next(type) {
if (this.nextBtn == true) {
const param = {
survey: {
......@@ -176,6 +176,22 @@ export class LiveComponent implements OnInit {
};
// 有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') {
this.loginModalFlag = true;
return;
......@@ -232,7 +248,7 @@ export class LiveComponent implements OnInit {
this.errorModal('手机号码输入有误');
return;
} 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']) {
this.sendBtnFlag = true;
this.errorModal('发送成功');
......@@ -276,15 +292,21 @@ export class LiveComponent implements OnInit {
}).then(res => {
if (res['success']) {
// 登录
this.commonService.login({ 'mobileNo': this.loginData.mobileNo }).then(response => {
this.commonService.login({'mobileNo': this.loginData.mobileNo}).then(response => {
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;
//获取customerId后调用获取orderId接口
if (response['data']['customerId']) {
sessionStorage.setItem('customerId', response['data']['customerId']);
}
this.getOrderId();
this.getOrderId(null);
} else {
// 登录失败
this.errorModal(res['message']);
......@@ -297,9 +319,13 @@ export class LiveComponent implements OnInit {
})
}
//获取orderId后调用保存问卷
getOrderId() {
const orderIdParam = {
// 获取orderId后调用保存问卷
getOrderId(obj) {
let orderIdParam;
if (obj) {
orderIdParam = obj;
} else {
orderIdParam = {
name: this.loginData.name,
customerId: sessionStorage.getItem('customerId'),
campaignInfo: {
......@@ -307,10 +333,12 @@ export class LiveComponent implements OnInit {
"campaignTaskCode": JSON.parse(sessionStorage.getItem('campaignInfo'))['campaignTaskCode']
}
}
}
this.commonService.createActivityOrder(orderIdParam).then(res => {
if (res['success']) {
sessionStorage.setItem('orderId', res['data']['orderId']);
this.next();
this.next(1);
} else {
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