ShopModle.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. Object.defineProperty(i, "__esModule", {value: !0});
  5. const o = t("App"),
  6. s = t("BaseModel"),
  7. a = t("ShopConst"),
  8. n = t("ShopItemConfig");
  9. i.default = class extends s.default {
  10. constructor(t) {
  11. super(t),
  12. (this.savaData = null),
  13. (this._saveKey = "Shop"),
  14. (this.mothCardDays = 31),
  15. o.default.SaveManage.add(this, this._saveKey, !0, !0),
  16. o.default.SaveManage.load(this._saveKey);
  17. }
  18. init() {
  19. this.initConfig();
  20. }
  21. initConfig() {
  22. (this.shopItemDatas = {}), (this.shopGiftDatas = {});
  23. let e = o.default.ConfigManager.getConfig("ShopItemConfig");
  24. for (var i in e) {
  25. var s = e[i];
  26. this.shopItemDatas[s.shopType] || (this.shopItemDatas[s.shopType] = []);
  27. let t = n.getShopItemData(s);
  28. i = this.savaData.record[t.id];
  29. if (
  30. (i ? ((t.buyCnt = i.cnt), (t.time = i.time)) : t.buyCnt,
  31. this.shopItemDatas[s.shopType].push(t),
  32. t.shopType == a.ShopType.GIFT)
  33. ) {
  34. const e = t.cfg.shopGift.type;
  35. this.shopGiftDatas[e] || (this.shopGiftDatas[e] = []), this.shopGiftDatas[e].push(t);
  36. }
  37. }
  38. }
  39. updateMonthCardTime(t = 0) {}
  40. addGiftBuyCnt(t) {}
  41. updateGiftBuyCnt() {}
  42. getGiftBuyCnt(t) {
  43. return 0;
  44. }
  45. updateCnt(t) {
  46. const e = this.savaData.record;
  47. e[t.id] || (e[t.id] = {cnt: 0}),
  48. e[t.id].cnt++,
  49. (t.buyCnt = e[t.id].cnt),
  50. (t.time = e[t.id].time = o.default.DateUtils.secondNow()),
  51. t.shopType == a.ShopType.GIFT &&
  52. t.cfg.shopGift.type == a.ShopGiftType.FIRST_GIFT &&
  53. 1 === e[t.id].cnt &&
  54. (t.time = e[t.id].time = 0);
  55. }
  56. isFirstShowFirstGift() {
  57. const t = this.shopGiftDatas[a.ShopGiftType.FIRST_GIFT][0],
  58. e = this.savaData.record;
  59. return !e[t.id] && ((e[t.id] = {cnt: 0}), !0);
  60. }
  61. createMemento() {
  62. return this.savaData;
  63. }
  64. setMemento(t) {
  65. this.savaData = t || {record: {}, bankDiamond: 0};
  66. }
  67. };