"use strict"; const common_vendor = require("../../common/vendor.js"); const common_assets = require("../../common/assets.js"); const store_user = require("../../store/user.js"); const api_order = require("../../api/order.js"); if (!Math) { CustomerServiceBtn(); } const CustomerServiceBtn = () => "../../components/CustomerServiceBtn.js"; const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({ __name: "index", setup(__props) { const userStore = store_user.useUserStore(); const showQrCode = common_vendor.ref(false); const showAbout = common_vendor.ref(false); const orderCount = common_vendor.ref(0); const isLoggedIn = common_vendor.ref(false); const statusBarHeight = common_vendor.ref(20); const navBarHeight = common_vendor.ref(44); try { const sysInfo = common_vendor.index.getSystemInfoSync(); statusBarHeight.value = sysInfo.statusBarHeight || 20; const menuBtn = common_vendor.index.getMenuButtonBoundingClientRect(); navBarHeight.value = (menuBtn.top - (sysInfo.statusBarHeight || 20)) * 2 + menuBtn.height; } catch { } function refreshData() { const token = common_vendor.index.getStorageSync("token"); isLoggedIn.value = !!token; if (token) { userStore.fetchProfile(); api_order.getOrderList().then((data) => { orderCount.value = Array.isArray(data) ? data.length : (data == null ? void 0 : data.total) || 0; }).catch(() => { }); } } common_vendor.onShow(() => { refreshData(); }); function handleUserCardClick() { if (!isLoggedIn.value) { common_vendor.index.navigateTo({ url: "/pages/login/index" }); } } function navigateTo(url) { const token = common_vendor.index.getStorageSync("token"); if (!token) { common_vendor.index.navigateTo({ url: "/pages/login/index" }); return; } common_vendor.index.navigateTo({ url }); } function showAgreement(type) { const title = type === "user" ? "用户协议" : "隐私协议"; common_vendor.index.showModal({ title, content: type === "user" ? "欢迎使用珠宝商城小程序。使用本小程序即表示您同意遵守相关服务条款。" : "我们重视您的隐私保护。我们仅收集必要的信息以提供服务,不会向第三方泄露您的个人信息。", showCancel: false, confirmText: "我知道了" }); } function handleLogout() { common_vendor.index.showModal({ title: "提示", content: "确定要退出登录吗?", success: (res) => { if (res.confirm) { userStore.logout(); isLoggedIn.value = false; orderCount.value = 0; common_vendor.index.showToast({ title: "已退出登录", icon: "success" }); setTimeout(() => { common_vendor.index.switchTab({ url: "/pages/index/index" }); }, 1e3); } } }); } return (_ctx, _cache) => { var _a, _b; return common_vendor.e({ a: navBarHeight.value + "px", b: statusBarHeight.value + "px", c: ((_a = common_vendor.unref(userStore).user) == null ? void 0 : _a.avatar) || "/static/logo.png", d: common_vendor.t(isLoggedIn.value ? ((_b = common_vendor.unref(userStore).user) == null ? void 0 : _b.nickname) || "微信用户" : "点击注册/登录"), e: common_vendor.o(handleUserCardClick), f: common_assets._imports_0$3, g: common_vendor.t(orderCount.value), h: common_vendor.o(($event) => navigateTo("/pages/order/list")), i: common_assets._imports_1$1, j: common_vendor.o(($event) => navigateTo("/pages/address/index")), k: common_assets._imports_2$1, l: common_vendor.o(($event) => showQrCode.value = true), m: common_assets._imports_3$1, n: common_vendor.o(($event) => showAbout.value = true), o: common_assets._imports_4, p: common_vendor.o(($event) => showAgreement("user")), q: common_assets._imports_5, r: common_vendor.o(($event) => showAgreement("privacy")), s: isLoggedIn.value }, isLoggedIn.value ? { t: common_assets._imports_6, v: common_vendor.o(handleLogout) } : {}, { w: showQrCode.value }, showQrCode.value ? { x: common_vendor.o(($event) => showQrCode.value = false), y: common_vendor.p({ mode: "qrcode" }) } : {}, { z: showAbout.value }, showAbout.value ? { A: common_vendor.o(($event) => showAbout.value = false), B: common_vendor.o(() => { }), C: common_vendor.o(($event) => showAbout.value = false) } : {}); }; } }); const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-569e925a"]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/mine/index.js.map