Browse Source

增加助力活动完成显示助力完成及切换按钮图片

zhangjiahao/feature-20250717125955-众筹
zhangjiahao 3 weeks ago
parent
commit
618f039c69
  1. 81
      src/views/zhongchou/index.vue

81
src/views/zhongchou/index.vue

@ -41,14 +41,21 @@
<!-- 美股剩余时间显示 --> <!-- 美股剩余时间显示 -->
<div class="stock-info" :class="{ 'time-almost-up': isTimeAlmostUp }"> <div class="stock-info" :class="{ 'time-almost-up': isTimeAlmostUp }">
<h3>{{ marketName }}实时数据</h3>
<h3>还剩{{ numberToChinese(usDisplayTime) }}分钟</h3>
<template v-if="!isCompleted">
<h3>{{ marketName }}实时数据</h3>
<h3>还剩{{ numberToChinese(usDisplayTime) }}分钟</h3>
</template>
<template v-else>
<h3>{{ marketName }}实时数据</h3>
<h3> 助力成功</h3>
</template>
</div> </div>
</div> </div>
</div> </div>
<!-- 美股助力按钮和底座 --> <!-- 美股助力按钮和底座 -->
<div class="boost-section"> <div class="boost-section">
<div class="boost-btn us-boost-btn" :class="{ 'boosted': usBoostStatus }"
<div class="boost-btn us-boost-btn"
:class="{ 'boosted': usBoostStatus && !isCompleted, 'completed': isCompleted }"
@click.stop="handleBoostClick('us')"></div> @click.stop="handleBoostClick('us')"></div>
<div class="base-image"> <div class="base-image">
<img src="@/assets/img/zhongchou/底座.png" alt="底座" /> <img src="@/assets/img/zhongchou/底座.png" alt="底座" />
@ -132,7 +139,7 @@
<script setup> <script setup>
import { addRecordAPI, getActivity1API } from '../../api/zhongchouApi' import { addRecordAPI, getActivity1API } from '../../api/zhongchouApi'
import { ref, computed, onMounted, nextTick, watch } from 'vue' import { ref, computed, onMounted, nextTick, watch } from 'vue'
const isCompleted = ref(false) // 1500
// //
const activityPeriod = ref('加载中...') const activityPeriod = ref('加载中...')
// IDID // IDID
@ -192,20 +199,30 @@ async function fetchActivity() {
const totalPeople = 1500 // 1500 const totalPeople = 1500 // 1500
const currentCount = item.marketCount || 0 // const currentCount = item.marketCount || 0 //
// (0-100)
const progressPercent = Math.min((currentCount / totalPeople) * 100, 100)
//
if (currentCount >= totalPeople) {
isCompleted.value = true //
usRemainingTime.value = 0 // 0
} else {
isCompleted.value = false
// (0-100)
const progressPercent = Math.min((currentCount / totalPeople) * 100, 100)
// (15100%)
const usedTime = (progressPercent / 100) * 15
const remainingTime = Math.max(0, 15 - usedTime)
// (15100%)
const usedTime = (progressPercent / 100) * 15
const remainingTime = Math.max(0, 15 - usedTime)
usRemainingTime.value = Math.round(remainingTime)
console.log(`${marketName.value}助力人数: ${currentCount}/${totalPeople}, 进度: ${progressPercent.toFixed(1)}%, 剩余时间: ${remainingTime.toFixed(1)}分钟`)
usRemainingTime.value = Math.round(remainingTime)
}
console.log(`${marketName.value}助力人数: ${currentCount}/${totalPeople}, 进度: ${currentCount >= totalPeople ? '100' : progressPercent.toFixed(1)}%, 剩余时间: ${usRemainingTime.value}分钟, 完成状态: ${isCompleted.value}`)
// //
nextTick(() => { nextTick(() => {
updateProgressDisplay() updateProgressDisplay()
}) })
} }
} }
} else { } else {
@ -359,11 +376,16 @@ onMounted(() => {
// } // }
const handleBoostClick = async (area) => { const handleBoostClick = async (area) => {
// 1500
if (isCompleted.value) {
return;
}
if (area === 'us' && !usBoostStatus.value) { if (area === 'us' && !usBoostStatus.value) {
try { try {
// IDID // IDID
if (!activityId.value || !usMarketId.value) { if (!activityId.value || !usMarketId.value) {
console.error('活动ID或市场ID未获取,请先获取活动数据') console.error('活动ID或市场ID未获取,请先获取活动数据')
await fetchActivity()
return return
} }
@ -382,15 +404,15 @@ const handleBoostClick = async (area) => {
setTimeout(() => { setTimeout(() => {
showBoostSuccess.value = false showBoostSuccess.value = false
}, 1000) }, 1000)
//
await fetchActivity()
console.log(`${marketName.value}已助力状态:`, usBoostStatus.value, '剩余时间:', usRemainingTime.value)
} else { } else {
console.error(`${marketName.value}助力失败:`, response.message) console.error(`${marketName.value}助力失败:`, response.message)
} }
} catch (error) { } catch (error) {
console.error(`${marketName.value}助力请求失败:`, error) console.error(`${marketName.value}助力请求失败:`, error)
} finally {
//
await fetchActivity()
console.log(`${marketName.value}已助力状态:`, usBoostStatus.value, '剩余时间:', usRemainingTime.value)
} }
} }
} }
@ -832,6 +854,23 @@ const hideRules = () => {
background-image: url('@/assets/img/zhongchou/美股已助力.png'); background-image: url('@/assets/img/zhongchou/美股已助力.png');
} }
/* 助力完成状态 - 当达到1500人时使用 */
.us-boost-btn.completed {
background-image: url('@/assets/img/zhongchou/港股已助力.png');
cursor: not-allowed;
/* 禁用鼠标指针 */
pointer-events: none;
/* 完全禁用鼠标事件 */
}
/* 修改悬浮效果,排除完成状态的按钮 */
.boost-btn:not(.completed):hover {
background-size: 110%;
}
/* 移除原有的通用悬浮效果 */
.boost-btn:hover {
/* 移除此样式或注释掉 */
}
/* 港股助力按钮 */ /* 港股助力按钮 */
/* .hk-boost-btn { /* .hk-boost-btn {
background-image: url('@/assets/img/zhongchou/助力港股.png'); background-image: url('@/assets/img/zhongchou/助力港股.png');
@ -1274,17 +1313,21 @@ const hideRules = () => {
.rules-list { .rules-list {
width: 100%; width: 100%;
line-height: 1.6; /* 增加行高 */
line-height: 1.6;
/* 增加行高 */
margin-top: 10%; margin-top: 10%;
margin-left: 10%; /* 减少左边距 */
padding-right: 5%; /* 添加右边距 */
margin-left: 10%;
/* 减少左边距 */
padding-right: 5%;
/* 添加右边距 */
} }
.rules-list p { .rules-list p {
margin: 10px 0; margin: 10px 0;
font-size: 16px; font-size: 16px;
color: #fff; color: #fff;
font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif; /* 使用更清晰的中文字体 */
font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
/* 使用更清晰的中文字体 */
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
line-height: 1.7; line-height: 1.7;
} }

Loading…
Cancel
Save