123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- <template>
- <view
- class="u-notice-bar"
- :style="{
- background: computeBgColor,
- padding: padding
- }"
- >
- <view class="u-icon-wrap">
- <u-icon class="u-left-icon" v-if="volumeIcon" name="volume-fill" :size="volumeSize" :color="computeColor"></u-icon>
- </view>
- <swiper :disable-touch="disableTouch" @change="change" :autoplay="autoplay && playState == 'play'" :vertical="vertical" circular :interval="duration" class="u-swiper">
- <swiper-item v-for="(item, index) in list" :key="index" class="u-swiper-item">
- <view
- class="u-news-item u-line-1"
- :style="{
- color: computeColor,
- fontSize: fontSize + 'rpx'
- }"
- @tap="click(index)"
- >
- {{ item }}
- </view>
- </swiper-item>
- </swiper>
- <view class="u-icon-wrap">
- <u-icon @click="getMore" class="u-right-icon" v-if="moreIcon" name="arrow-right" :size="26" :color="computeColor"></u-icon>
- <u-icon @click="close" class="u-right-icon" v-if="closeIcon" name="close" :size="24" :color="computeColor"></u-icon>
- </view>
- </view>
- </template>
- <script>
- export default {
- props: {
-
- list: {
- type: Array,
- default() {
- return [];
- }
- },
-
- type: {
- type: String,
- default: 'warning'
- },
-
- volumeIcon: {
- type: Boolean,
- default: true
- },
-
- moreIcon: {
- type: Boolean,
- default: false
- },
-
- closeIcon: {
- type: Boolean,
- default: false
- },
-
- autoplay: {
- type: Boolean,
- default: true
- },
-
- color: {
- type: String,
- default: ''
- },
-
- bgColor: {
- type: String,
- default: ''
- },
-
- direction: {
- type: String,
- default: 'row'
- },
-
- show: {
- type: Boolean,
- default: true
- },
-
- fontSize: {
- type: [Number, String],
- default: 26
- },
-
- duration: {
- type: [Number, String],
- default: 2000
- },
-
- volumeSize: {
- type: [Number, String],
- default: 34
- },
-
- speed: {
- type: Number,
- default: 160
- },
-
- isCircular: {
- type: Boolean,
- default: true
- },
-
- mode: {
- type: String,
- default: 'horizontal'
- },
-
- playState: {
- type: String,
- default: 'play'
- },
-
-
- disableTouch: {
- type: Boolean,
- default: true
- },
-
- padding: {
- type: [Number, String],
- default: '18rpx 24rpx'
- }
- },
- computed: {
-
- computeColor() {
- if (this.color) return this.color;
- else if(this.type == 'none') return this.$u.color['contentColor'];
- else return this.$u.color[this.type];
- },
-
- vertical() {
- if(this.mode == 'horizontal') return false;
- else return true;
- },
-
- computeBgColor() {
- if (this.bgColor) return this.bgColor;
- else if(this.type == 'none') return 'transparent';
- else return this.$u.color[this.type + 'Light'];
- }
- },
- data() {
- return {
-
- };
- },
- methods: {
-
- click(index) {
- this.$emit('click', index);
- },
-
- close() {
- this.$emit('close');
- },
-
- getMore() {
- this.$emit('getMore');
- },
- change(e) {
- let index = e.detail.current;
- if(index == this.list.length - 1) {
- this.$emit('end');
- }
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .u-notice-bar {
- width: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- flex-wrap: nowrap;
- padding: 18rpx 24rpx;
- overflow: hidden;
- }
- .u-swiper {
- font-size: 26rpx;
- height: 32rpx;
- display: flex;
- align-items: center;
- flex: 1;
- margin-left: 12rpx;
- }
- .u-swiper-item {
- display: flex;
- align-items: center;
- overflow: hidden;
- }
- .u-news-item {
- overflow: hidden;
- }
- .u-right-icon {
- margin-left: 12rpx;
- display: inline-flex;
- align-items: center;
- }
- .u-left-icon {
- display: inline-flex;
- align-items: center;
- }
- </style>
|