GameShop.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. TopBtnImg_OnChecked: {
  5. default: null,
  6. type: cc.Texture2D,
  7. serializable: true,
  8. },
  9. TopBtnImg_UnChecked: {
  10. default: null,
  11. type: cc.Texture2D,
  12. serializable: true,
  13. },
  14. GoodsList_Diamonds: {
  15. default: null,
  16. type: cc.Node,
  17. serializable: true,
  18. },
  19. GoodsList_Tools: {
  20. default: null,
  21. type: cc.Node,
  22. serializable: true,
  23. },
  24. TopBtn_Diamond: {
  25. default: null,
  26. type: cc.Node,
  27. serializable: true,
  28. },
  29. TopBtn_Tools: {
  30. default: null,
  31. type: cc.Node,
  32. serializable: true,
  33. },
  34. PayPage: {
  35. default: null,
  36. type: cc.Node,
  37. serializable: true,
  38. },
  39. Tip_AfterPay: {
  40. default: null,
  41. type: cc.Node,
  42. serializable: true,
  43. },
  44. GoodsPriceList_Diamonds:null,
  45. GoodsPriceList_Tools:null,
  46. },
  47. OnActive()
  48. {
  49. },
  50. start () {
  51. this.GoodsPriceList_Diamonds=[
  52. {
  53. GoodsID: 0,
  54. GoodsPrice:1,
  55. GoodsNum:10
  56. },
  57. {
  58. GoodsID: 1,
  59. GoodsPrice:2,
  60. GoodsNum:20
  61. },
  62. {
  63. GoodsID: 2,
  64. GoodsPrice:3,
  65. GoodsNum:30
  66. },
  67. {
  68. GoodsID: 3,
  69. GoodsPrice:5,
  70. GoodsNum:80
  71. },
  72. {
  73. GoodsID: 4,
  74. GoodsPrice:10,
  75. GoodsNum:180
  76. },
  77. {
  78. GoodsID: 5,
  79. GoodsPrice:20,
  80. GoodsNum:500
  81. },
  82. ];
  83. this.GoodsPriceList_Tools=[
  84. {
  85. GoodsID: 0,
  86. GoodsName:'矿泉水',
  87. GoodsPrice:10,
  88. GoodsNum:1
  89. },
  90. {
  91. GoodsID: 1,
  92. GoodsName:'乳酸',
  93. GoodsPrice:20,
  94. GoodsNum:1
  95. }
  96. ]
  97. },
  98. //0钻石1道具
  99. ShopTypeOnChecked(event,customData){
  100. if(customData==0){
  101. this.TopBtn_Diamond.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(this.TopBtnImg_OnChecked);
  102. this.TopBtn_Tools.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(this.TopBtnImg_UnChecked);
  103. this.GoodsList_Diamonds.active = true;
  104. this.GoodsList_Tools.active = false;
  105. }else if(customData==1){
  106. this.TopBtn_Diamond.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(this.TopBtnImg_UnChecked);
  107. this.TopBtn_Tools.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(this.TopBtnImg_OnChecked);
  108. this.GoodsList_Diamonds.active = false;
  109. this.GoodsList_Tools.active = true;
  110. }
  111. },
  112. //钻石购买customData传回来GoodsID
  113. GoodsDiamondsPriceBtnOnClick(event,customData){
  114. for(var i = 0;i<this.GoodsPriceList_Diamonds.length;i++){
  115. if(customData == this.GoodsPriceList_Diamonds[i].GoodsID){
  116. var PayPageCtrl = this.PayPage.getComponent('PayPage');
  117. var Tip_AfterPayText = '钻石+'+this.GoodsPriceList_Diamonds[i].GoodsNum;
  118. PayPageCtrl.PayPageInit(Tip_AfterPayText,this.GoodsPriceList_Diamonds[i].GoodsPrice);
  119. this.PayPage.active = true;
  120. }
  121. }
  122. },
  123. //道具购买customData传回来GoodsID
  124. GoodsToolsPriceBtnOnClick(event,customData){
  125. for(var i = 0;i<this.GoodsPriceList_Tools.length;i++){
  126. if(customData == this.GoodsPriceList_Tools[i].GoodsID){
  127. var Tip_AfterPayText = this.GoodsPriceList_Tools[i].GoodsName+'+'+this.GoodsPriceList_Tools[i].GoodsNum;
  128. this.Tip_AfterPay.getChildByName('TipText').getComponent(cc.Label).string = Tip_AfterPayText;
  129. this.Tip_AfterPay.active = true;
  130. var animCtrl = this.Tip_AfterPay.getComponent(cc.Animation);
  131. animCtrl.play();
  132. }
  133. }
  134. },
  135. });