使用地址:
- http://car.toutiao.com/cxf/maopu/20200109/
复制代码使用教程可以参考这个视频
点击下载视频
代码如下:
- var msgArr = [{name:”卢仁佳”,phone:”13800138001″},{name:”路人乙”,phone:”13800138002″},{name:”路人丁”,phone:”13800138003″}];//抽奖列表
- var timer = 10000,//提交间隔
- maxTimer = 5000,//随机最大提交时间间隔
- minTimer = 2000,//随机最小提交时间间隔
- maxScore = 2000,//最大分数
- minScore = 500;//最小分数
- function random(n, m) {
- return Math.floor(Math.random() * (m – n 1) n);
- }
- function post(name,phone,score){
- console.log(`用户名:${name} 手机号码:${phone} 分数:${score}`);
- fetch(‘http://car.toutiao.com/cxf/tp5/public/index.php/request/mpuser’,{
- method: “POST”,
- mode: “cors”,
- credentials: “include”,
- headers: {
- “Content-Type”: “application/x-www-form-urlencoded”
- },
- body: `name=${name}&phone=${phone}&score=${score}`
- }
- ).then((res) => res.json())
- .then((json) => {
- console.log(`提交结果:${JSON.stringify(json)}`);
- if(json.prize!=0){
- alert(‘好像中奖了!’)//1:100E卡 2:毛铺黑荞酒*2 3:毛铺紫荞酒*2 4:iphone11
- }else{
- setTimeout(()=>{
- var msg = msgArr[random(0,msgArr.length-1)],
- rScore = random(minScore,maxScore);
- post(msg[‘name’],msg[‘phone’],rScore);
- },timer random(minTimer,maxTimer))
- }
- });
- }
- setTimeout(()=>{
- var msg = msgArr[random(0,msgArr.length-1)],
- rScore = random(minScore,maxScore);
- post(msg[‘name’],msg[‘phone’],rScore);
- },timer random(minTimer,maxTimer))//提交的时间=提交间隔 随机最小提交时间间隔~随机最大提交时间间隔
复制代码下班~