strong.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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: "strong",
  7. setup(__props) {
  8. common_vendor.ref(false);
  9. const isPurchased = common_vendor.ref(false);
  10. const showModal = common_vendor.ref(false);
  11. const selectedPlan = common_vendor.ref("monthly");
  12. const stockList = common_vendor.ref([
  13. {
  14. name: "美的集团",
  15. code: "000333",
  16. price: "68.00",
  17. score: "88.5"
  18. },
  19. {
  20. name: "贵州茅台",
  21. code: "600519",
  22. price: "1700.00",
  23. score: "85.1"
  24. }
  25. ]);
  26. const selectedDate = common_vendor.ref("2025年11月20日");
  27. const checkPurchaseStatus = () => {
  28. try {
  29. const purchaseInfo = common_vendor.index.getStorageSync("strong_pool_purchase");
  30. if (purchaseInfo) {
  31. const now = Date.now();
  32. const expireTime = purchaseInfo.expireTime;
  33. if (now < expireTime) {
  34. isPurchased.value = true;
  35. } else {
  36. common_vendor.index.removeStorageSync("strong_pool_purchase");
  37. isPurchased.value = false;
  38. }
  39. } else {
  40. isPurchased.value = false;
  41. }
  42. } catch (e) {
  43. console.error("检查购买状态失败:", e);
  44. isPurchased.value = false;
  45. }
  46. };
  47. const showPurchaseModal = () => {
  48. console.log("点击立即解锁");
  49. if (!utils_auth.isLoggedIn()) {
  50. console.log("未登录,跳转到登录页");
  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. console.log("已登录,显示购买弹窗");
  67. showModal.value = true;
  68. };
  69. const closePurchaseModal = () => {
  70. showModal.value = false;
  71. };
  72. const handlePurchase = () => {
  73. if (!selectedPlan.value) {
  74. common_vendor.index.showToast({
  75. title: "请选择订阅方案",
  76. icon: "none"
  77. });
  78. return;
  79. }
  80. const now = Date.now();
  81. let expireTime = now;
  82. if (selectedPlan.value === "monthly") {
  83. expireTime = now + 30 * 24 * 60 * 60 * 1e3;
  84. }
  85. const purchaseInfo = {
  86. plan: selectedPlan.value,
  87. purchaseTime: now,
  88. expireTime
  89. };
  90. common_vendor.index.setStorageSync("strong_pool_purchase", purchaseInfo);
  91. isPurchased.value = true;
  92. closePurchaseModal();
  93. common_vendor.index.showToast({
  94. title: "解锁成功",
  95. icon: "success"
  96. });
  97. };
  98. const onHistorySearch = () => {
  99. common_vendor.index.showToast({
  100. title: "历史查询功能开发中",
  101. icon: "none"
  102. });
  103. };
  104. common_vendor.onLoad(() => {
  105. checkPurchaseStatus();
  106. });
  107. common_vendor.onShow(() => {
  108. checkPurchaseStatus();
  109. common_vendor.index.setNavigationBarTitle({ title: "量化交易大师" });
  110. });
  111. return (_ctx, _cache) => {
  112. return common_vendor.e({
  113. a: !isPurchased.value
  114. }, !isPurchased.value ? {
  115. b: common_vendor.o(showPurchaseModal)
  116. } : {
  117. c: common_vendor.f(stockList.value, (stock, index, i0) => {
  118. return {
  119. a: common_vendor.t(stock.name),
  120. b: common_vendor.t(stock.code),
  121. c: index
  122. };
  123. })
  124. }, {
  125. d: selectedDate.value,
  126. e: common_vendor.o(($event) => selectedDate.value = $event.detail.value),
  127. f: common_vendor.o(onHistorySearch),
  128. g: showModal.value
  129. }, showModal.value ? {
  130. h: common_vendor.o(closePurchaseModal),
  131. i: common_vendor.o(handlePurchase),
  132. j: common_vendor.o(() => {
  133. }),
  134. k: common_vendor.o(closePurchaseModal)
  135. } : {});
  136. };
  137. }
  138. };
  139. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/program/gupiao-wx/src/pages/strong/strong.vue"]]);
  140. wx.createPage(MiniProgramPage);