"use strict"; const common_vendor = require("../../common/vendor.js"); if (!Array) { const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons"); _easycom_uni_icons2(); } const _easycom_uni_icons = () => "../../uni_modules/uni-icons/components/uni-icons/uni-icons.js"; if (!Math) { _easycom_uni_icons(); } const _sfc_main = { __name: "config", setup(__props) { const strategies = [ { name: "HFEA 风险平价", desc: "利用 3x 杠杆股债平衡,适合长期持有。", color: "#10B981" }, { name: "双均线趋势跟踪", desc: "金叉买入死叉卖出,捕捉大波段。", color: "#3B82F6" }, { name: "网格交易 (Grid)", desc: "震荡行情下的高抛低吸策略。", color: "#F59E0B" }, { name: "手动自管", desc: "不使用自动化策略,仅做资产记账。", color: "#6B7280" } ]; const strategyIndex = common_vendor.ref(-1); const form = common_vendor.ref({ name: "", stocks: [ { name: "", price: "", amount: "", date: "" } // 默认有一行 ] }); const selectedStrategy = common_vendor.computed(() => { if (strategyIndex.value === -1) return null; return strategies[strategyIndex.value]; }); const totalInvestment = common_vendor.computed(() => { let total = 0; form.value.stocks.forEach((stock) => { const p = parseFloat(stock.price) || 0; const a = parseFloat(stock.amount) || 0; total += p * a; }); return total.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 }); }); const onStrategyChange = (e) => { strategyIndex.value = e.detail.value; }; const onDateChange = (e, index) => { form.value.stocks[index].date = e.detail.value; }; const addStockRow = () => { form.value.stocks.push({ name: "", price: "", amount: "", date: "" }); }; const removeStockRow = (index) => { form.value.stocks.splice(index, 1); }; const submitForm = () => { if (!form.value.name) return common_vendor.index.showToast({ title: "请输入组合名称", icon: "none" }); if (strategyIndex.value === -1) return common_vendor.index.showToast({ title: "请选择策略", icon: "none" }); common_vendor.index.__f__("log", "at pages/config/config.vue:162", "提交的数据:", { ...form.value, strategy: strategies[strategyIndex.value].name }); common_vendor.index.showLoading({ title: "创建中..." }); setTimeout(() => { common_vendor.index.hideLoading(); common_vendor.index.showToast({ title: "创建成功" }); setTimeout(() => common_vendor.index.navigateBack(), 1500); }, 1e3); }; return (_ctx, _cache) => { return common_vendor.e({ a: common_vendor.p({ type: "settings", size: "18", color: "#064E3B" }), b: form.value.name, c: common_vendor.o(($event) => form.value.name = $event.detail.value), d: selectedStrategy.value }, selectedStrategy.value ? { e: selectedStrategy.value.color, f: common_vendor.t(selectedStrategy.value.name) } : {}, { g: common_vendor.p({ type: "bottom", size: "14", color: "#9CA3AF" }), h: common_vendor.o(onStrategyChange), i: strategyIndex.value, j: strategies, k: selectedStrategy.value }, selectedStrategy.value ? { l: common_vendor.t(selectedStrategy.value.desc) } : {}, { m: common_vendor.p({ type: "wallet", size: "18", color: "#1D4ED8" }), n: common_vendor.p({ type: "plus", size: "14", color: "#064E3B" }), o: common_vendor.o(addStockRow), p: common_vendor.f(form.value.stocks, (item, index, i0) => { return common_vendor.e({ a: common_vendor.t(index + 1) }, form.value.stocks.length > 1 ? { b: common_vendor.o(($event) => removeStockRow(index), index), c: "4d7ff163-4-" + i0, d: common_vendor.p({ type: "trash", size: "18", color: "#EF4444" }) } : {}, { e: item.name, f: common_vendor.o(($event) => item.name = $event.detail.value, index), g: item.price, h: common_vendor.o(($event) => item.price = $event.detail.value, index), i: item.amount, j: common_vendor.o(($event) => item.amount = $event.detail.value, index), k: common_vendor.t(item.date || "请选择日期"), l: "4d7ff163-5-" + i0, m: item.date, n: common_vendor.o((e) => onDateChange(e, index), index), o: index }); }), q: form.value.stocks.length > 1, r: common_vendor.p({ type: "calendar", size: "16", color: "#9CA3AF" }), s: common_vendor.t(totalInvestment.value), t: common_vendor.o(submitForm) }); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4d7ff163"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/config/config.js.map