From 9f2506b49854bed84d1caf0b2d2b214ac16e7a0f Mon Sep 17 00:00:00 2001 From: expdsn <18111002318@163.com> Date: Mon, 11 Nov 2024 10:59:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=B0=8F=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/widgets/discount/Large.tsx | 55 +++++++++++++++++++++++++++++++-- src/widgets/discount/Middle.tsx | 47 +++++++++++++++++++++++++--- 2 files changed, 95 insertions(+), 7 deletions(-) diff --git a/src/widgets/discount/Large.tsx b/src/widgets/discount/Large.tsx index b83de91..2980098 100644 --- a/src/widgets/discount/Large.tsx +++ b/src/widgets/discount/Large.tsx @@ -1,9 +1,58 @@ -import { defineComponent } from 'vue' +import { computed, defineComponent, onMounted, ref } from 'vue' +import useDiscountStore from './useDiscountStore' export default defineComponent(() => { + const store = useDiscountStore() + const idx = ref(0) + const selectItem = computed(() => { + return store.list[idx.value] + }) + onMounted(() => { + setInterval(() => { + idx.value = idx.value + 1 + if (idx.value > store.list.length - 1) { + idx.value = 0 + } + }, 5000) + }) return () => ( -
- large +
+
+
+ -13% +
+ 剩余1天 +
+
+
+ {selectItem.value.name} +
+ + {selectItem.value.typename} + +
+
+ + ¥{selectItem.value.commdity[0]?.price} + + + ¥{selectItem.value.commdity[0]?.oldprice} + +
+ + +
+
) }) diff --git a/src/widgets/discount/Middle.tsx b/src/widgets/discount/Middle.tsx index 53edc23..1c91629 100644 --- a/src/widgets/discount/Middle.tsx +++ b/src/widgets/discount/Middle.tsx @@ -1,10 +1,49 @@ -import { defineComponent } from 'vue' +import { computed, defineComponent, onMounted, ref } from 'vue' +import useDiscountStore from './useDiscountStore' export default defineComponent(() => { - + const store = useDiscountStore() + const idx = ref(0) + const selectItem = computed(() => { + return store.list[idx.value] + }) + onMounted(() => { + setInterval(() => { + idx.value = idx.value + 1 + if (idx.value > store.list.length - 1) { + idx.value = 0 + } + }, 5000) + }) return () => ( -
- middle +
+
+
+ -13% +
+
+
+
+ {selectItem.value.name} + +
+ + ¥{selectItem.value.commdity[0]?.price} + + + ¥{selectItem.value.commdity[0]?.oldprice} + +
+ + +
+
) })