uniapp 微信小程序 上下滚动的公告通知(只取前3条)

效果图:

bash 复制代码
<template>
	<view class="notice" @click="policyInformation">
		<view class="notice-icon">
			<image mode="aspectFit" class="img" src="@/static/img/megaphone.png"></image>
		</view>
		<view class="notice-content">
			<swiper circular :autoplay="true" :vertical="true">
				<swiper-item class="flex justify-content-between" v-for="(item, index) in noticeBarList"
					:key="index" @click="toNotice(item)">
					<text class="text text-ellipsis flex-grow">{{ item.mtitle }}</text>
				</swiper-item>
			</swiper>
		</view>
		<view class="notice-arrow">
			<image mode="aspectFit" class="img" src="@/static/img/supervisoryEnd/arrow.png"></image>
		</view>
	</view>
</template>
bash 复制代码
data() {
	return {
		noticeBarList: [],	
	}
}
bash 复制代码
onLoad: function(options) {
	this.getNotice()
},
bash 复制代码
methods: {
	//查询通知公告
	getNotice(){
		uni.showLoading();
		var params = {
			url: "/transporterList",
			method: "GET",
			data: {
				readStatus:-1
			},
			callBack: res => {
				uni.hideLoading()
				if(res.rows.length > 3){
					//最多只显示前三个通知
					this.noticeBarList = res.rows.slice(0,3);
				}else{								
					this.noticeBarList = res.rows;
				}
			}
		};
		http.request(params);
	},
	//进入公告通知详情页
	toNotice(item){
		uni.navigateTo({
			url:"/pages/notice-detail/notice-detail?messageId="+item.messageId
		})
	},
}
bash 复制代码
<style lang="scss" scoped>
.notice {
	display: flex;
	display: -webkit-flex;
	align-items: center;
	box-shadow: 0rpx 2rpx 10rpx 0rpx rgba(0, 0, 0, 0.05);
	background: rgba(255, 255, 255, 0.8);
	margin-top: 20rpx;
	border-radius: 10rpx;

	.notice-icon {
		.img {
			display: block;
			width: 30rpx;
			height: 30rpx;
			margin-left: 15rpx;
		}
	}

	.notice-content {
		flex-grow: 1;

		swiper {
			height: 56rpx;
			padding: 0 17rpx;

			swiper-item {
				display: flex;
				display: -webkit-flex;
				align-items: center;
				justify-content: space-between;

				.text {
					height: 56rpx;
					font-size: 26rpx;
					color: #666666;
					line-height: 56rpx;
					flex-grow: 1;
				}
			}
		}
	}

	.notice-arrow {
		.img {
			display: block;
			width: 32rpx;
			height: 32rpx;
		}
	}
}
</style]>
相关推荐
微爱帮监所写信寄信1 分钟前
微爱帮监狱寄信写信小程序:深入理解JavaScript中的Symbol特性
开发语言·javascript·网络协议·小程序·监狱寄信·微爱帮
计算机毕设指导61 小时前
基于微信小程序的智慧社区娱乐服务管理系统【源码文末联系】
java·spring boot·微信小程序·小程序·tomcat·maven·娱乐
微爱帮监所写信寄信2 小时前
6G+AI:重构微爱帮监狱写信寄信小程序的特殊通信未来
人工智能·小程序·重构·6g·监狱信件·监狱系统·服刑人员子女
赵庆明老师2 小时前
uniapp 微信小程序页面JS模板
javascript·微信小程序·uni-app
熬耶2 小时前
uniapp 简单实现列表左滑操作
uni-app
kdniao12 小时前
问答FAQ|快递鸟对接系统/小程序常见问题解答产品篇(二)
大数据·小程序
小白学过的代码3 小时前
UniApp 引入 Cesium 开发: RenderJS 避坑
uni-app
jingling5553 小时前
uni-app 安卓端完美接入卫星地图:解决图层缺失与层级过高难题
android·前端·javascript·uni-app
星盾网安3 小时前
智慧门店系统开发-03-新嘉丽小程序基础搭建
小程序
项目題供诗3 小时前
微信小程序黑马优购(项目)(九)
微信小程序·小程序