Share.service.ts 819 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import { Injectable } from '@angular/core';
  2. @Injectable({
  3. providedIn: 'root'
  4. })
  5. export class SharedService
  6. {
  7. private userId: string = '';
  8. private username: string = '';
  9. private userImgScr: string = '';
  10. private islogin: boolean = false;
  11. setUsername(username: string ,userId:string): void {
  12. this.username = username;
  13. this.userId=userId
  14. if(username!=null){
  15. this.userImgScr="http://q1.qlogo.cn/g?b=qq&nk="+userId+"&s=100"
  16. }
  17. }
  18. getUsername(): string {
  19. return this.username;
  20. }
  21. getUserId(): string {
  22. return this.userId;
  23. }
  24. getUserImg(): string {
  25. return this.userImgScr;
  26. }
  27. pdlogin(): boolean {
  28. return this.islogin;
  29. }
  30. isLogin():void{
  31. this.islogin=true;
  32. }
  33. outLogin():void{
  34. this.userImgScr='';
  35. this.username='';
  36. this.islogin=false
  37. }
  38. }