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;
			}
		}
相关推荐
小徐_23331 天前
uni-app vue3 也能使用 Echarts?Wot Starter 是这样做的!
前端·uni-app·echarts
iOS阿玮2 天前
永远不要站在用户的对立面,挑战大众的公知。
uni-app·app·apple
xw52 天前
uni-app中v-if使用”异常”
前端·uni-app
!win !2 天前
uni-app中v-if使用”异常”
前端·uni-app
2501_915918412 天前
iOS 上架全流程指南 iOS 应用发布步骤、App Store 上架流程、uni-app 打包上传 ipa 与审核实战经验分享
android·ios·小程序·uni-app·cocoa·iphone·webview
00后程序员张2 天前
iOS App 混淆与加固对比 源码混淆与ipa文件混淆的区别、iOS代码保护与应用安全场景最佳实践
android·安全·ios·小程序·uni-app·iphone·webview
00后程序员张2 天前
详细解析苹果iOS应用上架到App Store的完整步骤与指南
android·ios·小程序·https·uni-app·iphone·webview
海绵宝宝不喜欢侬2 天前
uniapp-微信小程序分享功能-onShareAppMessage
微信小程序·小程序·uni-app
2501_915106322 天前
Xcode 上传 ipa 全流程详解 App Store 上架流程、uni-app 生成 ipa 文件上传与审核指南
android·macos·ios·小程序·uni-app·iphone·xcode
xkxnq2 天前
Uniapp崩溃监控体系构建:内存泄漏三维定位法(堆栈/资源/线程)
uni-app