drawP: function (bgimg) {
var than = this ;
canvasOb = wx.createCanvasContext( "canvasId" , this );
than.roundRect(canvasOb, 0, 0, than.data.canvasInfo.w, than.data.canvasInfo.h, 10);
canvasOb.draw();
canvasOb.drawImage(bgimg, 0, 0, than.data.canvasInfo.w, than.data.canvasInfo.h);
var proImg = than.data.shareData.productInfo.images[0];
var proImgWH = appinit.getQuery(proImg, 'image' );
if (proImgWH != null ) {
var wh_arr = proImgWH.split( ',' );
var arr_w = Number(wh_arr[0]);
var arr_h = Number(wh_arr[1]);
if (arr_w != arr_h) {
var strs = '' ;
if (arr_w > arr_h) {
strs = '&x-oss-process=image/crop,w_' + arr_h + ',h_' + arr_h + ',g_center' ;
} else {
strs = '&x-oss-process=image/crop,w_' + arr_w + ',h_' + arr_w + ',g_center' ;
}
proImg = proImg + '' + strs;
}
}
wx.getImageInfo({
src: proImg,
success(res) {
var imgw = than.data.canvasInfo.w;
var imgh = imgw;
canvasOb.drawImage(res.path, 0, 0, imgw, imgw);
canvasOb.save();
var nameX = than.data.canvasInfo.w * 0.05;
var nameY = than.data.canvasInfo.h * 0.72;
let details = {
x: nameX,
y: nameY,
width: than.data.canvasInfo.w - (nameX * 2),
height: 20,
line: 2,
color: '#1A1A1A' ,
size: 11,
align: 'left' ,
text: than.data.shareData.productInfo.title,
bold: true
}
than.textWrap(details);
var ggy = than.data.shareType == "productdetail" ? "为您推荐一款精选好货~" : "为您送来一张免费抽奖券~" ;
let bannerInfo = {
x: than.data.canvasInfo.w * 0.21,
y: than.data.canvasInfo.h * 0.961,
width: than.data.canvasInfo.w * 0.5,
height: 20,
line: 1,
color: '#939393' ,
size: 10,
align: 'left' ,
text: ggy,
bold: false
}
than.textWrap(bannerInfo);
let text1 = {
x: than.data.canvasInfo.w * 0.685,
y: than.data.canvasInfo.h * 0.963,
width: than.data.canvasInfo.w * 0.4,
height: 20,
line: 1,
color: '#1A1A1A' ,
size: 10,
align: 'left' ,
text: '长按识别二维码' ,
bold: true ,
boldW:0.2
}
than.textWrap(text1);
wx.getImageInfo({
src: than.data.qrCodeImg,
success(res) {
var ewmX = than.data.canvasInfo.w * 0.7;
var ewmY = than.data.canvasInfo.h * 0.75;
var ewmW = than.data.canvasInfo.w * 0.26;
canvasOb.drawImage(res.path, ewmX, ewmY, ewmW, ewmW);
canvasOb.save();
let nicknameInfo = {
x: than.data.canvasInfo.w * 0.21,
y: than.data.canvasInfo.h * 0.921,
width: than.data.canvasInfo.w * 0.5,
height: 20,
line: 1,
color: '#1A1A1A' ,
size: 11,
align: 'left' ,
text: appinit.appData.userInfo.nickname,
bold: true
}
than.textWrap(nicknameInfo);
wx.getImageInfo({
src: appinit.appData.userInfo.headimg,
success(res) {
var headImgw = than.data.canvasInfo.w * 0.13;
var headImgh = headImgw;
var haedx = than.data.canvasInfo.w * 0.05;
var haedy = than.data.canvasInfo.h * 0.89;
canvasOb.setStrokeStyle( 'rgba(255,255,255,1)' )
var touxB = headImgw / 2;
canvasOb.arc(haedx + touxB, haedy + touxB, touxB, 0, 2 * Math.PI)
canvasOb.stroke()
canvasOb.clip();
canvasOb.drawImage(res.path, haedx, haedy, headImgw, headImgh);
canvasOb.restore();
canvasOb.save();
canvasOb.draw();
than.setData({
canvasShow: true
})
}
})
}
})
}
})
},
|
你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)