user_info_view.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { _decorator, Component, Node, Label, Sprite } from 'cc';
  2. import { ClientEvent } from '../clientEvent';
  3. import { Constant } from '../constant';
  4. import { GameMng } from '../GameMng';
  5. import GBaseUI from '../gcommon/GBaseUI';
  6. import { UIButton } from '../gcommon/UIButton';
  7. import UITips from '../gcommon/UITips';
  8. import { msgManager } from '../socket/msgManager';
  9. import { Tools } from '../Tools';
  10. import { userData } from '../UserData/userData';
  11. const { ccclass, property } = _decorator;
  12. @ccclass('user_info_view')
  13. export class user_info_view extends GBaseUI {
  14. @property(Node)
  15. lab_name: Node = null;
  16. @property(Node)
  17. btn_close: Node = null;
  18. @property(Node)
  19. spr_icon: Node = null;
  20. @property(Node)
  21. lab_id: Node = null;
  22. @property(Node)
  23. btn_add_firend: Node = null;
  24. start() {
  25. UIButton.BindClick(this.btn_close,()=>{
  26. this.closeUI()
  27. },this)
  28. ClientEvent.on(Constant.EVENT_TYPE.MSG_ADD_FIREND,this.on_add_firend,this)
  29. }
  30. onDestroy(){
  31. ClientEvent.off(Constant.EVENT_TYPE.MSG_ADD_FIREND,this.on_add_firend,this)
  32. }
  33. on_add_firend(){
  34. UITips.show("添加好友成功!")
  35. }
  36. show(user_data:userData){
  37. let self = this;
  38. if(user_data.userid===GameMng._userData.userid||GameMng.isMyFirend(user_data.userid)){
  39. this.btn_add_firend.active = false;
  40. }else{
  41. this.btn_add_firend.active = true;
  42. }
  43. UIButton.BindClick(this.btn_add_firend,()=>{
  44. msgManager.add_firend(user_data.userid)
  45. self.btn_add_firend.active = false;
  46. },this)
  47. Tools.loadWeiXinHead(user_data.user_avatar,this.spr_icon.getComponent(Sprite))
  48. this.lab_name.getComponent(Label).string = user_data.user_name
  49. this.lab_id.getComponent(Label).string ="ID:"+user_data.userid
  50. }
  51. update(deltaTime: number) {
  52. }
  53. }