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;
			}
		}
相关推荐
00后程序员张7 小时前
HTTP抓包工具推荐,Fiddler配置方法、代理设置与使用教程详解(开发者必学网络调试技巧)
网络·http·ios·小程序·fiddler·uni-app·webview
带着梦想扬帆启航10 小时前
UniApp 多个异步开关控制教程
前端·javascript·uni-app
喵喵侠w12 小时前
uni-app微信小程序相机组件二次拍照白屏问题的排查与解决
前端·数码相机·微信小程序·小程序·uni-app
2501_9159184115 小时前
HTTP和HTTPS工作原理、安全漏洞及防护措施全面解析
android·http·ios·小程序·https·uni-app·iphone
iOS阿玮16 小时前
淘宝 9 块 9 的 DeepSeek,撕开了魔幻世界的一角
uni-app·app·apple
2501_9160074717 小时前
如何在 Windows 电脑上调试 iOS 设备上的 Safari?完整方案与实战经验分享
android·windows·ios·小程序·uni-app·iphone·safari
2501_9159184117 小时前
uni-app iOS日志管理实战,从调试控制台到系统日志的全链路采集与分析指南
android·ios·小程序·https·uni-app·iphone·webview
hdsoft_huge18 小时前
小程序弱网 / 无网场景下 CacheManager 离线表单与拍照上传解决方案
java·小程序·uni-app
WKK_18 小时前
uniapp小程序 订阅消息推送
小程序·uni-app
软件架构师-叶秋18 小时前
Vue3+tyepescript+ElementPlus+Axios前端技术栈
前端·vue3·elementplus