Commit ad8e33bb by zeyang

1.解决首次登录后token未及时更新的BUG

parent 5c4c35bf
import { Component, OnDestroy, OnInit,HostListener,ViewChild,ElementRef } from '@angular/core'; import { Component, OnDestroy, OnInit, HostListener, ViewChild, ElementRef } from '@angular/core';
import { NavigationExtras, Router } from '@angular/router'; import { NavigationExtras, Router } from '@angular/router';
import { AuthService } from '../auth.service'; import { AuthService } from '../auth.service';
import { LifeCommonService } from '../../common/life-common.service'; import { LifeCommonService } from '../../common/life-common.service';
@Component({ @Component({
selector: 'ydlife-login', selector: 'ydlife-login',
templateUrl: './login.component.html', templateUrl: './login.component.html',
styleUrls: ['./login.component.scss'] styleUrls: ['./login.component.scss']
}) })
export class LoginComponent implements OnInit, OnDestroy { export class LoginComponent implements OnInit, OnDestroy {
@ViewChild('dragContainer') dragContainer: ElementRef; @ViewChild('dragContainer') dragContainer : ElementRef;
@ViewChild('dragHandler') dragHandler: ElementRef; @ViewChild('dragHandler') dragHandler : ElementRef;
MOBILE_REGEXP = /^(1)\d{10}$/; MOBILE_REGEXP = /^(1)\d{10}$/;
sendCodeHtml: string = '获取验证码'; sendCodeHtml : string = '获取验证码';
timer: any; timer : any;
remainTimes: number = 60; remainTimes : number = 60;
disabledSendBtn: boolean = false; disabledSendBtn : boolean = false;
userInfo: any = { userInfo : any = {
mobileNo: null, mobileNo: null,
verificationCode: null verificationCode: null
}; };
isNeedAlert: boolean; isNeedAlert : boolean;
dialogInfo: any; dialogInfo : any;
redirect: any; redirect : any;
dragBg:any; dragBg : any;
dragText:any; dragText : any;
maxHandlerOffset:any; maxHandlerOffset : any;
isVertifySucc:boolean = true; isVertifySucc : boolean = true;
left:any; left : any;
deviceType:any; deviceType : any;
len:any; len : any;
constructor(public authService: AuthService, public router: Router, public lifeCommonService: LifeCommonService) { constructor(public authService : AuthService, public router : Router, public lifeCommonService : LifeCommonService) {
this.deviceType = this.lifeCommonService.checkDeviceType(); this.deviceType = this.lifeCommonService.checkDeviceType();
} }
// 监听document离开事件 // 监听document离开事件
@HostListener('document:touchend', ['$event']) @HostListener('document:touchend', ['$event'])
ontouchend(event) { ontouchend(event) {
// 只用当元素移动过了,离开函数体才会触发。 // 只用当元素移动过了,离开函数体才会触发。
this.onDragHandlerMouseUp(); this.onDragHandlerMouseUp();
} }
// 监听document离开事件
@HostListener(`mouseup`, ['$event'])
onmouseup(event) {
// 只用当元素移动过了,离开函数体才会触发。
this.onDragHandlerMouseUp();
}
ngOnInit() { // 监听document离开事件
// //获取滑动控件容器,灰色背景 @HostListener(`mouseup`, ['$event'])
// this.dragContainer.nativeElement.clientWidth = document.getElementById("dragContainer"); onmouseup(event) {
// //获取滑块左边部分,绿色背景 // 只用当元素移动过了,离开函数体才会触发。
this.dragBg = document.getElementById("dragBg"); this.onDragHandlerMouseUp();
// //获取滑动验证容器文本 }
this.dragText = document.getElementById("dragText");
// //获取滑块
// this.dragHandler.nativeElement = document.getElementsByClassName("slideController")[0];
// //滑块的最大偏移量 = 滑动验证容器文本长度 - 滑块长度
this.maxHandlerOffset = this.dragContainer.nativeElement.clientWidth - this.dragHandler.nativeElement.clientWidth;
this.initDrag();
this.len = (window.innerWidth-document.body.clientWidth)/2;
}
ngOnDestroy() { ngOnInit() {
clearInterval(this.timer); // //获取滑动控件容器,灰色背景
} // this.dragContainer.nativeElement.clientWidth = document.getElementById("dragContainer");
// //获取滑块左边部分,绿色背景
this.dragBg = document.getElementById("dragBg");
// //获取滑动验证容器文本
this.dragText = document.getElementById("dragText");
// //获取滑块
// this.dragHandler.nativeElement = document.getElementsByClassName("slideController")[0];
// //滑块的最大偏移量 = 滑动验证容器文本长度 - 滑块长度
this.maxHandlerOffset = this.dragContainer.nativeElement.clientWidth - this.dragHandler.nativeElement.clientWidth;
this.initDrag();
this.len = (window.innerWidth - document.body.clientWidth) / 2;
inputBlur() { }
window.scrollTo(0, 0)
}
login() { ngOnDestroy() {
const compareInfo = { clearInterval(this.timer);
mobileNo: this.userInfo.mobileNo, }
verificationCode: this.userInfo.verificationCode,
expireTime: '3600',
fromSystemName:'ydLife'
};
if (this.MOBILE_REGEXP.test(this.userInfo.mobileNo) && this.userInfo.verificationCode && this.userInfo.verificationCode.length == 6) {
this.authService.compare(compareInfo).subscribe(res => {
if (res['success']) {
this.authService.login({ mobileNo: this.userInfo.mobileNo,fromSystemName:'ydLife' }).subscribe((response) => {
if (response['success']) {
this.authService.isLoggedIn = true;
if(response['data']['practitionerBasicInfo'] && response['data']['practitionerBasicInfo']['subordinateName']){
sessionStorage.setItem('subordinateSystemName', response['data']['practitionerBasicInfo']['subordinateName'])
}
const lifeCustomerInfo = { ...response.data, mobileNo: this.userInfo.mobileNo, commonResult: null };
this.authService.obtainToken(this.userInfo.mobileNo,response['data']['customerId']).subscribe((res)=>{
if (res['success']) {
localStorage.setItem('lifeToken', res['data']['token']);
}
})
if (lifeCustomerInfo['customerId'] && lifeCustomerInfo['practitionerId']) {
// if (response['data']['practitionerTypeId'] == 28) {
localStorage.setItem('lifeCustomerInfo', JSON.stringify(lifeCustomerInfo));
//如果有openId跳页由后端判断,没有的话根据登录次数前端判断跳页
if (response['data']['getOpenIdUrl']) {
const deviceType = this.lifeCommonService.checkDeviceType()
if (deviceType == 3) {
window.location.href = response['data']['getOpenIdUrl'];
} else {
if (response['data']['loginTimes'] > 0) {
this.redirect = this.authService.redirectUrl ? this.router.parseUrl(this.authService.redirectUrl) : '/my';
this.router.navigateByUrl(this.redirect);
} else {
this.redirect = this.authService.redirectUrl ? this.router.parseUrl(this.authService.redirectUrl) : '/thanks?type=1';
this.router.navigateByUrl(this.redirect);
}
}
} else {
if (response['data']['loginTimes'] > 0) {
this.redirect = this.authService.redirectUrl ? this.router.parseUrl(this.authService.redirectUrl) : '/my';
this.router.navigateByUrl(this.redirect);
} else {
this.redirect = this.authService.redirectUrl ? this.router.parseUrl(this.authService.redirectUrl) : '/thanks?type=1';
this.router.navigateByUrl(this.redirect);
}
}
// } else {
// this.openPopInfo('你好,只有授权的经纪人才可登录,请联系我们的客服4009219290');
// // this.openPopInfo(`你好,只有授权的经纪人才可登录,请联系我们的客服 <a href="tel:4009219290">4009219290 </a>`);
// return;
// }
} else { inputBlur() {
this.openPopInfo('暂无查询资格'); window.scrollTo(0, 0)
} }
} else {
this.openPopInfo(response['message']);
}
});
} else {
this.openPopInfo(res['message']);
}
});
} else {
this.openPopInfo('手机号或验证码不正确');
}
}
// 发送验证码 login() {
verificationCode() { const compareInfo = {
const verificationInfo = { mobileNo: this.userInfo.mobileNo,
mobileNo: this.userInfo.mobileNo, verificationCode: this.userInfo.verificationCode,
type: '1' expireTime: '3600',
}; fromSystemName: 'ydLife'
if (this.MOBILE_REGEXP.test(this.userInfo.mobileNo) && !this.disabledSendBtn) { };
this.authService.verificationCode(verificationInfo).subscribe(res => { if (this.MOBILE_REGEXP.test(this.userInfo.mobileNo) && this.userInfo.verificationCode && this.userInfo.verificationCode.length == 6) {
if (res['success']) { this.authService.compare(compareInfo).subscribe(res => {
this.countDown(); if (res['success']) {
} else { this.authService.login({ mobileNo: this.userInfo.mobileNo, fromSystemName: 'ydLife' }).subscribe((response) => {
this.openPopInfo(res['message']); if (response['success']) {
} this.authService.isLoggedIn = true;
}); if (response['data']['practitionerBasicInfo'] && response['data']['practitionerBasicInfo']['subordinateName']) {
} else if (!this.MOBILE_REGEXP.test(this.userInfo.mobileNo)) { sessionStorage.setItem('subordinateSystemName', response['data']['practitionerBasicInfo']['subordinateName'])
this.openPopInfo('手机号不正确'); }
} const lifeCustomerInfo = { ...response.data, mobileNo: this.userInfo.mobileNo, commonResult: null };
} this.authService.obtainToken(this.userInfo.mobileNo, response['data']['customerId']).subscribe((res2) => {
if (res2['success']) {
localStorage.setItem('lifeToken', res2['data']['token']);
}
if (lifeCustomerInfo['customerId'] && lifeCustomerInfo['practitionerId']) {
// if (response['data']['practitionerTypeId'] == 28) {
localStorage.setItem('lifeCustomerInfo', JSON.stringify(lifeCustomerInfo));
//如果有openId跳页由后端判断,没有的话根据登录次数前端判断跳页
if (response['data']['getOpenIdUrl']) {
const deviceType = this.lifeCommonService.checkDeviceType()
if (deviceType == 3) {
window.location.href = response['data']['getOpenIdUrl'];
} else {
if (response['data']['loginTimes'] > 0) {
this.redirect = this.authService.redirectUrl ? this.router.parseUrl(this.authService.redirectUrl) : '/my';
this.router.navigateByUrl(this.redirect);
} else {
this.redirect = this.authService.redirectUrl ? this.router.parseUrl(this.authService.redirectUrl) : '/thanks?type=1';
this.router.navigateByUrl(this.redirect);
}
}
} else {
if (response['data']['loginTimes'] > 0) {
this.redirect = this.authService.redirectUrl ? this.router.parseUrl(this.authService.redirectUrl) : '/my';
this.router.navigateByUrl(this.redirect);
} else {
this.redirect = this.authService.redirectUrl ? this.router.parseUrl(this.authService.redirectUrl) : '/thanks?type=1';
this.router.navigateByUrl(this.redirect);
}
}
// } else {
// this.openPopInfo('你好,只有授权的经纪人才可登录,请联系我们的客服4009219290');
// // this.openPopInfo(`你好,只有授权的经纪人才可登录,请联系我们的客服 <a href="tel:4009219290">4009219290 </a>`);
// return;
// }
} else {
this.openPopInfo('暂无查询资格');
}
})
} else {
this.openPopInfo(response['message']);
}
});
} else {
this.openPopInfo(res['message']);
}
});
} else {
this.openPopInfo('手机号或验证码不正确');
}
}
// 倒计时 // 发送验证码
countDown() { verificationCode() {
this.disabledSendBtn = true; const verificationInfo = {
this.timer = setInterval(() => { mobileNo: this.userInfo.mobileNo,
this.remainTimes--; type: '1'
this.sendCodeHtml = `${this.remainTimes}(S)`; };
if (this.remainTimes <= 0) { if (this.MOBILE_REGEXP.test(this.userInfo.mobileNo) && !this.disabledSendBtn) {
this.sendCodeHtml = '获取验证码'; this.authService.verificationCode(verificationInfo).subscribe(res => {
this.remainTimes = 60; if (res['success']) {
this.disabledSendBtn = false; this.countDown();
clearInterval(this.timer); } else {
} this.openPopInfo(res['message']);
}, 1000); }
} });
} else if (!this.MOBILE_REGEXP.test(this.userInfo.mobileNo)) {
this.openPopInfo('手机号不正确');
}
}
// 打开弹窗 // 倒计时
openPopInfo(message) { countDown() {
this.isNeedAlert = true; this.disabledSendBtn = true;
this.dialogInfo = { this.timer = setInterval(() => {
title: null, this.remainTimes--;
content: { value: message, align: 'center' }, this.sendCodeHtml = `${this.remainTimes}(S)`;
footer: [{ value: '我知道了', routerLink: '', className: 'weui-dialog__btn_primary' }], if (this.remainTimes <= 0) {
}; this.sendCodeHtml = '获取验证码';
} this.remainTimes = 60;
this.disabledSendBtn = false;
clearInterval(this.timer);
}
}, 1000);
}
// 关闭弹窗 // 打开弹窗
getPopInfo() { openPopInfo(message) {
this.isNeedAlert = false; this.isNeedAlert = true;
} this.dialogInfo = {
title: null,
content: { value: message, align: 'center' },
footer: [{ value: '我知道了', routerLink: '', className: 'weui-dialog__btn_primary' }],
};
}
initDrag() { // 关闭弹窗
//在滑动验证容器文本写入“拖动滑块验证” getPopInfo() {
this.dragText.textContent = "拖动滑块验证"; this.isNeedAlert = false;
//给滑块添加鼠标按下监听 }
if(this.deviceType == 2 || this.deviceType == 3){
this.dragHandler.nativeElement.addEventListener("touchstart", ()=>{
this.onDragHandlerMouseDown()
},false);
}else{
this.dragHandler.nativeElement.addEventListener("mousedown", ()=>{
this.onDragHandlerMouseDown()
});
}
} initDrag() {
//在滑动验证容器文本写入“拖动滑块验证”
this.dragText.textContent = "拖动滑块验证";
//给滑块添加鼠标按下监听
if (this.deviceType == 2 || this.deviceType == 3) {
this.dragHandler.nativeElement.addEventListener("touchstart", () => {
this.onDragHandlerMouseDown()
}, false);
} else {
this.dragHandler.nativeElement.addEventListener("mousedown", () => {
this.onDragHandlerMouseDown()
});
}
//选中滑块 }
onDragHandlerMouseDown() {
if(this.deviceType == 2 || this.deviceType == 3){
//鼠标移动监听
document.addEventListener("touchmove", ()=>{
this.onDragHandlerMouseMove(event)
},false);
//鼠标松开监听
document.addEventListener("touchend", ()=>{
this.onDragHandlerMouseUp
});
}else{
document.querySelector('#dragHandler').classList.add('slideController');
//获取滑块
this.dragHandler.nativeElement = document.getElementsByClassName("slideController")[0];
//鼠标移动监听
this.dragHandler.nativeElement.addEventListener("mousemove",(e)=>{
this.onDragHandlerMouseMove(e);
});
//鼠标松开监听
this.dragHandler.nativeElement.addEventListener("mouseup", ()=>{this.onDragHandlerMouseUp});
}
} //选中滑块
onDragHandlerMouseDown() {
if (this.deviceType == 2 || this.deviceType == 3) {
//鼠标移动监听
document.addEventListener("touchmove", () => {
this.onDragHandlerMouseMove(event)
}, false);
//鼠标松开监听
document.addEventListener("touchend", () => {
this.onDragHandlerMouseUp
});
} else {
document.querySelector('#dragHandler').classList.add('slideController');
//获取滑块
this.dragHandler.nativeElement = document.getElementsByClassName("slideController")[0];
//鼠标移动监听
this.dragHandler.nativeElement.addEventListener("mousemove", (e) => {
this.onDragHandlerMouseMove(e);
});
//鼠标松开监听
this.dragHandler.nativeElement.addEventListener("mouseup", () => { this.onDragHandlerMouseUp });
}
//滑块移动 }
onDragHandlerMouseMove(event) {
event.preventDefault();
let touch;
if (event.touches) {
touch = event.touches[0];
} else {
touch = event;
}
/*
html元素不存在width属性,只有clientWidth
offsetX是相对当前元素的,clientX和pageX是相对其父元素的
*/
//滑块移动量
if(this.deviceType == 2 || this.deviceType == 3){
this.left = touch.clientX - this.dragHandler.nativeElement.clientWidth / 2 - this.len;
}else{
//获取滑块
this.dragHandler.nativeElement = document.getElementsByClassName("slideController")[0];
if(this.dragHandler.nativeElement){
this.left = touch.clientX - this.dragHandler.nativeElement.clientWidth / 2 - this.len;
}else{
this.left = 0;
}
}
if(this.left < 0) {
this.left = 0;
//如果滑块移动量 > 滑块的最大偏移量 ,则调用验证成功函数
} else if(this.left > this.maxHandlerOffset) {
this.left = this.maxHandlerOffset;
this.verifySucc();
}
if(this.dragHandler.nativeElement){
//滑块移动量
this.dragHandler.nativeElement.style.left = this.left + "px";
//绿色背景的长度
this.dragBg.style.width = this.dragHandler.nativeElement.style.left;
}
}
//松开滑块函数 //滑块移动
onDragHandlerMouseUp() { onDragHandlerMouseMove(event) {
if(this.deviceType == 2 || this.deviceType == 3){ event.preventDefault();
//移除鼠标移动监听 let touch;
document.removeEventListener("touchmove", this.onDragHandlerMouseMove); if (event.touches) {
//移除鼠标松开监听 touch = event.touches[0];
document.removeEventListener("touchend", this.onDragHandlerMouseUp); } else {
}else{ touch = event;
//移除鼠标移动监听 }
document.removeEventListener("mousemove", this.onDragHandlerMouseMove); /*
//移除鼠标松开监听 html元素不存在width属性,只有clientWidth
document.removeEventListener("mouseup", this.onDragHandlerMouseUp); offsetX是相对当前元素的,clientX和pageX是相对其父元素的
document.querySelector('#dragHandler').classList.remove('slideController'); */
} //滑块移动量
if(this.isVertifySucc){ if (this.deviceType == 2 || this.deviceType == 3) {
//初始化滑块移动量 this.left = touch.clientX - this.dragHandler.nativeElement.clientWidth / 2 - this.len;
this.dragHandler.nativeElement.style.left = 0; } else {
//初始化绿色背景 //获取滑块
this.dragBg.style.width = 0; this.dragHandler.nativeElement = document.getElementsByClassName("slideController")[0];
} if (this.dragHandler.nativeElement) {
} this.left = touch.clientX - this.dragHandler.nativeElement.clientWidth / 2 - this.len;
} else {
this.left = 0;
}
}
if (this.left < 0) {
this.left = 0;
//如果滑块移动量 > 滑块的最大偏移量 ,则调用验证成功函数
} else if (this.left > this.maxHandlerOffset) {
this.left = this.maxHandlerOffset;
this.verifySucc();
}
if (this.dragHandler.nativeElement) {
//滑块移动量
this.dragHandler.nativeElement.style.left = this.left + "px";
//绿色背景的长度
this.dragBg.style.width = this.dragHandler.nativeElement.style.left;
}
}
//验证成功 //松开滑块函数
verifySucc() { onDragHandlerMouseUp() {
this.isVertifySucc = false; if (this.deviceType == 2 || this.deviceType == 3) {
this.dragText.textContent = "验证通过"; //移除鼠标移动监听
this.dragText.style.color = "white"; document.removeEventListener("touchmove", this.onDragHandlerMouseMove);
this.dragHandler.nativeElement.setAttribute("class", "dragHandlerOkBg"); //移除鼠标松开监听
if(this.deviceType == 2 || this.deviceType == 3){ document.removeEventListener("touchend", this.onDragHandlerMouseUp);
this.dragHandler.nativeElement.removeEventListener("touchstart", this.onDragHandlerMouseDown); } else {
document.removeEventListener("touchmove", this.onDragHandlerMouseMove); //移除鼠标移动监听
document.removeEventListener("touchend", this.onDragHandlerMouseUp); document.removeEventListener("mousemove", this.onDragHandlerMouseMove);
}else{ //移除鼠标松开监听
this.dragHandler.nativeElement.removeEventListener("mousedown", this.onDragHandlerMouseDown); document.removeEventListener("mouseup", this.onDragHandlerMouseUp);
this.dragHandler.nativeElement.removeEventListener("mousemove", this.onDragHandlerMouseMove); document.querySelector('#dragHandler').classList.remove('slideController');
this.dragHandler.nativeElement.removeEventListener("mouseup", this.onDragHandlerMouseUp); }
} if (this.isVertifySucc) {
setTimeout(()=>{ //初始化滑块移动量
this.dragContainer.nativeElement.style.display = 'none' this.dragHandler.nativeElement.style.left = 0;
},1000) //初始化绿色背景
this.dragBg.style.width = 0;
}
}
}; //验证成功
} verifySucc() {
this.isVertifySucc = false;
this.dragText.textContent = "验证通过";
this.dragText.style.color = "white";
this.dragHandler.nativeElement.setAttribute("class", "dragHandlerOkBg");
if (this.deviceType == 2 || this.deviceType == 3) {
this.dragHandler.nativeElement.removeEventListener("touchstart", this.onDragHandlerMouseDown);
document.removeEventListener("touchmove", this.onDragHandlerMouseMove);
document.removeEventListener("touchend", this.onDragHandlerMouseUp);
} else {
this.dragHandler.nativeElement.removeEventListener("mousedown", this.onDragHandlerMouseDown);
this.dragHandler.nativeElement.removeEventListener("mousemove", this.onDragHandlerMouseMove);
this.dragHandler.nativeElement.removeEventListener("mouseup", this.onDragHandlerMouseUp);
}
setTimeout(() => {
this.dragContainer.nativeElement.style.display = 'none'
}, 1000)
};
}
\ No newline at end of file
...@@ -2,181 +2,176 @@ import { Component, OnInit, ViewChild, ElementRef, AfterViewInit } from '@angula ...@@ -2,181 +2,176 @@ import { Component, OnInit, ViewChild, ElementRef, AfterViewInit } from '@angula
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { LifeCommonService } from 'src/app/common/life-common.service'; import { LifeCommonService } from 'src/app/common/life-common.service';
import { MyService } from '../my.service'; import { MyService } from '../my.service';
declare var wx: any; declare var wx : any;
@Component({ @Component({
selector: 'ydlife-my-center-home', selector: 'ydlife-my-center-home',
templateUrl: './my-center-home.component.html', templateUrl: './my-center-home.component.html',
styleUrls: ['./my-center-home.component.scss'], styleUrls: ['./my-center-home.component.scss'],
}) })
export class MyCenterHomeComponent implements OnInit { export class MyCenterHomeComponent implements OnInit {
messageUnreadCount:string; messageUnreadCount : string;
productInfo: any; productInfo : any;
inquiry: any; inquiry : any;
public announcementInfo: string; public announcementInfo : string;
public searchText: string; public searchText : string;
public featureLists = [ public featureLists = [
{ key: '00', name: '产品库', icon: 'productLibary', link: '/product', isOpen: true }, { key: '00', name: '产品库', icon: 'productLibary', link: '/product', isOpen: true },
{ key: '01', name: '计划书', icon: 'proposals', link: '', isOpen: false }, { key: '01', name: '计划书', icon: 'proposals', link: '', isOpen: false },
{ key: '02', name: '我的保单', icon: 'policyLists', link: '/salesDetail', isOpen: true }, { key: '02', name: '我的保单', icon: 'policyLists', link: '/salesDetail', isOpen: true },
{ key: '03', name: '续期管理', icon: 'renewalManagement', link: '/renewal_reminder', isOpen: true }, { key: '03', name: '续期管理', icon: 'renewalManagement', link: '/renewal_reminder', isOpen: true },
{ key: '04', name: '成交客户', icon: 'customers', link: '/customer', isOpen: true }, { key: '04', name: '成交客户', icon: 'customers', link: '/customer', isOpen: true },
{ key: '05', name: '我的增员', icon: 'increaseStaff', link: '/recruiting', isOpen: true }, { key: '05', name: '我的增员', icon: 'increaseStaff', link: '/recruiting', isOpen: true },
]
public bannerLists = [];
public hotProductLists = [];
public onlineProductLists = [];
lifeCustomerInfo: any = JSON.parse(localStorage.getItem('lifeCustomerInfo')) ? JSON.parse(localStorage.getItem('lifeCustomerInfo')) : null;
canSeeSchool:any='';
state = {
modal1: false,
};
onClose(key) {
this.state[key] = false;
}
submit(value) { ]
if (value.trim()) { public bannerLists = [];
this.router.navigate(['/product', { queryName: value.trim() }]) public hotProductLists = [];
} public onlineProductLists = [];
} lifeCustomerInfo : any = JSON.parse(localStorage.getItem('lifeCustomerInfo')) ? JSON.parse(localStorage.getItem('lifeCustomerInfo')) : null;
canSeeSchool : any = '';
querySystemMessage(){ state = {
this.myService.querySystemMessage({practitionerId:localStorage.getItem('lifeCustomerInfo') ? JSON.parse(localStorage.getItem('lifeCustomerInfo')).practitionerId : null}).subscribe(res=>{ modal1: false,
if(res['success']){ };
this.messageUnreadCount = res['data']['unReadcount']; onClose(key) {
if(Number(this.messageUnreadCount) > 99){ this.state[key] = false;
this.messageUnreadCount = '99+'; }
}
}else{
this.messageUnreadCount = null;
}
})
}
searchProduct() { submit(value) {
// 查询互联网产品 if (value.trim()) {
this.router.navigate(['/product', { queryTagId: 272 }]) this.router.navigate(['/product', { queryName: value.trim() }])
} }
}
clear(value) {
this.searchText = '';
}
// 查询银盾公告 querySystemMessage() {
announcementQuery() { this.myService.querySystemMessage({ practitionerId: localStorage.getItem('lifeCustomerInfo') ? JSON.parse(localStorage.getItem('lifeCustomerInfo')).practitionerId : null }).subscribe(res => {
this.myService.announcementQuery(null, 37).subscribe(res => { if (res['success']) {
if (res['success']) { this.messageUnreadCount = res['data']['unReadcount'];
this.announcementInfo = res['data']['announcementInfoList'] ? res['data']['announcementInfoList'][0]['title'] : '银盾公告' if (Number(this.messageUnreadCount) > 99) {
} this.messageUnreadCount = '99+';
}) }
} } else {
// 点击模块导航 this.messageUnreadCount = null;
featureSelect(item) { }
if (item.isOpen) { })
this.router.navigate([item.link]); }
} else {
this.state.modal1 = true;
}
}
// 获取轮播图
filePathQuery() {
this.myService.filePath(6, 0, 7, null, null).subscribe(res => {
if (res['success']) {
this.bannerLists = res['data']['fileUploadItemList'] || [];
}
})
}
// 模糊查询产品
queryproductlistbytag(tagId, dataName) {
this.myService.queryproductlistbytag({ mdTagId: tagId }).subscribe(res => {
if (res['success']) {
this[dataName] = res['data']['plans']
}
})
}
// 点击产品进入详情页 searchProduct() {
goProductDetail(product): void { // 查询互联网产品
if (product.isThirdpartyPurchase == 1) { this.router.navigate(['/product', { queryTagId: 272 }])
if (product.thirdpartyPurchaseUrl) { }
window.location.href = product.thirdpartyPurchaseUrl;
} else {
alert('请配置跳转链接');
}
} else {
this.productInfo = product;
this.productInfo.type = 2;
this.inquiry = {
planId: this.productInfo.planId,
adultCount: this.productInfo.adultCount,
childCount: this.productInfo.childCount,
eldCount: this.productInfo.eldCount,
dayCount: this.productInfo.minDay
};
this.setInitDate();
localStorage.setItem('inquiry', JSON.stringify(this.inquiry));
if (this.productInfo.noPlanProduct === true) {
window.location.href = `https://${window.location.host}/life/${this.productInfo.productId}`
} else {
if (this.productInfo.productCategoryId === 1 || this.productInfo.productCategoryId === 4) {
window.location.href = `https://${window.location.host}/pdetail/${this.productInfo.planId}`
} else if (this.productInfo.productCategoryId === 2) {
window.location.href = `https://${window.location.host}/hProductDetail/${this.productInfo.planId}?type=7`
} else if (this.productInfo.productCategoryId === 5) {
window.location.href = `https://${window.location.host}/hProductDetail/${this.productInfo.planId}?type=9`
} else {
window.location.href = `https://${window.location.host}/life/${this.productInfo.productId}`
this.router.navigate(['/pdetail', this.productInfo.planId]);
}
}
}
}
// 根据开始时间设置结束时间,天数应减1,当日~当日是一天 clear(value) {
setInitDate() { this.searchText = '';
this.productInfo.dayCount = this.lifeCommonService.yearDayCount(this.productInfo.dayCount, this.productInfo.insurerId == '5'); }
this.lifeCommonService.setInitDate(this.productInfo.dayCount);
}
goBannerPro(destinationAddress) { // 查询银盾公告
if (destinationAddress) { announcementQuery() {
window.open(destinationAddress); this.myService.announcementQuery(null, 37).subscribe(res => {
} else { if (res['success']) {
return; this.announcementInfo = res['data']['announcementInfoList'] ? res['data']['announcementInfoList'][0]['title'] : '银盾公告'
} }
} })
queryCanSee(){ }
this.myService.queryCanSee({practitionerId: this.lifeCustomerInfo?this.lifeCustomerInfo['practitionerId']:null,}).subscribe((res)=>{ // 点击模块导航
if(res['success']){ featureSelect(item) {
this.canSeeSchool = res['data']['canSeeYdCollege']; if (item.isOpen) {
if (this.canSeeSchool.includes('insuranceABC') || this.canSeeSchool.includes('preJobTraining') || this.canSeeSchool.includes('newTraining') ||this.canSeeSchool.includes('promotionTraining') this.router.navigate([item.link]);
|| this.canSeeSchool.includes('productTraining') || this.canSeeSchool.includes('myTraining')) { } else {
this.featureLists.push({ key: '06', name: '银盾学院', icon: 'ydCollege', link: '/ydCollege', isOpen: true },); this.state.modal1 = true;
}else{
this.featureLists.push({ key: '06', name: '新人入口', icon: 'potentialCustomers', link: '/newPeople', isOpen: true });
} }
this.featureLists.push({ key: '07', name: '更多功能', icon: 'more', link: '/moreFeatures', isOpen: true }); }
// 获取轮播图
filePathQuery() {
} this.myService.filePath(6, 0, 7, null, null).subscribe(res => {
}) if (res['success']) {
} this.bannerLists = res['data']['fileUploadItemList'] || [];
constructor(private myService: MyService, private router: Router, private lifeCommonService: LifeCommonService) { } }
ngOnInit(): void { })
this.filePathQuery() }
// 查询互联网产品 // 模糊查询产品
this.queryproductlistbytag(272, 'onlineProductLists'); queryproductlistbytag(tagId, dataName) {
// 查询热销产品 this.myService.queryproductlistbytag({ mdTagId: tagId }).subscribe(res => {
this.queryproductlistbytag(119, 'hotProductLists'); if (res['success']) {
// 查询最新一条公告 this[dataName] = res['data']['plans']
this.announcementQuery(); }
// 查询未读消息总数 })
this.querySystemMessage(); }
this.queryCanSee();
}
} // 点击产品进入详情页
goProductDetail(product) : void {
if (product.isThirdpartyPurchase == 1) {
if (product.thirdpartyPurchaseUrl) {
window.location.href = product.thirdpartyPurchaseUrl;
} else {
alert('请配置跳转链接');
}
} else {
this.productInfo = product;
this.productInfo.type = 2;
this.inquiry = {
planId: this.productInfo.planId,
adultCount: this.productInfo.adultCount,
childCount: this.productInfo.childCount,
eldCount: this.productInfo.eldCount,
dayCount: this.productInfo.minDay
};
this.setInitDate();
localStorage.setItem('inquiry', JSON.stringify(this.inquiry));
if (this.productInfo.noPlanProduct === true) {
window.location.href = `https://${window.location.host}/life/${this.productInfo.productId}`
} else {
if (this.productInfo.productCategoryId === 1 || this.productInfo.productCategoryId === 4) {
window.location.href = `https://${window.location.host}/pdetail/${this.productInfo.planId}`
} else if (this.productInfo.productCategoryId === 2) {
window.location.href = `https://${window.location.host}/hProductDetail/${this.productInfo.planId}?type=7`
} else if (this.productInfo.productCategoryId === 5) {
window.location.href = `https://${window.location.host}/hProductDetail/${this.productInfo.planId}?type=9`
} else {
window.location.href = `https://${window.location.host}/life/${this.productInfo.productId}`
this.router.navigate(['/pdetail', this.productInfo.planId]);
}
}
}
}
// 根据开始时间设置结束时间,天数应减1,当日~当日是一天
setInitDate() {
this.productInfo.dayCount = this.lifeCommonService.yearDayCount(this.productInfo.dayCount, this.productInfo.insurerId == '5');
this.lifeCommonService.setInitDate(this.productInfo.dayCount);
}
goBannerPro(destinationAddress) {
if (destinationAddress) {
window.open(destinationAddress);
} else {
return;
}
}
queryCanSee() {
this.myService.queryCanSee({ practitionerId: this.lifeCustomerInfo ? this.lifeCustomerInfo['practitionerId'] : null, }).subscribe((res) => {
if (res['success']) {
this.canSeeSchool = res['data']['canSeeYdCollege'];
if (this.canSeeSchool.includes('insuranceABC') || this.canSeeSchool.includes('preJobTraining') || this.canSeeSchool.includes('newTraining') || this.canSeeSchool.includes('promotionTraining')
|| this.canSeeSchool.includes('productTraining') || this.canSeeSchool.includes('myTraining')) {
this.featureLists.push({ key: '06', name: '银盾学院', icon: 'ydCollege', link: '/ydCollege', isOpen: true },);
} else {
this.featureLists.push({ key: '06', name: '新人入口', icon: 'potentialCustomers', link: '/newPeople', isOpen: true });
}
this.featureLists.push({ key: '07', name: '更多功能', icon: 'more', link: '/moreFeatures', isOpen: true });
}
})
}
constructor(private myService : MyService, private router : Router, private lifeCommonService : LifeCommonService) { }
ngOnInit() : void {
this.filePathQuery()
// 查询互联网产品
this.queryproductlistbytag(272, 'onlineProductLists');
// 查询热销产品
this.queryproductlistbytag(119, 'hotProductLists');
// 查询最新一条公告
this.announcementQuery();
// 查询未读消息总数
this.querySystemMessage();
this.queryCanSee();
}
}
\ 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