rank_my_info.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { _decorator, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
  2. import { rankData } from '../../data';
  3. import { tools } from '../../tools';
  4. import { GameManager } from '../../GameManager';
  5. const { ccclass, property } = _decorator;
  6. @ccclass('rank_my_info')
  7. export class rank_my_info extends Component {
  8. @property(Node) img_weishangbang:Node = null
  9. @property(Node) icon_number_bg:Node = null
  10. @property(Node) icon_number_img:Node = null
  11. @property(Node) icon_number_other_bg:Node = null
  12. @property(Node) lab_number_other:Node = null
  13. @property(SpriteFrame) sf_rank_icon_1:SpriteFrame = null
  14. @property(SpriteFrame) sf_rank_icon_2:SpriteFrame = null
  15. @property(SpriteFrame) sf_rank_icon_3:SpriteFrame = null
  16. @property(Node) img_avatar:Node = null
  17. @property(Node) lab_nickname:Node = null
  18. @property(Node) lab_score:Node = null
  19. @property(Node) img_car:Node = null
  20. initView(data:rankData) {
  21. if(data.number==0) {
  22. this.img_weishangbang.active = true
  23. this.icon_number_bg.active = false
  24. this.icon_number_other_bg.active = false
  25. } else {
  26. this.img_weishangbang.active = false
  27. if(data.number<=3) {
  28. this.icon_number_bg.active = true
  29. switch (data.number) {
  30. case 1:
  31. this.icon_number_img.getComponent(Sprite).spriteFrame = this.sf_rank_icon_1
  32. break;
  33. case 2:
  34. this.icon_number_img.getComponent(Sprite).spriteFrame = this.sf_rank_icon_2
  35. break;
  36. case 3:
  37. this.icon_number_img.getComponent(Sprite).spriteFrame = this.sf_rank_icon_3
  38. break;
  39. default:
  40. break;
  41. }
  42. } else {
  43. this.icon_number_other_bg.active = true
  44. this.lab_number_other.getComponent(Label).string = data.number + ''
  45. }
  46. }
  47. tools.loadRemoteImg(data.avatarUrl, (r)=>{
  48. this.img_avatar.getComponent(Sprite).spriteFrame = r.sf
  49. })
  50. this.lab_nickname.getComponent(Label).string = data.nickName
  51. this.lab_score.getComponent(Label).string = data.score + ' 分'
  52. this.img_car.getComponent(Sprite).spriteFrame = GameManager.getUserDefaultRankCarSf()
  53. }
  54. }