小程序自定弹窗

wxml

<view bindtap="showRule">点击出现弹窗</view>

<!-- 弹窗 -->
<view class="cover {{isRuleTrue?'isRuleShow':'isRuleHide'}}">
	<view class="window">
		<image class="PopupWindowImg1" src="../../images/sendCardImg.png"></image>
		<view class="closeBox" bindtap="hideRule">
			<image class="close" src="../../images/colse.png"></image>
		</view>
		<view class="title">
			<view>恭喜您获得一张优惠券</view>
			<view>快去使用吧!</view>
		</view>
		<navigator open-type="navigate" hover-class="none" url="{{toDiscount}}">
			<image class="PopupWindowImg2" src="../../images/lookDiscount.png" mode="widthFix"></image>
		</navigator>
	</view>
</view>

wxss

/* 弹窗 */
.cover {
	width: 100%;
	height: 100%;
	position: fixed;
	top: 0;
	left: 0;
	background-color: rgba(0, 0, 0, .8);
	z-index: 2;
	padding-top: 300rpx;
	padding-left: 75rpx;
	z-idnex: 500;
	overflow: hidden;
}

.isRuleShow {
	display: block;
}

.isRuleHide {
	display: none;
}

.window {
	width: 460rpx;
	background: #ffffff;
	border-radius: 10px;
	padding: 24rpx 70rpx 40rpx 70rpx;
	position: relative;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
}

.closeBox {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40rpx;
	height: 40rpx;
	position: absolute;
	top: 20rpx;
	right: 20rpx;
}

.close {
	width: 24rpx;
	height: 24rpx;
}

.PopupWindowImg1 {
	width: 450rpx;
	height: 272rpx;
	position: absolute;
	top: -207rpx;
	left: 70rpx;
}

.title {
	display: block;
	text-align: center;
	font-size: 30rpx;
	font-weight: 600;
	margin-top: 90rpx;
	margin-bottom: 50rpx;
	color: #323332;
}

.PopupWindowImg2 {
	display: inline-block;
	width: 200rpx;
}

js 

//显示弹窗
  showRule: function () {
    this.setData({
      isRuleTrue: true
    })
  },


  //关闭弹窗
  hideRule: function () {
    this.setData({
      isRuleTrue: false
    })

 注意:

穿透问题(一个是灭有滑动的穿透问题,一个是有滑动穿透问题)

textarea标签造成的穿透比较特殊需要对该标签进行处理

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值