uniapp使用uni-popup做底部弹出选项(vue3)

效果图

页面代码

xml 复制代码
<!-- 发票筛选弹出框 -->
		<uni-popup ref="popupRef" type="bottom" border-radius="10px 10px 0 0" background-color="#fff">
			<h4 style="text-align: center;margin-bottom: 20px;">发票筛选</h4>
			<h4>发票状态</h4>
			<view class="choose-item">
				<p @click="activeBtn('status',1)" :class="[invoiceForm.status==1?'active':'']">正常</p>
				<p @click="activeBtn('status',2)" :class="[invoiceForm.status==2?'active':'']">已作废</p>
				<p @click="activeBtn('status',3)" :class="[invoiceForm.status==3?'active':'']">已冲红-全额</p>
				<p @click="activeBtn('status',4)" :class="[invoiceForm.status==4?'active':'']">已冲红-部分</p>
			</view>
			<h4>发票使用状态</h4>
			<view class="choose-item">
				<p @click="activeBtn('use',1)" :class="[invoiceForm.use==1?'active':'']">未使用</p>
				<p @click="activeBtn('use',2)" :class="[invoiceForm.use==2?'active':'']">已使用</p>
			</view>
			<h4>发票认证状态</h4>
			<view class="choose-item">
				<p @click="activeBtn('authentication',1)" :class="[invoiceForm.authentication==1?'active':'']">未认证</p>
				<p @click="activeBtn('authentication',2)" :class="[invoiceForm.authentication==2?'active':'']">已认证</p>
			</view>
			<h4>开票起止时间</h4>
			<view class="choose-item time-class">

				<uni-datetime-picker type="date" style="width: 50%" v-model="invoiceForm.starTime">
					<p style="width: 77%;text-align: center;">{{invoiceForm.starTime || "开票开始时间"}}</p>
				</uni-datetime-picker>

				<uni-datetime-picker type="date" style="width: 50%" v-model="invoiceForm.endTime">
					<p style="width: 77%;text-align: center;">{{invoiceForm.endTime || "开票结束时间"}}</p>
				</uni-datetime-picker>
			</view>
			<view class="tow-btn-class">
				<view @click="onreset"
					style="width: 45%;height: 100%;color: #fff;background: #FF8604;border-radius: 10px;line-height: 36px;text-align: center;">
					重置
				</view>
				<view @click="submitBtn"
					style="width: 45%;height: 100%;color: #fff;background: #0087FD;border-radius: 10px;line-height: 36px;text-align: center;">
					确认
				</view>
			</view>
		</uni-popup>

逻辑代码

javascript 复制代码
	const popupRef = ref()
	// 打开弹框的方法-绑在触发的元素上
	const showPopupBtn = () => {
		popupRef.value.open('bottom')
	}
	// 发票筛选
	let invoiceForm = ref({
		status: "",
		use: "",
		authentication: "",
		starTime: "",
		endTime: ""
	})
	// 切换激活状态
	const activeBtn = (type, val) => {
		invoiceForm.value[type] = val
	}
	// 提交
	const submitBtn = () => {
		popupRef.value.close()
	}
	// 重置选项
	const onreset = () => {
		invoiceForm.value.status = ""
		invoiceForm.value.use = ""
		invoiceForm.value.authentication = ""
		invoiceForm.value.starTime = ""
		invoiceForm.value.endTime = ""
	}

css

javascript 复制代码
::v-deep .uni-popup__wrapper {
			padding: 10px 10px 0;
			display: flex;
			flex-direction: column;

			.choose-item {
				display: flex;
				width: 100%;
				margin: 10px 0 30px;

				p {
					width: fit-content;
					padding: 6px 10px;
					border-radius: 10px;
					background: #F1F0F1;
					font-size: 14px;
					margin-right: 7px;
				}

				.active {
					background: #37C2BC;
					color: #fff;
				}
			}

			::v-deep .uni-date-editor {
				display: flex;
				justify-content: center;
			}

			.tow-btn-class {
				width: 100%;
				height: 36px;
				display: flex;
				justify-content: space-around;
				margin-bottom: 30px;
			}
		}
相关推荐
鸭子嘎鹅子呱11 小时前
uniapp使用高德地图设置marker标记点,后续根据接口数据改变某个marker标记点,动态更新
uni-app·map·高德地图
计算机源码社16 小时前
分享一个基于微信小程序的居家养老服务小程序 养老服务预约安卓app uniapp(源码、调试、LW、开题、PPT)
android·微信小程序·uni-app·毕业设计项目·毕业设计源码·计算机课程设计·计算机毕业设计开题
Angus-zoe19 小时前
uniapp+vue+微信小程序实现侧边导航
vue.js·微信小程序·uni-app
Pluto & Ethereal19 小时前
uni-app尺寸单位、flex布局于背景图片
uni-app
天空下sky1 天前
uniapp+若依 开发租房小程序源码分享
uni-app
帅过二硕ฅ1 天前
uniapp点击跳转到对应位置
前端·javascript·uni-app
山水阳泉曲1 天前
开发后台管理系统-开发环境搭建
vue3·cdn·后台管理·从零开始
佩淇呢1 天前
uniapp vue3 梯形选项卡组件
前端·vue.js·uni-app
[廾匸]1 天前
uni-app获取设备唯一值、静态IP以及公网IP的方法
uni-app·ip·imei·唯一值
陈逸子风2 天前
.net core8 使用JWT鉴权(附当前源码)
vue3·webapi·权限·流程