首页
Search
1
解决visual studio code (vscode)安装时没有选择安装路径问题
335 阅读
2
如何在 Clash for Windows 上配置服务
232 阅读
3
Arch Linux 下解决 KDE Plasma Discover 的 Unable to load applications 错误
153 阅读
4
Linux 下 Bash 脚本 bad interpreter 报错的解决方法
153 阅读
5
uniapp打包app提示通讯录权限问题,如何取消通讯录权限
119 阅读
clash
服务器
javascript
全部
游戏资讯
登录
Search
加速器之家
累计撰写
1,707
篇文章
累计收到
0
条评论
首页
栏目
clash
服务器
javascript
全部
游戏资讯
页面
搜索到
1707
篇与
的结果
2024-08-22
H5微信9宫格抽奖+概率设置
9宫格抽奖百度找了很久也没有找到可以设置中奖概率的,后面找到一篇文章,结合后端PHP设置的中奖概率。以下是个例子,供大家参考和使用。1、抽奖界面代码:<!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"> <meta content="yes" name="apple-mobile-web-app-capable"> <meta content="black" name="apple-mobile-web-app-status-bar-style"> <script type="text/javascript" src="https://libs.baidu.com/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="https://www.tpxhm.com/fdetail/index.css?" /> </head> <script type="text/javascript"> function fontSize(){ var deviceWidth=document.documentElement.clientWidth>640?640:document.documentElement.clientWidth; document.documentElement.style.fontSize=(deviceWidth/25)+"px"; } fontSize(); window.onresize=fontSize; </script> <body> <div class="p1"> <div id="lottery" class="wxicke"> <style> .wxicke{ position: relative; } .zpbg_04{ width: 100%; height: 100%; position: absolute; left: 0px; top: 0px;} </style> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td class="lottery-unit lottery-unit-0"><span></span><div class="mask"></div></td> <td class="lottery-unit lottery-unit-1"><span></span><div class="mask"></div></td> <td class="lottery-unit lottery-unit-2"><span></span><div class="mask"></div></td> </tr> <tr> <td class="lottery-unit lottery-unit-4"><span></span><div class="mask"></div></td> <td colspan="2" class="btndon"><a><img src="https://www.tpxhm.com/fdetail/images/sz_03.png" alt="" class="c_stsn"></a></td> <td class="lottery-unit lottery-unit-5"><span></span><div class="mask"></div></td> </tr> <tr> <td class="lottery-unit lottery-unit-6"><span></span><div class="mask"></div></td> <td class="lottery-unit lottery-unit-7"><span></span><div class="mask"></div></td> <td class="lottery-unit lottery-unit-8"><span></span><div class="mask"></div></td> </tr> </table> </div> </div> <!-- 弹窗 --> <div class="resful"> <div class="resfulbox"> <img src="https://www.tpxhm.com/fdetail/images/close.png" alt="" class="bigclose" onclick="bigclose()"> <h1>获得<span>【</span><span class="pronum"></span><span>】</span>一份</h1> <div class="forms"> <label for="">姓名:</label> <input type="text" class="txun_name" /> <label for="">手机:</label> <input type="text" class="txun_tel" /> <button type="button" class="wxapisub">登记领取</button> </div> </div> </div> <script> /* 抽奖 */ var lottery={ index:-1, //当前转动到哪个位置,起点位置 count:0, //总共有多少个位置 timer:0, //setTimeout的ID,用clearTimeout清除 speed:20, //初始转动速度 times:0, //转动次数 cycle:50, //转动基本次数:即至少需要转动多少次再进入抽奖环节 prize:-1, //中奖位置 prize:0, //中奖位置 prizes:0, //中奖位置自定义+ prizesName:'', //奖项自定义+ pass: [0,1,2], // 跳过的位置,从0开始 init:function(id){ if ($("#"+id).find(".lottery-unit").length>0) { $lottery = $("#"+id); $units = $lottery.find(".lottery-unit"); this.obj = $lottery; this.count = $units.length; $lottery.find(".lottery-unit-"+this.index).addClass("active"); }; }, roll:function(){ var index = this.index; var count = this.count; var lottery = this.obj; $(lottery).find(".lottery-unit-"+index).removeClass("active"); index += 1; if (index>count-1) { index = 0; }; $(lottery).find(".lottery-unit-"+index).addClass("active"); this.index=index; return false; }, stop:function(index){ this.prize=index; return false; } }; // 检查中奖位置是否可用 function check(index) { var result = true; for(var i = 0, len = lottery.pass.length; i < len; i++) { if (index == lottery.pass[i]) { result = false; break; } } return result; } function roll(){ lottery.times += 1; lottery.roll();//转动过程调用的是lottery的roll方法,这里是第一次调用初始化 // 中奖 lottery.prize =lottery.prizes if (lottery.times > lottery.cycle+5 && lottery.prize==lottery.index) { clearTimeout(lottery.timer); lottery.prize=-1; lottery.times=0; click=false; // console.log($('.active').text()) console.log(lottery.prize) console.log(lottery.prizesName) // 获得写入缓存 localStorage.setItem('awards',lottery.prizesName) setTimeout('swr()',1000); // swr() }else{ if (lottery.times<lottery.cycle) { lottery.speed -= 5; } // 基本转动已结束,开始计算中奖位置 else if(lottery.times==lottery.cycle) { var index = Math.random()*(lottery.count)|0; while(!check(index)) { index = Math.random()*(lottery.count)|0; } lottery.prize = index; }else{ // 转动次数大于基本次数+10,且(转动位置在最后一个中奖位置是第一个)或(下一个位置就是中奖位置) 开始进入抽奖环节的最后阶段,转动速度更慢 if (lottery.times > lottery.cycle+5 && ((lottery.prize==0 && lottery.index==9) || lottery.prize==lottery.index+1)) { lottery.speed += 25; }else{ // 刚进入抽奖环节,减慢速度 lottery.speed += 5; } } if (lottery.speed<15) { lottery.speed=15; }; //console.log(lottery.times+'^^^^^^'+lottery.speed+'^^^^^^^'+lottery.prize); lottery.timer = setTimeout(roll,lottery.speed);//循环调用 } return false; } var click=false; window.onload=function(){ lottery.init('lottery'); $("#lottery a").click(function(){ if (click) {//click控制一次抽奖过程中不能重复点击抽奖按钮,后面的点击不响应 return false; }else{ $('.c_stsn').css('display','none') //点击抽奖关闭手指 lottery.speed=25; roll(); //转圈过程不响应click事件,会将click置为false click=true; //一次抽奖完成后,设置click为true,可继续抽奖 $.get("http://www.example.com/gl/", function(data) { //获取奖品 // console.log(data) lottery.prizes =data.id; lottery.prizesName = data.prize }, "json") return false; } }); }; function swr(){ var active=localStorage.getItem('awards'); $('.resful').css('visibility','visible') $('.pronum').text(active);//中奖结果 } </script> </body> </html>2、后端中奖概率设置。算法:计算总奖品概率,v即为概率,执行方法之后会返回中奖奖品名称及idpublic function gl(){ $prize_arr = [ '0' => ['id' => 1, 'prize' => '奖品1', 'v' => 20], '1' => ['id' => 2, 'prize' => '奖品2', 'v' => 10], '2' => ['id' => 3, 'prize' => '奖品3', 'v' => 20], '3' => ['id' => 4, 'prize' => '奖品4', 'v' => 5], '4' => ['id' => 5, 'prize' => '奖品5', 'v' => 19], '5' => ['id' => 6, 'prize' => '奖品6', 'v' => 5], '6' => ['id' => 7, 'prize' => '奖品7', 'v' => 10], '7' => ['id' => 8, 'prize' => '奖品8', 'v' => 10], ]; foreach ($prize_arr as $key => $val) { $arr[$val['id']] = $val['v']; } $rid = $this->get_prize($arr); //根据概率获取奖项id $data = $prize_arr[$rid-1]; return json($data); } public function get_prize($proArr) { $result = ''; //概率数组的总概率精度 $proSum = array_sum($proArr); //概率数组循环 foreach ($proArr as $key => $proCur) { $randNum = mt_rand(1, $proSum); if ($randNum <= $proCur) { $result = $key; break; } else { $proSum -= $proCur; } } unset ($proArr); return $result; }
2024年08月22日
9 阅读
0 评论
0 点赞
2024-08-22
H5网页实现打开页面自动播放背景音乐,以及点击关闭背景音乐
相信大家都见过一些H5邀请函,打开之后会自动播放音乐,屏幕有上角也会自动360度旋转图标,以下是简单的案例,大家可以参考。1、html部分代码:放置音乐、放置旋转按钮<div style="display: none;"> <audio id="music1" src="https://www.tpxhm.com/fdetail/music/EasyBreeze.mp3" controls> <source src="https://www.tpxhm.com/fdetail/music/EasyBreeze.mp3" type="audio/mpeg" /> </audio> </div> <a href="javascript:;" class="closemusic rotates"></a> <style> .closemusic{ display: block; width: 2rem; height: 2rem; background: url(images/bgmBtn-fbd2dc.svg) no-repeat; background-size: 100% 100%; position: fixed; right: 0.8rem; top:0.8rem; z-index: 11; } .closemusic.rotates{ animation: 2s rotates linear infinite } @keyframes rotates { 0%{} 100%{transform:rotate(360deg);} } </style>2、按钮点击事件:实现点击关闭和开启音乐<script> $(".closemusic").click(function(){ if($(this).hasClass('rotates')){ $(this).removeClass('rotates') document.getElementById('music1').pause(); }else{ $(this).addClass('rotates') document.getElementById('music1').play(); } }) </script>3、效果展示:4、关于ios微信不自动播放音乐可以参考这边文章:https://www.tpxhm.com/fdetail/818.html
2024年08月22日
8 阅读
0 评论
0 点赞
2024-08-22
WebUploader文件多次上传和删除无法上传文件的问题解决方法
WebUploader上传成功之后。移除文件,再次上传,选择了文件,但是没有渲染到页面上,博主想到的方法就是重置WebUploader状态//成功事件, 针对一个文件uploader.on('uploadSuccess', function (file, response) { uploader.removeFile(file); });// 多文件下所有文件上传成功后调用uploader.on('uploadFinished', function () { //清空队列 uploader.reset(); });这样重置之后,就能继续选择文件上传了
2024年08月22日
6 阅读
0 评论
0 点赞
2024-08-22
mobiscroll.custom2.17日期时间插件使用方法以及禁止选择之前的日期
mobiscroll.custom插件用在移动端的日期选择上,受到广泛的前端开发者喜爱,以下是使用方法、时间日期限制,及插件参数使用 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>mobiscroll练习</title> <link rel="stylesheet" type="" href="https://www.tpxhm.com/06-mobiscoll插件案例/css/mobiscroll.custom-2.17.1.min.css"> </head> <body> <input type="text" id="demo_date"> <input type="text" id="demo_time"> <script src="https://www.tpxhm.com/js/jquery.min.js"></script> <script src="https://www.tpxhm.com/js/mobiscroll.custom-2.17.1.min.js"></script> <script> var now = new Date(); var currYear = now.getFullYear(); var currMonth = now.getMonth() + 1; var currDay = now.getDate(); var currHours = now.getHours(); var currMinutes = now.getMinutes(); $('#demo_date').mobiscroll().date({ preset: 'date', //日期,可选:date\datetime\time\tree_list\image_text\select theme: "ios"; //皮肤样式,可选:default\android\android-ics light\android-ics\ios\jqm\sense-ui\wp light\wp mode: "scroller", display: "bottom",//显示方式 ,可选:modal\inline\bubble\top\bottom lang: "zh", showLabel: true,//false 显示头部 rows: 5,//显示多少行,定义3就显示3行, dateFormat: 'yyyy-mm-dd', // 面板日期格式 setText: '确认', //确认按钮名称 cancelText: '取消', //取消按钮名称 dateOrder: 'yyyymmdd', //面板中日期排列格式 dayText: '日', monthText: '月', yearText: '年', //面板中年月日文字 // showNow: false, nowText: "今", endYear: currYear + 10, //结束年份 minDate: new Date(currYear, currMonth - 1, currDay + 1), onSelect: function (textVale, inst) { //选中时触发事件 console.log("我被选中了....."); }, onClose: function (textVale, inst) { //插件效果退出时执行 inst:表示点击的状态反馈:set/cancel console.log("textVale--" + textVale); console.log(this.id);//this表示调用该插件的对象 } //wheels:[[11,12,13],[21,22,23],[01,02,03]],// 当前你定义的数组(即要滚动的数组), //defaultValue: [12,22]//默认显示当前滚动到哪个值, // formatResult://滚动到某个值后执行某个方法 // function(){ // console.log(1); // } }); $('#demo_time').mobiscroll().time({ preset: 'date', //日期,可选:date\datetime\time\tree_list\image_text\select theme: "ios"; //皮肤样式,可选:default\android\android-ics light\android-ics\ios\jqm\sense-ui\wp light\wp mode: "scroller", display: "bottom",//显示方式 ,可选:modal\inline\bubble\top\bottom lang: "zh", showLabel: true,//false 显示头部 rows: 5,//显示多少行,定义3就显示3行, dateFormat: 'yyyy-mm-dd', // 面板日期格式 setText: '确认', //确认按钮名称 cancelText: '取消', //取消按钮名称 dateOrder: 'yyyymmdd', //面板中日期排列格式 dayText: '日', monthText: '月', yearText: '年', //面板中年月日文字 // showNow: false, nowText: "今", endYear: currYear + 10, //结束年份 minDate: new Date(currYear, currMonth - 1, currDay + 1), onSelect: function (textVale, inst) { //选中时触发事件 console.log("我被选中了....."); }, onClose: function (textVale, inst) { //插件效果退出时执行 inst:表示点击的状态反馈:set/cancel console.log("textVale--" + textVale); console.log(this.id);//this表示调用该插件的对象 } //wheels:[[11,12,13],[21,22,23],[01,02,03]],// 当前你定义的数组(即要滚动的数组), //defaultValue: [12,22]//默认显示当前滚动到哪个值, // formatResult://滚动到某个值后执行某个方法 // function(){ // console.log(1); // } }); </script> </body> </html>其他说明:时间限制:minDate: new Date(2023,2,25,11,24),附件:mobiscroll.custom.min.jsjquery-1.10.2.jsmobiscroll.custom.min.css
2024年08月22日
8 阅读
0 评论
0 点赞
2024-08-22
解决苹果手机点击html网页输入框出现页面自动放大问题
做好网站,发现苹果手机,点击输入框调起键盘之后,解网页被方法,出现这个问题是应为没有在meta标签设置好禁止放大的缘故解决苹果手机点击html网页输入框出现页面自动放大问题:原始配置:<meta name="viewport" content="width=device-width, initial-scale=1.0">正确配置<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">说明:区别在于加入了maximum-scale=1.0, user-scalable=no",使得缩放比例为1,这样在苹果手机上就不会自动放大
2024年08月22日
7 阅读
0 评论
0 点赞
1
...
312
313
314
...
342