Compare commits

...

3 Commits

Author SHA1 Message Date
zerosaturation
1ee151630d feat: 修改收益bug 2026-05-19 20:00:22 +08:00
7dd947ca12 feat: 添加背景滚动功能 2026-05-19 19:53:00 +08:00
6d36f308a3 修改应援活动的钻石实时更新 2026-05-19 19:09:11 +08:00
8 changed files with 110 additions and 21 deletions

View File

@ -631,7 +631,7 @@ func (r *socialRepositoryImpl) GetMyLikedAssets(userID, starID int64, page, page
if err := r.db.Where("asset_id = ? AND deleted_at IS NULL", item.AssetID).
First(&exhibition).Error; err == nil {
item.HourlyEarnings = calculateHourlyEarnings(item.LikeCount)
item.Earnings = calculateRealtimeEarnings(item.LikeCount, exhibition.StartTime, now)
item.Earnings = calculateRealtimeEarnings(item.LikeCount, exhibition.StartTime, now, exhibition.ExpireAt)
}
}
@ -664,9 +664,16 @@ func calculateHourlyEarnings(likeCount int32) float64 {
// calculateRealtimeEarnings 实时计算展示收益
// 公式R1 = R0 × T × [100% + Buff(n)]
// R0 = 5 水晶/小时T = 上架时长小时Buff(n) 根据点赞数计算
func calculateRealtimeEarnings(likeCount int32, startTime, now int64) int64 {
// 注意:使用 min(now, expireAt) 确保过期后收益不再增长
func calculateRealtimeEarnings(likeCount int32, startTime, now, expireAt int64) int64 {
// 计算有效截止时间(展览结束时间 vs 当前时间,取较小值)
endTime := now
if expireAt > 0 && expireAt < now {
endTime = expireAt
}
// 计算上架时长(毫秒转小时)
T := (now - startTime) / 3600000
T := (endTime - startTime) / 3600000
if T <= 0 {
T = 1 // 最少1小时
}
@ -721,7 +728,7 @@ func (r *socialRepositoryImpl) GetMyTodayLikedAssets(userID, starID int64, page,
if err := r.db.Where("asset_id = ? AND deleted_at IS NULL AND expire_at > ?", item.AssetID, now.UnixMilli()).
First(&exhibition).Error; err == nil {
item.HourlyEarnings = calculateHourlyEarnings(item.LikeCount)
item.Earnings = calculateRealtimeEarnings(item.LikeCount, exhibition.StartTime, now.UnixMilli())
item.Earnings = calculateRealtimeEarnings(item.LikeCount, exhibition.StartTime, now.UnixMilli(), exhibition.ExpireAt)
}
}
@ -782,7 +789,7 @@ func (r *socialRepositoryImpl) GetMyWeekLikedAssets(userID, starID int64, page,
if err := r.db.Where("asset_id = ? AND deleted_at IS NULL AND expire_at > ?", item.AssetID, nowMillis).
First(&exhibition).Error; err == nil {
item.HourlyEarnings = calculateHourlyEarnings(item.LikeCount)
item.Earnings = calculateRealtimeEarnings(item.LikeCount, exhibition.StartTime, nowMillis)
item.Earnings = calculateRealtimeEarnings(item.LikeCount, exhibition.StartTime, nowMillis, exhibition.ExpireAt)
}
}
@ -832,7 +839,7 @@ func (r *socialRepositoryImpl) GetUserLikedAssets(userID, starID int64, page, pa
if err := r.db.Where("asset_id = ? AND deleted_at IS NULL AND expire_at > ?", item.AssetID, now).
First(&exhibition).Error; err == nil {
item.HourlyEarnings = calculateHourlyEarnings(item.LikeCount)
item.Earnings = calculateRealtimeEarnings(item.LikeCount, exhibition.StartTime, now)
item.Earnings = calculateRealtimeEarnings(item.LikeCount, exhibition.StartTime, now, exhibition.ExpireAt)
}
}

View File

@ -289,7 +289,7 @@ onUnload(() => {
flex-direction: column;
align-items: center;
justify-content: center;
padding: 200rpx 40rpx 100rpx;
padding: 80rpx 40rpx 100rpx;
box-sizing: border-box;
}
@ -389,6 +389,8 @@ onUnload(() => {
display: flex;
justify-content: center;
animation: fadeIn 1s ease-out 0.6s both;
position: fixed;
bottom: 112rpx;
}
@keyframes fadeIn {

View File

@ -381,7 +381,9 @@ const handleExhibitionCardTap = (item, index) => {
// exhibitionWorks.value[index].earnings = data.earnings;
// } else {
//
await loadExhibitedAssets();
await loadLikedAssets();
// }
uni.showToast({ title: '点赞成功', icon: 'success' });

View File

@ -75,7 +75,7 @@ const props = defineProps({
isActive: { type: Boolean, default: true }, //
})
const emit = defineEmits(['cardClick'])
const emit = defineEmits(['cardClick', 'scroll'])
// ========== ==========
const rpx2px = (rpx) => Math.round(uni.getSystemInfoSync().windowWidth / 750 * rpx)
@ -121,18 +121,44 @@ const iosScrollPaused = ref(true)
const startIOSAutoScroll = () => {
if (!isComponentMounted || !isIOS) return
iosScrollPaused.value = false
// iOS scrollLeft
clearInterval(iosScrollEmitTimer)
iosScrollEmitTimer = setInterval(() => {
if (!isComponentMounted) return
// iOS CSS 0 totalWidth.value
const scrollDist = totalWidth.value
const duration = scrollDist / AUTO_SCROLL_SPEED_IOS
const elapsed = (Date.now() % duration)
const pos = (elapsed / duration) * scrollDist
emit('scroll', pos)
}, 16)
}
const stopIOSAutoScroll = () => {
iosScrollPaused.value = true
clearInterval(iosScrollEmitTimer)
iosScrollEmitTimer = null
}
const pauseIOSAutoScroll = () => {
iosScrollPaused.value = true
clearInterval(iosScrollEmitTimer)
iosScrollEmitTimer = null
}
const resumeIOSAutoScroll = () => {
iosScrollPaused.value = false
// iOS
clearInterval(iosScrollEmitTimer)
iosScrollEmitTimer = setInterval(() => {
if (!isComponentMounted) return
const scrollDist = totalWidth.value
const duration = scrollDist / AUTO_SCROLL_SPEED_IOS
const elapsed = (Date.now() % duration)
const pos = (elapsed / duration) * scrollDist
emit('scroll', pos)
}, 16)
}
let rafId = null
let userInteracting = false
@ -141,6 +167,8 @@ let appendTimer = null // 防抖定时器
let autoScrollPos = 0 //
let momentumTimer = null // iOS/Android
let scrollUpdateTimer = null // scrollLeft Android
let iosScrollEmitTimer = null // iOS
let iosCurrentScrollPos = 0 // iOS CSS
const startAutoScroll = () => {
if (!isComponentMounted || isIOS) return
@ -269,6 +297,9 @@ const onScroll = (e) => {
if (!isComponentMounted) return
currentScrollLeft = e.detail.scrollLeft
//
emit('scroll', currentScrollLeft)
// iOS
if (isIOS && isManualScrolling) {
return

View File

@ -1,7 +1,14 @@
<template>
<view class="square-container">
<!-- 固定背景 -->
<image class="background-fixed" src="/static/square/squearbj.png" mode="aspectFill" />
<!-- 可横向滑动的背景 -->
<view class="bg-wrapper">
<image
class="background-fixed"
:style="{ transform: `translateX(${-bgScrollLeft}px)` }"
src="/static/square/squearbj1.png"
mode="aspectFill"
/>
</view>
<!-- 横向瀑布流卡片层内部自带横向滚动 -->
<WaterfallGrid
@ -13,6 +20,7 @@
:category="activeContentTab"
:isActive="isActive"
@cardClick="handleCardClick"
@scroll="handleWaterfallScroll"
class="fall-bg"
/>
@ -105,11 +113,19 @@ const {
// banner(216+360rpx) + tab(16+80rpx) + (8rpx) 680rpx
const bannerBottomPx = computed(() => Math.round(screenWidth.value / 750 * 715))
const bgScrollLeft = ref(0)
// ========== Handlers ==========
const handleCardClick = (card) => {
// WaterfallGrid
}
const handleWaterfallScroll = (scrollLeft) => {
// 30%
bgScrollLeft.value = scrollLeft * 0.3
}
const handleActivityClick = (item) => {
uni.navigateTo({
url: `/pages/support-activity/index?id=${item.id}`,
@ -260,13 +276,19 @@ onUnmounted(() => {
margin-bottom: 8rpx;
} */
.background-fixed {
.bg-wrapper {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 110%;
z-index: 0;
overflow: hidden;
}
.background-fixed {
width: 300%;
height: 100%;
}
.nav-mask {

View File

@ -334,13 +334,36 @@ async function handleConfirmContribute() {
}
// API
let successCount = 0
let lastRemainingBalance = null
let lastErrorMessage = ''
for (let i = 0; i < quantity.value; i++) {
await contributeItem(item, false, true)
const res = await contributeItem(item, true, true)
console.log(`${i+1}次调用返回值:`, res)
if (res && res.success !== false) {
successCount++
lastRemainingBalance = res.remainingBalance
} else {
lastErrorMessage = res?.message || '活动不在进行中,无法购买'
}
}
// 使
if (lastRemainingBalance !== null) {
await updateLocalBalanceFromResult(lastRemainingBalance)
}
//
if (successCount === quantity.value) {
showResultToast('✅', `贡献成功\n+${item.cost * successCount} 贡献值已到账`)
} else if (successCount > 0) {
showResultToast('⚠️', `部分成功 ${successCount}/${quantity.value}`)
} else {
showResultToast('❌', lastErrorMessage || '贡献失败')
}
} finally {
processingItems.delete(item.type)
isContributing.value = false
// selectedItem
}
}
@ -366,11 +389,13 @@ async function contributeItem(item, isRetry = false, silent = false) {
try {
// 使 activity-config.js purchaseItem
const result = await purchaseItem(props.activityId, item.type, 1)
console.log(`[contributeItem] result:`, result, 'isRetry:', isRetry, 'silent:', silent)
//
if (!result.success) {
if (!silent) showResultToast('', result.message || '活动不在进行中,无法购买')
return false
const msg = result.message || '活动不在进行中,无法购买'
if (!silent) showResultToast('', msg)
return { success: false, message: msg }
}
//
@ -393,7 +418,7 @@ async function contributeItem(item, isRetry = false, silent = false) {
}
// syncPendingActions true
return isRetry ? { contribution: result.totalContribution, remainingBalance: result.remainingBalance } : true
return isRetry ? { contribution: result.totalContribution, remainingBalance: result.remainingBalance, success: true } : { success: true }
} catch (error) {
console.error('贡献失败:', error)
@ -404,12 +429,12 @@ async function contributeItem(item, isRetry = false, silent = false) {
if (!queued) {
// 退
refundLocalBalance(item.cost)
return false
return { success: false, message: '网络异常,已加入队列' }
}
showResultToast('', '网络异常,已加入队列')
return { success: false, message: '网络异常,已加入队列' }
}
return false
return { success: false, message: error.message || '贡献失败' }
}
}

View File

@ -22,11 +22,11 @@
/>
<!-- 实时贡献列表 -->
<ContributionList
<!-- <ContributionList
v-if="activityId && !isLoading"
:activity-id="activityId"
class="contribution-list-wrapper"
/>
/> -->
<!-- 舞台区域 -->
<StageArea

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 MiB