"use strict"; const common_vendor = require("../../common/vendor.js"); const utils_auth = require("../../utils/auth.js"); require("../../utils/api.js"); const _sfc_main = { __name: "strong", setup(__props) { const isLoggedIn = common_vendor.ref(false); const stockList = common_vendor.ref([ { name: "美的集团", code: "000333", price: "68.00", score: "88.5" }, { name: "贵州茅台", code: "600519", price: "1700.00", score: "85.1" } ]); const selectedDate = common_vendor.ref("2025年11月20日"); const showBuyModalFlag = common_vendor.ref(false); const showSellModalFlag = common_vendor.ref(false); const currentStock = common_vendor.ref({}); const buyQuantity = common_vendor.ref("100"); const sellQuantity = common_vendor.ref("100"); const checkLogin = () => { isLoggedIn.value = utils_auth.isLoggedIn(); console.log("[强势池] 登录状态:", isLoggedIn.value); }; const goToLogin = () => { common_vendor.index.navigateTo({ url: "/pages/login/login" }); }; const buyTotalAmount = common_vendor.computed(() => { const qty = parseInt(buyQuantity.value) || 0; const price = parseFloat(currentStock.value.price) || 0; return qty * price; }); const sellTotalAmount = common_vendor.computed(() => { const qty = parseInt(sellQuantity.value) || 0; const price = parseFloat(currentStock.value.price) || 0; return qty * price; }); const showBuyModal = (stock) => { console.log("点击买入按钮"); currentStock.value = { ...stock }; buyQuantity.value = "100"; showBuyModalFlag.value = true; }; const closeBuyModal = () => { showBuyModalFlag.value = false; }; const showSellModal = (stock) => { console.log("点击卖出按钮"); currentStock.value = { ...stock }; sellQuantity.value = "100"; showSellModalFlag.value = true; }; const closeSellModal = () => { showSellModalFlag.value = false; }; const onBuyQuantityChange = (e) => { const value = e.detail.value; if (value && parseInt(value) % 100 !== 0) { common_vendor.index.showToast({ title: "股数必须是100的倍数", icon: "none" }); } }; const onSellQuantityChange = (e) => { const value = e.detail.value; if (value && parseInt(value) % 100 !== 0) { common_vendor.index.showToast({ title: "股数必须是100的倍数", icon: "none" }); } }; const handleBuy = () => { const qty = parseInt(buyQuantity.value); if (!qty || qty <= 0) { common_vendor.index.showToast({ title: "请输入有效的股数", icon: "none" }); return; } if (qty % 100 !== 0) { common_vendor.index.showToast({ title: "股数必须是100的倍数", icon: "none" }); return; } const transaction = { type: "buy", stockName: currentStock.value.name, stockCode: currentStock.value.code, price: parseFloat(currentStock.value.price), quantity: qty, totalAmount: buyTotalAmount.value, timestamp: Date.now() }; const transactions = common_vendor.index.getStorageSync("simulated_transactions") || []; transactions.push(transaction); common_vendor.index.setStorageSync("simulated_transactions", transactions); closeBuyModal(); common_vendor.index.showToast({ title: "买入成功", icon: "success" }); }; const handleSell = () => { const qty = parseInt(sellQuantity.value); if (!qty || qty <= 0) { common_vendor.index.showToast({ title: "请输入有效的股数", icon: "none" }); return; } if (qty % 100 !== 0) { common_vendor.index.showToast({ title: "股数必须是100的倍数", icon: "none" }); return; } const transaction = { type: "sell", stockName: currentStock.value.name, stockCode: currentStock.value.code, price: parseFloat(currentStock.value.price), quantity: qty, totalAmount: sellTotalAmount.value, timestamp: Date.now() }; const transactions = common_vendor.index.getStorageSync("simulated_transactions") || []; transactions.push(transaction); common_vendor.index.setStorageSync("simulated_transactions", transactions); closeSellModal(); common_vendor.index.showToast({ title: "卖出成功", icon: "success" }); }; const onHistorySearch = () => { common_vendor.index.showToast({ title: "历史查询功能开发中", icon: "none" }); }; common_vendor.onLoad(() => { checkLogin(); }); common_vendor.onShow(() => { checkLogin(); }); return (_ctx, _cache) => { return common_vendor.e({ a: common_vendor.t(stockList.value.length), b: common_vendor.f(stockList.value, (stock, index, i0) => { return { a: common_vendor.t(stock.name), b: common_vendor.t(stock.code), c: common_vendor.t(stock.price), d: common_vendor.t(stock.score), e: common_vendor.o(($event) => showBuyModal(stock), index), f: common_vendor.o(($event) => showSellModal(stock), index), g: index }; }), c: selectedDate.value, d: common_vendor.o(($event) => selectedDate.value = $event.detail.value), e: common_vendor.o(onHistorySearch), f: !isLoggedIn.value ? 1 : "", g: !isLoggedIn.value }, !isLoggedIn.value ? { h: common_vendor.o(goToLogin) } : {}, { i: showBuyModalFlag.value }, showBuyModalFlag.value ? { j: common_vendor.o(closeBuyModal), k: common_vendor.t(currentStock.value.name), l: common_vendor.t(currentStock.value.code), m: common_vendor.t(currentStock.value.price), n: common_vendor.o([($event) => buyQuantity.value = $event.detail.value, onBuyQuantityChange]), o: buyQuantity.value, p: common_vendor.t(common_vendor.unref(buyTotalAmount).toFixed(2)), q: common_vendor.o(handleBuy), r: common_vendor.o(() => { }), s: common_vendor.o(closeBuyModal) } : {}, { t: showSellModalFlag.value }, showSellModalFlag.value ? { v: common_vendor.o(closeSellModal), w: common_vendor.t(currentStock.value.name), x: common_vendor.t(currentStock.value.code), y: common_vendor.t(currentStock.value.price), z: common_vendor.o([($event) => sellQuantity.value = $event.detail.value, onSellQuantityChange]), A: sellQuantity.value, B: common_vendor.t(common_vendor.unref(sellTotalAmount).toFixed(2)), C: common_vendor.o(handleSell), D: common_vendor.o(() => { }), E: common_vendor.o(closeSellModal) } : {}); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/program/gupiao-wx/src/pages/strong/strong.vue"]]); wx.createPage(MiniProgramPage);