From f26f29d84e0a68831a6af14dab3eec5500496d2e Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期三, 28 五月 2025 16:48:52 +0800 Subject: [PATCH] 初始化项目 --- uview-ui/components/u-column-notice/u-column-notice.vue | 237 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 237 insertions(+), 0 deletions(-) diff --git a/uview-ui/components/u-column-notice/u-column-notice.vue b/uview-ui/components/u-column-notice/u-column-notice.vue new file mode 100644 index 0000000..dd8bd31 --- /dev/null +++ b/uview-ui/components/u-column-notice/u-column-notice.vue @@ -0,0 +1,237 @@ +<template> + <view + class="u-notice-bar" + :style="{ + background: computeBgColor, + padding: padding + }" + :class="[ + type ? `u-type-${type}-light-bg` : '' + ]" + > + <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="[textStyle]" + @tap="click(index)" + :class="['u-type-' + type]" + > + {{ 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 []; + } + }, + // 鏄剧ず鐨勪富棰橈紝success|error|primary|info|warning + 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: '' + }, + // 婊氬姩鏂瑰悜锛宺ow-姘村钩婊氬姩锛宑olumn-鍨傜洿婊氬姩 + direction: { + type: String, + default: 'row' + }, + // 鏄惁鏄剧ず + show: { + type: Boolean, + default: true + }, + // 瀛椾綋澶у皬锛屽崟浣峳px + fontSize: { + type: [Number, String], + default: 26 + }, + // 婊氬姩涓�涓懆鏈熺殑鏃堕棿闀匡紝鍗曚綅ms + duration: { + type: [Number, String], + default: 2000 + }, + // 闊抽噺鍠囧彮鐨勫ぇ灏� + volumeSize: { + type: [Number, String], + default: 34 + }, + // 姘村钩婊氬姩鏃剁殑婊氬姩閫熷害锛屽嵆姣忕婊氬姩澶氬皯rpx锛岃繖鏈夊埄浜庢帶鍒舵枃瀛楁棤璁哄灏戞椂锛岄兘鑳芥湁涓�涓亽瀹氱殑閫熷害 + speed: { + type: Number, + default: 160 + }, + // 姘村钩婊氬姩鏃讹紝鏄惁閲囩敤琛旀帴褰㈠紡婊氬姩 + isCircular: { + type: Boolean, + default: true + }, + // 婊氬姩鏂瑰悜锛宧orizontal-姘村钩婊氬姩锛寁ertical-鍨傜洿婊氬姩 + mode: { + type: String, + default: 'horizontal' + }, + // 鎾斁鐘舵�侊紝play-鎾斁锛宲aused-鏆傚仠 + playState: { + type: String, + default: 'play' + }, + // 鏄惁绂佹鐢ㄦ墜婊戝姩鍒囨崲 + // 鐩墠HX2.6.11锛屽彧鏀寔App 2.5.5+銆丠5 2.5.5+銆佹敮浠樺疂灏忕▼搴忋�佸瓧鑺傝烦鍔ㄥ皬绋嬪簭 + disableTouch: { + type: Boolean, + default: true + }, + // 閫氱煡鐨勮竟璺� + padding: { + type: [Number, String], + default: '18rpx 24rpx' + } + }, + computed: { + // 璁$畻瀛椾綋棰滆壊锛屽鏋滄病鏈夎嚜瀹氫箟鐨勶紝灏辩敤uview涓婚棰滆壊 + computeColor() { + if (this.color) return this.color; + // 濡傛灉鏄棤涓婚锛屽氨榛樿浣跨敤content-color + else if(this.type == 'none') return '#606266'; + else return this.type; + }, + // 鏂囧瓧鍐呭鐨勬牱寮� + textStyle() { + let style = {}; + if (this.color) style.color = this.color; + else if(this.type == 'none') style.color = '#606266'; + style.fontSize = this.fontSize + 'rpx'; + return style; + }, + // 鍨傜洿鎴栬�呮按骞虫粴鍔� + vertical() { + if(this.mode == 'horizontal') return false; + else return true; + }, + // 璁$畻鑳屾櫙棰滆壊 + computeBgColor() { + if (this.bgColor) return this.bgColor; + else if(this.type == 'none') return 'transparent'; + } + }, + data() { + return { + // animation: false + }; + }, + 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> +@import "../../libs/css/style.components.scss"; + +.u-notice-bar { + width: 100%; + @include vue-flex; + align-items: center; + justify-content: center; + flex-wrap: nowrap; + padding: 18rpx 24rpx; + overflow: hidden; +} + +.u-swiper { + font-size: 26rpx; + height: 32rpx; + @include vue-flex; + align-items: center; + flex: 1; + margin-left: 12rpx; +} + +.u-swiper-item { + @include vue-flex; + align-items: center; + overflow: hidden; +} + +.u-news-item { + overflow: hidden; +} + +.u-right-icon { + margin-left: 12rpx; + /* #ifndef APP-NVUE */ + display: inline-flex; + /* #endif */ + align-items: center; +} + +.u-left-icon { + /* #ifndef APP-NVUE */ + display: inline-flex; + /* #endif */ + align-items: center; +} +</style> -- Gitblit v1.9.3