ShareTaskLayer.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. import ResMgr from "../base/ResMgr";
  2. import SoundMgr from "../base/SoundMgr";
  3. import Tool from "../base/Tool";
  4. import UIMgr from "../base/UIMgr";
  5. var baseLayer = require('BaseLayer');
  6. cc.Class({
  7. extends: baseLayer,
  8. properties: {
  9. lab1: cc.Label, //贝利
  10. lab2: cc.Label, //金币
  11. labCode: cc.Label,
  12. labBindCode: cc.Label,
  13. blueNode: cc.Node,
  14. labCool: cc.Label,
  15. itemPre: cc.Node,
  16. conNode: cc.Node,
  17. helpView: cc.Node,
  18. bindView: cc.Node,
  19. editBind: cc.EditBox,
  20. detailView: cc.Node,
  21. labDBi: cc.Label,
  22. itemDPre: cc.Node,
  23. conDNode: cc.Node,
  24. },
  25. // LIFE-CYCLE CALLBACKS:
  26. // onLoad () {},
  27. start () {
  28. this.initData();
  29. },
  30. initData(){
  31. this.lab1.string = `x${12321}`;
  32. this.lab2.string = `x${222}`;
  33. this.labCode.string = 778899;
  34. this.labBindCode.string = 'xxxxxx';
  35. this.blueNode.active = true;
  36. this.lerpTime = 2134;
  37. this.daoshiji();
  38. this.schedule(this.daoshiji, 1, cc.macro.REPEAT_FOREVER);
  39. this.initItems();
  40. this.initDItems();
  41. },
  42. daoshiji(){
  43. if(this.lerpTime <= 1){
  44. this.labCool.node.active = false;
  45. this.unschedule(this.daoshiji);
  46. return;
  47. }
  48. this.lerpTime -= 1;
  49. this.labCool.string = Tool.timesBySec(this.lerpTime);
  50. },
  51. initItems(){
  52. this.conNode.removeAllChildren();
  53. for(let i=0; i < 4; i++){
  54. let temp = cc.instantiate(this.itemPre);
  55. temp.setParent(this.conNode);
  56. temp.name = `${i}`;
  57. temp.active = true;
  58. temp.getChildByName('labDes').getComponent(cc.RichText).string = '哈哈哈哈';
  59. temp.getChildByName('sp1').active = true; //贝利
  60. temp.getChildByName('sp2').active = false; //金币
  61. temp.getChildByName('labNum').getComponent(cc.Label).string = `x${998}`;
  62. }
  63. },
  64. initDItems(){
  65. this.labDBi.string = '00908';
  66. this.conDNode.removeAllChildren();
  67. for(let i=0; i < 10; i++){
  68. let temp = cc.instantiate(this.itemDPre);
  69. temp.setParent(this.conDNode);
  70. temp.name = `${i}`;
  71. temp.active = true;
  72. temp.getChildByName('labName').getComponent(cc.Label).string = '法外狂徒';
  73. }
  74. },
  75. onClickHelpView(){
  76. SoundMgr.playClick();
  77. this.helpView.active = !this.helpView.active;
  78. },
  79. onClickBindView(){
  80. SoundMgr.playClick();
  81. this.bindView.active = !this.bindView.active;
  82. },
  83. onClickEditSure(){
  84. console.log('确定: ', this.editBind.string);
  85. },
  86. onClickDetailView(){
  87. SoundMgr.playClick();
  88. this.detailView.active = !this.detailView.active;
  89. },
  90. onClickGet(){
  91. SoundMgr.playClick();
  92. UIMgr.openUI('prefabs/TipsLayer', (pf)=>{
  93. pf.getComponent('TipsLayer').setCon('没有可领取的红包');
  94. });
  95. },
  96. onClickPYQ(){
  97. SoundMgr.playClick();
  98. },
  99. onClickWX(){
  100. SoundMgr.playClick();
  101. },
  102. onClickCopy(){
  103. SoundMgr.playClick();
  104. },
  105. });