二期项目中生成的简历二维码是使用canvs生成的,微信浏览器中不能识别二维码,只能扫码。懒的换phpqrcode,于是转canvs。
//设置一个url
var url = "{yun:}$config.sy_weburl{/yun}/mingli/index.php?c=member&a=resume_preview&uid={yun:}$resumeInfo.uid{/yun}&type=scan";
//利用jquery.qrcode.js生成url对应的canvs对象
var qrcode=jQuery('#code').qrcode({
width: 160,
height:160,
text : url
});
//获取页面中的canvs对象
var canvas=qrcode.find('canvas').get(0);
//转canvs对象为base64
console.log(canvas.toDataURL('image/jpg'));