|
|
|
|
@ -10,8 +10,8 @@
|
|
|
|
|
<script>
|
|
|
|
|
//二维码宽高
|
|
|
|
|
var qrcodewidth = 120;
|
|
|
|
|
var qrcodeheight = 120;
|
|
|
|
|
var qrcodeleft = 30;
|
|
|
|
|
var qrcodeheight = 120;
|
|
|
|
|
var qrcodeleft = 30;
|
|
|
|
|
var qrcodetop = 50;
|
|
|
|
|
//canvas宽高
|
|
|
|
|
var canvaswidth = 340;
|
|
|
|
|
@ -26,14 +26,14 @@
|
|
|
|
|
var logoleft = (qrcodewidth - logowidth) / 2;
|
|
|
|
|
var logotop = (qrcodeheight - logoheight) / 2;
|
|
|
|
|
$(function() {
|
|
|
|
|
var printObj = JSON.parse(getCookie('objs'))
|
|
|
|
|
$(".wrap").html("")
|
|
|
|
|
for(var i=0;i<printObj.length;i++){
|
|
|
|
|
var index = parseInt(i) +1
|
|
|
|
|
$(".wrap").append("<li id='page"+index+"' style='width: 9cm; height: 5cm;'>"+
|
|
|
|
|
// "<img src='' style='display: block;width:9cm; height:5cm;'>"+
|
|
|
|
|
"</li>")
|
|
|
|
|
createCode("#page"+index,printObj[i])
|
|
|
|
|
var printObj = JSON.parse(getCookie('objs'))
|
|
|
|
|
$(".wrap").html("")
|
|
|
|
|
for (var i = 0; i < printObj.length; i++) {
|
|
|
|
|
var index = parseInt(i) + 1
|
|
|
|
|
$(".wrap").append("<li id='page" + index + "' style='width: 9cm; height: 5cm;'>" +
|
|
|
|
|
// "<img src='' style='display: block;width:9cm; height:5cm;'>"+
|
|
|
|
|
"</li>")
|
|
|
|
|
createCode("#page" + index, printObj[i])
|
|
|
|
|
}
|
|
|
|
|
// createCode()
|
|
|
|
|
console.log(printObj)
|
|
|
|
|
@ -60,10 +60,10 @@
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function createCode(id,printObji) {
|
|
|
|
|
function createCode(id, printObji) {
|
|
|
|
|
var qrcode = $(id).qrcode({
|
|
|
|
|
render: 'canvas',
|
|
|
|
|
text: utf16to8(printObji['wuzibianma']+"-"+printObji['id']),
|
|
|
|
|
text: utf16to8(printObji['wuzibianma'] + "-" + printObji['id']),
|
|
|
|
|
width: qrcodewidth,
|
|
|
|
|
height: qrcodeheight,
|
|
|
|
|
background: '#ffffff',
|
|
|
|
|
@ -75,8 +75,8 @@
|
|
|
|
|
img.onload = function() {
|
|
|
|
|
canvas.width = canvaswidth;
|
|
|
|
|
canvas.height = canvasheight;
|
|
|
|
|
var ctx = canvas.getContext('2d');
|
|
|
|
|
|
|
|
|
|
var ctx = canvas.getContext('2d');
|
|
|
|
|
|
|
|
|
|
//设置文字样式
|
|
|
|
|
//设置画布背景
|
|
|
|
|
ctx.fillStyle = '#ffffff';
|
|
|
|
|
@ -85,23 +85,23 @@
|
|
|
|
|
ctx.fillStyle = '#000000';
|
|
|
|
|
ctx.font = 'bold ' + 16 + 'px Arial';
|
|
|
|
|
ctx.textAlign = 'center';
|
|
|
|
|
//文字描述
|
|
|
|
|
//文字描述
|
|
|
|
|
ctx.fillText("苏州河道处", 160, 30);
|
|
|
|
|
// ctx.fillText("资产名称:"+decodeURI(decodeURI(printObji['zichanmingcheng'])), qrcodeleft+180,80);
|
|
|
|
|
// ctx.fillText("物资类型:"+"123", qrcodeleft+180,110);
|
|
|
|
|
// ctx.fillText("资产名称:"+decodeURI(decodeURI(printObji['zichanmingcheng'])), qrcodeleft+180,80);
|
|
|
|
|
// ctx.fillText("物资类型:"+"123", qrcodeleft+180,110);
|
|
|
|
|
// ctx.fillText("入库数量:"+printObji['rukushuliang'], qrcodeleft+180,140);
|
|
|
|
|
//绘制二维码
|
|
|
|
|
//绘制二维码
|
|
|
|
|
|
|
|
|
|
ctx.drawImage(img, qrcodeleft,qrcodetop);
|
|
|
|
|
ctx.drawImage(img, qrcodeleft, qrcodetop);
|
|
|
|
|
// //设置logo
|
|
|
|
|
// var logo = new Image(logowidth, logoheight);
|
|
|
|
|
// logo.src = canvas;
|
|
|
|
|
// logo.onload = function() {
|
|
|
|
|
// ctx.drawImage(logo, logoleft, logotop, logowidth, logoheight);
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// img.src=canvas.toDataURL("image/png");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// img.src=canvas.toDataURL("image/png");
|
|
|
|
|
// $(id).children("img").attr("src",img.src)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -134,6 +134,22 @@
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function delCookie(name)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var exp = new Date();
|
|
|
|
|
|
|
|
|
|
exp.setTime(exp.getTime() - 1);
|
|
|
|
|
|
|
|
|
|
var cval = getCookie(name);
|
|
|
|
|
|
|
|
|
|
if (cval != null)
|
|
|
|
|
|
|
|
|
|
document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getCookie(cookieName) {
|
|
|
|
|
//获取所有的cookie "psw=1234we; rememberme=true; user=Annie"
|
|
|
|
|
var totalCookie = document.cookie;
|
|
|
|
|
@ -230,7 +246,7 @@
|
|
|
|
|
<ul class="wrap">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- <li id="page2" style="width: 9cm; height: 5cm;">
|
|
|
|
|
<!-- <li id="page2" style="width: 9cm; height: 5cm;">
|
|
|
|
|
<img src="/storage/temp/755_1.jpg" style=" display: block;width:9cm; height:5cm;">
|
|
|
|
|
</li>
|
|
|
|
|
<li id="page3" style="width: 9cm; height: 5cm;">
|
|
|
|
|
@ -258,4 +274,4 @@
|
|
|
|
|
codebase="jatoolsPrinter.cab#version=8,6,0,0">
|
|
|
|
|
</OBJECT>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|
|
|
|
|
</html>
|