...
|
...
|
@@ -153,14 +153,10 @@ Component({ |
|
|
},
|
|
|
|
|
|
creatProductDetailSnapShoot() {
|
|
|
|
|
|
var that = this;
|
|
|
const app = getApp() || {};
|
|
|
let userInfo = app.props.globalData.userInfo;
|
|
|
var product = that.properties.shareData;
|
|
|
|
|
|
console.log('====================================');
|
|
|
console.log(product);
|
|
|
console.log('====================================');
|
|
|
|
|
|
if(!product){
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -173,7 +169,7 @@ Component({ |
|
|
// console.log(windowWidth,screenHeight,snapWidth,snapHeight,scale)
|
|
|
let logoHeight = 50 * HScale;
|
|
|
let logoWidth = 50 * scale;
|
|
|
let logoTop = 40 * HScale;
|
|
|
let logoTop = 38 * HScale;
|
|
|
let logoMarginBottom = 25 * HScale;
|
|
|
let logoLeft = 30 * scale //logo左边坐标
|
|
|
|
...
|
...
|
@@ -196,27 +192,37 @@ Component({ |
|
|
let qrImgWH = 70 * scale
|
|
|
let qrCodeLeft = (snapWidth - qrImgWH)/2
|
|
|
|
|
|
let tipLeft = (snapWidth - 180 * scale)/2
|
|
|
let tipTop = qrCodeTop + qrImgWH + 20 * scale
|
|
|
|
|
|
const app = getApp() || {};
|
|
|
let userInfo = app.props.globalData.userInfo;
|
|
|
|
|
|
var pCtx = wx.createCanvasContext("productDetailCanvas", this);
|
|
|
pCtx.setFillStyle('white');
|
|
|
pCtx.fillRect(0, 0, snapWidth, snapHeight);
|
|
|
pCtx.setStrokeStyle('#e0e0e0');
|
|
|
|
|
|
/*---------开始新的作画-----------*/
|
|
|
//头像
|
|
|
pCtx.drawImage(userInfo.avatarUrl, logoLeft , logoTop, logoWidth, logoHeight)//画logo
|
|
|
pCtx.setFillStyle('#ffffff');
|
|
|
pCtx.setStrokeStyle('#e0e0e0')
|
|
|
// pCtx.arc(logoLeft+logoWidth/2, logoTop+logoHeight/2, logoWidth/2, 0, 2*Math.PI)
|
|
|
// this.circleImg(pCtx, userInfo.avatarUrl, logoLeft, logoTop, logoWidth)
|
|
|
//圆形头像
|
|
|
if (userInfo.avatarUrl) {
|
|
|
wx.getImageInfo({
|
|
|
src: userInfo.avatarUrl,
|
|
|
success:function(res){
|
|
|
pCtx.beginPath();
|
|
|
pCtx.arc(logoLeft+logoWidth/2, logoTop+logoHeight/2, logoWidth/2, 0, 2*Math.PI, false)
|
|
|
pCtx.stroke();//画空心圆
|
|
|
pCtx.closePath();
|
|
|
pCtx.save();
|
|
|
pCtx.clip(); //裁剪上面的圆形
|
|
|
pCtx.drawImage(res.path, logoLeft , logoTop, logoWidth, logoHeight)
|
|
|
pCtx.restore(); //恢复之前保存的绘图上下文,以便可以继续绘制
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
//昵称
|
|
|
if (userInfo.nickName) {
|
|
|
pCtx.setFillStyle('#000')
|
|
|
pCtx.setFontSize(20*scale)
|
|
|
pCtx.fillText(userInfo.nickName, nameLeft, nameTop)
|
|
|
}
|
|
|
|
|
|
pCtx.setFillStyle('#000')
|
|
|
pCtx.setFontSize(12*scale)
|
...
|
...
|
@@ -225,16 +231,12 @@ Component({ |
|
|
pCtx.strokeRect(imgContainerLeft, imgContainerTop, imgContainerWidth , imgtextContainerHeight)//图片容器
|
|
|
|
|
|
var defaultImage = getImgUrl(product.default_image, imgContainerWidth, imgContainerHeight);
|
|
|
if (defaultImage) {
|
|
|
if (defaultImage && defaultImage.indexOf("https://") == -1) {
|
|
|
defaultImage = defaultImage.replace('http://', 'https://');
|
|
|
}
|
|
|
product.default_image = defaultImage;
|
|
|
|
|
|
that.setData({
|
|
|
shareData: product,
|
|
|
userInfo
|
|
|
})
|
|
|
|
|
|
wx.getImageInfo({
|
|
|
src: defaultImage,
|
|
|
success:function(res){
|
...
|
...
|
@@ -246,7 +248,14 @@ Component({ |
|
|
pCtx.draw(true)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
that.setData({
|
|
|
shareData: product,
|
|
|
userInfo
|
|
|
})
|
|
|
|
|
|
if (product.product_qrCode) {
|
|
|
wx.getImageInfo({
|
|
|
src: product.product_qrCode,
|
|
|
success:function(res){
|
...
|
...
|
@@ -254,6 +263,7 @@ Component({ |
|
|
pCtx.draw(true)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
pCtx.setFillStyle('#999999')
|
|
|
pCtx.setFontSize(12*scale)
|
...
|
...
|
@@ -263,17 +273,7 @@ Component({ |
|
|
/*---------结束新的作画-----------*/
|
|
|
},
|
|
|
|
|
|
circleImg(ctx, img, x, y, r) {
|
|
|
ctx.save();
|
|
|
var d = 2 * r;
|
|
|
var cx = x + r;
|
|
|
var cy = y + r;
|
|
|
ctx.beginPath();
|
|
|
ctx.arc(cx, cy, r, 0, 2 * Math.PI);
|
|
|
ctx.clip();
|
|
|
ctx.drawImage(img, x, y, d, d);
|
|
|
},
|
|
|
|
|
|
//绘制商品名
|
|
|
drawLongText(longtext, cxt, begin_width, begin_height, color, fontSize, numsForLine,numberOfLine,
|
|
|
isCenter = true,lineL = 0) {
|
|
|
let linelenght = lineL;//行间距
|
...
|
...
|
|