| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const utils_auth = require("../../utils/auth.js");
- 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: ""
- });
- common_vendor.onMounted(() => {
- loadUserInfo();
- });
- common_vendor.onShow(() => {
- loadUserInfo();
- common_vendor.index.setNavigationBarTitle({ title: "量化交易大师" });
- });
- 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);
- }
- }
- };
- 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 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.o(handleTransactionRecord),
- e: isLoggedIn.value
- }, isLoggedIn.value ? {
- f: 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);
|