diff --git a/frontend/pages/square/components/CreationGrid.vue b/frontend/pages/square/components/CreationGrid.vue index 44d4807..9866611 100644 --- a/frontend/pages/square/components/CreationGrid.vue +++ b/frontend/pages/square/components/CreationGrid.vue @@ -2,6 +2,16 @@ + + + #{{ item.certificate_id }} @@ -11,10 +21,7 @@ {{ item.creator_name }} - + @@ -48,6 +55,7 @@ const cursor = ref('') const isLoading = ref(false) const noMore = ref(false) let isComponentMounted = false +const likingMap = ref({}); const formatCount = (count) => { if (!count) return '0' @@ -83,6 +91,7 @@ const loadUsers = async () => { creator_avatar: item.owner_avatar || '', creator_name: item.owner_nickname || item.name || '', like_count: item.likes || item.like_count || 0, + is_liked: item.is_liked || false, } }) } else { @@ -115,6 +124,7 @@ const loadMore = async () => { creator_avatar: item.owner_avatar || '', creator_name: item.owner_nickname || item.name || '', like_count: item.likes || item.like_count || 0, + is_liked: item.is_liked || false, } }) @@ -129,24 +139,49 @@ const loadMore = async () => { } } -watch(() => props.category, () => { - loadUsers() -}) +watch( + () => props.category, + () => { + loadUsers(); + }, +); -watch(() => props.isActive, (active) => { - if (active && creationList.value.length === 0) { - loadUsers() - } -}) +watch( + () => props.isActive, + (active) => { + if (active && creationList.value.length === 0) { + loadUsers(); + } + }, +); onMounted(() => { - isComponentMounted = true - loadUsers() -}) + isComponentMounted = true; + // 监听点赞事件,实时更新点赞数 + uni.$on("assetLiked", ({ asset_id, data }) => { + // 触发动画 + likingMap.value = { ...likingMap.value, [asset_id]: true }; + setTimeout(() => { + likingMap.value = { ...likingMap.value, [asset_id]: false }; + }, 600); + const idx = creationList.value.findIndex((c) => c.id === asset_id); + if (idx !== -1) { + if (data && typeof data.new_like_count === "number") { + creationList.value[idx].like_count = data.new_like_count; + } + if (data && typeof data.is_liked === "boolean") { + creationList.value[idx].is_liked = data.is_liked; + } + creationList.value = [...creationList.value]; + } + }); + loadUsers(); +}); onUnmounted(() => { - isComponentMounted = false -}) + isComponentMounted = false; + uni.$off("assetLiked"); +}); defineExpose({ loadMore }) @@ -175,6 +210,49 @@ defineExpose({ loadMore }) height: 400rpx; } +.wf-like-wave { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + pointer-events: none; + opacity: 0; + z-index: 1; +} + +.wf-like-wave-outer { + background: radial-gradient( + circle, + rgba(255, 107, 107, 0.8) 0%, + transparent 70% + ); +} + +.wf-like-wave-inner { + background: radial-gradient( + circle, + rgba(255, 184, 0, 0.6) 0%, + transparent 70% + ); +} + +.wf-like-wave-active { + animation: likeWave 0.6s ease-out forwards; +} + +@keyframes likeWave { + 0% { + opacity: 0.9; + transform: scale(0.8); + } + + 100% { + opacity: 0; + transform: scale(1.5); + } +} + .creation-info { padding: 16rpx; } @@ -213,22 +291,46 @@ defineExpose({ loadMore }) color: #fff; } -.like-info { +.like-badge { + position: absolute; + top: 0; + left: 0; + width: 122rpx; + height: 140rpx; + opacity: 1; + border-top-left-radius: 7px; + border-bottom-right-radius: 21.5px; + background: linear-gradient(177.83deg, + rgba(83, 244, 211, 0.2) 2.52%, + rgba(15, 9, 0, 0) 69.07%); + backdrop-filter: blur(0px); + z-index: 5; +} + +.like-icon-wrapper { display: flex; align-items: center; + padding: 8rpx; } -.like-icon { - width: 24rpx; - height: 24rpx; - margin-right: 4rpx; +.like-badge .like-icon { + width: 38rpx; + height: 38rpx; + margin-right: 6rpx; } -.like-count { - font-size: 22rpx; - color: #fff; +.like-badge .like-count { + font-size: 32rpx; + font-weight: 400; + line-height: 100%; + letter-spacing: 0%; + color: #fffabd; + text-shadow: + -1px 1px 4px #ce0909d6, + 0px 0px 10px #fffabd; } + .loading-more, .no-more { width: 100%; diff --git a/frontend/pages/square/components/HotCategoryBlock.vue b/frontend/pages/square/components/HotCategoryBlock.vue index 1f04001..d8c9873 100644 --- a/frontend/pages/square/components/HotCategoryBlock.vue +++ b/frontend/pages/square/components/HotCategoryBlock.vue @@ -1,46 +1,60 @@ diff --git a/frontend/pages/square/square.vue b/frontend/pages/square/square.vue index 0a77ed5..101096c 100644 --- a/frontend/pages/square/square.vue +++ b/frontend/pages/square/square.vue @@ -31,7 +31,7 @@ - + @@ -56,8 +56,7 @@ + :category="activeContentTab" :isActive="isActive" @cardClick="handleCardClick" ref="creationGridRef" />