uni-popup 小程序首页弹出层

景: 要求在首页加载的时候弹出弹框显示一张图片,弹出五秒后自动关闭,也可以点击
叉号手动关闭;如图:
在这里插入图片描述
代码:

<template>
  <u-popup
	class="auth-popup"
	mode="center"
	width="600rpx"
	height="770rpx"
	:closeable="true"
	close-icon-color="#010101"
	:mask-close-able="false"
	close-icon-size="42"
	border-radius="5">
		   <view class="back_box">
				<image
					class="back_img"
					:src="popUpUrl"
					:key="index"
				></image>
			</view>
  </u-popup>
</template>
<script>
	import http from '@/api/http.js';
	import {
		getImsgPushlogmsg
	} from '@/api/interfaceHDB.js';
	
	export default {
		data() {
			return {
				isShowPoupon: false, //是否隐藏对话框
				popUpUrl: "", //首页弹窗图片
			}
		},
		mounted() {
			this.getLogdatainfo();
		},
	    methods: {
			// 获取弹窗内容
			getLogdatainfo() {
				http.get(getImsgPushlogmsg).then(res => {
				    if (res.list[0]) {
						this.popUpUrl = res.list[0].pushmsgJpushType; //图片地址
						this.isShowPoupon = true;
						
						//设置五秒后弹窗自动关闭
						let time = setTimeout(item => {
							this.isShowPoupon = false;
							clearTimeout(time)
						}, 5000)
					} else {
						console.log('没有弹窗数据')
					}
				})
			},
		}
</script>
<style lang="less" scoped>
	.back_box {
		position: relative;
		width: 100%;
		height: 100%;
		
		.back_img {
			width: 100%;
			height: 100%;
		}
	}
</style>

接口数据:
在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值