天天看点

H5 嵌入条码和二维码生成

效果动画演示
H5 嵌入条码和二维码生成
 实现步骤

第一步:创建窗口“H5”

H5 嵌入条码和二维码生成

第二步:找到对应的H5处理页面(自己可以自行开发,或开发打印功能都可以的)

H5 嵌入条码和二维码生成

 Html5页面对应的页面代码如下:

<!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>
    <title>条码和二维码生成器</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="generator" content="pandoc" />
    <meta name="date" content="" />
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="jquery.qrcode.min.js"></script>
    <script type="text/javascript" src="jquery.qrcode.js"></script>
    <script type="text/javascript" src="qrcode.js"></script>
    <script type="text/javascript" src="JsBarcode.all.min.js"></script>
</head>
<body style="overflow:hidden;">
    <p></p>
    <div style="width:90%; text-align:center;">
        <img id="qrcodeTiaoMa" style="width:400px;" />
    </div>
    <p></p>
    <div style="width:90%; text-align:center;">
        <div id="qrcodeTable" style="margin:0 auto; width:260px;"></div>
    </div>
    <script type="text/javascript">
window.onload = function () {
    var codeValue = "9780199532179";
    codeValue = getUrlParam("code");
    if (codeValue == null || codeValue.length <= 0) { codeValue = "0000000000000" }
    createCode(codeValue);

}
function createCode(codeValue) {
    //生成条码
    JsBarcode("#qrcodeTiaoMa", codeValue, {
        displayValue: false,
        fontSize: 100
    });
    //生成二维码
    jQuery('#qrcodeTable').qrcode({
        render: "table",
        text: codeValue
    });
}
//获取url中的参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r != null) return unescape(r[2]); return null; //返回参数值
}
    </script>
</body>
</html>
           

第三步:在窗体打开的时候,加载 Web浏览器 对应的 条码生成h5

H5 嵌入条码和二维码生成
Dim h5Path,codeValue
h5Path="file:///"&Sys.ProjectDir &"\H5CreateCode\index.html"
codeValue=文本框0.Text
If Len(codeValue)<=0 then
    Exit Sub
End If
h5Path=h5Path&"?code="&codeValue
Web浏览器0.Url=h5Path
Web浏览器0.print()           

 第四步:生成按钮的事件代码

Dim h5Path,codeValue
h5Path="file:///"&Sys.ProjectDir &"\H5CreateCode\index.html"
codeValue=文本框0.Text
If Len(codeValue)<=0 then
    MsgBox "请输入要生成的条码内容!"
    Exit Sub
End If
h5Path=h5Path&"?code="&codeValue
Web浏览器0.Url=h5Path
Web浏览器0.print()           
上一篇: 第五章心得
下一篇: 第四章心得

继续阅读