|
|
@@ -1,33 +1,37 @@
|
|
|
<!--
|
|
|
店铺公告条(首页 / 购物车 / 订单提交等复用)
|
|
|
拉取 /shop-notice/show-list;position:1首页 2分类 4购物车 8订单提交
|
|
|
- 点击文案进详情;点击右侧 › 进公告列表(全部上架公告)
|
|
|
+ 图标与样式对齐 shop-category:喇叭雪碧图 + 浅粉条 + 粉色向右箭头
|
|
|
+ 点击文案进详情;点击右侧箭头进公告列表(全部上架公告)
|
|
|
-->
|
|
|
<template>
|
|
|
- <view class="home-notice-bar" v-if="noticeList.length">
|
|
|
- <!-- 原 32upx 喇叭图,颜色与公告条主题色一致 -->
|
|
|
- <zui-svg-icon class="notice-icon" icon="general-notice-horn" :width="16" :height="16" />
|
|
|
- <text class="notice-tag">公告</text>
|
|
|
- <!-- 标题/摘要区域:跳转当前轮播条详情 -->
|
|
|
- <swiper
|
|
|
- class="notice-swiper"
|
|
|
- :key="'home-notice-' + position + '-' + noticeList.length"
|
|
|
- vertical
|
|
|
- :autoplay="noticeList.length > 1"
|
|
|
- :circular="noticeList.length > 1"
|
|
|
- :interval="6000"
|
|
|
- :duration="400"
|
|
|
- :disable-touch="disableTouch"
|
|
|
- :skip-hidden-item-layout="true"
|
|
|
- @change="onNoticeChange"
|
|
|
- @tap.stop="openNoticeDetail"
|
|
|
- >
|
|
|
- <swiper-item v-for="item in noticeList" :key="item.id">
|
|
|
- <text class="notice-text">{{ item.title || item.summary }}</text>
|
|
|
- </swiper-item>
|
|
|
- </swiper>
|
|
|
- <!-- 右侧箭头:进入该位置公告列表 -->
|
|
|
- <text class="notice-arrow" @tap.stop="openNoticeList">›</text>
|
|
|
+ <!-- 外层占组件根节点:微信小程序根节点 margin 不生效,左右/上边距必须写在内层 -->
|
|
|
+ <view class="notice-bar-host" v-if="noticeList.length">
|
|
|
+ <view class="notice-bar" :class="{ 'notice-bar--flush': flush }">
|
|
|
+ <view class="notice-left" @tap.stop="openNoticeDetail">
|
|
|
+ <sprite-icon name="notice" :size="30" custom-class="notice-horn-icon" />
|
|
|
+ <text class="notice-tag">公告</text>
|
|
|
+ <swiper
|
|
|
+ class="notice-swiper"
|
|
|
+ :key="'home-notice-' + position + '-' + noticeList.length"
|
|
|
+ vertical
|
|
|
+ :autoplay="noticeList.length > 1"
|
|
|
+ :circular="noticeList.length > 1"
|
|
|
+ :interval="6000"
|
|
|
+ :duration="400"
|
|
|
+ :disable-touch="disableTouch"
|
|
|
+ :skip-hidden-item-layout="true"
|
|
|
+ @change="onNoticeChange"
|
|
|
+ >
|
|
|
+ <swiper-item v-for="item in noticeList" :key="item.id">
|
|
|
+ <text class="notice-summary">{{ item.title || item.summary }}</text>
|
|
|
+ </swiper-item>
|
|
|
+ </swiper>
|
|
|
+ </view>
|
|
|
+ <view class="notice-arrow" @tap.stop="openNoticeList">
|
|
|
+ <sprite-icon name="xiangyou-pink" :size="15" />
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
@@ -59,6 +63,14 @@ export default {
|
|
|
disableTouch: {
|
|
|
type: Boolean,
|
|
|
default: false
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 是否嵌在已有左右内边距的容器里(如结算页)
|
|
|
+ * 为 true 时去掉公告条自身左右外边距,与同级卡片同宽
|
|
|
+ */
|
|
|
+ flush: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
@@ -106,7 +118,7 @@ export default {
|
|
|
query: { id: item.id, account: this.resolveAccount() }
|
|
|
})
|
|
|
},
|
|
|
- /** 点击右侧 ›:跳转公告列表(全部上架公告,不按位置过滤) */
|
|
|
+ /** 点击粉色向右箭头:跳转公告列表(全部上架公告,不按位置过滤) */
|
|
|
openNoticeList() {
|
|
|
this.$util.pageTo({
|
|
|
url: '/pages/home/shop-notice-list',
|
|
|
@@ -120,54 +132,72 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-.home-notice-bar {
|
|
|
+.notice-bar-host {
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
+
|
|
|
+/* 通知公告:间距写在内层,避免小程序组件根节点吃掉 margin */
|
|
|
+.notice-bar {
|
|
|
display: flex;
|
|
|
+ flex-direction: row;
|
|
|
align-items: center;
|
|
|
- height: 64upx;
|
|
|
- margin: 8upx 24upx 12upx;
|
|
|
- padding: 0 20upx;
|
|
|
- border-radius: 32upx;
|
|
|
- background: #FFF0F3;
|
|
|
- box-shadow: 0 2upx 12upx rgba(255, 77, 125, 0.1);
|
|
|
+ margin: 16upx 24upx 16upx;
|
|
|
+ padding: 16upx 20upx;
|
|
|
+ background: #fff5f5;
|
|
|
+ border-radius: 12upx;
|
|
|
box-sizing: border-box;
|
|
|
}
|
|
|
-.notice-icon {
|
|
|
- flex-shrink: 0;
|
|
|
- margin-right: 8upx;
|
|
|
+
|
|
|
+/* 结算页已有 20upx 内边距,去掉左右外边距以免比商品卡片更窄 */
|
|
|
+.notice-bar--flush {
|
|
|
+ margin: 0 0 20upx;
|
|
|
+ width: 100%;
|
|
|
+}
|
|
|
+
|
|
|
+.notice-left {
|
|
|
+ flex: 1;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: row;
|
|
|
+ align-items: center;
|
|
|
+ overflow: hidden;
|
|
|
+ min-width: 0;
|
|
|
}
|
|
|
+
|
|
|
.notice-tag {
|
|
|
flex-shrink: 0;
|
|
|
- height: 32upx;
|
|
|
- line-height: 30upx;
|
|
|
- padding: 0 8upx;
|
|
|
- margin-right: 12upx;
|
|
|
- font-size: 20upx;
|
|
|
- color: #FF4D7D;
|
|
|
- border: 1upx solid #FF4D7D;
|
|
|
- border-radius: 6upx;
|
|
|
- box-sizing: border-box;
|
|
|
+ font-size: 26upx;
|
|
|
+ font-weight: 600;
|
|
|
+ color: #ff4757;
|
|
|
+ margin: 0 12upx;
|
|
|
}
|
|
|
+
|
|
|
.notice-swiper {
|
|
|
flex: 1;
|
|
|
width: 0;
|
|
|
height: 40upx;
|
|
|
min-width: 0;
|
|
|
}
|
|
|
-.notice-text {
|
|
|
+
|
|
|
+.notice-summary {
|
|
|
display: block;
|
|
|
- font-size: 24upx;
|
|
|
- color: #FF4D7D;
|
|
|
+ font-size: 26upx;
|
|
|
+ color: #666;
|
|
|
line-height: 40upx;
|
|
|
overflow: hidden;
|
|
|
text-overflow: ellipsis;
|
|
|
white-space: nowrap;
|
|
|
}
|
|
|
+
|
|
|
.notice-arrow {
|
|
|
flex-shrink: 0;
|
|
|
- font-size: 32upx;
|
|
|
- line-height: 1;
|
|
|
- color: #FF4D7D;
|
|
|
margin-left: 8upx;
|
|
|
padding: 8upx 4upx 8upx 12upx;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+}
|
|
|
+
|
|
|
+::v-deep .notice-horn-icon {
|
|
|
+ flex-shrink: 0;
|
|
|
}
|
|
|
</style>
|