|
@@ -39,7 +39,7 @@ Page({
|
|
|
imageArray: [], //请求数据后的图片列表
|
|
|
imageId: null, // 用户选中图片的id
|
|
|
imageSrc: null, // 选中图片后的路径
|
|
|
- touch: {
|
|
|
+ imgTouch: {
|
|
|
isActive: '1', // 1表示是正面
|
|
|
src: null,
|
|
|
x: 0,
|
|
@@ -50,7 +50,9 @@ Page({
|
|
|
height: null,
|
|
|
scale: 1, // 图片宽高比例
|
|
|
angle: 0, // 旋转度数
|
|
|
- }
|
|
|
+ },
|
|
|
+ fontTouch:{},//文字对象
|
|
|
+ fontAnimationData:{},
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -61,13 +63,16 @@ Page({
|
|
|
that.animation = wx.createAnimation({
|
|
|
timingFunction: 'step-start', // "linear","ease","ease-in","ease-in-out","ease-out","step-start","step-end"
|
|
|
})
|
|
|
+ that.fontAnimation = wx.createAnimation({
|
|
|
+ timingFunction: 'step-start', // "linear","ease","ease-in","ease-in-out","ease-out","step-start","step-end"
|
|
|
+ })
|
|
|
if ('id' in options) {
|
|
|
let cupNum = util.changeCup(options.id);
|
|
|
let madeTouchImg = wx.getStorageSync('madeCupImgData' + options.id);
|
|
|
if (madeTouchImg) {
|
|
|
that.animation.rotate(madeTouchImg.angle).step();
|
|
|
that.setData({
|
|
|
- touch: madeTouchImg,
|
|
|
+ imgTouch: madeTouchImg,
|
|
|
animationData: this.animation.export(),
|
|
|
dataPositionObj: cupNum.dataPositionObj,
|
|
|
propSize: cupNum.propSize,
|
|
@@ -75,12 +80,12 @@ Page({
|
|
|
});
|
|
|
} else {
|
|
|
that.setData({
|
|
|
- 'touch.isActive': options.id,
|
|
|
+ 'imgTouch.isActive': options.id,
|
|
|
dataPositionObj: cupNum.dataPositionObj,
|
|
|
propSize: cupNum.propSize
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|
|
@@ -94,14 +99,16 @@ Page({
|
|
|
that.setData({
|
|
|
host: host,
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
- this.getImgList();
|
|
|
+ let that = this;
|
|
|
+ that.getImgList();
|
|
|
+ that.getDataTouch(that)
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -138,20 +145,27 @@ Page({
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
},
|
|
|
+ touchstart(e){
|
|
|
+ this.fontTouchstart(e)
|
|
|
+ },
|
|
|
+ touchmove(e){
|
|
|
+ this.fontTouchmove(e)
|
|
|
+ },
|
|
|
// touch 事件
|
|
|
fontTouchstart(e) {
|
|
|
//1.获取鼠标点击下去的
|
|
|
+
|
|
|
this.setData({
|
|
|
- "touch.clientX": e.touches[0].clientX - this.data.touch.x,
|
|
|
- "touch.clientY": e.touches[0].clientY - this.data.touch.y
|
|
|
+ "imgTouch.clientX": e.touches[0].clientX - this.data.imgTouch.x,
|
|
|
+ "imgTouch.clientY": e.touches[0].clientY - this.data.imgTouch.y
|
|
|
});
|
|
|
- console.log(this.data.touch, "touch")
|
|
|
+ console.log(this.data.imgTouch, "touch")
|
|
|
},
|
|
|
fontTouchmove(e) {
|
|
|
// 鼠标移动的位置
|
|
|
this.setData({
|
|
|
- "touch.x": e.changedTouches[0].clientX - this.data.touch.clientX,
|
|
|
- "touch.y": e.changedTouches[0].clientY - this.data.touch.clientY
|
|
|
+ "imgTouch.x": e.changedTouches[0].clientX - this.data.imgTouch.clientX,
|
|
|
+ "imgTouch.y": e.changedTouches[0].clientY - this.data.imgTouch.clientY
|
|
|
});
|
|
|
|
|
|
// console.log(this.data.touch)
|
|
@@ -159,7 +173,7 @@ Page({
|
|
|
imgDelete() { // 图片删除
|
|
|
let that = this;
|
|
|
that.setData({
|
|
|
- 'touch.src': null,
|
|
|
+ 'imgTouch.src': null,
|
|
|
madeStatic: false, // 表示已经有图片
|
|
|
})
|
|
|
},
|
|
@@ -167,15 +181,15 @@ Page({
|
|
|
let that = this;
|
|
|
console.log(e.detail.value, 'eee')
|
|
|
that.setData({
|
|
|
- 'touch.width': e.detail.value,
|
|
|
- 'touch.height': e.detail.value / that.data.touch.scale
|
|
|
+ 'imgTouch.width': e.detail.value,
|
|
|
+ 'imgTouch.height': e.detail.value / that.data.imgTouch.scale
|
|
|
})
|
|
|
},
|
|
|
imgRotate(e) { // 旋转
|
|
|
this.animation.rotate(e.detail.value).step();
|
|
|
this.setData({
|
|
|
animationData: this.animation.export(),
|
|
|
- 'touch.angle': e.detail.value
|
|
|
+ 'imgTouch.angle': e.detail.value
|
|
|
})
|
|
|
},
|
|
|
getImgList() { // 根据userid 获取图片列表
|
|
@@ -189,7 +203,7 @@ Page({
|
|
|
url: host + '/queryImgListByPlaceIdAndGoodsId',
|
|
|
data: {
|
|
|
customGoodsId: 1, // 商品id
|
|
|
- customGoodsImgPlaceId: that.data.touch.isActive * 1 - 1
|
|
|
+ customGoodsImgPlaceId: that.data.imgTouch.isActive * 1 - 1
|
|
|
},
|
|
|
type: 'get',
|
|
|
success(res) {
|
|
@@ -243,11 +257,11 @@ Page({
|
|
|
success: function (res) {
|
|
|
console.log(res, "fff")
|
|
|
that.setData({
|
|
|
- 'touch.width': that.data.dataPositionObj.width,
|
|
|
- 'touch.height': res.height * that.data.dataPositionObj.width / res.width,
|
|
|
- 'touch.scale': res.width / res.height, // 宽高比例
|
|
|
+ 'imgTouch.width': that.data.dataPositionObj.width,
|
|
|
+ 'imgTouch.height': res.height * that.data.dataPositionObj.width / res.width,
|
|
|
+ 'imgTouch.scale': res.width / res.height, // 宽高比例
|
|
|
})
|
|
|
- console.log(that.data.touch)
|
|
|
+ console.log(that.data.imgTouch)
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -255,7 +269,7 @@ Page({
|
|
|
let that = this;
|
|
|
if (that.data.imageSrc) {
|
|
|
that.setData({
|
|
|
- 'touch.src': that.data.imageSrc,
|
|
|
+ 'imgTouch.src': that.data.imageSrc,
|
|
|
madeStatic: true, // 表示已经有图片
|
|
|
})
|
|
|
that.getScale(that, that.data.imageSrc)
|
|
@@ -269,7 +283,7 @@ Page({
|
|
|
madeConfirm() {
|
|
|
// 确认设计
|
|
|
if (this.data.madeStatic) { // 设计完成存储数据
|
|
|
- wx.setStorageSync('madeCupImgData' + this.data.touch.isActive, this.data.touch);
|
|
|
+ wx.setStorageSync('madeCupImgData' + this.data.imgTouch.isActive, this.data.imgTouch);
|
|
|
wx.navigateBack()
|
|
|
// wx.redirectTo({
|
|
|
// url: '/customized/pages/made/made?id=' + this.data.touch.isActive
|
|
@@ -280,5 +294,18 @@ Page({
|
|
|
icon: 'none'
|
|
|
})
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ getDataTouch(that) {
|
|
|
+ let madeTouchFont = wx.getStorageSync('madeCupFontData' + that.data.imgTouch.isActive)
|
|
|
+ console.log(madeTouchFont,"madeTouchFont")
|
|
|
+ if (madeTouchFont) {
|
|
|
+ console.log(that.fontAnimation,"that.fontAnimation")
|
|
|
+ that.fontAnimation.rotate(madeTouchFont.angle).step();
|
|
|
+ that.setData({
|
|
|
+ fontAnimationData: that.fontAnimation.export(),
|
|
|
+ fontTouch: madeTouchFont ? madeTouchFont : {},
|
|
|
+ madeStatic: true,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
})
|