UserHead.ts 967 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { _decorator, Component, Label, Node, Sprite } from 'cc';
  2. import { ModuleDef } from '../../scripts/ModuleDef';
  3. import { UserMgr } from '../scripts/UserMgr';
  4. import { UIUserInfo } from '../ui_user_info/UIUserInfo';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('UserHead')
  7. export class UserHead extends Component {
  8. @property(Label)
  9. lblUserName: Label;
  10. @property(Label)
  11. lblUserId: Label;
  12. @property(Sprite)
  13. headImg: Sprite;
  14. @property(Label)
  15. lblCoin: Label;
  16. start() {
  17. UserMgr.inst.setUserIconAndName(UserMgr.inst.uid, this.headImg, this.lblUserName, ModuleDef.BASIC);
  18. this.lblUserId.string = 'ID:' + UserMgr.inst.uid;
  19. this.lblCoin.string = '战币:' + UserMgr.inst.coin;
  20. }
  21. async onHeadImgClicked() {
  22. let info = await UserMgr.inst.rpc_GetUserInfo(UserMgr.inst.uid);
  23. tgx.UIMgr.inst.showUI(UIUserInfo, null, null, info);
  24. }
  25. update(deltaTime: number) {
  26. }
  27. }