|
@@ -5,10 +5,11 @@ Page({
|
|
* 页面的初始数据
|
|
* 页面的初始数据
|
|
*/
|
|
*/
|
|
data: {
|
|
data: {
|
|
- dataPositionObj:{
|
|
|
|
|
|
+ dataPositionObj:{ //正面数据
|
|
top:'156rpx',
|
|
top:'156rpx',
|
|
left:'286rpx',
|
|
left:'286rpx',
|
|
- // width:'100rpx',
|
|
|
|
|
|
+ width:'',
|
|
|
|
+ height:''
|
|
},
|
|
},
|
|
propSize:{
|
|
propSize:{
|
|
top:'8cm',
|
|
top:'8cm',
|
|
@@ -16,24 +17,22 @@ Page({
|
|
bottom: '8cm',
|
|
bottom: '8cm',
|
|
left:'8cm',
|
|
left:'8cm',
|
|
},
|
|
},
|
|
- obverseImg: '/images/customized/cup_black_big.png',/*正面 */
|
|
|
|
|
|
+ isActive: '1', // 默认是正面
|
|
|
|
+ obverseImgObject:{
|
|
|
|
+ '1': '/images/customized/cup_black_big.png',/*正面 */
|
|
|
|
+ '2': '/images/customized/cup_black_side.png',/*侧面面 */
|
|
|
|
+ '3': '/images/customized/cup_black_handle.png',/*手柄 */
|
|
|
|
+ '4': '/images/customized/cup_black_bottom.png',/*底部 */
|
|
|
|
+ },
|
|
|
|
+ fontColor: ['#000', '#fff', '#e70012', '#ff8500', '#fff100', '#22ad38', '#00b7f0','#920784']
|
|
|
|
+ // obverseImg: '/images/customized/cup_black_big.png',/*正面 */
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
*/
|
|
onLoad: function (options) {
|
|
onLoad: function (options) {
|
|
- console.log(this.data.obverseImg,"dd")
|
|
|
|
- let canvasBg = this.data.obverseImg;
|
|
|
|
- wx.getSystemInfo({
|
|
|
|
- success: function (res) {
|
|
|
|
- let rpx = res.windowWidth / 750;
|
|
|
|
- console.log(res.windowWidth)
|
|
|
|
- const ctx = wx.createCanvasContext('madeContent');
|
|
|
|
- ctx.drawImage(canvasBg, 0, 0, 750 * rpx, 588 * rpx)
|
|
|
|
- ctx.draw()
|
|
|
|
- },
|
|
|
|
- })
|
|
|
|
|
|
+ this.changeCupImg(this.data.isActive);
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -87,5 +86,98 @@ Page({
|
|
*/
|
|
*/
|
|
onShareAppMessage: function () {
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
|
|
+ },
|
|
|
|
+ changeCupImg(index){
|
|
|
|
+ let canvasBg = this.data.obverseImgObject[index];
|
|
|
|
+ wx.getSystemInfo({
|
|
|
|
+ success: function (res) {
|
|
|
|
+ let rpx = res.windowWidth / 750;
|
|
|
|
+ const ctx = wx.createCanvasContext('madeContent');
|
|
|
|
+ ctx.drawImage(canvasBg, 0, 0, 750 * rpx, 588 * rpx)
|
|
|
|
+ ctx.draw()
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ changeCup(e){
|
|
|
|
+ // data-id== 1正面,2背面,3手柄,4杯底
|
|
|
|
+ this.changeCupImg(e.currentTarget.dataset.id);
|
|
|
|
+ let dataPositionObj = null, propSize=null;
|
|
|
|
+ switch (e.currentTarget.dataset.id){
|
|
|
|
+ case '1':
|
|
|
|
+ // console.log('正面')
|
|
|
|
+ dataPositionObj = { // 正面数据
|
|
|
|
+ top: '156rpx',
|
|
|
|
+ left: '286rpx',
|
|
|
|
+ width: '',
|
|
|
|
+ height: ''
|
|
|
|
+ };
|
|
|
|
+ propSize={
|
|
|
|
+ top: '8cm',
|
|
|
|
+ right: '8cm',
|
|
|
|
+ bottom: '8cm',
|
|
|
|
+ left: '8cm',
|
|
|
|
+ };
|
|
|
|
+ break;
|
|
|
|
+ case '2':
|
|
|
|
+ dataPositionObj = { // 正面数据
|
|
|
|
+ top: '156rpx',
|
|
|
|
+ left: '180rpx',
|
|
|
|
+ width: '',
|
|
|
|
+ height: ''
|
|
|
|
+ };
|
|
|
|
+ propSize = {
|
|
|
|
+ top: '8cm',
|
|
|
|
+ right: '8cm',
|
|
|
|
+ bottom: '8cm',
|
|
|
|
+ left: '8cm',
|
|
|
|
+ };
|
|
|
|
+ // console.log('背面');
|
|
|
|
+ break;
|
|
|
|
+ case '3':
|
|
|
|
+ dataPositionObj = { // 正面数据
|
|
|
|
+ top: '160rpx',
|
|
|
|
+ left: '348rpx',
|
|
|
|
+ width: '70rpx',
|
|
|
|
+ height: '268rpx'
|
|
|
|
+ };
|
|
|
|
+ propSize = {
|
|
|
|
+ top: '1cm',
|
|
|
|
+ right: '6cm',
|
|
|
|
+ bottom: '1cm',
|
|
|
|
+ left: '6cm',
|
|
|
|
+ };
|
|
|
|
+ // console.log('手柄');
|
|
|
|
+ break;
|
|
|
|
+ case '4':
|
|
|
|
+ dataPositionObj = { // 正面数据
|
|
|
|
+ top: '160rpx',
|
|
|
|
+ left: '190rpx',
|
|
|
|
+ width: '265rpx',
|
|
|
|
+ height: '265rpx'
|
|
|
|
+ };
|
|
|
|
+ propSize = {
|
|
|
|
+ top: '6cm',
|
|
|
|
+ right: '6cm',
|
|
|
|
+ bottom: '6cm',
|
|
|
|
+ left: '6cm',
|
|
|
|
+ };
|
|
|
|
+ // console.log('杯底');
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ this.setData({
|
|
|
|
+ isActive: e.currentTarget.dataset.id,
|
|
|
|
+ dataPositionObj: dataPositionObj,
|
|
|
|
+ propSize: propSize
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ addImg(){
|
|
|
|
+ console.log('添加图片')
|
|
|
|
+ },
|
|
|
|
+ addFont() {
|
|
|
|
+ console.log('添加文字')
|
|
}
|
|
}
|
|
})
|
|
})
|