"use strict"; const common_vendor = require("../../common/vendor.js"); const _sfc_main = { __name: "strong", setup(__props) { 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 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) => { currentStock.value = { ...stock }; buyQuantity.value = "100"; showBuyModalFlag.value = true; }; const closeBuyModal = () => { showBuyModalFlag.value = false; }; const showSellModal = (stock) => { 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(() => { }); common_vendor.onShow(() => { }); 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: showBuyModalFlag.value }, showBuyModalFlag.value ? { g: common_vendor.o(closeBuyModal), h: common_vendor.t(currentStock.value.name), i: common_vendor.t(currentStock.value.code), j: common_vendor.t(currentStock.value.price), k: common_vendor.o([($event) => buyQuantity.value = $event.detail.value, onBuyQuantityChange]), l: buyQuantity.value, m: common_vendor.t(common_vendor.unref(buyTotalAmount).toFixed(2)), n: common_vendor.o(handleBuy), o: common_vendor.o(() => { }), p: common_vendor.o(closeBuyModal) } : {}, { q: showSellModalFlag.value }, showSellModalFlag.value ? { r: common_vendor.o(closeSellModal), s: common_vendor.t(currentStock.value.name), t: common_vendor.t(currentStock.value.code), v: common_vendor.t(currentStock.value.price), w: common_vendor.o([($event) => sellQuantity.value = $event.detail.value, onSellQuantityChange]), x: sellQuantity.value, y: common_vendor.t(common_vendor.unref(sellTotalAmount).toFixed(2)), z: common_vendor.o(handleSell), A: common_vendor.o(() => { }), B: common_vendor.o(closeSellModal) } : {}); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/program/miniprogram-1/src/pages/strong/strong.vue"]]); wx.createPage(MiniProgramPage);