This commit is contained in:
yj 2024-12-23 00:41:59 +08:00
parent 2b68401d29
commit 78c54f2ec6
1 changed files with 19 additions and 7 deletions

View File

@ -6,15 +6,18 @@
<div class="stats-container"> <div class="stats-container">
<div class="stat-box quantity-box" style="margin-right: 20px;" @click="goToShangpinIndex"> <div class="stat-box quantity-box" style="margin-right: 20px;" @click="goToShangpinIndex">
<span>商品数量</span> <span>商品数量</span>
<p>50</p> <!-- <p>{{ productQuantity }}</p> -->
<p>30</p>
</div> </div>
<div class="stat-box sales-box" style="margin-right: 20px;"> <div class="stat-box sales-box" style="margin-right: 20px;">
<span>评价数量</span> <span>评价数量</span>
<p>120</p> <!-- <p>{{ commentQuantity }}</p> -->
<p>30</p>
</div> </div>
<div class="stat-box order-box"> <div class="stat-box order-box">
<span>订单数量</span> <span>订单数量</span>
<p>30</p> <!-- <p>{{ orderQuantity }}</p> -->
<p>50</p>
</div> </div>
</div> </div>
<!-- 商品公告栏 --> <!-- 商品公告栏 -->
@ -45,12 +48,12 @@
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
// //
@ -88,14 +91,17 @@ const currentNoticeIndex = ref(0);
// //
const currentNotices = ref([]); const currentNotices = ref([]);
// //
const updateCurrentNotices = () => { const updateCurrentNotices = () => {
const startIndex = currentNoticeIndex.value; const startIndex = currentNoticeIndex.value;
currentNotices.value = notices.value.slice(startIndex, startIndex + 3).map((notice, i) => notices.value[(startIndex + i) % notices.value.length]); currentNotices.value = notices.value.slice(startIndex, startIndex + 3).map((notice, i) => notices.value[(startIndex + i) % notices.value.length]);
}; };
onMounted(() => { onMounted(() => {
//
updateDateTimeAndColor(); updateDateTimeAndColor();
// //
setInterval(() => { setInterval(() => {
@ -110,8 +116,15 @@ onMounted(() => {
currentNoticeIndex.value = (currentNoticeIndex.value + 1) % notices.value.length; currentNoticeIndex.value = (currentNoticeIndex.value + 1) % notices.value.length;
updateCurrentNotices(); updateCurrentNotices();
}, 3000); }, 3000);
});
//
fetchOrderQuantity();
// fetchProductQuantity();
// fetchCommentQuantity();
setInterval(() => {
fetchOrderQuantity();
}, 60000);
});
const updateDateTimeAndColor = () => { const updateDateTimeAndColor = () => {
const now = dayjs(); const now = dayjs();
currentDateTime.value = now.format('YYYY-MM-DD HH:mm:ss'); currentDateTime.value = now.format('YYYY-MM-DD HH:mm:ss');
@ -124,7 +137,6 @@ const updateDateTimeAndColor = () => {
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.app-container { .app-container {
padding: 20px; padding: 20px;