获取验证码,倒计时

Continue Read..
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script type="text/javascript" src="js/jquery.js"></script> </head> <body> <input type="button" id="btn" value="免费获取验证码" onclick="settime(this)" /> <script type="text/javascript"> var countdown=60; function settime(val) { if (countdown == 0) { 
val.removeAttribute("disabled");    
val.value="免费获取验证码"; 
countdown = 60; 
} else { 
val.setAttribute("disabled", true); 
val.value="重新发送(" + countdown + ")"; 
countdown--; 
} 
setTimeout(function() { 
settime(val) 
},1000) 
} </script> </body> </html> 

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

二维码生成

Continue Read..

1:

<script type="text/javascript" src="../js/jQuery-1.11.3.min.js"></script>

<script src="../js/jquery.cookie.js"></script>

<script src="../js/jquery.qrcode.min.js" type="text/javascript"></script>

<div id="div_div" style="width:200px;height:200px;margin:35px auto 0 auto;"></div>

<script type="text/javascript"> 

$(function () {

var orderVO = sessionStorage.getItem("orderVO");//取回students变量  

orderVO = JSON.parse(orderVO);//把字符串转换成JSON对象

if(orderVO){

var recordCode=orderVO.recordCode;

if(recordCode){

$("#div_div").qrcode(utf16to8(recordCode));

}

else{

$("#div_div").qrcode(utf16to8(""));

}

}); 

function utf16to8(str) { //转码 

var out, i, len, c; 

out = ""; 

len = str.length; 

for (i = 0; i < len; i++) { 

c = str.charCodeAt(i); 

if ((c >= 0x0001) && (c <= 0x007F)) { 

out += str.charAt(i); 

} else if (c > 0x07FF) { 

out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F)); 

out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F)); 

out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); 

} else { 

out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F)); 

out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)); 

return out; 

</script> 

 

2.

jquery:'http://cdn.bootcss.com/jquery/1.11.1/jquery.min',qrcode:'common/qrcode'

<div class="code" id="ewmCode"></div>

var qrcode = new QRCode(document.getElementById("ewmCode"));qrcode.makeCode(res.data.unionid_wx);


声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权

日期相关方法

Continue Read..
function numStr(num) {
    var numStr = '';
    if(num < 10) {
        numStr = '0'+num;
    }else {
        numStr = num;
    }
    return numStr; }function DateFormat(date){
    var year = date.getFullYear();
    var mouth = numStr(date.getMonth()+1);
    var currentDay = numStr(date.getDate());
    var dateStr = year+'-'+mouth+'-'+currentDay;
    return dateStr;
}function splitDate(dateStr) {
    var newStr = '';

    var indexNum = dateStr.indexOf('-');
    if(dateStr.indexOf('-')!= -1) {
        newStr = dateStr.substring(indexNum+1);
    }
    return newStr;
}

声明:此文系舞林cuznwww.wulinlw.org)原创稿件,转载请保留版权