pool.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const utils_auth = require("../../utils/auth.js");
  4. require("../../utils/api.js");
  5. const _sfc_main = {
  6. __name: "pool",
  7. setup(__props) {
  8. const isPurchased = common_vendor.ref(false);
  9. const showModal = common_vendor.ref(false);
  10. const showPhoneAuth = common_vendor.ref(false);
  11. common_vendor.ref("reward");
  12. const startMonth = common_vendor.ref("2025-01");
  13. const endMonth = common_vendor.ref("2025-11");
  14. const isLoggedIn = common_vendor.ref(false);
  15. const formatMonth = (monthStr) => {
  16. if (!monthStr)
  17. return "请选择";
  18. const [year, month] = monthStr.split("-");
  19. return `${year}年${month}月`;
  20. };
  21. const checkLogin = () => {
  22. isLoggedIn.value = utils_auth.isLoggedIn();
  23. return isLoggedIn.value;
  24. };
  25. const checkPurchaseStatus = () => {
  26. if (!checkLogin()) {
  27. isPurchased.value = false;
  28. return;
  29. }
  30. try {
  31. const purchaseInfo = common_vendor.index.getStorageSync("pool_purchase");
  32. if (purchaseInfo) {
  33. const now = Date.now();
  34. const expireTime = purchaseInfo.expireTime;
  35. if (now < expireTime) {
  36. isPurchased.value = true;
  37. } else {
  38. common_vendor.index.removeStorageSync("pool_purchase");
  39. isPurchased.value = false;
  40. }
  41. } else {
  42. isPurchased.value = false;
  43. }
  44. } catch (e) {
  45. console.error("检查购买状态失败:", e);
  46. isPurchased.value = false;
  47. }
  48. };
  49. const showPurchaseModal = () => {
  50. if (!checkLogin()) {
  51. common_vendor.index.showModal({
  52. title: "登录提示",
  53. content: "此功能需要登录后使用,是否前往登录?",
  54. confirmText: "去登录",
  55. cancelText: "取消",
  56. success: (res) => {
  57. if (res.confirm) {
  58. common_vendor.index.navigateTo({
  59. url: "/pages/login/login"
  60. });
  61. }
  62. }
  63. });
  64. return;
  65. }
  66. showModal.value = true;
  67. };
  68. const closePurchaseModal = () => {
  69. showModal.value = false;
  70. };
  71. const handlePurchase = () => {
  72. const now = Date.now();
  73. const today = /* @__PURE__ */ new Date();
  74. today.setHours(23, 59, 59, 999);
  75. const expireTime = today.getTime();
  76. const purchaseInfo = {
  77. plan: "reward",
  78. purchaseTime: now,
  79. expireTime
  80. };
  81. common_vendor.index.setStorageSync("pool_purchase", purchaseInfo);
  82. isPurchased.value = true;
  83. closePurchaseModal();
  84. common_vendor.index.showToast({
  85. title: "解锁成功",
  86. icon: "success"
  87. });
  88. };
  89. const onStartMonthChange = (e) => {
  90. startMonth.value = e.detail.value;
  91. };
  92. const onEndMonthChange = (e) => {
  93. endMonth.value = e.detail.value;
  94. };
  95. const onHistorySearch = () => {
  96. if (!startMonth.value || !endMonth.value) {
  97. common_vendor.index.showToast({
  98. title: "请选择开始和结束月份",
  99. icon: "none"
  100. });
  101. return;
  102. }
  103. if (startMonth.value > endMonth.value) {
  104. common_vendor.index.showToast({
  105. title: "开始月份不能晚于结束月份",
  106. icon: "none"
  107. });
  108. return;
  109. }
  110. common_vendor.index.showToast({
  111. title: `查询${formatMonth(startMonth.value)}至${formatMonth(endMonth.value)}`,
  112. icon: "none",
  113. duration: 2e3
  114. });
  115. };
  116. common_vendor.onLoad(() => {
  117. const loginStatus = checkLogin();
  118. console.log("[超短池] 登录状态:", loginStatus);
  119. checkPurchaseStatus();
  120. });
  121. common_vendor.onShow(() => {
  122. const loginStatus = checkLogin();
  123. console.log("[超短池] 登录状态:", loginStatus);
  124. checkPurchaseStatus();
  125. common_vendor.index.setNavigationBarTitle({ title: "量化交易大师" });
  126. });
  127. return (_ctx, _cache) => {
  128. return common_vendor.e({
  129. a: !isPurchased.value
  130. }, !isPurchased.value ? {
  131. b: common_vendor.o(showPurchaseModal)
  132. } : {}, {
  133. c: common_vendor.t(formatMonth(startMonth.value)),
  134. d: startMonth.value,
  135. e: common_vendor.o(onStartMonthChange),
  136. f: common_vendor.t(formatMonth(endMonth.value)),
  137. g: endMonth.value,
  138. h: common_vendor.o(onEndMonthChange),
  139. i: common_vendor.o(onHistorySearch),
  140. j: showPhoneAuth.value
  141. }, showPhoneAuth.value ? {
  142. k: common_vendor.o((...args) => _ctx.onGetPhoneNumber && _ctx.onGetPhoneNumber(...args)),
  143. l: common_vendor.o(() => {
  144. }),
  145. m: common_vendor.o((...args) => _ctx.closePhoneAuth && _ctx.closePhoneAuth(...args))
  146. } : {}, {
  147. n: showModal.value
  148. }, showModal.value ? {
  149. o: common_vendor.o(closePurchaseModal),
  150. p: common_vendor.o(handlePurchase),
  151. q: common_vendor.o(() => {
  152. }),
  153. r: common_vendor.o(closePurchaseModal)
  154. } : {});
  155. };
  156. }
  157. };
  158. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/program/gupiao-wx/src/pages/pool/pool.vue"]]);
  159. wx.createPage(MiniProgramPage);