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 { AuthService } from '../auth.service';
import { LifeCommonService } from '../../common/life-common.service';
@Component({
selector: 'ydlife-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
selector: 'ydlife-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit, OnDestroy {
@ViewChild('dragContainer') dragContainer: ElementRef;
@ViewChild('dragHandler') dragHandler: ElementRef;
MOBILE_REGEXP = /^(1)\d{10}$/;
sendCodeHtml: string = '获取验证码';
timer: any;
remainTimes: number = 60;
disabledSendBtn: boolean = false;
userInfo: any = {
mobileNo: null,
verificationCode: null
};
isNeedAlert: boolean;
dialogInfo: any;
redirect: any;
dragBg:any;
dragText:any;
maxHandlerOffset:any;
isVertifySucc:boolean = true;
left:any;
deviceType:any;
len:any;
constructor(public authService: AuthService, public router: Router, public lifeCommonService: LifeCommonService) {
this.deviceType = this.lifeCommonService.checkDeviceType();
}
@ViewChild('dragContainer') dragContainer : ElementRef;
@ViewChild('dragHandler') dragHandler : ElementRef;
MOBILE_REGEXP = /^(1)\d{10}$/;
sendCodeHtml : string = '获取验证码';
timer : any;
remainTimes : number = 60;
disabledSendBtn : boolean = false;
userInfo : any = {
mobileNo: null,
verificationCode: null
};
isNeedAlert : boolean;
dialogInfo : any;
redirect : any;
dragBg : any;
dragText : any;
maxHandlerOffset : any;
isVertifySucc : boolean = true;
left : any;
deviceType : any;
len : any;
constructor(public authService : AuthService, public router : Router, public lifeCommonService : LifeCommonService) {
this.deviceType = this.lifeCommonService.checkDeviceType();
}
// 监听document离开事件
@HostListener('document:touchend', ['$event'])
ontouchend(event) {
// 只用当元素移动过了,离开函数体才会触发。
this.onDragHandlerMouseUp();
}
// 监听document离开事件
@HostListener(`mouseup`, ['$event'])
onmouseup(event) {
// 只用当元素移动过了,离开函数体才会触发。
this.onDragHandlerMouseUp();
}
// 监听document离开事件
@HostListener('document:touchend', ['$event'])
ontouchend(event) {
// 只用当元素移动过了,离开函数体才会触发。
this.onDragHandlerMouseUp();
}
ngOnInit() {
// //获取滑动控件容器,灰色背景
// 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;
// 监听document离开事件
@HostListener(`mouseup`, ['$event'])
onmouseup(event) {
// 只用当元素移动过了,离开函数体才会触发。
this.onDragHandlerMouseUp();
}
}
ngOnDestroy() {
clearInterval(this.timer);
}
ngOnInit() {
// //获取滑动控件容器,灰色背景
// 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() {
const compareInfo = {
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;
// }
ngOnDestroy() {
clearInterval(this.timer);
}
} else {
this.openPopInfo('暂无查询资格');
}
} else {
this.openPopInfo(response['message']);
}
});
} else {
this.openPopInfo(res['message']);
}
});
} else {
this.openPopInfo('手机号或验证码不正确');
}
}
inputBlur() {
window.scrollTo(0, 0)
}
// 发送验证码
verificationCode() {
const verificationInfo = {
mobileNo: this.userInfo.mobileNo,
type: '1'
};
if (this.MOBILE_REGEXP.test(this.userInfo.mobileNo) && !this.disabledSendBtn) {
this.authService.verificationCode(verificationInfo).subscribe(res => {
if (res['success']) {
this.countDown();
} else {
this.openPopInfo(res['message']);
}
});
} else if (!this.MOBILE_REGEXP.test(this.userInfo.mobileNo)) {
this.openPopInfo('手机号不正确');
}
}
login() {
const compareInfo = {
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((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() {
this.disabledSendBtn = true;
this.timer = setInterval(() => {
this.remainTimes--;
this.sendCodeHtml = `${this.remainTimes}(S)`;
if (this.remainTimes <= 0) {
this.sendCodeHtml = '获取验证码';
this.remainTimes = 60;
this.disabledSendBtn = false;
clearInterval(this.timer);
}
}, 1000);
}
// 发送验证码
verificationCode() {
const verificationInfo = {
mobileNo: this.userInfo.mobileNo,
type: '1'
};
if (this.MOBILE_REGEXP.test(this.userInfo.mobileNo) && !this.disabledSendBtn) {
this.authService.verificationCode(verificationInfo).subscribe(res => {
if (res['success']) {
this.countDown();
} else {
this.openPopInfo(res['message']);
}
});
} else if (!this.MOBILE_REGEXP.test(this.userInfo.mobileNo)) {
this.openPopInfo('手机号不正确');
}
}
// 打开弹窗
openPopInfo(message) {
this.isNeedAlert = true;
this.dialogInfo = {
title: null,
content: { value: message, align: 'center' },
footer: [{ value: '我知道了', routerLink: '', className: 'weui-dialog__btn_primary' }],
};
}
// 倒计时
countDown() {
this.disabledSendBtn = true;
this.timer = setInterval(() => {
this.remainTimes--;
this.sendCodeHtml = `${this.remainTimes}(S)`;
if (this.remainTimes <= 0) {
this.sendCodeHtml = '获取验证码';
this.remainTimes = 60;
this.disabledSendBtn = false;
clearInterval(this.timer);
}
}, 1000);
}
// 关闭弹窗
getPopInfo() {
this.isNeedAlert = false;
}
// 打开弹窗
openPopInfo(message) {
this.isNeedAlert = true;
this.dialogInfo = {
title: null,
content: { value: message, align: 'center' },
footer: [{ value: '我知道了', routerLink: '', className: 'weui-dialog__btn_primary' }],
};
}
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()
});
}
// 关闭弹窗
getPopInfo() {
this.isNeedAlert = false;
}
}
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() {
if(this.deviceType == 2 || this.deviceType == 3){
//移除鼠标移动监听
document.removeEventListener("touchmove", this.onDragHandlerMouseMove);
//移除鼠标松开监听
document.removeEventListener("touchend", this.onDragHandlerMouseUp);
}else{
//移除鼠标移动监听
document.removeEventListener("mousemove", this.onDragHandlerMouseMove);
//移除鼠标松开监听
document.removeEventListener("mouseup", this.onDragHandlerMouseUp);
document.querySelector('#dragHandler').classList.remove('slideController');
}
if(this.isVertifySucc){
//初始化滑块移动量
this.dragHandler.nativeElement.style.left = 0;
//初始化绿色背景
this.dragBg.style.width = 0;
}
}
//滑块移动
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;
}
}
//验证成功
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)
//松开滑块函数
onDragHandlerMouseUp() {
if (this.deviceType == 2 || this.deviceType == 3) {
//移除鼠标移动监听
document.removeEventListener("touchmove", this.onDragHandlerMouseMove);
//移除鼠标松开监听
document.removeEventListener("touchend", this.onDragHandlerMouseUp);
} else {
//移除鼠标移动监听
document.removeEventListener("mousemove", this.onDragHandlerMouseMove);
//移除鼠标松开监听
document.removeEventListener("mouseup", this.onDragHandlerMouseUp);
document.querySelector('#dragHandler').classList.remove('slideController');
}
if (this.isVertifySucc) {
//初始化滑块移动量
this.dragHandler.nativeElement.style.left = 0;
//初始化绿色背景
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
import { Router } from '@angular/router';
import { LifeCommonService } from 'src/app/common/life-common.service';
import { MyService } from '../my.service';
declare var wx: any;
declare var wx : any;
@Component({
selector: 'ydlife-my-center-home',
templateUrl: './my-center-home.component.html',
styleUrls: ['./my-center-home.component.scss'],
selector: 'ydlife-my-center-home',
templateUrl: './my-center-home.component.html',
styleUrls: ['./my-center-home.component.scss'],
})
export class MyCenterHomeComponent implements OnInit {
messageUnreadCount:string;
productInfo: any;
inquiry: any;
public announcementInfo: string;
public searchText: string;
public featureLists = [
{ key: '00', name: '产品库', icon: 'productLibary', link: '/product', isOpen: true },
{ key: '01', name: '计划书', icon: 'proposals', link: '', isOpen: false },
{ key: '02', name: '我的保单', icon: 'policyLists', link: '/salesDetail', isOpen: true },
{ key: '03', name: '续期管理', icon: 'renewalManagement', link: '/renewal_reminder', isOpen: true },
{ key: '04', name: '成交客户', icon: 'customers', link: '/customer', 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;
}
messageUnreadCount : string;
productInfo : any;
inquiry : any;
public announcementInfo : string;
public searchText : string;
public featureLists = [
{ key: '00', name: '产品库', icon: 'productLibary', link: '/product', isOpen: true },
{ key: '01', name: '计划书', icon: 'proposals', link: '', isOpen: false },
{ key: '02', name: '我的保单', icon: 'policyLists', link: '/salesDetail', isOpen: true },
{ key: '03', name: '续期管理', icon: 'renewalManagement', link: '/renewal_reminder', isOpen: true },
{ key: '04', name: '成交客户', icon: 'customers', link: '/customer', isOpen: true },
{ key: '05', name: '我的增员', icon: 'increaseStaff', link: '/recruiting', isOpen: true },
submit(value) {
if (value.trim()) {
this.router.navigate(['/product', { queryName: value.trim() }])
}
}
querySystemMessage(){
this.myService.querySystemMessage({practitionerId:localStorage.getItem('lifeCustomerInfo') ? JSON.parse(localStorage.getItem('lifeCustomerInfo')).practitionerId : null}).subscribe(res=>{
if(res['success']){
this.messageUnreadCount = res['data']['unReadcount'];
if(Number(this.messageUnreadCount) > 99){
this.messageUnreadCount = '99+';
}
}else{
this.messageUnreadCount = null;
}
})
}
]
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;
}
searchProduct() {
// 查询互联网产品
this.router.navigate(['/product', { queryTagId: 272 }])
}
clear(value) {
this.searchText = '';
}
submit(value) {
if (value.trim()) {
this.router.navigate(['/product', { queryName: value.trim() }])
}
}
// 查询银盾公告
announcementQuery() {
this.myService.announcementQuery(null, 37).subscribe(res => {
if (res['success']) {
this.announcementInfo = res['data']['announcementInfoList'] ? res['data']['announcementInfoList'][0]['title'] : '银盾公告'
}
})
}
// 点击模块导航
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']
}
})
}
querySystemMessage() {
this.myService.querySystemMessage({ practitionerId: localStorage.getItem('lifeCustomerInfo') ? JSON.parse(localStorage.getItem('lifeCustomerInfo')).practitionerId : null }).subscribe(res => {
if (res['success']) {
this.messageUnreadCount = res['data']['unReadcount'];
if (Number(this.messageUnreadCount) > 99) {
this.messageUnreadCount = '99+';
}
} else {
this.messageUnreadCount = null;
}
})
}
// 点击产品进入详情页
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]);
}
}
}
}
searchProduct() {
// 查询互联网产品
this.router.navigate(['/product', { queryTagId: 272 }])
}
// 根据开始时间设置结束时间,天数应减1,当日~当日是一天
setInitDate() {
this.productInfo.dayCount = this.lifeCommonService.yearDayCount(this.productInfo.dayCount, this.productInfo.insurerId == '5');
this.lifeCommonService.setInitDate(this.productInfo.dayCount);
}
clear(value) {
this.searchText = '';
}
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 });
// 查询银盾公告
announcementQuery() {
this.myService.announcementQuery(null, 37).subscribe(res => {
if (res['success']) {
this.announcementInfo = res['data']['announcementInfoList'] ? res['data']['announcementInfoList'][0]['title'] : '银盾公告'
}
})
}
// 点击模块导航
featureSelect(item) {
if (item.isOpen) {
this.router.navigate([item.link]);
} else {
this.state.modal1 = 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();
}
}
// 获取轮播图
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']
}
})
}
}
// 点击产品进入详情页
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