"use strict"; const common_vendor = require("../../common/vendor.js"); const common_assets = require("../../common/assets.js"); const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({ __name: "login", setup(__props) { const phone = common_vendor.ref(""); const password = common_vendor.ref(""); const rememberMe = common_vendor.ref(false); const isLoading = common_vendor.ref(false); const mockUsers = [ { id: "1", name: "管理员", phone: "13800138000", role: "admin", createTime: "2024-01-01" }, { id: "2", name: "回收员小王", phone: "18698102228", role: "collector", createTime: "2024-01-15" } ]; const login = async () => { if (!phone.value) { common_vendor.index.showToast({ title: "请输入手机号", icon: "none" }); return; } if (phone.value.length !== 11) { common_vendor.index.showToast({ title: "请输入正确的手机号", icon: "none" }); return; } if (!password.value) { common_vendor.index.showToast({ title: "请输入密码", icon: "none" }); return; } isLoading.value = true; try { const user = mockUsers.find((u) => u.phone === phone.value && u.role === "collector"); console.log("Available users:", JSON.stringify(mockUsers)); console.log("Input phone:", phone.value); console.log("Found user:", JSON.stringify(user)); if (user) { if (password.value === "123456") { common_vendor.index.setStorageSync("collector_login", true); common_vendor.index.setStorageSync("collector_info", JSON.stringify(user)); common_vendor.index.showToast({ title: "登录成功", icon: "success" }); setTimeout(() => { common_vendor.index.switchTab({ url: "/pages/index/index" }); }, 1500); } else { common_vendor.index.showToast({ title: "密码错误", icon: "none" }); } } else { common_vendor.index.showToast({ title: "用户不存在", icon: "none" }); } } catch (error) { console.error("Login error:", error); common_vendor.index.showToast({ title: "登录失败", icon: "none" }); } finally { isLoading.value = false; } }; const forgotPassword = () => { common_vendor.index.showToast({ title: "请联系管理员重置密码", icon: "none" }); }; return (_ctx, _cache) => { return common_vendor.e({ a: common_assets._imports_0, b: phone.value, c: common_vendor.o(($event) => phone.value = $event.detail.value), d: password.value, e: common_vendor.o(($event) => password.value = $event.detail.value), f: rememberMe.value }, rememberMe.value ? {} : {}, { g: rememberMe.value ? 1 : "", h: common_vendor.o(($event) => rememberMe.value = !rememberMe.value), i: isLoading.value }, isLoading.value ? {} : {}, { j: common_vendor.o(login), k: isLoading.value ? 1 : "", l: common_vendor.o(forgotPassword) }); }; } }); const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-ebed24a8"]]); wx.createPage(MiniProgramPage);