Brak opisu

seeEqupQRcode.html 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>二维码打印</title>
  6. <style media="all">
  7. .codeBox {
  8. /*width: 500px!important;*/
  9. margin: 0 auto!important;
  10. -webkit-print-color-adjust: exact;
  11. color: #000;
  12. }
  13. div.wrapper-content{
  14. padding-top: 8px;
  15. }
  16. @media print {
  17. .codeBox {
  18. -webkit-print-color-adjust: exact;
  19. }
  20. #codeHtml {
  21. z-index: 9999999;
  22. position: relative;
  23. }
  24. }
  25. </style>
  26. </head>
  27. <body class="gray-bg">
  28. <div class="wrapper-content animated fadeInRight">
  29. <input type="hidden" id="qrCode" />
  30. <!--startprint-->
  31. <div class="codeBox" style="margin: 0 auto; padding-bottom: 20px; width: 360px; height: 180px;">
  32. <div style="display: inline-block; margin-top: 10px;margin-left: 28px;vertical-align: middle;">
  33. <img src='../../img/equp-logo.png' class="logo_img" style="width: 112px; height: 94px;margin: 0;padding: 0; display: none;">
  34. <p style="font-size: 14px;margin-top: 22px;margin-bottom: 0;color: #000;font-family: '微软雅黑';text-align: center;">微信[扫一扫]</p>
  35. <p style="font-size: 14px;margin-top: 5px;margin-bottom: 0;color: #000;font-family: '微软雅黑';text-align: center;">获取设备信息</p>
  36. </div>
  37. <div style="display: inline-block; margin-top: 0px; margin-left: 46px; vertical-align: middle;">
  38. <p class="eq_code_con" style="font-size: 14px;color: #000;text-align: left;margin-bottom: 5px;">设备编号:<span id="eq_code" style="display: inline-block;width:76px;border-bottom: 2px solid #000; padding: 0 1px;text-align: center;margin-bottom: -5px;"></span></p>
  39. <div id="codeHtml" style="z-index: 9999999;position: relative;">
  40. <div id="code"></div>
  41. </div>
  42. </div>
  43. </div>
  44. <!--endprint-->
  45. <p style="text-align: center;margin-top: 25px;"><button class="btns" id="print" onclick="stamp()">打印二维码</button></p>
  46. </div>
  47. <link rel="stylesheet" href="../../css/init.css" />
  48. <link rel="stylesheet" href="../../css/Table/table1.css" />
  49. <script src="../../Script/Common/huayi.load.js"></script>
  50. <script src="../../Script/Common/huayi.config.js"></script>
  51. <script src="../js/qrcode.min.js"></script>
  52. <script>
  53. var ids= helper.request.queryString("ids");
  54. $('#eq_code').text(ids);
  55. var qrUrl="http://wechat.nuodajituan.com/index.html?menucode=SBXX&id="+ids+"&type=2";//设备
  56. $('#qrCode').val(qrUrl);
  57. $(document).ready(function(){
  58. makeCode ();
  59. })
  60. $("#codeHtml").html('<div id="code"></div>');
  61. var qrcode = new QRCode(document.getElementById("code"), {
  62. render: 'canva',
  63. width: 146, //宽度
  64. height: 146, //高度
  65. text: toUtf8(name) //任意内容 :中文存在乱码,需要转换编码
  66. })
  67. function toUtf8(str) {
  68. var out, i, len, c;
  69. out = "";
  70. len = str.length;
  71. for(i = 0; i < len; i++) {
  72. c = str.charCodeAt(i);
  73. if ((c >= 0x0001) && (c <= 0x007F)) {
  74. out += str.charAt(i);
  75. } else if (c > 0x07FF) {
  76. out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
  77. out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
  78. out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
  79. } else {
  80. out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
  81. out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
  82. }
  83. }
  84. return out;
  85. }
  86. function makeCode () {
  87. var elText = document.getElementById("qrCode");
  88. if (!elText.value) {
  89. elText.focus();
  90. return;
  91. }
  92. qrcode.makeCode(elText.value);
  93. var canvas = $('#code canvas')
  94. var img = canvas[0].toDataURL("image/png")
  95. $('#code').html("<img src='" + img + "'>")
  96. }
  97. function stamp(){
  98. var bdhtml = window.document.body.innerHTML;
  99. var sprnstr = "<!--startprint-->";
  100. var eprnstr = "<!--endprint-->";
  101. var prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);
  102. prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr));
  103. var newWindow=window.open("打印二维码","_self");
  104. newWindow.document.write(prnhtml);
  105. // newWindow.document.close();
  106. // setTimeout(function(){
  107. newWindow.print();
  108. newWindow.close();
  109. // newWindow.document.body.innerHTML=bdhtml;
  110. // }, 10);
  111. var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  112. parent.layer.close(index); //再执行关闭
  113. }
  114. </script>
  115. </body>
  116. </html>