| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- "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);
- 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();
- if (isLoggedIn.value) {
- const storedInfo = utils_auth.getUserInfo();
- if (storedInfo) {
- userInfo.value = storedInfo;
- isAdmin.value = storedInfo.status === 2;
- console.log("[我的] 本地缓存头像:", storedInfo.avatar);
- }
- const latestInfo = await utils_auth.refreshUserInfo();
- if (latestInfo) {
- userInfo.value = latestInfo;
- isAdmin.value = latestInfo.status === 2;
- console.log("[我的] 后端返回头像:", latestInfo.avatar);
- console.log("[我的] 处理后头像URL:", latestInfo.avatar ? utils_api.getImageUrl(latestInfo.avatar) : "无");
- }
- } else {
- isAdmin.value = false;
- }
- };
- const handleUserCardClick = () => {
- if (!isLoggedIn.value) {
- handleLogin();
- } else {
- common_vendor.index.navigateTo({
- url: "/pages/profile/edit"
- });
- }
- };
- 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 handleOrderRecord = () => {
- if (!utils_auth.checkLogin()) {
- return;
- }
- common_vendor.index.navigateTo({
- url: "/pages/order/order"
- });
- };
- const handleContactUs = () => {
- if (!utils_auth.checkLogin()) {
- return;
- }
- common_vendor.index.navigateTo({
- url: "/pages/contact/contact"
- });
- };
- 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 ? common_vendor.unref(utils_api.getImageUrl)(userInfo.value.avatar) : common_vendor.unref(utils_api.getImageUrl)("/static/images/head.png"),
- b: common_vendor.t(isLoggedIn.value ? userInfo.value.nickname || "微信用户" : "登录/注册"),
- c: common_vendor.o(handleUserCardClick),
- d: common_vendor.o(handleOrderRecord),
- e: common_vendor.o(handleContactUs),
- f: isAdmin.value
- }, isAdmin.value ? {
- g: common_vendor.o(handleShortPoolManage)
- } : {}, {
- h: isLoggedIn.value
- }, isLoggedIn.value ? {
- i: common_vendor.o(handleLogout)
- } : {});
- };
- }
- };
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "D:/program/gupiao/gupiao-wx/src/pages/mine/mine.vue"]]);
- wx.createPage(MiniProgramPage);
|