"use strict"; const common_vendor = require("../../common/vendor.js"); const utils_auth = require("../../utils/auth.js"); require("../../utils/api.js"); const _sfc_main = { __name: "pool", setup(__props) { const isPurchased = common_vendor.ref(false); const showModal = common_vendor.ref(false); const showPhoneAuth = common_vendor.ref(false); const selectedPlan = common_vendor.ref("daily"); const selectedDate = common_vendor.ref("2025年11月20日"); const isLoggedIn = common_vendor.ref(false); const paymentMethod = common_vendor.ref("wechat"); const userPoints = common_vendor.ref(0); const checkLogin = () => { isLoggedIn.value = utils_auth.isLoggedIn(); console.log("[超短池] 登录状态:", isLoggedIn.value); return isLoggedIn.value; }; const getUserPoints = () => { try { const points = common_vendor.index.getStorageSync("user_points") || 0; userPoints.value = points; } catch (e) { console.error("获取积分失败:", e); userPoints.value = 0; } }; const checkPurchaseStatus = () => { try { const purchaseInfo = common_vendor.index.getStorageSync("pool_purchase"); if (purchaseInfo) { const now = Date.now(); const expireTime = purchaseInfo.expireTime; if (now < expireTime) { isPurchased.value = true; } else { common_vendor.index.removeStorageSync("pool_purchase"); isPurchased.value = false; } } else { isPurchased.value = false; } } catch (e) { console.error("检查购买状态失败:", e); isPurchased.value = false; } }; const showPurchaseModal = () => { console.log("点击立即解锁"); if (!checkLogin()) { console.log("未登录,跳转到登录页"); common_vendor.index.showModal({ title: "登录提示", content: "此功能需要登录后使用,是否前往登录?", confirmText: "去登录", cancelText: "取消", success: (res) => { if (res.confirm) { common_vendor.index.navigateTo({ url: "/pages/login/login" }); } } }); return; } console.log("已登录,显示购买弹窗"); getUserPoints(); showModal.value = true; }; const closePurchaseModal = () => { showModal.value = false; }; const handlePurchase = () => { if (!selectedPlan.value) { common_vendor.index.showToast({ title: "请选择订阅方案", icon: "none" }); return; } if (paymentMethod.value === "points") { const requiredPoints = selectedPlan.value === "daily" ? 180 : 980; if (userPoints.value < requiredPoints) { common_vendor.index.showToast({ title: "积分不足,请充值或选择微信支付", icon: "none" }); return; } const newPoints = userPoints.value - requiredPoints; common_vendor.index.setStorageSync("user_points", newPoints); userPoints.value = newPoints; } const now = Date.now(); let expireTime = now; if (selectedPlan.value === "daily") { const today = /* @__PURE__ */ new Date(); today.setHours(23, 59, 59, 999); expireTime = today.getTime(); } else if (selectedPlan.value === "weekly") { expireTime = now + 7 * 24 * 60 * 60 * 1e3; } const purchaseInfo = { plan: selectedPlan.value, purchaseTime: now, expireTime, paymentMethod: paymentMethod.value }; common_vendor.index.setStorageSync("pool_purchase", purchaseInfo); isPurchased.value = true; closePurchaseModal(); common_vendor.index.showToast({ title: paymentMethod.value === "points" ? "积分支付成功" : "解锁成功", icon: "success" }); }; const onHistorySearch = () => { common_vendor.index.showToast({ title: "历史查询功能开发中", icon: "none" }); }; common_vendor.onLoad(() => { checkLogin(); checkPurchaseStatus(); getUserPoints(); }); common_vendor.onShow(() => { checkLogin(); checkPurchaseStatus(); getUserPoints(); }); return (_ctx, _cache) => { return common_vendor.e({ a: !isPurchased.value }, !isPurchased.value ? { b: common_vendor.o(showPurchaseModal) } : {}, { c: selectedDate.value, d: common_vendor.o(($event) => selectedDate.value = $event.detail.value), e: common_vendor.o(onHistorySearch), f: showPhoneAuth.value }, showPhoneAuth.value ? { g: common_vendor.o((...args) => _ctx.onGetPhoneNumber && _ctx.onGetPhoneNumber(...args)), h: common_vendor.o(() => { }), i: common_vendor.o((...args) => _ctx.closePhoneAuth && _ctx.closePhoneAuth(...args)) } : {}, { j: showModal.value }, showModal.value ? common_vendor.e({ k: common_vendor.o(closePurchaseModal), l: selectedPlan.value === "daily" ? 1 : "", m: common_vendor.o(($event) => selectedPlan.value = "daily"), n: selectedPlan.value === "weekly" ? 1 : "", o: common_vendor.o(($event) => selectedPlan.value = "weekly"), p: paymentMethod.value === "wechat" }, paymentMethod.value === "wechat" ? {} : {}, { q: paymentMethod.value === "wechat" ? 1 : "", r: common_vendor.o(($event) => paymentMethod.value = "wechat"), s: common_vendor.t(userPoints.value), t: common_vendor.t(selectedPlan.value === "daily" ? 180 : 980), v: paymentMethod.value === "points" }, paymentMethod.value === "points" ? {} : {}, { w: paymentMethod.value === "points" ? 1 : "", x: common_vendor.o(($event) => paymentMethod.value = "points"), y: common_vendor.t(paymentMethod.value === "points" ? "确认积分支付" : "确认支付并解锁"), z: paymentMethod.value === "points" ? 1 : "", A: common_vendor.o(handlePurchase), B: common_vendor.o(() => { }), C: common_vendor.o(closePurchaseModal) }) : {}); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/program/gupiao-wx/src/pages/pool/pool.vue"]]); wx.createPage(MiniProgramPage);