字体:
font-family:Monospaced Number,Chinese Quote,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif!important;
// 条形码,二维码
var barcode = require('./barcode');
function convert_length(length) {
return Math.round(wx.getSystemInfoSync().windowWidth * length / 750);
}
function barc(id, code, width, height) {
barcode.code128(wx.createCanvasContext(id), code, convert_length(width), convert_length(height))
}
var qrcode = require('./qrcode');
function qrc(id, code, width, height) {
qrcode.api.draw(code, {
ctx: wx.createCanvasContext(id),
width: convert_length(width),
height: convert_length(height),
margin: 0
})
}
module.exports = {
barcode: barc,
qrcode: qrc
}
// 单位rpx
barcode('id', code, 500, 200);
qrcode('id', code, 200, 200);
网友评论