微信電子健康卡——獲取健康卡二維碼接口

靜態二維碼

通過調用barcodeJs生成二維碼

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wechatFrm.aspx.cs" Inherits="HealthCardSDKWeb.wechatFrm" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>我的二維碼</title>
    <link href="../View/ViewForm/css/font-awesome.min.css" rel="stylesheet" />
    <link href="../View/ViewForm/css/index.css" rel="stylesheet" />
    <link href="../View/ViewForm/TcCss/index.css" rel="stylesheet" />
    <script src="js/base.js"></script>



    <script src="barcodeJS/jquery-1.3.2.js"></script>
    <script src="barcodeJS/jquery-barcode.js"></script>
    <script src="barcodeJS/jquery.barcode.0.3.js"></script>
    <script src="barcodeJS/jquery.qrcode.min.js"></script>
        <script type="text/javascript">
            function toUtf8(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;
            }


            $(document).ready(function () {
                generateC39 = function () {
                    $('.barcode39').barcode({ code: 'code39' });
                };
                generateI25 = function () {
                    $('.barcodeI25').barcode({ code: 'I25' });
                };

            }
            );

            window.onload = function () {
                if ($("#mytxt").val() != "") {
                    PrintBarcode();
                }
            }

            function PrintBarcode() {
                var barcodeValue = $("#mytxt").val();
                if (barcodeValue == "") {
                    alert("請輸入條形碼內容");
                    return;
                }
                //隱藏域保存獲取的條形碼
                //$("#hidBarcode").html(barcodeValue);
                //$("#hidBarcode").barcode({ code: 'code39' });

                //$("#hidBarcode").empty().barcode(barcodeValue, "code128", { barWidth: 1, barHeight: 80, showHRI: false });

                ///二維碼
                $("#code").empty();
                var str = toUtf8($("#mytxt").val());

                $("#code").qrcode({
                    render: "table",
                    width: 200,
                    height: 200,
                    text: str
                });

                //打印的內容
                //var prnhtml = "<div style='height:20mm;border:0px solid black; text-align:center; /*width:100mm; */'>";
                //prnhtml += "<div id='imgBarcode' style='margin:3px 2px 0px;'>" + document.getElementById("hidBarcode").outerHTML; + "</div>";
                //prnhtml += "<div id='valBarcode' style='height:10px;font-size:10px;letter-spacing:2px;text-align: center;'>" + barcodeValue + "</div>";
                //prnhtml += "</div>";

                //bdhtml = window.document.body.innerHTML;//獲取當前頁的html代碼 
                //window.document.body.innerHTML = prnhtml;
                ////window.print();
                //window.document.body.innerHTML = bdhtml;

                //$("#divShow").html(prnhtml);
            }
    </script>

     <style type="text/css">
        .mask {
            position: absolute;
            top: 0px;
            filter: alpha(opacity=60);
            background-color: #777;
            z-index: 1002;
            left: 0px;
            opacity: 0.5;
            -moz-opacity: 0.5;
        }
    </style>
    <script type="text/javascript">
        function msgbox(title, content, cancel) {
            $("#ts").show();
            var temp = "<div id=\"mask\" class=\"mask\"></div><div class=\"con-out\"><div class=\"con-header\">" + title + "</div><div class=\"con-body  text-center\">" + content + "</div><div class=\"con-foot text-right\"><div class=\"container-fluid text-center\">";
            if (cancel != '1') {
                alert(cancel);
                temp += "<button class=\"btn1 btn-w2\" onclick=\"qx();\">取消</button>&nbsp;&nbsp;";
            }
            temp += "<button class=\"btn1 btn-w2\" onclick=\"qr();\">確認</button></div></div></div>";
            $("#ts").html(temp);
            showMask();
        }

        function qx() {
            $("#ts").hide();
        }
        function qr() {
            $("#ts").hide();
            //alert("點擊確認按鈕");
        }

        function showMask() {
            $("#mask").css("height", $(document).height());
            $("#mask").css("width", $(document).width());
            $("#mask").show();
        }
        //隱藏遮罩層  
        function hideMask() {

            $("#mask").hide();
        }
</script>
</head>
<body>
    <div id="body3">
        <div class="main-wrap px-24">
            <form class="form" runat="server">
                <div class="form-group" style="margin-top:0.2rem; display:none; ">
                    <label for="person">請輸入內容生成條形碼</label>
                    <input type="text" class="form-control" id="mytxt" placeholder="請輸入內容然後提交生成條形碼或者二維碼" runat="server" value="56656569FCAC6D78FC04BC0A4F75D96ABD8E16E77666639ABE66564EC0E6B623:1">
                </div>
               <%-- <button type="submit" class="linkbtn mt20" onclick="PrintBarcode()" >生成條形碼和二維碼</button>--%>
                <div class="main-wrap">
                <div class="card-wrap">
                    <div class="card-title">我的二維碼</div>
                </div>
                </div>
                <div class="form-group">
                   <div id="main" style="text-align: center; margin-top:0.3rem;">
                    <div class="demo">
                        <div id="code" style="margin-left: 21%; margin-top: 0.3rem;"></div>
                         <div style="margin-top:0.3rem">注:此二維碼用於醫院消費</div>
                    </div>
                   </div>
                </div>
                <div class="kk" id="ts"></div>
            </form>
        </div>

    </div>
</body>
</html>


動態二維碼

        /// <summary>
        /// 獲取動態健康卡二維碼接口
        /// </summary>
        /// <returns></returns>

        public string Lx_GetDynamicQRCode()
        {
            var result = proxy.GetDynamicQRCode(
               new GetDynamicQRCodeReq
               {
                   healthCardId = "56656569FCAC6D78FC04BC0A4F75D96ABD8E16E77666639ABE66564EC0E6B623",
                   idType = "01",
                   idNumber = "410221198908203453",
                   codeType = 0
               },
               new com.tencent.healthcard.HealthCardOpenAPI.CommonIn
               {
                   requestId = System.Guid.NewGuid().ToString(),
                   hospitalId = LxAppConfig.GetHospitalId(),
                   appToken = appToken
               }
               );
            var commonOut = (com.tencent.healthcard.HealthCardOpenAPI.CommonOut)result["commonOut"];
            var rsp = (GetDynamicQRCodeRsp)result["rsp"];
            return JsonConvert.SerializeObject(rsp);
        
        }

獲取base64位顯示頁面

  <img src="data:image/png;base64,base64代碼" />

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章