import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) export class SharedService { private userId: string = ''; private username: string = ''; private userImgScr: string = ''; private islogin: boolean = false; setUsername(username: string ,userId:string): void { this.username = username; this.userId=userId if(username!=null){ this.userImgScr="http://q1.qlogo.cn/g?b=qq&nk="+userId+"&s=100" } } getUsername(): string { return this.username; } getUserId(): string { return this.userId; } getUserImg(): string { return this.userImgScr; } pdlogin(): boolean { return this.islogin; } isLogin():void{ this.islogin=true; } outLogin():void{ this.userImgScr=''; this.username=''; this.islogin=false } }