This commit is contained in:
2025-07-07 16:07:46 +08:00
parent 2d03c09cc1
commit 06e4d99691

View File

@@ -1,5 +1,5 @@
<script setup> <script setup>
import {computed, nextTick, onMounted, ref, watch} from "vue"; import {nextTick, ref, watch} from "vue";
import warn from '../static/icons/warn.png'; import warn from '../static/icons/warn.png';
import success from '../static/icons/info.png'; import success from '../static/icons/info.png';
@@ -33,12 +33,6 @@ const {text, status, tile, textColor} = defineProps({
} }
}); });
const showIndex = ref(0); const showIndex = ref(0);
const textC = computed(() => {
return text.map((v, index) => ({
show: index === showIndex.value,
text: `${index + 1}. ${v}`,
}))
});
const XNoticeBox = ref(); const XNoticeBox = ref();
const Context = ref(); const Context = ref();
@@ -64,17 +58,24 @@ watch(
{deep: true} {deep: true}
) )
onMounted(() => { const changeCur = ({detail: {current}}) => {
setInterval(() => { if (
showIndex.value++; Context.value[current].$el.clientWidth
if (showIndex.value > text.length - 1) { >
showIndex.value = 0; XNoticeBox.value[current].$el.clientWidth
) {
setTimeout(() => {
roll.value = true;
}, 500);
} else {
roll.value = false;
}
} }
}, 5000);
});
</script> </script>
<template> <template>
<swiper style="height: 80rpx;" autoplay vertical @change="changeCur">
<swiper-item v-for="v in text">
<view ref="XNoticeBox" :class="['x-notice-box', STATUS[status].bg]"> <view ref="XNoticeBox" :class="['x-notice-box', STATUS[status].bg]">
<view ref="Context" :class="['context', roll ? 'roll' : '', STATUS[status].context]" <view ref="Context" :class="['context', roll ? 'roll' : '', STATUS[status].context]"
:style="{alignItems: tile ? 'start' : 'center'}"> :style="{alignItems: tile ? 'start' : 'center'}">
@@ -84,14 +85,15 @@ onMounted(() => {
<view <view
class="!whitespace-nowrap flex-shrink-0" class="!whitespace-nowrap flex-shrink-0"
:style="{color: textColor}" :style="{color: textColor}"
v-for="v in textC.filter(v => v.show)" v-html="v">
v-html="v.text">
</view> </view>
</view> </view>
<text v-else :style="{color: textColor}" v-html="text"> <text v-else :style="{color: textColor}" v-html="text">
</text> </text>
</view> </view>
</view> </view>
</swiper-item>
</swiper>
</template> </template>
<style scoped lang="scss"> <style scoped lang="scss">