2025-03-28 15:34:00 +08:00
|
|
|
<script setup>
|
2025-07-07 16:07:46 +08:00
|
|
|
import {nextTick, ref, watch} from "vue";
|
2025-03-28 15:34:00 +08:00
|
|
|
import warn from '../static/icons/warn.png';
|
2025-04-07 18:04:39 +08:00
|
|
|
import success from '../static/icons/info.png';
|
|
|
|
|
|
|
|
|
|
const STATUS = {
|
|
|
|
|
error: {
|
|
|
|
|
bg: 'x-notice-box-error',
|
|
|
|
|
context: 'context-error'
|
|
|
|
|
},
|
|
|
|
|
success: {
|
|
|
|
|
bg: 'x-notice-box-success',
|
|
|
|
|
context: 'context-success'
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2025-05-21 15:45:10 +08:00
|
|
|
const {text, status, tile, textColor} = defineProps({
|
2025-04-07 18:04:39 +08:00
|
|
|
text: {
|
2025-07-07 15:23:10 +08:00
|
|
|
type: Array,
|
|
|
|
|
default: ['1.你好你好', '2.啊我就会发回复哈', '3.测试啊u发哈u发货']
|
2025-04-07 18:04:39 +08:00
|
|
|
},
|
2025-05-21 15:45:10 +08:00
|
|
|
textColor: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '#000'
|
|
|
|
|
},
|
2025-04-07 18:04:39 +08:00
|
|
|
status: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'error'
|
2025-04-14 17:26:40 +08:00
|
|
|
},
|
|
|
|
|
tile: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false,
|
2025-04-07 18:04:39 +08:00
|
|
|
}
|
|
|
|
|
});
|
2025-07-07 15:23:10 +08:00
|
|
|
const showIndex = ref(0);
|
2025-03-28 15:34:00 +08:00
|
|
|
|
|
|
|
|
const XNoticeBox = ref();
|
|
|
|
|
const Context = ref();
|
|
|
|
|
const roll = ref(false);
|
|
|
|
|
|
2025-06-13 21:01:33 +08:00
|
|
|
watch(
|
2025-07-07 15:23:10 +08:00
|
|
|
() => showIndex.value,
|
2025-06-13 21:01:33 +08:00
|
|
|
() => {
|
|
|
|
|
if (!tile) {
|
2025-07-07 15:23:10 +08:00
|
|
|
nextTick(() => {
|
|
|
|
|
if (
|
|
|
|
|
Context.value.$el.clientWidth
|
|
|
|
|
>
|
|
|
|
|
XNoticeBox.value.$el.clientWidth
|
|
|
|
|
) {
|
|
|
|
|
roll.value = true;
|
|
|
|
|
} else {
|
|
|
|
|
roll.value = false;
|
|
|
|
|
}
|
|
|
|
|
})
|
2025-06-13 21:01:33 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{deep: true}
|
|
|
|
|
)
|
|
|
|
|
|
2025-07-07 16:07:46 +08:00
|
|
|
const changeCur = ({detail: {current}}) => {
|
|
|
|
|
if (
|
|
|
|
|
Context.value[current].$el.clientWidth
|
|
|
|
|
>
|
|
|
|
|
XNoticeBox.value[current].$el.clientWidth
|
|
|
|
|
) {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
roll.value = true;
|
|
|
|
|
}, 500);
|
|
|
|
|
} else {
|
|
|
|
|
roll.value = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-03-28 15:34:00 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2025-07-07 16:07:46 +08:00
|
|
|
<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="Context" :class="['context', roll ? 'roll' : '', STATUS[status].context]"
|
|
|
|
|
:style="{alignItems: tile ? 'start' : 'center'}">
|
|
|
|
|
<image v-if="status==='error'" class="!size-[26rpx] flex-shrink-0" :src="warn"></image>
|
|
|
|
|
<image v-else class="!size-[26rpx] flex-shrink-0" :src="success"></image>
|
|
|
|
|
<view v-if="!tile">
|
|
|
|
|
<view
|
|
|
|
|
class="!whitespace-nowrap flex-shrink-0"
|
|
|
|
|
:style="{color: textColor}"
|
|
|
|
|
v-html="v">
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<text v-else :style="{color: textColor}" v-html="text">
|
|
|
|
|
</text>
|
2025-07-07 15:23:10 +08:00
|
|
|
</view>
|
|
|
|
|
</view>
|
2025-07-07 16:07:46 +08:00
|
|
|
</swiper-item>
|
|
|
|
|
</swiper>
|
2025-03-28 15:34:00 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2025-04-07 18:04:39 +08:00
|
|
|
.x-notice-box-error {
|
|
|
|
|
background-color: #FFF7E8;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.x-notice-box-success {
|
|
|
|
|
background-color: #E8F3FF;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.context-error {
|
|
|
|
|
color: rgb(255, 87, 34);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.context-success {
|
|
|
|
|
color: rgb(29, 33, 41);
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-28 15:34:00 +08:00
|
|
|
.x-notice-box {
|
|
|
|
|
padding: 18rpx 24rpx;
|
2025-04-07 18:04:39 +08:00
|
|
|
width: 100%;
|
|
|
|
|
overflow: hidden;
|
2025-03-28 15:34:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.context {
|
|
|
|
|
font-size: 24rpx;
|
|
|
|
|
font-weight: 400;
|
|
|
|
|
line-height: 22px;
|
|
|
|
|
letter-spacing: 0;
|
|
|
|
|
text-align: left;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
gap: 18rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.roll {
|
|
|
|
|
animation: 10s Roll linear infinite forwards;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@keyframes Roll {
|
|
|
|
|
0% {
|
2025-07-07 15:23:10 +08:00
|
|
|
transform: translateX(0%);
|
2025-03-28 15:34:00 +08:00
|
|
|
}
|
|
|
|
|
100% {
|
|
|
|
|
transform: translateX(-100%);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|