StoreSubcript.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. const DWTool = require("../utils/DWTool");
  2. const WeChat = require('../net/WeChat');
  3. const GameModule = require("../utils/GameModule");
  4. cc.Class({
  5. extends: cc.Component,
  6. properties: {
  7. btnArr: [cc.Button],
  8. moneyLabels: [cc.Label],
  9. titleLabels: [cc.Label],
  10. recommendSprite: cc.Node,
  11. },
  12. // LIFE-CYCLE CALLBACKS:
  13. // onLoad () {},
  14. start () {
  15. },
  16. init(shopDatas) {
  17. this._shopDatas = shopDatas;
  18. /// 如果只有一个 那么说明买过了
  19. if (this._shopDatas.length == 1) {
  20. this.recommendSprite.active = false;
  21. this.btnArr[0].node.active = false;
  22. this.btnArr[2].node.active = false;
  23. let titileArr = ['周使用权', '月使用权', '年使用权'];
  24. this.titleLabels[1].string = titileArr[shopDatas[0].shopId - 1];
  25. /// 转换为天数
  26. let cdTime = shopDatas[0].cdTime;
  27. let dayTime = 1000 * 60 * 60 * 24;
  28. let days = parseInt(cdTime / dayTime);
  29. let hours = parseInt((parseInt(cdTime) % dayTime ) / (1000 * 60 * 60));
  30. if (days === 0) {
  31. if (hours == 0) {
  32. this.moneyLabels[1].string = DWTool.calculateTime(shopDatas[0].cdTime / 1000);
  33. } else {
  34. this.moneyLabels[1].string = '剩余' + hours + '小时';
  35. }
  36. } else {
  37. this.moneyLabels[1].string = '剩余' + days + '天' + hours + '小时';
  38. }
  39. /// 不能点击
  40. this.btnArr[1].interactable = false;
  41. /// 更新价格信息
  42. } else {
  43. this.moneyLabels[0].string = '¥' + this._shopDatas[1].price;
  44. this.moneyLabels[1].string = '¥' + this._shopDatas[0].price;
  45. this.moneyLabels[2].string = '¥' + this._shopDatas[2].price;
  46. }
  47. },
  48. closeButtonAction() {
  49. GameModule.audioMng.playClickButton();
  50. this.node.destroy();
  51. },
  52. //// eventData 1 2 3 月 周 年
  53. buyAction() {
  54. GameModule.audioMng.playClickButton();
  55. WeChat.jumpCustomerServices()
  56. }
  57. // update (dt) {},
  58. });