spring
2025-12-04 f7f25f593a731ea71e307257f5cec3ba562dacda
src/pages/mine/index.vue
@@ -7,7 +7,7 @@
        <view class="avatar-container" @click="navigateToProfile">
          <image
            class="avatar"
            :src="isLogin ? userInfo!.avatar : defaultAvatar"
            :src="isLogin ? userInfo?.avatar : defaultAvatar"
            mode="aspectFill"
          />
          <view v-if="isLogin" class="avatar-edit">
@@ -16,7 +16,7 @@
        </view>
        <view class="user-details">
          <block v-if="isLogin">
            <view class="nickname">{{ userInfo!.nickname || "匿名用户" }}</view>
            <view class="nickname">{{ userInfo?.nickname || "匿名用户" }}</view>
            <view class="user-id">ID: {{ userInfo?.username || "0000000" }}</view>
          </block>
          <block v-else>
@@ -211,9 +211,14 @@
      </view>
    </view> -->
    <!-- <view v-if="isLogin" class="logout-btn-container">
    <view v-if="isLogin" class="logout-btn-container">
      <wd-button class="logout-btn" @click="handleLogout">退出登录</wd-button>
    </view> -->
    </view>
    <!-- 版本号 -->
    <view class="version">
      <text class="version-text">版本号:{{ versionName }}</text>
    </view>
    <wd-toast />
  </view>
@@ -223,7 +228,7 @@
import { useToast } from "wot-design-uni";
import { useUserStore } from "@/store/modules/user";
import { useThemeStore } from "@/store/modules/theme";
import { computed } from "vue";
import { computed, ref, onMounted } from "vue";
const toast = useToast();
const userStore = useUserStore();
@@ -231,6 +236,35 @@
const userInfo = computed(() => userStore.userInfo);
const isLogin = computed(() => !!userInfo.value);
const defaultAvatar = "/static/images/default-avatar.png";
// 版本号
const versionName = ref("1.0.16");
// 获取版本号
onMounted(() => {
  // #ifdef MP-WEIXIN
  try {
    const accountInfo = uni.getAccountInfoSync();
    if (accountInfo?.miniProgram?.version) {
      versionName.value = accountInfo.miniProgram.version;
    }
  } catch (e) {
    // 获取失败时使用默认值
  }
  // #endif
  // #ifdef APP-PLUS
  try {
    // @ts-ignore
    if (plus?.runtime?.version) {
      // @ts-ignore
      versionName.value = plus.runtime.version;
    }
  } catch (e) {
    // 获取失败时使用默认值
  }
  // #endif
});
// 登录
const navigateToLoginPage = () => {
@@ -252,6 +286,7 @@
      if (res.confirm) {
        userStore.logout();
        toast.show("已退出登录");
        uni.reLaunch({ url: "/pages/login/index" });
      }
    },
  });
@@ -267,14 +302,14 @@
};
// 常见问题
const navigateToFAQ = () => {
  uni.navigateTo({ url: "/pages/mine/faq/index" });
};
// const navigateToFAQ = () => {
//   uni.navigateTo({ url: "/pages/mine/faq/index" });
// };
// 关于我们
const navigateToAbout = () => {
  uni.navigateTo({ url: "/pages/mine/about/index" });
};
// const navigateToAbout = () => {
//   uni.navigateTo({ url: "/pages/mine/about/index" });
// };
// 设置
const navigateToSettings = () => {
@@ -282,9 +317,9 @@
};
// 问题反馈
const handleQuestionFeedback = () => {
  uni.navigateTo({ url: "/pages/mine/feedback/index" });
};
// const handleQuestionFeedback = () => {
//   uni.navigateTo({ url: "/pages/mine/feedback/index" });
// };
// 导航到各个板块
const navigateToSection = (section: string, subSection?: string) => {
@@ -660,4 +695,17 @@
    }
  }
}
// 版本号
.version {
  display: flex;
  justify-content: center;
  margin-top: 20rpx;
  margin-bottom: 40rpx;
}
.version-text {
  font-size: 22rpx;
  color: #9ca3af;
}
</style>