"use strict"; const common_vendor = require("../../common/vendor.js"); const utils_auth = require("../../utils/auth.js"); const utils_api = require("../../utils/api.js"); const _sfc_main = { __name: "mine", setup(__props) { const isLoggedIn = common_vendor.ref(false); common_vendor.ref(false); const userInfo = common_vendor.ref({ nickname: "", avatar: "", phone: "" }); const points = common_vendor.ref(0); common_vendor.onMounted(() => { loadUserInfo(); }); common_vendor.onShow(() => { loadUserInfo(); }); const loadUserInfo = async () => { isLoggedIn.value = utils_auth.isLoggedIn(); console.log("[个人中心] 登录状态:", isLoggedIn.value); if (isLoggedIn.value) { const storedInfo = utils_auth.getUserInfo(); if (storedInfo) { userInfo.value = storedInfo; console.log("[个人中心] 加载用户信息:", userInfo.value); } await loadUserPoints(); } }; const loadUserPoints = async () => { try { const res = await utils_api.getUserPointsApi(); if (res.code === 200 && res.data) { points.value = res.data.totalPoints || 0; console.log("[个人中心] 用户积分:", points.value); } } catch (e) { console.error("获取积分失败:", e); points.value = 0; } }; const handleUserCardClick = () => { if (!isLoggedIn.value) { handleLogin(); } }; const handleLogin = async () => { console.log("[我的] 开始登录流程"); common_vendor.index.navigateTo({ url: "/pages/login/login" }); }; const handleLogout = () => { common_vendor.index.showModal({ title: "提示", content: "确定要退出登录吗?", success: (res) => { if (res.confirm) { utils_auth.logout(); isLoggedIn.value = false; userInfo.value = { nickname: "", avatar: "", phone: "" }; common_vendor.index.showToast({ title: "已退出登录", icon: "none" }); } } }); }; const handleRecharge = () => { if (!utils_auth.checkLogin()) { return; } common_vendor.index.showToast({ title: "充值功能开发中", icon: "none" }); }; const handleHistory = () => { if (!utils_auth.checkLogin()) { return; } common_vendor.index.navigateTo({ url: "/pages/points/points" }); }; const handleTransactionRecord = () => { if (!utils_auth.checkLogin()) { return; } common_vendor.index.navigateTo({ url: "/pages/transaction/transaction" }); }; return (_ctx, _cache) => { return common_vendor.e({ a: isLoggedIn.value && userInfo.value.avatar ? userInfo.value.avatar : "/static/images/head.png", b: common_vendor.t(isLoggedIn.value ? userInfo.value.nickname || "微信用户" : "登录/注册"), c: common_vendor.o(handleUserCardClick), d: common_vendor.t(isLoggedIn.value ? points.value : 0), e: common_vendor.o(handleRecharge), f: common_vendor.o(handleHistory), g: common_vendor.o(handleTransactionRecord), h: isLoggedIn.value }, isLoggedIn.value ? { i: common_vendor.o(handleLogout) } : {}); }; } }; const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/program/gupiao-wx/src/pages/mine/mine.vue"]]); wx.createPage(MiniProgramPage);