| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- "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);
- const isAdmin = common_vendor.ref(false);
- const userInfo = common_vendor.ref({
- nickname: "",
- avatar: "",
- status: 0
- });
- 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();
- console.log("[个人中心] 存储的用户信息:", JSON.stringify(storedInfo));
- if (storedInfo) {
- userInfo.value = storedInfo;
- isAdmin.value = storedInfo.status === 2;
- console.log("[个人中心] status值:", storedInfo.status, "是否管理员:", isAdmin.value);
- }
- } else {
- isAdmin.value = false;
- }
- };
- 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: "" };
- common_vendor.index.showToast({ title: "已退出登录", icon: "none" });
- }
- }
- });
- };
- const handleSubscriptionRecord = () => {
- if (!utils_auth.checkLogin()) {
- return;
- }
- common_vendor.index.navigateTo({
- url: "/pages/transaction/transaction"
- });
- };
- const handleShortPoolManage = () => {
- if (!isAdmin.value) {
- common_vendor.index.showToast({ title: "无权限访问", icon: "none" });
- return;
- }
- common_vendor.index.navigateTo({
- url: "/pages/admin/shortPool"
- });
- };
- 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(handleSubscriptionRecord),
- e: isAdmin.value
- }, isAdmin.value ? {
- f: common_vendor.o(handleShortPoolManage)
- } : {}, {
- g: isLoggedIn.value
- }, isLoggedIn.value ? {
- h: 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);
|