MailTipLayer.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import ResMgr from "../base/ResMgr";
  2. import SoundMgr from "../base/SoundMgr";
  3. import Tool from "../base/Tool";
  4. var baseLayer = require('BaseLayer');
  5. cc.Class({
  6. extends: baseLayer,
  7. properties: {
  8. labTitle: cc.Label,
  9. labRen: cc.Label,
  10. labTime: cc.Label,
  11. labCon: cc.Label,
  12. itemPre: cc.Node,
  13. conNode: cc.Node,
  14. },
  15. // LIFE-CYCLE CALLBACKS:
  16. // onLoad () {},
  17. start () {
  18. this.initData();
  19. },
  20. initData(){
  21. this.labTitle.string = 'xxxx';
  22. this.labRen.string = `发送人:${'西门吹雪'}`;
  23. this.labTime.string = `发送时间: ${Tool.timestampToDate(1713511270000) + Tool.timesBySec(1713511270)}`;
  24. this.labCon.string = '天下武功唯快不破';
  25. this.conNode.removeAllChildren();
  26. for(let i=0; i < 3; i++){
  27. let temp = cc.instantiate(this.itemPre);
  28. temp.setPosition(cc.v2(0, 0));
  29. temp.setParent(this.conNode);
  30. temp.name = `${i}`;
  31. temp.active = true;
  32. temp.getChildByName('labNum').getComponent(cc.Label).string = `x${12}`;
  33. ResMgr.loadTexture('texture/resIcon/9005', (spFrame)=>{
  34. temp.getChildByName('sp').getComponent(cc.Sprite).spriteFrame = spFrame;
  35. });
  36. }
  37. },
  38. closeCb(cb){
  39. this.cb = cb;
  40. },
  41. onClickGet(){
  42. SoundMgr.playClick();
  43. console.log('领取');
  44. this.onClose();
  45. if(this.cb)
  46. this.cb();
  47. },
  48. });