¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <view |
| | | class="u-notice" |
| | | @tap="clickHandler" |
| | | > |
| | | <slot name="icon"> |
| | | <view |
| | | class="u-notice__left-icon" |
| | | v-if="icon" |
| | | > |
| | | <u-icon |
| | | :name="icon" |
| | | :color="color" |
| | | size="19" |
| | | ></u-icon> |
| | | </view> |
| | | </slot> |
| | | <swiper |
| | | :disable-touch="disableTouch" |
| | | :vertical="step ? false : true" |
| | | circular |
| | | :interval="duration" |
| | | :autoplay="true" |
| | | class="u-notice__swiper" |
| | | @change="noticeChange" |
| | | > |
| | | <swiper-item |
| | | v-for="(item, index) in text" |
| | | :key="index" |
| | | class="u-notice__swiper__item" |
| | | > |
| | | <text |
| | | class="u-notice__swiper__item__text u-line-1" |
| | | :style="[textStyle]" |
| | | >{{ item }}</text> |
| | | </swiper-item> |
| | | </swiper> |
| | | <view |
| | | class="u-notice__right-icon" |
| | | v-if="['link', 'closable'].includes(mode)" |
| | | > |
| | | <u-icon |
| | | v-if="mode === 'link'" |
| | | name="arrow-right" |
| | | :size="17" |
| | | :color="color" |
| | | ></u-icon> |
| | | <u-icon |
| | | v-if="mode === 'closable'" |
| | | name="close" |
| | | :size="16" |
| | | :color="color" |
| | | @click="close" |
| | | ></u-icon> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import props from './props.js'; |
| | | /** |
| | | * ColumnNotice æ»å¨éç¥ä¸çåç´æ»å¨ å
é¨ç»ä»¶ |
| | | * @description 该ç»ä»¶ç¨äºæ»å¨éååºæ¯ï¼æ¯å
¶ä¸çåç´æ»å¨æ¹å¼ |
| | | * @tutorial https://www.uviewui.com/components/noticeBar.html |
| | | * @property {Array} text æ¾ç¤ºçå
容ï¼å符串 |
| | | * @property {String} icon æ¯å¦æ¾ç¤ºå·¦ä¾§çé³é徿 ï¼ é»è®¤ 'volume' ï¼ |
| | | * @property {String} mode é忍¡å¼ï¼link-æ¾ç¤ºå³ç®å¤´ï¼closable-æ¾ç¤ºå³ä¾§å
³é徿 |
| | | * @property {String} color æåé¢è²ï¼å徿 ä¹ä¼ä½¿ç¨æåé¢è² ï¼ é»è®¤ '#f9ae3d' ï¼ |
| | | * @property {String} bgColor èæ¯é¢è² ï¼ é»è®¤ '#fdf6ec' ï¼ |
| | | * @property {String | Number} fontSize åä½å¤§å°ï¼åä½px ï¼ é»è®¤ 14 ï¼ |
| | | * @property {String | Number} speed æ°´å¹³æ»å¨æ¶çæ»å¨é度ï¼å³æ¯ç§æ»å¨å¤å°px(rpx)ï¼è¿æå©äºæ§å¶æåæ 论å¤å°æ¶ï¼é½è½æä¸ä¸ªæå®çé度 ï¼ é»è®¤ 80 ï¼ |
| | | * @property {Boolean} step direction = rowæ¶ï¼æ¯å¦ä½¿ç¨æ¥è¿å½¢å¼æ»å¨ ï¼ é»è®¤ false ï¼ |
| | | * @property {String | Number} duration æ»å¨ä¸ä¸ªå¨æçæ¶é´é¿ï¼åä½ms ï¼ é»è®¤ 1500 ï¼ |
| | | * @property {Boolean} disableTouch æ¯å¦ç¦æ¢ç¨ææ»å¨åæ¢ ç®åHX2.6.11ï¼åªæ¯æApp 2.5.5+ãH5 2.5.5+ãæ¯ä»å®å°ç¨åºãåèè·³å¨å°ç¨åº ï¼ é»è®¤ true ï¼ |
| | | * @example |
| | | */ |
| | | export default { |
| | | mixins: [uni.$u.mpMixin, uni.$u.mixin,props], |
| | | watch: { |
| | | text: { |
| | | immediate: true, |
| | | handler(newValue, oldValue) { |
| | | if(!uni.$u.test.array(newValue)) { |
| | | uni.$u.error('noticebarç»ä»¶direction为columnæ¶ï¼è¦æ±textåæ°ä¸ºæ°ç»å½¢å¼') |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | computed: { |
| | | // æåå
å®¹çæ ·å¼ |
| | | textStyle() { |
| | | let style = {} |
| | | style.color = this.color |
| | | style.fontSize = uni.$u.addUnit(this.fontSize) |
| | | return style |
| | | }, |
| | | // åç´æè
æ°´å¹³æ»å¨ |
| | | vertical() { |
| | | if (this.mode == 'horizontal') return false |
| | | else return true |
| | | }, |
| | | }, |
| | | data() { |
| | | return { |
| | | index:0 |
| | | } |
| | | }, |
| | | methods: { |
| | | noticeChange(e){ |
| | | this.index = e.detail.current |
| | | }, |
| | | // ç¹å»éåæ |
| | | clickHandler() { |
| | | this.$emit('click', this.index) |
| | | }, |
| | | // ç¹å»å
³éæé® |
| | | close() { |
| | | this.$emit('close') |
| | | } |
| | | } |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "../../libs/css/components.scss"; |
| | | |
| | | .u-notice { |
| | | @include flex; |
| | | align-items: center; |
| | | justify-content: space-between; |
| | | |
| | | &__left-icon { |
| | | align-items: center; |
| | | margin-right: 5px; |
| | | } |
| | | |
| | | &__right-icon { |
| | | margin-left: 5px; |
| | | align-items: center; |
| | | } |
| | | |
| | | &__swiper { |
| | | height: 16px; |
| | | @include flex; |
| | | align-items: center; |
| | | flex: 1; |
| | | |
| | | &__item { |
| | | @include flex; |
| | | align-items: center; |
| | | overflow: hidden; |
| | | |
| | | &__text { |
| | | font-size: 14px; |
| | | color: $u-warning; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </style> |