rank_my_info.ts 2.5 KB

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