Files
rating/pages/mine/mine.vue

471 lines
12 KiB
Vue
Raw Normal View History

2026-05-07 11:05:30 +08:00
<template>
<view class="mine-page">
<!-- Custom Navbar -->
<view
class="nav-bar"
:style="{ paddingTop: navBarTop + 'px', height: navBarHeight + 'px' }"
>
2026-06-08 19:08:13 +08:00
<!-- Optional title -->
2026-05-07 11:05:30 +08:00
</view>
<scroll-view
scroll-y
class="content-scroll"
:style="{ paddingTop: navBarTop + navBarHeight + 'px' }"
>
<view class="content-wrap">
2026-06-08 19:08:13 +08:00
2026-05-07 11:05:30 +08:00
<!-- User Card -->
2026-06-08 19:08:13 +08:00
<view class="user-card">
<view class="avatar-container" @tap="handleUserClick">
<view class="avatar-ring">
<image :src="userInfo.avatarUrl" class="avatar" mode="aspectFill" />
2026-05-07 11:05:30 +08:00
</view>
</view>
2026-06-08 19:08:13 +08:00
<text class="nickname" @tap="handleUserClick">{{ userInfo.nickName }}</text>
<view class="tags-container" v-if="isLoggedIn && userStats.label && userStats.label.length">
<text class="sparkle-icon"></text>
<text class="tags-text">{{ userStats.label.join(' | ') }}</text>
</view>
<view class="tags-container" v-else-if="!isLoggedIn">
<text class="tags-text">点击登录解锁更多功能</text>
</view>
<view class="stats-container">
<view class="stat-item">
<text class="stat-num">{{ isLoggedIn ? userStats.participant : '-' }}</text>
<text class="stat-label">参与话题</text>
</view>
<view class="stat-divider"></view>
<view class="stat-item">
<text class="stat-num">{{ isLoggedIn ? userStats.comment : '-' }}</text>
<text class="stat-label">评论数</text>
2026-05-07 11:05:30 +08:00
</view>
2026-06-08 19:08:13 +08:00
<view class="stat-divider"></view>
<view class="stat-item">
<text class="stat-num">{{ isLoggedIn ? userStats.liked : '-' }}</text>
<text class="stat-label">获赞</text>
2026-05-07 11:05:30 +08:00
</view>
</view>
2026-06-08 19:08:13 +08:00
<view class="action-buttons">
<button class="btn-primary" @tap="navTo('profile')">编辑资料</button>
2026-06-10 00:41:11 +08:00
<button v-if="isLoggedIn" class="btn-secondary" open-type="share">
<text class="share-icon-btn"></text> 分享主页
</button>
<button v-else class="btn-secondary" @tap="openLoginPopup('请先登录后再分享主页')">
2026-06-08 19:08:13 +08:00
<text class="share-icon-btn"></text> 分享主页
</button>
2026-05-07 11:05:30 +08:00
</view>
</view>
2026-06-08 19:08:13 +08:00
<!-- Menu Group 1 -->
<view class="menu-card">
2026-06-08 10:57:20 +08:00
<view class="menu-item" @tap="navTo('/pages/mine/topics')">
2026-06-08 19:08:13 +08:00
<view class="icon-left"><text class="icon-bookmark"></text></view>
<text class="menu-text">我的参与</text>
<text class="menu-value" v-if="isLoggedIn">{{ userStats.participant }}</text>
</view>
<view class="menu-item" @tap="navTo('comments')">
<view class="icon-left"><text class="icon-document"></text></view>
<text class="menu-text">我的评论</text>
<text class="menu-value" v-if="isLoggedIn">{{ userStats.comment }}</text>
2026-05-07 11:05:30 +08:00
</view>
</view>
2026-06-08 19:08:13 +08:00
<!-- Menu Group 2 -->
<view class="menu-card">
2026-05-07 11:05:30 +08:00
<view class="menu-item" @tap="navTo('feedback')">
2026-06-08 19:08:13 +08:00
<view class="icon-left"><text class="icon-feedback"></text></view>
2026-05-07 11:05:30 +08:00
<text class="menu-text">意见反馈</text>
<text class="arrow"></text>
</view>
</view>
<view style="height: 120rpx"></view>
</view>
</scroll-view>
<!-- Login Popup -->
<LoginPopup ref="loginPopupRef" @logind="handleLogind" />
</view>
</template>
<script setup>
import { ref, computed } from "vue";
import { useUserStore } from "@/stores/user";
2026-06-10 00:34:12 +08:00
import { onShareAppMessage, onShareTimeline, onLoad, onShow } from "@dcloudio/uni-app";
2026-05-07 11:05:30 +08:00
import { getShareToken } from "@/utils/common";
import { getShareReward } from "@/api/system";
2026-06-08 19:08:13 +08:00
import { fetchUserNums } from "@/api/mine";
2026-05-07 11:05:30 +08:00
import LoginPopup from "@/components/LoginPopup/LoginPopup.vue";
const userStore = useUserStore();
const loginPopupRef = ref(null);
// Navigation Bar
const navBarTop = ref(20);
const navBarHeight = ref(44);
// User Info
2026-06-08 19:08:13 +08:00
const defaultAvatarUrl = "https://api.dicebear.com/7.x/avataaars/svg?seed=fallback";
2026-05-07 11:05:30 +08:00
const userInfo = computed(() => ({
nickName: userStore.userInfo.nickName || "点击登录",
avatarUrl: userStore.userInfo.avatarUrl || defaultAvatarUrl,
isVip: userStore.userInfo.isVip || false,
}));
2026-06-10 00:45:45 +08:00
const isLoggedIn = computed(() => !!userStore.token || !!userStore.userInfo.nickName);
2026-05-07 11:05:30 +08:00
2026-06-08 19:08:13 +08:00
// User Stats
const userStats = ref({
participant: 0,
comment: 0,
liked: 0,
label: []
});
const loadUserStats = async () => {
2026-06-10 00:45:45 +08:00
if (!isLoggedIn.value) {
userStats.value = {
participant: 0,
comment: 0,
liked: 0,
label: []
};
return;
}
2026-06-08 19:08:13 +08:00
try {
const res = await fetchUserNums();
const data = res?.data || res || {};
userStats.value = {
participant: data.participant || 0,
comment: data.comment || 0,
liked: data.liked || 0,
label: data.label || []
};
} catch (error) {
console.error("获取用户数据失败:", error);
}
};
2026-05-07 11:05:30 +08:00
2026-06-08 19:08:13 +08:00
onLoad(() => {
2026-05-07 11:05:30 +08:00
const sysInfo = uni.getSystemInfoSync();
navBarTop.value = sysInfo.statusBarHeight;
navBarHeight.value = 44;
});
2026-06-08 19:08:13 +08:00
onShow(() => {
loadUserStats();
});
2026-05-07 11:05:30 +08:00
onShareAppMessage(async () => {
const shareToken = await getShareToken("mine");
getShareReward({ scene: "mine" });
2026-06-10 00:34:12 +08:00
const nickName = isLoggedIn.value ? userInfo.value.nickName : "我";
2026-05-07 11:05:30 +08:00
return {
2026-06-10 00:34:12 +08:00
title: `${nickName}也在玩夯拉评分来看看TA的主页`,
path: "/pages/mine/mine?shareToken=" + shareToken,
2026-06-08 19:08:13 +08:00
imageUrl: "https://file.lihailezzc.com/resource/8dd026d76ef7a63d123b7fd698fb989b.png",
2026-05-07 11:05:30 +08:00
};
});
2026-06-10 00:34:12 +08:00
onShareTimeline(async () => {
const shareToken = await getShareToken("mine");
getShareReward({ scene: "mine_timeline" });
const nickName = isLoggedIn.value ? userInfo.value.nickName : "我";
const participant = userStats.value.participant || 0;
return {
title: `${nickName}已参与 ${participant} 个话题,来夯拉评分一起围观`,
query: `shareToken=${shareToken}`,
};
});
2026-05-07 11:05:30 +08:00
const handleUserClick = () => {
if (!isLoggedIn.value) {
2026-06-10 00:41:11 +08:00
openLoginPopup("请先登录");
2026-05-07 11:05:30 +08:00
} else {
uni.navigateTo({
url: "/pages/mine/profile",
});
}
};
const handleLogind = async () => {
2026-06-08 19:08:13 +08:00
loadUserStats();
2026-05-07 11:05:30 +08:00
};
2026-06-10 00:41:11 +08:00
const openLoginPopup = (message = "请先登录") => {
loginPopupRef.value.open();
if (message) {
uni.showToast({ title: message, icon: "none" });
}
};
2026-05-07 11:05:30 +08:00
const navTo = (page) => {
if (!isLoggedIn.value) {
2026-06-10 00:41:11 +08:00
openLoginPopup("请先登录");
2026-05-07 11:05:30 +08:00
return;
}
2026-06-08 10:57:20 +08:00
if (page === "profile") {
2026-06-08 19:08:13 +08:00
uni.navigateTo({ url: "/pages/mine/profile" });
2026-06-08 10:57:20 +08:00
return;
}
2026-05-07 11:05:30 +08:00
if (page === "feedback") {
2026-06-08 19:08:13 +08:00
uni.navigateTo({ url: "/pages/feedback/index" });
2026-05-07 11:05:30 +08:00
return;
}
2026-06-08 19:08:13 +08:00
2026-06-08 10:57:20 +08:00
if (page === "/pages/mine/topics") {
uni.navigateTo({ url: page });
return;
}
2026-05-07 11:05:30 +08:00
uni.showToast({ title: "功能开发中", icon: "none" });
};
</script>
<style lang="scss" scoped>
.mine-page {
min-height: 100vh;
2026-06-08 19:08:13 +08:00
background-color: #f8f9fc;
2026-05-07 11:05:30 +08:00
box-sizing: border-box;
}
.nav-bar {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
display: flex;
align-items: center;
justify-content: center;
2026-06-08 19:08:13 +08:00
background: transparent;
2026-05-07 11:05:30 +08:00
}
.content-scroll {
height: 100vh;
}
2026-06-08 19:08:13 +08:00
2026-05-07 11:05:30 +08:00
.content-wrap {
2026-06-08 19:08:13 +08:00
padding: 20rpx 32rpx 40rpx;
2026-05-07 11:05:30 +08:00
}
/* User Card */
.user-card {
background: #fff;
2026-06-08 19:08:13 +08:00
border-radius: 40rpx;
padding: 60rpx 40rpx 40rpx;
2026-05-07 11:05:30 +08:00
display: flex;
2026-06-08 19:08:13 +08:00
flex-direction: column;
2026-05-07 11:05:30 +08:00
align-items: center;
2026-06-08 19:08:13 +08:00
margin-bottom: 32rpx;
box-shadow: 0 16rpx 40rpx rgba(77, 68, 241, 0.04);
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.avatar-container {
margin-bottom: 24rpx;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.avatar-ring {
width: 176rpx;
height: 176rpx;
2026-05-07 11:05:30 +08:00
border-radius: 50%;
2026-06-08 19:08:13 +08:00
padding: 6rpx;
background: linear-gradient(135deg, #7B46F1, #4d44f1, #00d2ff);
2026-05-07 11:05:30 +08:00
display: flex;
align-items: center;
justify-content: center;
}
2026-06-08 19:08:13 +08:00
.avatar {
width: 100%;
height: 100%;
border-radius: 50%;
border: 4rpx solid #fff;
background-color: #fff;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
2026-05-07 11:05:30 +08:00
.nickname {
2026-06-08 19:08:13 +08:00
font-size: 40rpx;
font-weight: 800;
color: #111;
margin-bottom: 12rpx;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.tags-container {
2026-05-07 11:05:30 +08:00
display: flex;
align-items: center;
2026-06-08 19:08:13 +08:00
margin-bottom: 48rpx;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.sparkle-icon {
font-size: 28rpx;
color: #7B46F1;
2026-05-07 11:05:30 +08:00
margin-right: 8rpx;
}
2026-06-08 19:08:13 +08:00
.tags-text {
2026-05-07 11:05:30 +08:00
font-size: 24rpx;
color: #666;
}
2026-06-08 19:08:13 +08:00
.stats-container {
2026-05-07 11:05:30 +08:00
display: flex;
align-items: center;
justify-content: center;
2026-06-08 19:08:13 +08:00
width: 100%;
margin-bottom: 48rpx;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.stat-item {
flex: 1;
2026-05-07 11:05:30 +08:00
display: flex;
flex-direction: column;
2026-06-08 19:08:13 +08:00
align-items: center;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.stat-num {
font-size: 40rpx;
font-weight: 800;
color: #111;
2026-05-07 11:05:30 +08:00
margin-bottom: 8rpx;
}
2026-06-08 19:08:13 +08:00
.stat-label {
font-size: 24rpx;
color: #888;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.stat-divider {
width: 2rpx;
height: 40rpx;
background-color: #f0f0f0;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.action-buttons {
width: 100%;
display: flex;
flex-direction: column;
gap: 20rpx;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.btn-primary {
width: 100%;
height: 88rpx;
background: linear-gradient(135deg, #5b54df, #453bc7);
color: #fff;
font-size: 30rpx;
font-weight: 600;
border-radius: 100rpx;
2026-05-07 11:05:30 +08:00
display: flex;
align-items: center;
2026-06-08 19:08:13 +08:00
justify-content: center;
box-shadow: 0 8rpx 20rpx rgba(77, 68, 241, 0.2);
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.btn-primary::after {
border: none;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.btn-secondary {
width: 100%;
height: 88rpx;
background-color: #f3f2ff;
color: #453bc7;
font-size: 30rpx;
font-weight: 600;
border-radius: 100rpx;
display: flex;
align-items: center;
justify-content: center;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.btn-secondary::after {
border: none;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.share-icon-btn {
width: 36rpx;
height: 36rpx;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23453bc7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='18' cy='5' r='3'%3E%3C/circle%3E%3Ccircle cx='6' cy='12' r='3'%3E%3C/circle%3E%3Ccircle cx='18' cy='19' r='3'%3E%3C/circle%3E%3Cline x1='8.59' y1='13.51' x2='15.42' y2='17.49'%3E%3C/line%3E%3Cline x1='15.41' y1='6.51' x2='8.59' y2='10.49'%3E%3C/line%3E%3C/svg%3E");
background-size: cover;
margin-right: 12rpx;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
/* Menu Card */
.menu-card {
background: #fff;
border-radius: 32rpx;
padding: 16rpx 0;
margin-bottom: 24rpx;
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.02);
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
2026-05-07 11:05:30 +08:00
.menu-item {
display: flex;
align-items: center;
2026-06-08 19:08:13 +08:00
padding: 32rpx 40rpx;
2026-05-07 11:05:30 +08:00
position: relative;
}
2026-06-08 19:08:13 +08:00
2026-05-07 11:05:30 +08:00
.menu-item:active {
2026-06-08 19:08:13 +08:00
background: #fcfcfc;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.icon-left {
width: 48rpx;
height: 48rpx;
2026-05-07 11:05:30 +08:00
display: flex;
align-items: center;
justify-content: center;
margin-right: 24rpx;
}
2026-06-08 19:08:13 +08:00
.icon-bookmark {
width: 40rpx;
height: 40rpx;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234d44f1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z'%3E%3C/path%3E%3C/svg%3E");
background-size: cover;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.icon-document {
2026-05-07 11:05:30 +08:00
width: 40rpx;
2026-06-08 19:08:13 +08:00
height: 40rpx;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237B46F1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'%3E%3C/path%3E%3Cpolyline points='14 2 14 8 20 8'%3E%3C/polyline%3E%3Cline x1='16' y1='13' x2='8' y2='13'%3E%3C/line%3E%3Cline x1='16' y1='17' x2='8' y2='17'%3E%3C/line%3E%3Cpolyline points='10 9 9 9 8 9'%3E%3C/polyline%3E%3C/svg%3E");
background-size: cover;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.icon-feedback {
width: 40rpx;
height: 40rpx;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23453bc7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'%3E%3C/path%3E%3Cline x1='9' y1='10' x2='15' y2='10'%3E%3C/line%3E%3C/svg%3E");
background-size: cover;
2026-05-07 11:05:30 +08:00
}
.menu-text {
flex: 1;
2026-06-08 19:08:13 +08:00
font-size: 30rpx;
2026-05-07 11:05:30 +08:00
color: #333;
font-weight: 500;
}
2026-06-08 19:08:13 +08:00
.menu-value {
2026-05-07 11:05:30 +08:00
font-size: 32rpx;
2026-06-08 19:08:13 +08:00
color: #999;
font-family: 'DIN Alternate', -apple-system, sans-serif;
2026-05-07 11:05:30 +08:00
}
2026-06-08 19:08:13 +08:00
.arrow {
2026-05-07 11:05:30 +08:00
color: #ccc;
2026-06-08 19:08:13 +08:00
font-size: 36rpx;
margin-left: 12rpx;
2026-05-07 11:05:30 +08:00
}
</style>