uniapp的uni-popup和uni-rate的使用

uni-popup 弹出层 | uni-app官网 (dcloud.net.cn)

uni-app官网 (dcloud.net.cn)

<template>
	<view class="lockScreen">
		<swiper circular>
			<swiper-item v-for="(item,index) in 6" :key="index">
				<image src="../../common/images/preview2.jpg" mode="aspectFill"  @click="maskChange"></image>
			</swiper-item>
		</swiper>
		<view class="mask" v-show="maskState">
			<view class="goBack"></view>
			<view class="count">4 / 7</view>
			<view class="time">
				<uni-dateformat :date="new Date()" format="hh:mm"></uni-dateformat>
			</view>
			<view class="date">
				<uni-dateformat :date="new Date()" format="MM月dd日"></uni-dateformat>
			</view>
			<view class="footer">
				<view class="box" @click="openPopup">
					<uni-icons type="info" size="30"></uni-icons>
					<text class="typeface">信息</text>
				</view>
				<view class="box" @click="clickScore">
					<uni-icons type="star" size="30"></uni-icons>
					<text class="typeface">5分</text>
				</view>
				<view class="box">
					<uni-icons type="download" size="28"></uni-icons>
					<text class="typeface">下载</text>
				</view>
			</view>
		</view>
		<!-- 弹出层 -->
		<uni-popup ref="infoPopup" type="bottom">
			<view class="infoPopup">
				<view class="headerPopup">
					<view></view>
					<view>壁纸信息</view>
					<view class="close" @click="closePopup">
						<uni-icons type="closeempty" size="18" color="#999"></uni-icons>
					</view>
				</view>
				<scroll-view scroll-y>
					<view class="content">
						<view class="row">
							<view class="label">壁纸ID:</view>
							<text selectable class="value">658bc0d56e5d2d7187185309</text>
						</view>
						
						<view class="row">
							<view class="label">分类:</view>
							<text class="value class">明星美女</text>
						</view>
						
						<view class="row">
							<view class="label">发布者:</view>
							<text class="value">小咪想吃鱼</text>
						</view>		
						<view class="row">
							<text class="label">评分:</text>
							<view class='value roteBox'>
								<uni-rate readonly touchable value="3" size="16"></uni-rate>
								<text class="score">5分</text>
							</view>
						</view>		
						<view class="row">
							<text class="label">摘要:</text>
							<view class='value'>
								张婧仪一袭金色礼服端庄大气。图源:微博@张婧仪
							</view>
						</view>		
						<view class="row">
							<text class="label">标签:</text>
							<view class='value tabs'>
								<view class="tab" v-for="tab in 3" :key="tab">
									小白
								</view>
							</view>
						</view>		
						<view class="copyright">
							声明:本图片来用户投稿,非商业使用,用于免费学习交流,如侵犯了您的权益,您可以拷贝壁纸ID举报至平台,邮箱513894357@qq.com,管理将删除侵权壁纸,维护您的权益		
						</view>
						
						<view class="safe-area-inset-bottom"></view>
					</view>
				</scroll-view>
			</view>
			
		</uni-popup>
		<!-- 评分弹出层 -->
		<uni-popup ref="scorePopup" :is-mask-click="false">
			<view class="scorePopup">
				<view class="headerPopup">
					<view> </view>
					<view>壁纸信息</view>
					<view class="close" @click="closePopup">
						<uni-icons type="closeempty" size="18" color="#999" @click="closeScore"></uni-icons>
					</view>
				</view>
				<view class="content">
					<view class='value'>
						<uni-rate  v-model="useScore" size="16" allowHalf></uni-rate>
						<text class="score">{{useScore}}分</text>
					</view>
				</view>
					<view class="footButton">
						<button type="default" size="mini" plain @click="submitScore" :disabled="!useScore">确定评分</button>
					</view>
			</view>
			
		</uni-popup>
	</view>
</template>

<script setup>
	import { ref } from 'vue';
	import { onShow } from "@dcloudio/uni-app";
	// 锁屏文字的显示与隐藏
	const maskState =ref(true)
	const maskChange =()=>{
		maskState.value=!maskState.value
	}
	//打开弹窗层
	const infoPopup =ref(null)
	const openPopup =()=>{
		infoPopup.value.open()
	}
	//关闭弹窗层
	const closePopup=()=>{
		infoPopup.value.close()
	}
	//打开评分
	const scorePopup=ref(null)
	const clickScore=()=>{
		scorePopup.value.open()
	}
	//关闭评分
	const closeScore=()=>{
		scorePopup.value.close()
	}
	//评分个数
	const useScore=ref(0)
	//确定评分
	const submitScore=()=>{
		console.log(12)
		
	}
</script>

<style lang="scss" scoped>
.lockScreen{
	width: 100%;
	height: 100vh;
	position: relative;
	swiper{
		width: 100%;
		height: 100%;
		swiper-item{			
			image{
				width: 100%;
				height: 100%;
			}
		}
	}
	.mask{
		// 父级紧邻的子元素公用属性
		&>view{
			position: absolute;
			left:0;
			margin: auto;
			right: 0;
			width: fit-content;//随内容变化设置宽度
			color:#fff;
		}
		.goBack{
			
		}
		.count{
			top:12vh;
			background: rgba(0,0,0,0.3);
			border-radius: 40rpx;
			font-size: 24rpx;
			padding: 4rpx 28rpx;
			backdrop-filter: blur(10rpx);//设置模糊
		}
		.time{
			font-size: 140rpx;
			top:calc( 10vh + 50rpx);
			
		}
		.date{
			font-size: 30rpx;
			top:calc(10vh + 225rpx);
		}
		.footer{
			bottom: 10vh;
			display: flex;
			justify-content: space-between;
			background-color: #fff;
			height: 125rpx;
			border-radius:125rpx;
			.box{
				display: flex;
				flex-direction: column;
				align-items: center;
				padding:0 30rpx;
				justify-content: center;
				margin-left: 10rpx;
				margin-right: 10rpx;
				.typeface{
					color: $text-font-color-2;
				}
			}
		}
	}
		.headerPopup {
					display: flex;
					justify-content: space-between;
					align-items: center;
		
					.title {
						color: $text-font-color-2;
						font-size: 26rpx;
					}
		
					.close {
						padding: 6rpx;
					}
				}
		.infoPopup {
				background: #fff;
				padding: 30rpx;
				border-radius: 30rpx 30rpx 0 0;
				overflow: hidden;
	
				scroll-view {
					max-height: 60vh;//限制最大高度,防止内容过多,遮住壁纸
	
					.content {
						.row {
							display: flex;
							padding: 16rpx 0;
							font-size: 32rpx;
							line-height: 1.7em;
	
							.label {
								color: $text-font-color-3;
								width: 140rpx;
								text-align: right;
								font-size: 30rpx;
							}
	
							.value {
								flex: 1;
								width: 0;
							}
	
							.roteBox {
								display: flex;
								align-items: center;
	
								.score {
									font-size: 26rpx;
									color: $text-font-color-2;
									padding-left: 10rpx;
								}
							}
	
							.tabs {
								display: flex;
								flex-wrap: wrap;
	
								.tab {
									border: 1px solid $brand-theme-color;
									color: $brand-theme-color;
									font-size: 22rpx;
									padding: 10rpx 30rpx;
									border-radius: 40rpx;
									line-height: 1em;
									margin: 0 10rpx 10rpx 0;
								}
							}
	
							.class {
								color: $brand-theme-color;
							}
	
	
						}
	
						.copyright {
							font-size: 28rpx;
							padding: 20rpx;
							background: #F6F6F6;
							color: #666;
							border-radius: 10rpx;
							margin: 20rpx 0;
							line-height: 1.6em;
						}
	
					}
				}
			}
		.scorePopup{
			width: 60vw;
			border-radius: 20rpx;
			background-color: #fff;
			padding: 30rpx;
			.content{
				.value{
					display: flex;
					align-items: center;
					justify-content: center;
					padding: 30rpx 0;
					.score{
						
							color: #FFCA3E;
							padding-left: 10rpx;
							width: 80rpx;
							line-height: 1em;
							text-align: right;
							font-size: 28rpx;
						
					}
				}
			}
			.footButton{
					display: flex;
					align-items: center;
					justify-content: center;
			}
		}

}
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值