| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const utils_auth = require("../../utils/auth.js");
- const _sfc_main = {
- __name: "mine",
- setup(__props) {
- const isLoggedIn = common_vendor.ref(false);
- const userInfo = common_vendor.ref({
- nickname: "",
- avatar: "",
- phone: ""
- });
- const points = common_vendor.ref(900);
- common_vendor.onMounted(() => {
- loadUserInfo();
- });
- common_vendor.onShow(() => {
- loadUserInfo();
- });
- const loadUserInfo = () => {
- isLoggedIn.value = utils_auth.isLoggedIn();
- if (isLoggedIn.value) {
- const storedInfo = utils_auth.getUserInfo();
- if (storedInfo) {
- userInfo.value = storedInfo;
- console.log("加载用户信息:", userInfo.value);
- }
- }
- };
- const handleEditProfile = () => {
- if (!utils_auth.checkLogin(() => {
- handleEditProfile();
- })) {
- return;
- }
- common_vendor.index.navigateTo({
- url: "/pages/profile/edit"
- });
- };
- const toggleLogin = () => {
- if (isLoggedIn.value) {
- 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" });
- }
- }
- });
- } else {
- common_vendor.index.navigateTo({
- url: "/pages/login/login"
- });
- }
- };
- const handleRecharge = () => {
- if (!utils_auth.checkLogin(() => {
- handleRecharge();
- })) {
- return;
- }
- common_vendor.index.showToast({ title: "充值功能开发中", icon: "none" });
- };
- const handleHistory = () => {
- if (!utils_auth.checkLogin(() => {
- handleHistory();
- })) {
- return;
- }
- common_vendor.index.showToast({ title: "记录功能开发中", icon: "none" });
- };
- return (_ctx, _cache) => {
- return common_vendor.e({
- a: isLoggedIn.value && userInfo.value.avatar ? userInfo.value.avatar : "/static/images/head.png",
- b: common_vendor.o(handleEditProfile),
- c: common_vendor.t(isLoggedIn.value ? userInfo.value.nickname || "微信用户" : "游客"),
- d: isLoggedIn.value && userInfo.value.phone
- }, isLoggedIn.value && userInfo.value.phone ? {
- e: common_vendor.t(userInfo.value.phone)
- } : {}, {
- f: common_vendor.t(isLoggedIn.value ? points.value : 0),
- g: common_vendor.o(handleRecharge),
- h: common_vendor.o(handleHistory),
- i: common_vendor.t(isLoggedIn.value ? "退出登录" : "登录"),
- j: common_vendor.o(toggleLogin)
- });
- };
- }
- };
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/program/gupiao-wx/src/pages/mine/mine.vue"]]);
- wx.createPage(MiniProgramPage);
|