TaskPage2.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import SoundMgr from "../base/SoundMgr";
  2. import Tool from "../base/Tool";
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. labDayLive: cc.Label,
  7. dayNodes: [cc.Node],
  8. spDayBar: cc.Sprite,
  9. labWeekLive: cc.Label,
  10. weekNodes: [cc.Node],
  11. spWeekBar: cc.Sprite,
  12. logoSpArr: [cc.SpriteFrame],
  13. propSpArr: [cc.SpriteFrame],
  14. itemPrefab: cc.Node,
  15. conNode: cc.Node,
  16. },
  17. // LIFE-CYCLE CALLBACKS:
  18. // onLoad () {},
  19. start () {
  20. },
  21. initData(index){
  22. this.type = index;
  23. //日
  24. for(let i=0; i< this.dayNodes.length; i++){
  25. this.dayNodes[i].getChildByName('done').active = false;
  26. this.dayNodes[i].getChildByName('num').getComponent(cc.Label).string = '2';
  27. }
  28. this.labDayLive.string = 128;
  29. this.spDayBar.fillRange = 0.8;
  30. //周
  31. for(let i=0; i < this.weekNodes.length; i++){
  32. this.weekNodes[i].getChildByName('done').active = false;
  33. this.weekNodes[i].getChildByName('num').getComponent(cc.Label).string = '8';
  34. }
  35. this.labWeekLive.string = 999;
  36. this.spWeekBar.fillRange = 0.3;
  37. //con
  38. this.data = [17,18,19,110,111,112];
  39. if(this.type == 1){
  40. this.data = [9,10];
  41. }
  42. this.conNode.removeAllChildren();
  43. for(let i=0; i < this.data.length; i++){
  44. let temp = cc.instantiate(this.itemPrefab);
  45. temp.setParent(this.conNode);
  46. temp.name = `${i}`;
  47. temp.active = true;
  48. temp.data = this.data[i];
  49. this.setItems(temp);
  50. }
  51. },
  52. setItems(tNode){
  53. tNode.getChildByName('logosp').getComponent(cc.Sprite).spriteFrame = this.logoSpArr[1];
  54. tNode.getChildByName('name').getComponent(cc.Label).string = '精英计划';
  55. tNode.getChildByName('bar').getComponent(cc.Sprite).fillRange = 0.8;
  56. tNode.getChildByName('labPro').getComponent(cc.Label).string = `${1}/${2}`;
  57. tNode.getChildByName('labCoin').getComponent(cc.Label).string = `x${3453}`;
  58. tNode.getChildByName('labAc').getComponent(cc.Label).string = `x${12}`;
  59. let gonode = tNode.getChildByName('go');
  60. gonode.active = false;
  61. Tool.addBtnListener(gonode, this.node, 'TaskPage2', 'onClickGo', tNode.data);
  62. let getnode = tNode.getChildByName('get');
  63. getnode.active = true;
  64. Tool.addBtnListener(getnode, this.node, 'TaskPage2', 'onClickGet', tNode.data);
  65. },
  66. onClickGo(event, customEventData){
  67. SoundMgr.playClick();
  68. console.log('go: ', customEventData);
  69. },
  70. onClickGet(event, customEventData){
  71. SoundMgr.playClick();
  72. console.log('get: ', customEventData);
  73. },
  74. onClickDayGift(event, index){
  75. SoundMgr.playClick();
  76. console.log('day: ', index);
  77. },
  78. onClickWeekGift(event, index){
  79. SoundMgr.playClick();
  80. console.log('week: ', index);
  81. },
  82. });