This commit is contained in:
2025-10-23 12:32:11 +08:00
parent 0c1021e13c
commit 8bc56a6212

View File

@ -2,13 +2,19 @@
<div class="training-products-container"> <div class="training-products-container">
<div class="products-section"> <div class="products-section">
<div class="products-grid"> <div class="products-grid">
<div class="product-card" v-for="(item, index) in products" :key="index"> <div
class="product-card"
v-for="(item, index) in products"
:key="index"
>
<div class="icon"> <div class="icon">
<img :src="item.icon" :alt="item.name" /> <img :src="item.icon" :alt="item.name" />
</div> </div>
<div class="info"> <div class="info">
<div class="label">{{ item.name }}</div> <div class="label">{{ item.name }}</div>
<div class="value">{{ animatedValues.products[index] }}<span></span></div> <div class="value">
{{ animatedValues.products[index] }}<span></span>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -17,28 +23,28 @@
</template> </template>
<script setup> <script setup>
import { ref, onMounted } from 'vue'; import { ref, onMounted } from "vue";
const products = ref([ const products = ref([
{ {
name: '退役军人', name: "退役军人",
count: 54, count: 54,
icon: require('@/assets/images/42.png') icon: require("@/assets/images/42.png")
}, },
{ {
name: '困难毕业生', name: "毕业生",
count: 570, count: 570,
icon: require('@/assets/images/43.png') icon: require("@/assets/images/43.png")
}, },
{ {
name: '领金人员', name: "领金人员",
count: 11, count: 11,
icon: require('@/assets/images/44.png') icon: require("@/assets/images/44.png")
}, },
{ {
name: '长期失业人员', name: "长期失业人员",
count: 7, count: 7,
icon: require('@/assets/images/45.png') icon: require("@/assets/images/45.png")
} }
]); ]);
@ -53,7 +59,9 @@ const animateNumber = (startValue, endValue, duration, updateCallback) => {
const animate = () => { const animate = () => {
const currentTime = Date.now(); const currentTime = Date.now();
const progress = Math.min((currentTime - startTime) / duration, 1); const progress = Math.min((currentTime - startTime) / duration, 1);
const currentValue = Math.floor(startValue + (endValue - startValue) * progress); const currentValue = Math.floor(
startValue + (endValue - startValue) * progress
);
updateCallback(currentValue); updateCallback(currentValue);
@ -67,7 +75,12 @@ const animateNumber = (startValue, endValue, duration, updateCallback) => {
onMounted(() => { onMounted(() => {
products.value.forEach((item, index) => { products.value.forEach((item, index) => {
animateNumber(0, item.count, 2000, (value) => animatedValues.value.products[index] = value); animateNumber(
0,
item.count,
2000,
(value) => (animatedValues.value.products[index] = value)
);
}); });
}); });
</script> </script>
@ -128,7 +141,7 @@ onMounted(() => {
color: #8cc8ff; color: #8cc8ff;
margin-bottom: 8px; margin-bottom: 8px;
font-family: "YSBTH"; font-family: "YSBTH";
@include textColor(#003D63, #ffffff); @include textColor(#003d63, #ffffff);
} }
.value { .value {