bag_avatar_preview.ts 1015 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { _decorator, Component, Node, Sprite } from 'cc';
  2. import { base_ui } from '../../fw/base_ui';
  3. import { tools } from '../../tools';
  4. import { userDataManager } from '../../manager/userDataManager';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('bag_avatar_preview')
  7. export class bag_avatar_preview extends base_ui {
  8. @property(Node) img_avatar:Node = null
  9. @property(Node) img_avatar_border:Node = null
  10. @property(Node) btn_close:Node = null
  11. @property(Node) btn_true:Node = null
  12. start() {
  13. this.onButtonListen(this.btn_close, ()=>{
  14. this.close()
  15. })
  16. this.onButtonListen(this.btn_true, ()=>{
  17. this.requestSetAvatar()
  18. })
  19. }
  20. initView() {
  21. tools.loadRemoteImg(userDataManager.user_data.avatarUrl, (d)=>{
  22. this.img_avatar.getComponent(Sprite).spriteFrame = d.sf
  23. })
  24. }
  25. protected close(): void {
  26. this.node.active = false
  27. }
  28. private requestSetAvatar() {
  29. this.close()
  30. }
  31. }