style:修改样式

This commit is contained in:
zheng020 2026-05-14 15:59:56 +08:00 committed by zerosaturation
parent 89c8f8f877
commit faa8b32e09

View File

@ -6,21 +6,21 @@
</transition>
<transition name="slide-up">
<view v-if="visible" class="modal-container" :class="{ 'dragging': isDragging }"
:style="{ transform: `translateY(${dragOffset}px)` }" @tap.stop>
<view v-if="visible" class="modal-container" :class="{ 'dragging': isDragging }" @tap.stop>
<!-- 背景图 -->
<view class="modal-background"></view>
<!-- 内容区域 -->
<view class="modal-content">
<!-- 头部区域 - 活动名称 + 关闭按钮 -->
<view class="header-section" @touchstart.stop="handleTouchStart" @touchmove.stop="handleTouchMove"
@touchend.stop="handleTouchEnd">
<text class="activity-title">{{ activityTitle }}</text>
<view class="close-button" @tap="handleClose">
<text class="close-icon"></text>
<image class="close-icon-img" src="/static/starbookcontent/tuichu.png" mode="aspectFit">
</image>
</view>
<image class="activity-title-img" src="/static/rank/activity-rank-badge.png" mode="aspectFit">
</image>
</view>
<!-- 滚动内容区域 -->
@ -42,11 +42,39 @@
<!-- TOP3 展示区域 -->
<view v-else-if="top3Users.length > 0" class="top3-section">
<TOP3Card v-for="user in top3Users" :key="user.userId" :rank="user.rank" :avatar="user.avatar"
:nickname="user.nickname" :popularityScore="user.popularityScore"
:artworkImage="user.artworkImage" :userId="user.userId"
:isCurrentUser="isCurrentUser(user.userId)" @visit="handleVisit(user.userId, user.nickname)"
@view-profile="handleViewProfile" @avatar-click="(payload) => emit('view-profile', { userId: payload.userId })" />
<view v-for="user in top3Users" :key="user.userId" class="top3-card-item">
<!-- 头像区域居中显示大尺寸 -->
<view class="avatar-container">
<image class="user-avatar" :src="user.avatar || '/static/avatar/1.jpeg'"
mode="aspectFill" @error="handleAvatarError"
@tap="handleViewProfile(user.userId)">
</image>
<!-- 排名图标在头像下方 -->
<view class="rank-badge-bottom">
<image class="rank-icon" :src="`/static/rank/charm-rank-icon${user.rank}.png`"
mode="aspectFit" @error="handleRankIconError"></image>
</view>
<view class="rank-badge-bottom rank-badge-bottom2">
<image class="rank-icon" :src="`/static/rank/rank-icon${user.rank}.png`"
mode="aspectFit" @error="handleRankIconError"></image>
</view>
</view>
<!-- 昵称在头像下方 -->
<view class="nickname-container">
<text class="user-nickname-name">{{ user.nickname || '未知用户' }}</text>
</view>
<!-- 消耗水晶值在头像上方 -->
<view class="popularity-container-top">
<image class="fire-icon" src="/static/icon/crystal.png" mode="aspectFit"></image>
<text class="popularity-score-top">{{ formatPopularityScore(user.popularityScore)
}}</text>
</view>
<!-- 拜访按钮 -->
<view v-if="!isCurrentUser(user.userId) && user.rank >= 4" class="visit-btn"
@tap="handleVisit(user.userId, user.nickname)">
<text class="visit-text">拜访</text>
</view>
</view>
</view>
<!-- 空数据提示 -->
@ -58,12 +86,33 @@
<!-- 排名列表区域 -->
<view v-if="!isLoadingData && !dataLoadError && listUsers.length > 0"
class="ranking-list-section">
<RankingListItem v-for="item in listUsers" :key="item.userId" :rank="item.rank"
:userId="item.userId" :avatar="item.avatar" :nickname="item.nickname"
:popularityScore="item.popularityScore" :artworkImage="item.artworkImage"
:artworkId="item.artworkId" :showVisitButton="!isCurrentUser(item.userId)"
:isCurrentUser="isCurrentUser(item.userId)" @visit="handleVisit(item.userId, item.nickname)"
@view-profile="handleViewProfile" @artwork-click="handleArtworkClick" />
<view v-for="item in listUsers" :key="item.userId" class="ranking-list-item">
<!-- 排名编号 -->
<view class="rank-number">
<text class="rank-text">{{ item.rank }}</text>
</view>
<!-- 左侧头像 + 昵称 -->
<view class="left-section">
<image class="user-avatar-small" :src="item.avatar || '/static/avatar/1.jpeg'"
mode="aspectFill" @error="handleItemAvatarError"
@tap="handleViewProfile(item.userId)"></image>
<text class="item-nickname">{{ item.nickname || '未知用户' }}</text>
</view>
<!-- 右侧人气值和拜访按钮 -->
<view class="right-section">
<view class="popularity-container-top">
<image class="fire-icon" src="/static/icon/crystal.png" mode="aspectFit">
</image>
<text class="popularity-score-top">{{
formatPopularityScore(item.popularityScore)
}}</text>
</view>
<view v-if="!isCurrentUser(item.userId)" class="visit-button"
@tap="handleVisit(item.userId, item.nickname)">
<text class="visit-btn-text">拜访</text>
</view>
</view>
</view>
</view>
<!-- 加载更多提示 -->
@ -91,7 +140,7 @@
<!-- 用户信息 -->
<view class="current-user-info">
<view class="current-user-score">
<image class="flame-icon" src="/static/rank/spark.png" mode="aspectFit"></image>
<image class="flame-icon" src="/static/icon/crystal.png" mode="aspectFit"></image>
<text class="score-text">{{ formatPopularityScore(currentUserInfo.popularityScore)
}}</text>
</view>
@ -110,10 +159,8 @@
</template>
<script setup>
import { ref, computed, watch, onMounted, onUnmounted } from 'vue';
import { ref, computed, watch, onUnmounted } from 'vue';
import { getActivityRankingApi } from '@/utils/api.js';
import TOP3Card from '@/pages/components/TOP3Card.vue';
import RankingListItem from '@/pages/components/RankingListItem.vue';
const props = defineProps({
visible: {
@ -185,14 +232,8 @@ const isCurrentUser = (userId) => {
return userId === currentUserInfo.value.userId;
};
// OSSURL - 使URL
const getOssImageUrl = async (fileName, type = 'avatar') => {
if (!fileName || fileName === '') return;
return fileName;
};
//
const transformActivityRankingData = async (apiResponse) => {
const transformActivityRankingData = (apiResponse) => {
if (!apiResponse || !apiResponse.data) {
return [];
}
@ -202,30 +243,22 @@ const transformActivityRankingData = async (apiResponse) => {
return [];
}
const transformedItems = await Promise.all(items.map(async (item) => {
const avatarUrl = await getOssImageUrl(item.avatar_url || '', 'avatar');
return {
return items.map(item => ({
rank: item.rank,
userId: String(item.user_id),
avatar: avatarUrl || '/static/avatar/1.jpeg',
avatar: item.avatar_url || '/static/avatar/1.jpeg',
nickname: item.nickname || '未知用户',
popularityScore: item.total_contribution || 0,
artworkImage: '',
artworkId: ''
};
}));
return transformedItems;
};
//
const transformMyActivityContribution = async (myContribution) => {
const avatarUrl = await getOssImageUrl(myContribution?.avatar_url, 'avatar');
const transformMyActivityContribution = (myContribution) => {
return {
userId: 'currentUser',
avatar: avatarUrl || '/static/avatar/1.jpeg',
avatar: myContribution?.avatar_url || '/static/avatar/1.jpeg',
popularityScore: myContribution?.total_contribution || 0,
rank: (myContribution?.rank > 0) ? myContribution.rank : null
};
@ -250,8 +283,7 @@ const loadRankingData = async (page = 1, isRefreshAction = false) => {
);
if (apiResponse && apiResponse.code === 200 && apiResponse.data) {
//
const transformedData = await transformActivityRankingData(apiResponse);
const transformedData = transformActivityRankingData(apiResponse);
if (page === 1) {
rankingData.value = transformedData;
@ -259,12 +291,10 @@ const loadRankingData = async (page = 1, isRefreshAction = false) => {
rankingData.value.push(...transformedData);
}
//
hasNoMoreData.value = transformedData.length < PAGE_SIZE;
//
if (page === 1 && apiResponse.data.my_contribution) {
const myContributionData = await transformMyActivityContribution(apiResponse.data.my_contribution);
const myContributionData = transformMyActivityContribution(apiResponse.data.my_contribution);
if (!props.currentUser) {
currentUserInfo.value = myContributionData;
}
@ -316,11 +346,9 @@ const handleRefresh = async () => {
isRefreshing.value = true;
try {
//
currentPage.value = 1;
hasNoMoreData.value = false;
//
const success = await loadRankingData(1, true);
if (success) {
@ -338,11 +366,6 @@ const handleRefresh = async () => {
}
} catch (error) {
console.error('Refresh failed:', error);
uni.showToast({
title: '刷新失败',
icon: 'none',
duration: 2000
});
} finally {
isRefreshing.value = false;
}
@ -381,11 +404,8 @@ const handleViewProfile = (userId) => {
};
//
const handleArtworkClick = (data) => {
emit('view-artwork', {
artworkId: data.artworkId,
userId: data.userId
});
const handleArtworkClick = () => {
//
};
//
@ -439,17 +459,30 @@ const handleCurrentUserAvatarError = (e) => {
e.target.src = '/static/avatar/1.jpeg';
};
//
const handleRankIconError = (e) => {
e.target.src = '/static/rank/charm-rank-icon1.png';
};
//
const handleAvatarError = (e) => {
e.target.src = '/static/avatar/1.jpeg';
};
//
const handleItemAvatarError = (e) => {
e.target.src = '/static/avatar/1.jpeg';
};
//
watch(() => props.visible, async (newVisible, oldVisible) => {
if (newVisible && !oldVisible) {
//
rankingData.value = [];
currentPage.value = 1;
hasNoMoreData.value = false;
isLoadingData.value = true;
dataLoadError.value = null;
// 使 currentUser
if (props.currentUser) {
currentUserInfo.value = { ...props.currentUser };
} else {
@ -462,7 +495,6 @@ watch(() => props.visible, async (newVisible, oldVisible) => {
};
}
//
await loadRankingData(1);
}
}, { immediate: false });
@ -535,8 +567,9 @@ onUnmounted(() => {
.modal-container {
position: absolute;
width: 100%;
height: 80vh;
bottom: 0;
height: 80%;
top: 50%;
transform: translateY(-50%);
border-radius: 48rpx 48rpx 0 0;
overflow: hidden;
z-index: 10;
@ -553,7 +586,7 @@ onUnmounted(() => {
left: 0;
right: 0;
bottom: 0;
background-image: url('/static/rank/paihangbang.png');
background-image: url('/static/rank/activity-support-icon/shengrihuipaihangbang.png');
background-size: 100% 100%;
background-repeat: no-repeat;
background-position: center;
@ -586,34 +619,39 @@ onUnmounted(() => {
align-items: center;
justify-content: center;
margin-bottom: 40rpx;
padding: 0 32rpx;
padding: 0 14rpx;
position: relative;
top: 48rpx;
width: 100%;
}
.activity-title {
font-size: 36rpx;
font-weight: bold;
color: #FFFFFF;
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.4);
font-family: 'yt', sans-serif;
.activity-title-img {
flex: 1;
max-width: 400rpx;
height: 60rpx;
object-fit: contain;
filter: drop-shadow(0 4rpx 8rpx rgba(0, 0, 0, 0.4));
pointer-events: none;
opacity: 1;
transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1),
transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
will-change: opacity, transform;
transform: scale(2.3);
}
.close-button {
position: absolute;
right: 32rpx;
left: 64rpx;
width: 56rpx;
height: 56rpx;
display: flex;
align-items: center;
justify-content: center;
background: rgba(255, 255, 255, 0.2);
border-radius: 50%;
}
.close-icon {
font-size: 32rpx;
color: #FFFFFF;
.close-icon-img {
width: 80rpx;
height: 80rpx;
}
/* 滚动内容区域 */
@ -694,6 +732,136 @@ onUnmounted(() => {
padding: 0 48rpx;
}
.top3-card-item {
display: flex;
flex-direction: column;
align-items: center;
width: 25%;
position: relative;
}
/* 人气值容器(在头像上方) */
.popularity-container-top {
display: flex;
align-items: center;
justify-content: center;
padding: 4rpx 20rpx 4rpx 64rpx;
background: linear-gradient(to bottom right,
#F0E4B1 0%,
#F08399 50%,
#B94E73 100%);
border-radius: 24rpx;
box-shadow:
0 4rpx 12rpx rgba(255, 143, 158, 0.2),
inset 0 2rpx 4rpx rgba(255, 255, 255, 0.4);
}
.popularity-container-top .fire-icon {
width: 80rpx;
height: 80rpx;
position: absolute;
left: -8rpx;
transform: rotate(-15deg);
}
.popularity-container-top .popularity-score-top {
font-size: 24rpx;
font-weight: bold;
color: #FFFFFF;
text-shadow:
0 2rpx 4rpx rgba(0, 0, 0, 0.5),
0 1rpx 2rpx rgba(0, 0, 0, 0.3);
font-family: 'yt', sans-serif;
margin-left: 16rpx;
}
/* 头像容器(居中显示,大尺寸) */
.avatar-container {
width: 180rpx;
height: 180rpx;
margin-bottom: 64rpx;
margin-top: 64rpx;
position: relative;
}
.user-avatar {
width: 180rpx;
height: 180rpx;
border-radius: 50%;
border: 5rpx solid rgba(255, 255, 255, 0.8);
box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.3);
}
/* 排名图标在头像下方 */
.rank-badge-bottom {
position: absolute;
bottom: -40rpx;
left: 50%;
transform: translateX(-50%) scale(2.5);
z-index: 10;
width: 80rpx;
height: 80rpx;
pointer-events: none;
}
.rank-badge-bottom2 {
bottom: -50rpx;
transform: translateX(-50%) scale(3);
}
.rank-icon {
width: 100%;
height: 100%;
filter: drop-shadow(0 4rpx 8rpx rgba(0, 0, 0, 0.3));
}
/* 昵称容器(在头像下方) */
.nickname-container {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
padding: 0 12rpx;
margin-bottom: 16rpx;
}
.user-nickname {
font-size: 12rpx;
margin-left: 10rpx;
color: #FFFFFF;
text-align: center;
max-width: 100%;
text-overflow: ellipsis;
white-space: nowrap;
text-shadow:
0 3rpx 6rpx rgba(0, 0, 0, 0.4),
0 1rpx 3rpx rgba(0, 0, 0, 0.3);
font-family: 'yt', sans-serif;
}
.user-nickname-name {
font-size: 24rpx;
margin-left: 0.5em;
color: #FFA500;
text-shadow:
0 3rpx 6rpx rgba(0, 0, 0, 0.4),
0 1rpx 3rpx rgba(0, 0, 0, 0.3);
font-family: 'yt', sans-serif;
}
.visit-btn {
margin-top: 12rpx;
padding: 8rpx 24rpx;
background: linear-gradient(135deg, rgba(255, 107, 157, 0.9), rgba(255, 177, 153, 0.9));
border-radius: 20rpx;
}
.visit-text {
font-size: 22rpx;
color: #FFFFFF;
font-family: 'yt', sans-serif;
}
/* 空数据提示 */
.empty-data {
display: flex;
@ -719,6 +887,92 @@ onUnmounted(() => {
padding: 0 48rpx;
}
.ranking-list-item {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 24rpx;
gap: 20rpx;
}
.rank-number {
min-width: 64rpx;
display: flex;
align-items: center;
justify-content: center;
}
.rank-text {
font-size: 32rpx;
font-weight: bold;
color: #FFFFFF;
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.5);
font-family: 'yt', sans-serif;
}
.left-section {
display: flex;
align-items: center;
gap: 16rpx;
flex: 1;
}
.user-avatar-small {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
border: 3rpx solid rgba(255, 255, 255, 0.7);
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.3);
}
.item-nickname {
font-size: 28rpx;
color: #FFFFFF;
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.5);
font-family: 'yt', sans-serif;
max-width: 200rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.right-section {
display: flex;
align-items: center;
gap: 16rpx;
}
.popularity-container {
display: flex;
align-items: center;
gap: 4rpx;
}
.fire-icon-small {
width: 28rpx;
height: 28rpx;
}
.item-score {
font-size: 24rpx;
color: #FFFFFF;
font-weight: bold;
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.5);
font-family: 'yt', sans-serif;
}
.visit-button {
padding: 12rpx 24rpx;
background: linear-gradient(135deg, rgba(255, 107, 157, 0.9), rgba(255, 177, 153, 0.9));
border-radius: 24rpx;
}
.visit-btn-text {
font-size: 24rpx;
color: #FFFFFF;
font-family: 'yt', sans-serif;
}
/* 加载更多容器 */
.loading-more-container {
display: flex;
@ -766,7 +1020,7 @@ onUnmounted(() => {
/* 当前用户栏 - 固定在底部 */
.current-user-bar {
position: absolute;
bottom: 120rpx;
bottom: 152rpx;
left: 84rpx;
right: 84rpx;
padding: 24rpx;
@ -816,18 +1070,20 @@ onUnmounted(() => {
.current-user-score {
display: flex;
align-items: center;
justify-content: center;
}
.flame-icon {
width: 44rpx;
width: 80rpx;
height: 80rpx;
filter: drop-shadow(0 2rpx 4rpx rgba(0, 0, 0, 0.3));
left: -8rpx;
transform: rotate(-15deg);
/* filter: drop-shadow(0 2rpx 4rpx rgba(0, 0, 0, 0.3)); */
}
.score-text {
font-size: 26rpx;
margin-left: 8rpx;
color: rgba(255, 255, 255, 0.95);
color: #fff;
font-family: 'yt', sans-serif;
font-weight: 500;
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.3);
@ -837,6 +1093,11 @@ onUnmounted(() => {
display: flex;
align-items: center;
padding: 16rpx 28rpx;
background-image: url('@/static/rank/activity-support-icon/beijingkuang.png');
background-size: cover;
background-position: center;
border-radius: 40rpx;
}
.rank-text {
@ -860,8 +1121,9 @@ onUnmounted(() => {
margin-bottom: 32rpx;
}
.activity-title {
font-size: 32rpx;
.activity-title-img {
width: 280rpx;
height: 75rpx;
}
.scrollable-content {
@ -877,6 +1139,23 @@ onUnmounted(() => {
padding: 0 8rpx;
}
/* TOP3 头像区域 */
.avatar-container {
width: 160rpx;
height: 160rpx;
}
.user-avatar {
width: 160rpx;
height: 160rpx;
}
.rank-badge-bottom {
width: 72rpx;
height: 72rpx;
bottom: -18rpx;
}
.current-user-bar {
bottom: 100rpx;
left: 15rpx;
@ -901,8 +1180,9 @@ onUnmounted(() => {
padding: 0 24rpx;
}
.activity-title {
font-size: 28rpx;
.activity-title-img {
width: 260rpx;
height: 70rpx;
}
.scrollable-content {
@ -915,6 +1195,30 @@ onUnmounted(() => {
padding: 0 4rpx;
}
/* TOP3 头像区域 */
.avatar-container {
width: 140rpx;
height: 140rpx;
margin-bottom: 14rpx;
}
.user-avatar {
width: 140rpx;
height: 140rpx;
}
.rank-badge-bottom {
width: 68rpx;
height: 68rpx;
bottom: -16rpx;
}
.popularity-container-top {
margin-top: 20rpx;
margin-bottom: 14rpx;
gap: 6rpx;
}
.ranking-list-section {
padding: 0 4rpx;
}
@ -969,13 +1273,19 @@ onUnmounted(() => {
}
.close-button {
right: 16rpx;
left: 16rpx;
width: 48rpx;
height: 48rpx;
}
.close-icon {
font-size: 28rpx;
.close-icon-img {
width: 48rpx;
height: 48rpx;
}
.activity-title-img {
width: 240rpx;
height: 65rpx;
}
.scrollable-content {
@ -988,6 +1298,44 @@ onUnmounted(() => {
padding: 0 2rpx;
}
/* TOP3 头像区域 */
.avatar-container {
width: 120rpx;
height: 120rpx;
margin-bottom: 12rpx;
}
.user-avatar {
width: 120rpx;
height: 120rpx;
border-width: 3rpx;
}
.rank-badge-bottom {
width: 64rpx;
height: 64rpx;
bottom: -14rpx;
}
.popularity-container-top {
margin-top: 16rpx;
margin-bottom: 12rpx;
gap: 5rpx;
}
.user-nickname {
font-size: 22rpx;
}
.fire-icon {
width: 24rpx;
height: 24rpx;
}
.popularity-score-top {
font-size: 24rpx;
}
.ranking-list-section {
padding: 0 2rpx;
}