123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- <template>
- <view class="u-notice-bar-wrap" v-if="isShow" :style="{
- borderRadius: borderRadius + 'rpx',
- }">
- <block v-if="mode == 'horizontal' && isCircular">
- <u-row-notice
- :type="type"
- :color="color"
- :bgColor="bgColor"
- :list="list"
- :volumeIcon="volumeIcon"
- :moreIcon="moreIcon"
- :volumeSize="volumeSize"
- :closeIcon="closeIcon"
- :mode="mode"
- :fontSize="fontSize"
- :speed="speed"
- :playState="playState"
- :padding="padding"
- @getMore="getMore"
- @close="close"
- @click="click"
- ></u-row-notice>
- </block>
- <block v-if="mode == 'vertical' || (mode == 'horizontal' && !isCircular)">
- <u-column-notice
- :type="type"
- :color="color"
- :bgColor="bgColor"
- :list="list"
- :volumeIcon="volumeIcon"
- :moreIcon="moreIcon"
- :closeIcon="closeIcon"
- :mode="mode"
- :volumeSize="volumeSize"
- :disable-touch="disableTouch"
- :fontSize="fontSize"
- :duration="duration"
- :playState="playState"
- :padding="padding"
- @getMore="getMore"
- @close="close"
- @click="click"
- @end="end"
- ></u-column-notice>
- </block>
- </view>
- </template>
- <script>
- export default {
- name: "u-notice-bar",
- props: {
-
- list: {
- type: Array,
- default() {
- return [];
- }
- },
-
- type: {
- type: String,
- default: 'warning'
- },
-
- volumeIcon: {
- type: Boolean,
- default: true
- },
-
- volumeSize: {
- type: [Number, String],
- default: 34
- },
-
- moreIcon: {
- type: Boolean,
- default: false
- },
-
- closeIcon: {
- type: Boolean,
- default: false
- },
-
- autoplay: {
- type: Boolean,
- default: true
- },
-
- color: {
- type: String,
- default: ''
- },
-
- bgColor: {
- type: String,
- default: ''
- },
-
- mode: {
- type: String,
- default: 'horizontal'
- },
-
- show: {
- type: Boolean,
- default: true
- },
-
- fontSize: {
- type: [Number, String],
- default: 28
- },
-
- duration: {
- type: [Number, String],
- default: 2000
- },
-
- speed: {
- type: [Number, String],
- default: 160
- },
-
-
- isCircular: {
- type: Boolean,
- default: true
- },
-
- playState: {
- type: String,
- default: 'play'
- },
-
-
- disableTouch: {
- type: Boolean,
- default: true
- },
-
- borderRadius: {
- type: [Number, String],
- default: 0
- },
-
- padding: {
- type: [Number, String],
- default: '18rpx 24rpx'
- },
-
- noListHidden: {
- type: Boolean,
- default: true
- }
- },
- computed: {
-
- isShow() {
- if(this.show == false || (this.noListHidden == true && this.list.length == 0)) return false;
- else return true;
- }
- },
- methods: {
-
- click(index) {
- this.$emit('click', index);
- },
-
- close() {
- this.$emit('close');
- },
-
- getMore() {
- this.$emit('getMore');
- },
-
- end() {
- this.$emit('end');
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- @import "../../libs/css/style.components.scss";
- .u-notice-bar-wrap {
- overflow: hidden;
- }
- .u-notice-bar {
- padding: 18rpx 24rpx;
- overflow: hidden;
- }
- .u-direction-row {
- @include vue-flex;
- align-items: center;
- justify-content: space-between;
- }
- .u-left-icon {
- @include vue-flex;
- align-items: center;
- }
- .u-notice-box {
- flex: 1;
- @include vue-flex;
- overflow: hidden;
- margin-left: 12rpx;
- }
- .u-right-icon {
- margin-left: 12rpx;
- @include vue-flex;
- align-items: center;
- }
- .u-notice-content {
- line-height: 1;
- white-space: nowrap;
- font-size: 26rpx;
- animation: u-loop-animation 10s linear infinite both;
- text-align: right;
- // 这一句很重要,为了能让滚动左右连接起来
- padding-left: 100%;
- }
- @keyframes u-loop-animation {
- 0% {
- transform: translate3d(0, 0, 0);
- }
- 100% {
- transform: translate3d(-100%, 0, 0);
- }
- }
- </style>
|