TreaRecordItem.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. const { ccclass, property } = cc._decorator;
  8. @ccclass
  9. export default class TreaRecordItem extends cc.Component {
  10. @property(cc.Label)
  11. labIssue: cc.Label = null;
  12. @property(cc.Label)
  13. labTime: cc.Label = null;
  14. @property(cc.Label)
  15. labNickname: cc.Label = null;
  16. @property(cc.RichText)
  17. labHasJoin: cc.RichText = null;
  18. @property(cc.Sprite)
  19. spHead: cc.Sprite = null;
  20. // LIFE-CYCLE CALLBACKS:
  21. // onLoad () {}
  22. start() {
  23. }
  24. /**
  25. * @param data
  26. * drawname 开奖名字
  27. * phase 开奖期数
  28. * drawtime 开奖时间
  29. * nikename 中奖者昵称
  30. * headimgurl 中奖者头像
  31. */
  32. init(data) {
  33. cc.loader.load(data.headimgurl + "?aaa=aa.jpg", (err, res) => {
  34. if (err) {
  35. console.log('err:', err);
  36. return;
  37. }
  38. let tex: cc.Texture2D = res as cc.Texture2D;
  39. this.spHead.spriteFrame = new cc.SpriteFrame(tex);
  40. })
  41. this.labNickname.string = data.nikename
  42. this.labIssue.string = `第${data.phase}期`
  43. this.labTime.string = data.drawtime
  44. this.labHasJoin.string = ''
  45. // this.labHasJoin.string = '是否参与:<color=#E12F09>否</color>'
  46. // this.labHasJoin.string = '是否参与:<color=#00AF0C>是</color>'
  47. }
  48. // update (dt) {}
  49. }