动态二维码

动态二维码的生成和调用方法

直接上代码
封装好的code方法

    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;   
}  
//用的时候直接调用该方法
var _storeId = id;
    var str = 路径 +_storeId + 参数
	str = toUtf8(str);
	//平台二维码
	$("#code").qrcode({
		render: "canvas",
		width: 90,
		height:90,
		correctLevel: QRErrorCorrectLevel.H,//纠错等级
		text: str
	});
});

猜你喜欢

转载自blog.csdn.net/abc_26zm/article/details/87981693
今日推荐