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} + +
+ + +
+
) })