rank_my_info.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. @property(Node) lab_region:Node = null
  21. initView(data:rankData) {
  22. if(data.number==0) {
  23. this.img_weishangbang.active = true
  24. this.icon_number_bg.active = false
  25. this.icon_number_other_bg.active = false
  26. } else {
  27. this.img_weishangbang.active = false
  28. if(data.number<=3) {
  29. this.icon_number_bg.active = true
  30. switch (data.number) {
  31. case 1:
  32. this.icon_number_img.getComponent(Sprite).spriteFrame = this.sf_rank_icon_1
  33. break;
  34. case 2:
  35. this.icon_number_img.getComponent(Sprite).spriteFrame = this.sf_rank_icon_2
  36. break;
  37. case 3:
  38. this.icon_number_img.getComponent(Sprite).spriteFrame = this.sf_rank_icon_3
  39. break;
  40. default:
  41. break;
  42. }
  43. } else {
  44. this.icon_number_other_bg.active = true
  45. this.lab_number_other.getComponent(Label).string = data.number + ''
  46. }
  47. }
  48. tools.loadRemoteImg(data.avatarUrl, (r)=>{
  49. this.img_avatar.getComponent(Sprite).spriteFrame = r.sf
  50. })
  51. this.lab_region.getComponent(Label).string = data.city_name
  52. this.lab_nickname.getComponent(Label).string = data.nickName
  53. this.lab_score.getComponent(Label).string = data.score + ' 分'
  54. this.img_car.getComponent(Sprite).spriteFrame = GameManager.getUserDefaultRankCarSf()
  55. }
  56. }