StoreSubcript.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. ////不需要显示
  24. // let titileArr = ['周使用权', '月使用权', '年使用权'];
  25. this.titleLabels[1].string = '';
  26. /// 转换为天数
  27. let cdTime = shopDatas[0].cdTime;
  28. let dayTime = 1000 * 60 * 60 * 24;
  29. let days = parseInt(cdTime / dayTime);
  30. let hours = parseInt((parseInt(cdTime) % dayTime ) / (1000 * 60 * 60));
  31. if (days === 0) {
  32. if (hours == 0) {
  33. this.moneyLabels[1].string = DWTool.calculateTime(shopDatas[0].cdTime / 1000);
  34. } else {
  35. this.moneyLabels[1].string = '剩余' + hours + '小时';
  36. }
  37. } else {
  38. this.moneyLabels[1].string = '剩余' + days + '天' + hours + '小时';
  39. }
  40. /// 不能点击
  41. this.btnArr[1].interactable = false;
  42. /// 更新价格信息
  43. } else {
  44. this.moneyLabels[0].string = '¥' + this._shopDatas[1].price;
  45. this.moneyLabels[1].string = '¥' + this._shopDatas[0].price;
  46. this.moneyLabels[2].string = '¥' + this._shopDatas[2].price;
  47. }
  48. },
  49. closeButtonAction() {
  50. GameModule.audioMng.playClickButton();
  51. this.node.destroy();
  52. },
  53. //// eventData 1 2 3 月 周 年
  54. buyAction() {
  55. GameModule.audioMng.playClickButton();
  56. WeChat.jumpCustomerServices()
  57. }
  58. // update (dt) {},
  59. });