uniapp开发微信小程序初次加载弹窗显示隐私政策

效果图:

 

废话不多说,直接上代码:

<uni-popup
			ref="uPopup"
			:mask-click="false"
			type="center">
			<view class="agreement-view" :style="{ width: scrollWidth * 0.80 + 'px', height: scrollHeight * 0.70 + 'px' }">
				<!-- 弹框提示头 -->
				<view class="u-text-center">用户使用须知</view>
				<scroll-view scroll-y class="agreement-content" :style="{ height: (scrollHeight - 110) * 0.70 + 'px' }">
					您描述的内容
				</scroll-view>
				<view class="agreement-btns" :style="{ height: (scrollHeight*0.7 - (scrollHeight - 120) * 0.70) - 42 + 'px' }">
					<navigator class="no-btn text" target="miniProgram" open-type="exit">
						暂不使用
					</navigator>
					<view class="yse-btn text" @tap="admit">同意</view>
				</view>
			</view>
		</uni-popup>

 声明变量

data() {
			return {
				// 内容的高度
				scrollWidth: uni.getSystemInfoSync().windowWidth,
				scrollHeight: uni.getSystemInfoSync().windowHeight,
			}
		}

初始化加载及函数操作

mounted() {
			this.judge();
		},
methods: {
			// 初始化的时候调用参数,判断用户是否第一次进入
			judge() {
				uni.getStorage({
					key:'agreement_key',
					success: () => {
						// 获取到了不显示弹窗
						this.$refs.uPopup.close();
						uni.showTabBar({
							animation: true
						})
					},
					fail: () => {
						uni.hideTabBar({
							animation: true
						})
						this.$refs.uPopup.open('center');
					}
				})
			},
			// 同意按钮
			admit() {
				try{
					uni.setStorageSync('agreement_key', 'yes');
					uni.setStorageSync('agreement_Date', new Date().toLocaleString())
				}catch(e){
					//TODO handle the exception
				}
				this.$refs.uPopup.close();
				uni.showTabBar({
					animation: true
				})
			},
}

css样式:

.line{
	/* line-height: 18px; */
	font-family:Arial,Helvetica,sans-serif;
	font-size:1em;
	vertical-align:middle;
	font-weight:normal
}
.agreement-view{
	margin-top: 20px;
	box-shadow: 0 5rpx 20rpx 0rpx rgba(0, 0, 150, .2);
	border-radius: 20rpx;
	padding: 20rpx 0rpx 0rpx 0rpx;
	display: flex;
	flex-direction: column;
	width: 300px;
	height: 400px;
	align-items: center;
	/* justify-content: center; */
	background-color: #fff;
}
.u-text-center{
	font-size: 15px;
	padding-bottom: 20rpx;
	font-family:Arial,Helvetica,sans-serif;
	font-weight: 600;
	width: 100%;
	height: 30px;
	text-align: center;
}
.agreement-content{
	overflow-y: scroll;
	padding: 0rpx 20rpx 10rpx 20rpx;
}
.agreement-btns{
	width: 100%;
	/* height: 85rpx; */
	display: flex;
	flex-direction: row;
}
.yse-btn{
	color: #fff;
	background-color: red;
	flex: 1;
	text-align: center;
	width: 100%;
	height: 100%;
	border-radius: 0 0 20rpx 0;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}
.no-btn{
	/* background-color: aquamarine; */
	flex: 1;
	text-align: center;
	width: 100%;
	height: 100%;
	border-radius: 0 0 0 20rpx;
}
.text{

	line-height: 46px;
}

  • 4
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值