"use strict"; const common_vendor = require("../../common/vendor.js"); const utils_auth = require("../../utils/auth.js"); const utils_api = require("../../utils/api.js"); if (!Math) { (PerformanceCard + HistorySearchCard + PurchaseModal)(); } const PurchaseModal = () => "../../components/PurchaseModal.js"; const PerformanceCard = () => "../../components/PerformanceCard.js"; const HistorySearchCard = () => "../../components/HistorySearchCard.js"; const _sfc_main = { __name: "strong", setup(__props) { const isPurchased = common_vendor.ref(false); const showModal = common_vendor.ref(false); const stockList = common_vendor.ref([ { name: "信维通信", code: "300136" }, { name: "中国卫星", code: "600118" } ]); const checkPurchaseStatus = () => { if (!utils_auth.isLoggedIn()) { isPurchased.value = false; return; } try { const purchaseInfo = common_vendor.index.getStorageSync("strong_pool_purchase"); if (purchaseInfo) { const now = Date.now(); if (now < purchaseInfo.expireTime) { isPurchased.value = true; } else { common_vendor.index.removeStorageSync("strong_pool_purchase"); isPurchased.value = false; } } else { isPurchased.value = false; } } catch (e) { console.error("检查购买状态失败:", e); isPurchased.value = false; } }; const showPurchaseModal = () => { if (!utils_auth.isLoggedIn()) { common_vendor.index.showModal({ title: "登录提示", content: "此功能需要登录后使用,是否前往登录?", confirmText: "去登录", cancelText: "取消", success: (res) => { if (res.confirm) { common_vendor.index.navigateTo({ url: "/pages/login/login" }); } } }); return; } showModal.value = true; }; const closePurchaseModal = () => { showModal.value = false; }; const handlePurchase = () => { const now = Date.now(); const expireTime = now + 365 * 24 * 60 * 60 * 1e3; common_vendor.index.setStorageSync("strong_pool_purchase", { plan: "yearly", purchaseTime: now, expireTime }); isPurchased.value = true; closePurchaseModal(); common_vendor.index.showToast({ title: "解锁成功", icon: "success" }); }; const onHistorySearch = ({ startMonth, endMonth }) => { const formatMonth = (monthStr) => { const [year, month] = monthStr.split("-"); return `${year}年${month}月`; }; common_vendor.index.showToast({ title: `查询${formatMonth(startMonth)}至${formatMonth(endMonth)}`, icon: "none", duration: 2e3 }); }; const addToMyStocks = async (stock) => { if (!utils_auth.isLoggedIn()) { common_vendor.index.showModal({ title: "登录提示", content: "添加自选股票需要登录,是否前往登录?", confirmText: "去登录", cancelText: "取消", success: (res) => { if (res.confirm) { common_vendor.index.navigateTo({ url: "/pages/login/login" }); } } }); return; } try { common_vendor.index.showLoading({ title: "添加中..." }); let currentPrice = null; try { const quoteRes = await utils_api.getStockQuotes(stock.code); if (quoteRes.code === 200 && quoteRes.data && quoteRes.data.length > 0) { currentPrice = quoteRes.data[0].currentPrice; } } catch (e) { console.error("获取行情数据失败:", e); } const addRes = await utils_api.addUserStock({ stockCode: stock.code, stockName: stock.name, currentPrice }); common_vendor.index.hideLoading(); if (addRes.code === 200 && addRes.data === true) { common_vendor.index.showToast({ title: "添加成功", icon: "success" }); } else if (addRes.code === 200 && addRes.data === false) { common_vendor.index.showToast({ title: "股票已存在", icon: "none" }); } else { common_vendor.index.showToast({ title: addRes.message || "添加失败", icon: "none" }); } } catch (e) { common_vendor.index.hideLoading(); console.error("添加股票失败:", e); common_vendor.index.showToast({ title: "添加失败", icon: "none" }); } }; common_vendor.onLoad(() => { console.log("[强势池] 登录状态:", utils_auth.isLoggedIn()); checkPurchaseStatus(); }); common_vendor.onShow(() => { console.log("[强势池] 登录状态:", utils_auth.isLoggedIn()); checkPurchaseStatus(); common_vendor.index.setNavigationBarTitle({ title: "量化交易大师" }); }); return (_ctx, _cache) => { return common_vendor.e({ a: common_vendor.p({ successRate: "88%", profitRate: "+12.5%", totalTrades: 45 }), b: !isPurchased.value }, !isPurchased.value ? { c: common_vendor.o(showPurchaseModal) } : { d: common_vendor.f(stockList.value, (stock, index, i0) => { return { a: common_vendor.t(stock.name), b: common_vendor.t(stock.code), c: common_vendor.o(($event) => addToMyStocks(stock), index), d: index }; }) }, { e: common_vendor.o(onHistorySearch), f: common_vendor.o(closePurchaseModal), g: common_vendor.o(handlePurchase), h: common_vendor.p({ visible: showModal.value, icon: "📅", title: "年订阅解锁", description: "订阅全年,解锁强势趋势池内容", amountLabel: "订阅金额:", amount: 98 }) }); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/program/gupiao-wx/src/pages/strong/strong.vue"]]); wx.createPage(MiniProgramPage);