...
分享

分享一个领红包插件代码

33191593681898_.pic_hd.jpg

直接上代码吧

我也是为了储存一下

<!--红包-->
<div id="hongbao" data-clipboard-target="#taokouling" data-clipboard-action="copy"
style="top: 0;left: 0; display: none; position: fixed; width: 100%; height: 100%; z-index: 1000; background-color: rgba(0,0,0,.4); ">
<input id="taokouling" value="PDqYzEuR4Lwyh26I" type="text" style="position: fixed; left: -9999px;">
<div
style="position: absolute; width: 240px; height: 360px; background-color: #ff2340; box-shadow: 0 0 10px #ff6080 inset;text-align: center; border-radius: 20px; left: 50%; top: 50%; transform: translate(-50%,-50%);box-sizing: border-box;padding: 30px 10px;">
<img src="https://www.vsay.net/content/uploadfile/201908/84c01566026214.jpg"
style="width: 80px;height: 80px; border-radius: 80px;">
<div style="font-size: 26px; font-weight: bold; color: #ffff7f; margin-top: 20px;">
¥100元
</div>
<div style="color: #ffff7f; font-weight: 400;margin-top: 1em;font-size: 16px;">
您有一个红包包要领吗?
</div>
<div style="padding: 30px; color: #222;">
<button class="btn" data-clipboard-target="#taokouling" data-clipboard-action="copy" type="button"
style="cursor: pointer; outline: none;background-color: #ffff7f; display: block; border-radius: 40px; border: 0; height: 40px; width: 100%;">领一下</button>
<button class="btn" data-clipboard-target="#taokouling" data-clipboard-action="copy" type="button"
style="cursor: pointer; outline: none;background-color: #f5f5f5; display: block; border-radius: 40px; border: 0; height: 40px; width: 100%; margin-top: 20px;">不要滚球</button>
</div>
</div>
<script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/clipboard.js/2.0.6/clipboard.min.js"></script>
<script>
// 检查是否是手机
function check() {
var userAgentInfo = navigator.userAgent;
var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
var flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false;
break;
}
}
return flag;
} ! function () {
// 获取本地储存 是否存在红包展示记录
var hongbao = localStorage.getItem('hongbao')
if (!check() && (((new Date(hongbao)).getTime()) + 60 * 60 * 1000) < (new Date()).getTime()) {
setTimeout(function () {
document.getElementById('hongbao').style.display = 'block'
}, 3000)
}
}()

function chuli(e) {
// 写入本次展示记录
localStorage.setItem("hongbao", new Date())
if (e.trigger.innerText == '领一下') {
window.location.href = 'https://dwz.cn/MkJsxfyH'
} else {
document.getElementById('hongbao').remove()
}
}
// 初始化剪切板库
var clipboard = new ClipboardJS('.btn');
clipboard.on('success', function (e) {
chuli(e)
});
clipboard.on('error', function (e) {
chuli(e)
});
var clipboard = new ClipboardJS('#hongbao');
clipboard.on('success', function (e) {
});
clipboard.on('error', function (e) {
});
</script>
</div>





Uniapp 小程序海报生成代码 clipboard.js不依赖flash剪切板操作库
biu biu biu
博客精灵,js浮动小人 怎样通过身份证号码取到年龄 JS取字符串长度含中文不准的解决方案 PHP Composer 安装与使用 前端入门学习路线图~