ExchangeTaskLayer.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. import SoundMgr from "../base/SoundMgr";
  2. import ResMgr from "../base/ResMgr";
  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. item1Pre: cc.Node,
  10. con1Node: cc.Node,
  11. lock3Node: cc.Node,
  12. item3Pre: cc.Node,
  13. scro3Node: cc.Node,
  14. con3Node: cc.Node,
  15. lab2Des: cc.Label,
  16. done2Node: cc.Node,
  17. buy2Node: cc.Node,
  18. go2Node: cc.Node,
  19. get2Node: cc.Node,
  20. },
  21. // LIFE-CYCLE CALLBACKS:
  22. onLoad () {
  23. this._super();
  24. },
  25. start () {
  26. this.setCon1();
  27. this.setCon2();
  28. this.setCon3();
  29. },
  30. setCon1(){
  31. this.con1Node.removeAllChildren();
  32. for(let i=0; i < 3; i++){
  33. let temp = cc.instantiate(this.item1Pre);
  34. temp.setParent(this.con1Node);
  35. temp.y =0;
  36. console.log(temp.y);
  37. temp.name = `${i}`;
  38. temp.active = true;
  39. let labTitle = cc.find('kuang/labTitle', temp).getComponent(cc.Label);
  40. labTitle.string = `悬赏${998}元`;
  41. let sp = cc.find('kuang/sp', temp).getComponent(cc.Sprite);
  42. ResMgr.loadTexture('texture/PassBg/500', (spFrame)=>{
  43. sp.spriteFrame = spFrame;
  44. });
  45. let labDes = cc.find('kuang/labDes', temp).getComponent(cc.Label);
  46. labDes.string = `当日悬赏次数${0}/${10}`;
  47. let labCost = cc.find('layout/labCost', temp).getComponent(cc.Label);
  48. labCost.string = 123;
  49. let doneNode = temp.getChildByName('done');
  50. doneNode.active = false;
  51. let buyNode = temp.getChildByName('buy');
  52. buyNode.getChildByName('lab').getComponent(cc.Label).string = `VIP${i+1}可接取`;
  53. buyNode.active = true;
  54. Tool.addBtnListener(buyNode, this.node, 'ExchangeTaskLayer', 'onClickBuy1', {data: 'xxxx'});
  55. let goNode = temp.getChildByName('go');
  56. goNode.active = false;
  57. Tool.addBtnListener(goNode, this.node, 'ExchangeTaskLayer', 'onClickGo1', {data: 'go'});
  58. let getNode = temp.getChildByName('get');
  59. getNode.active = false;
  60. Tool.addBtnListener(getNode, this.node, 'ExchangeTaskLayer', 'onClickGet1', {data: 'get'});
  61. }
  62. },
  63. setCon2(){
  64. this.lab2Des.string = `悬赏1元`;
  65. this.done2Node.active = false;
  66. this.buy2Node.active = true;
  67. this.go2Node.active = false;
  68. this.get2Node.active = false;
  69. },
  70. setCon3(){
  71. this.lock3Node.active = false;
  72. this.scro3Node.active = true;
  73. this.con3Node.removeAllChildren();
  74. for(let i=0; i < 5; i++){
  75. let temp = cc.instantiate(this.item3Pre);
  76. temp.setParent(this.con3Node);
  77. temp.name = `${i}`;
  78. temp.active = true;
  79. let labTitle = cc.find('kuang/labTitle', temp).getComponent(cc.Label);
  80. labTitle.string = `悬赏${998}元`;
  81. let sp = cc.find('kuang/sp', temp).getComponent(cc.Sprite);
  82. ResMgr.loadTexture('texture/PassBg/500', (spFrame)=>{
  83. sp.spriteFrame = spFrame;
  84. });
  85. let labDes = cc.find('kuang/labDes', temp).getComponent(cc.Label);
  86. labDes.string = `当日悬赏次数${0}/${10}`;
  87. let labCost = cc.find('layout/labCost', temp).getComponent(cc.Label);
  88. labCost.string = 123;
  89. let doneNode = temp.getChildByName('done');
  90. doneNode.active = false;
  91. let buyNode = temp.getChildByName('buy');
  92. buyNode.active = true;
  93. Tool.addBtnListener(buyNode, this.node, 'ExchangeTaskLayer', 'onClickBuy3', {data: 'xxxx'});
  94. let goNode = temp.getChildByName('go');
  95. goNode.active = false;
  96. Tool.addBtnListener(goNode, this.node, 'ExchangeTaskLayer', 'onClickGo3', {data: 'go'});
  97. let getNode = temp.getChildByName('get');
  98. getNode.active = false;
  99. Tool.addBtnListener(getNode, this.node, 'ExchangeTaskLayer', 'onClickGet3', {data: 'get'});
  100. }
  101. },
  102. // click con1 start -------
  103. onClickBuy1(event, customEventData){
  104. SoundMgr.playClick();
  105. console.log('customEventData: ', customEventData);
  106. },
  107. onClickGo1(event, customEventData){
  108. SoundMgr.playClick();
  109. console.log('customEventData: ', customEventData);
  110. },
  111. onClickGet1(event, customEventData){
  112. SoundMgr.playClick();
  113. console.log('customEventData: ', customEventData);
  114. },
  115. // click con1 end ---------
  116. // click con2 start -------
  117. onClickBuy2(){
  118. SoundMgr.playClick();
  119. UIMgr.openUI('prefabs/SevenInvestLayer');
  120. },
  121. onClickGo2(){
  122. SoundMgr.playClick();
  123. },
  124. onClickGet2(){
  125. SoundMgr.playClick();
  126. },
  127. // click con2 end ---------
  128. // click con3 start -------
  129. onClickBuy3(event, customEventData){
  130. SoundMgr.playClick();
  131. console.log('customEventData: ', customEventData);
  132. },
  133. onClickGo3(event, customEventData){
  134. SoundMgr.playClick();
  135. console.log('customEventData: ', customEventData);
  136. },
  137. onClickGet3(event, customEventData){
  138. SoundMgr.playClick();
  139. console.log('customEventData: ', customEventData);
  140. },
  141. // click con3 end ---------
  142. });