从一个小例子来看setInterval的使用
来源:互联网 发布:lable java 编辑:程序博客网 时间:2024/06/08 04:31
从一个小例子来看setInterval的使用
<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>乐运动数据同步</title> <link href="http://apps.bdimg.com/libs/bootstrap/3.3.4/css/bootstrap.css" rel="stylesheet"> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js"></script> <style type="text/css"> html,body{width:100%;height:100%;margin:0;font:14px "Microsoft Yahei","微软雅黑",Tahoma,Arial,Helvetica,STHeiti;color:#ccc;background-color:#27ae60;}.logo{width:150px;height:64px;background:url(./images/spite_index) -29px -432px no-repeat;margin:80px auto 20px;}.header{color:#f4f4f4;margin-bottom:15px;font-size:21px;font-weight:200;text-align:center;}.header span{font-size:14px;}.form-group{margin-top:40px;margin-bottom:15px;}.form-group .text{width:450px;border:2px solid #27ae60;-webkit-box-shadow:none;box-shadow:none;font-size:16px;padding:13px 30px;border-radius:0;height:auto;text-align:center;margin:10px auto;}.form-group .text:focus{border-color:#208d4e;}a.submit{width:446px;background:#239650;border:1px solid #239650;-webkit-box-shadow:none;box-shadow:none;font-size:18px;color:#fff;padding:10px 30px;border-radius:0;height:auto;text-align:center;margin:0 auto;}a:hover{cursor:pointer;text-decoration:none;background:#208d4e;border-color:#208d4e;}.tip{width:375px;height:87px;background:url(./images/spite_index)-21px -513px;margin:80px auto 0;} </style> <script type="text/javascript"> $(function(){ $('#submit').on('click',function() { alert("程序已运行!"); var timeTask=setInterval(function(){ var date=new Date(); var h=date.getHours(); var m=date.getMinutes(); var s=date.getSeconds(); if(h==8&&m==59&&s==0){ console.log('9点段开始设置'); runstepset1(); } if(h==14&&m==59&&s==0){ runstepset2(); console.log('15点段开始设置'); } if(h==21&&m==15&&s==28){ runstepset3(); console.log('21点段开始设置'); } },1000); } ) }); function runstepset1() { var Min = 0; var Max = 8000; var Range = Max - Min; var Rand = Math.random(); var step = (Min + Math.round(Rand * Range)); $.ajax({ //一个Ajax过程 type : "get", dataType: 'JSONP', url : 'http://appt.igeekery.com/wx-run/set-step.json?_lan=zh&_k=da3e20cc7e524a5a\ b22360372f564875&_v=36&_ch=16&_nw=wifi&_sdk=19&_product=fitmix&_terminal=2&uid=458009&uni\ onid=oIoQTsy2pk-LKb4hnq0EK9m_3QC4&openid=oBmGhuPxQVTPVBfZyWhskgT4TTos&step\='+step, success : function(ret) { if(ret.code==0) {console.log('设置成功'+step);} else {console.log('设置成功'+step); } }, error : function(error) {console.log('设置失败'+step); } }); } function runstepset2() { var Min = 8000; var Max = 16000; var Range = Max - Min; var Rand = Math.random(); var step = (Min + Math.round(Rand * Range)); $.ajax({ //一个Ajax过程 type : "get", dataType: 'JSONP', url : 'http://appt.igeekery.com/wx-run/set-step.json?_lan=zh&_k=da3e20cc7e524a5a\ b22360372f564875&_v=36&_ch=16&_nw=wifi&_sdk=19&_product=fitmix&_terminal=2&uid=458009&uni\ onid=oIoQTsy2pk-LKb4hnq0EK9m_3QC4&openid=oBmGhuPxQVTPVBfZyWhskgT4TTos&step\='+step, success : function(ret) { if(ret.code==0) { console.log('设置成功'+step);} else {console.log('设置成功'+step); } }, error : function(error) {console.log('设置失败'+step); } }); } function runstepset3() { var Min = 16000; var Max = 24000; var Range = Max - Min; var Rand = Math.random(); var step = (Min + Math.round(Rand * Range)); $.ajax({ //一个Ajax过程 type : "get", dataType: 'JSONP', url : 'http://appt.igeekery.com/wx-run/set-step.json?_lan=zh&_k=da3e20cc7e524a5a\ b22360372f564875&_v=36&_ch=16&_nw=wifi&_sdk=19&_product=fitmix&_terminal=2&uid=458009&uni\ onid=oIoQTsy2pk-LKb4hnq0EK9m_3QC4&openid=oBmGhuPxQVTPVBfZyWhskgT4TTos&step\='+step, success : function(ret) { if(ret.code==0) {console.log('设置成功'+step); } else {console.log('设置成功'+step); } }, error : function(error) {console.log('设置失败'+step); } }); }</script></head><body> <div class="container"> <div class="logo"></div> <p class="header">陆嵩小主,请问是否开始设置的微信运动步数<br/> <div class="form-group"> <form id="form" method="POST" action="http://pl.api.ledongli.cn/xq/io.ashx"> <a id="submit" class="form-control submit">确定</a> </form> </div> </p> <div class="tip"></div> </div></body></html>
用一个小技巧可以每天固定时刻做一个动作,周而复始,而不是要从现在开始,每隔多少时间做一次。
0 0
- 从一个小例子来看setInterval的使用
- 从两个小例子来看matlab系统仿真的使用
- 从一个最简单的例子来看Retrofit(二)
- 从一个最简单的例子来看Retrofit(一)
- 关于setInterval的一个例子
- 从一个小程序来看C++类的存储方式
- 一个setInterval的小问题
- 从一个csdn的例子来看标准算法和容器,跌带器的关系
- 使用存储过程的一个小例子
- 一个quartz如何使用的小例子
- 封装使用的一个小例子
- abap 指针使用的一个小例子
- JS setTimeout 和 setInterval 的区别小例子
- 一个简单的setTimeout模拟setInterval的例子
- 一个小的例子
- 用一个简单的例子来看MIDlet的生命周期
- 从一个加密程序来看安全漏洞的问题
- 从“绘制一个立方体”来看OpenGL的进化过程
- Android面试题整理-3
- 腾讯多元化战略特征
- javascript更换背景
- 人生的缓冲带
- sparkSQL用jdbc访问mysql
- 从一个小例子来看setInterval的使用
- HttpUtility.UrlDecode(),HttpUtility()escape()、encodeURI()、encodeURIComponent()区别详解以及相应的前台解码和.net后台解码
- Mongodb缓存的使用
- 总结学习 —— 前置定义
- ThreadLocal源码分析
- java泛型总结学习
- python csv文件读取reader
- Mysql常用sql(函数)
- CSS清除浮动大全共8种方法