微信小程序

字体:

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); 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。