|
@@ -40,7 +40,7 @@ Page({
|
|
|
height: 132
|
|
|
},
|
|
|
rpx: 1,
|
|
|
- obverseImgObject:['', '/customized/images/customized/cup_black_big.png', '/customized/images/customized/cup_black_side.png', '/customized/images/customized/cup_black_handle.png', '/customized/images/customized/cup_black_bottom.png'],
|
|
|
+ obverseImgObject: ['', '/customized/images/customized/cup_black_big.png', '/customized/images/customized/cup_black_side.png', '/customized/images/customized/cup_black_handle.png', '/customized/images/customized/cup_black_bottom.png', '/customized/images/customized/box_white_big_1.png', '/customized/images/customized/box_white_big_2.png'],
|
|
|
// obverseImgObject: {
|
|
|
// '1': ,
|
|
|
// /*正面 */
|
|
@@ -54,9 +54,7 @@ Page({
|
|
|
imgSrcArray: [],
|
|
|
buildSrcArrayText:{
|
|
|
'1':'正面',
|
|
|
- '2':'侧面',
|
|
|
- '3':'手柄',
|
|
|
- '4':'底部',
|
|
|
+ '2':'背面',
|
|
|
},
|
|
|
buildSrcArray: [],
|
|
|
customGoodsImg:"",
|
|
@@ -67,19 +65,6 @@ Page({
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
-
|
|
|
- // if (wx.getStorageSync('madeCupImgData1')) {
|
|
|
- // this.setData({
|
|
|
- // imgTouch: wx.getStorageSync('madeCupImgData1')
|
|
|
- // })
|
|
|
- // }
|
|
|
- // if (wx.getStorageSync('madeCupFontData1')) {
|
|
|
- // this.setData({
|
|
|
- // fontTouch: wx.getStorageSync('madeCupFontData1')
|
|
|
- // })
|
|
|
- // }
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -91,24 +76,12 @@ Page({
|
|
|
title: '图片合成中...'
|
|
|
})
|
|
|
let that = this, result = true;
|
|
|
- // for (let i = 1; i <= 4; i++) {
|
|
|
- // if (wx.getStorageSync('madeCupImgData' + i) || wx.getStorageSync('madeCupFontData' + i)) {
|
|
|
- // console.log(i, "iiiii")
|
|
|
- // that.getCombImg(that, i);
|
|
|
- // }
|
|
|
- // }
|
|
|
|
|
|
- if (wx.getStorageSync('madeCupImgData1') || wx.getStorageSync('madeCupFontData1')) {
|
|
|
- that.getCombImg(that, 1);
|
|
|
- result = false
|
|
|
- } else if (wx.getStorageSync('madeCupImgData2') || wx.getStorageSync('madeCupFontData2')) {
|
|
|
- that.getCombImg(that, 2);
|
|
|
- result = false
|
|
|
- } else if (wx.getStorageSync('madeCupImgData3') || wx.getStorageSync('madeCupFontData3')) {
|
|
|
- that.getCombImg(that, 3);
|
|
|
+ if (wx.getStorageSync('madeCupImgData5') || wx.getStorageSync('madeCupFontData5')) {
|
|
|
+ that.getCombImg(that, 5);
|
|
|
result = false
|
|
|
- } else if (wx.getStorageSync('madeCupImgData4') || wx.getStorageSync('madeCupFontData4')) {
|
|
|
- that.getCombImg(that, 4);
|
|
|
+ } else if (wx.getStorageSync('madeCupImgData6') || wx.getStorageSync('madeCupFontData6')) {
|
|
|
+ that.getCombImg(that, 6);
|
|
|
result = false
|
|
|
}
|
|
|
|
|
@@ -239,27 +212,12 @@ Page({
|
|
|
ctx.fillText(fontTouch.fontContent, 0, simulationFont.height / 5 * 4 + 1)
|
|
|
}
|
|
|
ctx.restore()
|
|
|
- // ctx.font = `'bold' ${fontTouch.fontSize} ${fontTouch.isColor} 'sans-serif'`;
|
|
|
- // const metrics = ctx.measureText(fontTouch.fontContent)
|
|
|
- // let movex = fontTouch.x + metrics.width / 2;
|
|
|
- // let movey = fontTouch.y + simulationFont.height / 2;
|
|
|
- // ctx.translate(movex, movey);
|
|
|
- // ctx.rotate(fontTouch.angle * Math.PI / 180);
|
|
|
- // ctx.fillText(fontTouch.fontContent, -metrics.width / 2, -simulationFont.height / 2 + simulationFont.height / 5 * 4);
|
|
|
- // ctx.fillText(fontTouch.fontContent, 0, simulationFont.height / 5 * 4)
|
|
|
ctx.draw(false,function () {
|
|
|
wx.canvasToTempFilePath({
|
|
|
canvasId: 'comb-font'+i,
|
|
|
success: function (res) {
|
|
|
console.log(res)
|
|
|
that.getCombFontImg(that, res.tempFilePath, fontTouch,i)
|
|
|
- // let imgArray = that.data.imgSrcArray;
|
|
|
- // imgArray.push(res.tempFilePath)
|
|
|
- // that.setData({
|
|
|
- // imgSrcArray: imgArray
|
|
|
- // })
|
|
|
- // console.log(that.data.imgSrcArray, "that.data.imgSrcArray")
|
|
|
- // that.getComb(that, that.data.imgSrcArray,i,true)
|
|
|
}
|
|
|
}, that)
|
|
|
})
|
|
@@ -280,11 +238,11 @@ Page({
|
|
|
// canvas截图区域与图片的宽度比例
|
|
|
const ctx = wx.createCanvasContext('comb-font' + i + '-2');
|
|
|
//画布中点坐标转移到图片中心
|
|
|
- let movex = fontTouch.x + 218 * rpx / 2;
|
|
|
- let movey = fontTouch.y + 218 * rpx / 2;
|
|
|
+ let movex = fontTouch.x + 536 * rpx / 2;
|
|
|
+ let movey = fontTouch.y + 712 * rpx / 2;
|
|
|
ctx.translate(movex, movey);
|
|
|
ctx.rotate(fontTouch.angle * Math.PI / 180);
|
|
|
- ctx.drawImage(img, -218 * rpx / 2, -218 * rpx / 2, 218 * rpx, 218 * rpx)
|
|
|
+ ctx.drawImage(img, -536 * rpx / 2, -712 * rpx / 2, 536 * rpx, 712 * rpx)
|
|
|
ctx.draw(false, function () {
|
|
|
wx.canvasToTempFilePath({
|
|
|
canvasId: 'comb-font' + i + '-2',
|
|
@@ -316,7 +274,7 @@ Page({
|
|
|
rpx: rpx
|
|
|
});
|
|
|
const ctx = wx.createCanvasContext('comb-canvas' + i);
|
|
|
- ctx.drawImage(canvasBg, 0, 0, 750 * rpx, 588 * rpx);
|
|
|
+ ctx.drawImage(canvasBg, 0, 0, 750 * rpx, 800 * rpx);
|
|
|
// 设置背景
|
|
|
ctx.draw(true)
|
|
|
imgSrcArray.forEach((res) => {
|
|
@@ -339,7 +297,7 @@ Page({
|
|
|
buildSrcArray: buildSrcArray,
|
|
|
})
|
|
|
console.log(that.data.buildSrcArray, "buildSrcArray")
|
|
|
- if (i < 4) {
|
|
|
+ if (i < 7) {
|
|
|
i = i + 1
|
|
|
that.getCombImg(that, i);
|
|
|
} else {
|