排行榜样式修正

This commit is contained in:
WindowBird 2025-11-13 13:51:52 +08:00
parent a94360dc4e
commit 57ca6f3291
2 changed files with 45 additions and 29 deletions

View File

@ -44,14 +44,15 @@
<view v-else class="ranking-list-container"> <view v-else class="ranking-list-container">
<!-- 当前用户排名高亮显示 --> <!-- 当前用户排名高亮显示 -->
<view v-if="currentUserRank" class="my-ranking-card"> <view v-if="currentUserRank" class="my-ranking-card">
<view class="my-ranking-header">
<text class="my-label"></text>
<view class="my-avatar">
<text class="avatar-text">{{ getAvatarText(currentUserRank.userName) }}</text>
</view>
<text class="my-rank">{{ currentUserRank.rank }}</text>
</view>
<view class="my-ranking-stats"> <view class="my-ranking-stats">
<view class="stat-item">
<text class="stat-value"></text>
</view>
<view class="stat-item">
<text class="stat-value">{{ currentUserRank.rank }}</text>
</view>
<view class="stat-item"> <view class="stat-item">
<text class="stat-value">{{ currentUserRank.addNum }}</text> <text class="stat-value">{{ currentUserRank.addNum }}</text>
</view> </view>
@ -95,9 +96,7 @@
<!-- 名称 --> <!-- 名称 -->
<view class="name-col"> <view class="name-col">
<view class="user-avatar">
<text class="avatar-text">{{ getAvatarText(item.userName) }}</text>
</view>
<text class="user-name">{{ item.userName }}</text> <text class="user-name">{{ item.userName }}</text>
</view> </view>
@ -147,27 +146,39 @@ const rankingData = ref({
// ID // ID
const userStore = useUserStore(); const userStore = useUserStore();
const currentUserId = computed(() => { const currentUserId = computed(() => {
const userId = userStore.userInfo?.id || userStore.userInfo?.userId || ''; const userId = userStore.userInfo?.user.userId;
console.log('userId',userStore.userInfo.user.userId);
return String(userId); // return String(userId); //
}); });
// //
const currentRankingList = computed(() => { const currentRankingList = computed(() => {
return rankingData.value[currentTab.value] || []; return rankingData.value[currentTab.value] || [];
}); });
// //
const currentUserRank = computed(() => { const currentUserRank = computed(() => {
const list = currentRankingList.value; const list = currentRankingList.value;
const userId = currentUserId.value; const userId = currentUserId.value;
// IDnull
if (!userId) return null; if (!userId) return null;
const index = list.findIndex(item => String(item.userId) === String(userId)); // ID
if (index === -1) return null; const userItem = list.find(item => String(item.userId) === String(userId));
// null
if (!userItem) return null;
// +1
const rank = list.findIndex(item => String(item.userId) === String(userId)) + 1;
console.log('userrank',rank);
//
return { return {
...list[index], ...userItem,
rank: index + 1 rank: rank
}; };
}); });
@ -334,7 +345,7 @@ onMounted(() => {
.my-ranking-card { .my-ranking-card {
background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%); background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
border-radius: 16rpx; border-radius: 16rpx;
padding: 24rpx; padding: 24rpx 0;
margin-bottom: 24rpx; margin-bottom: 24rpx;
} }
@ -345,6 +356,7 @@ onMounted(() => {
} }
.my-label { .my-label {
flex: 1;
font-size: 28rpx; font-size: 28rpx;
font-weight: 600; font-weight: 600;
color: #1976d2; color: #1976d2;
@ -369,6 +381,7 @@ onMounted(() => {
} }
.my-rank { .my-rank {
flex: 1;
font-size: 28rpx; font-size: 28rpx;
font-weight: 600; font-weight: 600;
color: #1976d2; color: #1976d2;
@ -400,24 +413,25 @@ onMounted(() => {
} }
.header-col { .header-col {
flex: 1;
font-size: 24rpx; font-size: 24rpx;
color: #666666; color: #666666;
text-align: center; text-align: center;
&.rank-col { &.rank-col {
width: 80rpx; flex:1;
flex-shrink: 0; flex-shrink: 0;
} }
&.name-col { &.name-col {
flex: 1;
text-align: left; text-align: left;
padding-left: 16rpx;
justify-content: center; justify-content: center;
} }
&.stat-col { &.stat-col {
width: 100rpx;
flex-shrink: 0; flex-shrink: 0;
} }
} }
@ -431,6 +445,8 @@ onMounted(() => {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 24rpx 0; padding: 24rpx 0;
flex:1;
border-bottom: 1rpx solid #f0f0f0; border-bottom: 1rpx solid #f0f0f0;
&:last-child { &:last-child {
@ -440,14 +456,13 @@ onMounted(() => {
&.is-current-user { &.is-current-user {
background: #f0f7ff; background: #f0f7ff;
border-radius: 8rpx; border-radius: 8rpx;
padding: 24rpx 16rpx;
margin: 8rpx 0; margin: 8rpx 0;
} }
} }
.rank-col { .rank-col {
width: 80rpx; flex:1;
flex-shrink: 0;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@ -465,10 +480,10 @@ onMounted(() => {
} }
.name-col { .name-col {
flex: 1; flex:1;
display: flex; display: flex;
align-items: center; align-items: center;
padding-left: 16rpx;
} }
.user-avatar { .user-avatar {
@ -494,7 +509,8 @@ onMounted(() => {
} }
.stat-col { .stat-col {
width: 100rpx; flex:1;
flex-shrink: 0; flex-shrink: 0;
text-align: center; text-align: center;
} }

View File

@ -11,7 +11,7 @@ export const Request = () => {
uni.$uv.http.setConfig((config) => { uni.$uv.http.setConfig((config) => {
/* config 为默认全局配置*/ /* config 为默认全局配置*/
config.baseURL = 'http://192.168.1.5:4001'; /* 根域名 */ config.baseURL = 'http://192.168.1.5:4001'; /* 根域名 */
config.baseURL = 'https://pm.ccttiot.com/prod-api'; /* 根域名 */ // config.baseURL = 'https://pm.ccttiot.com/prod-api'; /* 根域名 */
return config return config
}) })