Explorar el Código

图片的合成

wangyong hace 6 años
padre
commit
7dc9169cb9

+ 1 - 1
app.json

@@ -96,7 +96,7 @@
         "pages/made/made",
         "pages/made/madeImg/madeImg",
         "pages/made/madeFont/madeFont",
-        "pages/made/combination/combination"
+        "pages/made/comb/comb"
       ]
     }
   ],

+ 1 - 1
components/component-made/made-solid.wxml

@@ -1,5 +1,5 @@
 <view class="wrapper">
-  <view class='solid' style='top:{{propPosition.top}};left:{{propPosition.left}};width:{{propPosition.width}};height:{{propPosition.height}}'>
+  <view class='solid' style='top:{{propPosition.top}}rpx;left:{{propPosition.left}}rpx;width:{{propPosition.width}}rpx;height:{{propPosition.height}}rpx'>
       <view class='top'>{{propSize.top}}</view>
       <view class='right'>{{propSize.right}}</view>
       <view class='bottom'>{{propSize.bottom}}</view>

+ 288 - 0
customized/pages/made/comb/comb.js

@@ -0,0 +1,288 @@
+// customized/pages/made/combination/combination.js
+import * as util from '../../../../utils/util.js'
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    dataPositionObj: { //正面数据
+      top: 156,
+      left: 286,
+      width: 270,
+      height: 270
+    },
+    imgTouch: {
+      isActive: "1",
+      src: "https://dlz.info666.com//temp/d945bfb0-5cc6-406d-a814-cf63b099041f.jpg",
+      x: -82,
+      y: 17,
+      clientX: 195,
+      clientY: 121,
+      width: 517,
+      height: 208.17866666666666,
+      scale: 2.4834437086092715,
+      angle: 27
+    },
+    fontTouch: {
+      isActive: "1",
+      fontContent: "Gg",
+      isColor: "#ffffff",
+      x: 10,
+      y: 10,
+      angle: 0,
+      fontSize: 100,
+      clientX: 0,
+      clientY: 0,
+      width: 138.34375,
+      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: {
+    //   '1': ,
+    //   /*正面 */
+    //   '2': '/customized/images/customized/cup_black_side.png',
+    //   /*侧面面 */
+    //   '3': '/customized/images/customized/cup_black_handle.png',
+    //   /*手柄 */
+    //   '4': '/customized/images/customized/cup_black_bottom.png',
+    //   /*底部 */
+    // },
+    imgSrcArray: [],
+    buildSrcArray: [],
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    
+    // if (wx.getStorageSync('madeCupImgData1')) {
+    //   this.setData({
+    //     imgTouch: wx.getStorageSync('madeCupImgData1')
+    //   })
+    // }
+    // if (wx.getStorageSync('madeCupFontData1')) {
+    //   this.setData({
+    //     fontTouch: wx.getStorageSync('madeCupFontData1')
+    //   })
+    // }
+
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+    // this.getCombImg(this);
+    wx.showLoading({
+      title: '图片合成中...'
+    })
+    let that = this;
+    // 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);
+    } else if(wx.getStorageSync('madeCupImgData2') || wx.getStorageSync('madeCupFontData2')) {
+      that.getCombImg(that, 2);
+    } else if (wx.getStorageSync('madeCupImgData3') || wx.getStorageSync('madeCupFontData3')) {
+      that.getCombImg(that, 3);
+    } else if (wx.getStorageSync('madeCupImgData4') || wx.getStorageSync('madeCupFontData4')) {
+      that.getCombImg(that, 4);
+    }
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  },
+  getCombImg(that,i) {
+    let imgTouch = null, dataPositionObj=null;
+    console.log(wx.getStorageSync('madeCupImgData' + i),"wx.getStorageSync('madeCupImgData' + i)")
+    if(wx.getStorageSync('madeCupImgData' + i)){
+      imgTouch = wx.getStorageSync('madeCupImgData'+i);
+      dataPositionObj = util.changeCup(i.toString()).dataPositionObj;
+      console.log(dataPositionObj,"dataPositionObj")
+      wx.getSystemInfo({
+        success: function (res) {
+          let rpx = res.windowWidth / 750;
+          that.setData({
+            rpx: rpx
+          });
+          wx.downloadFile({
+            url: imgTouch.src, // 仅为示例,并非真实的资源
+            success(res) {
+              // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
+              console.log(res)
+              if (res.statusCode === 200) {
+                // canvas截图区域与图片的宽度比例
+                let dWidth = dataPositionObj.width / imgTouch.width;
+                // canvas截图区域与图片的高度比例
+                let dHeight = dataPositionObj.height / imgTouch.height;
+                const ctx = wx.createCanvasContext('comb-img'+i);
+                //画布中点坐标转移到图片中心
+                let movex = imgTouch.x + imgTouch.width * rpx / 2;
+                let movey = imgTouch.y + imgTouch.height * rpx / 2;
+                ctx.translate(movex, movey);
+                ctx.rotate(imgTouch.angle * Math.PI / 180);
+                ctx.drawImage(res.tempFilePath, -imgTouch.width * rpx / 2, -imgTouch.height * rpx / 2, imgTouch.width * rpx, imgTouch.height * rpx)
+                ctx.draw(false,function () {
+                  wx.canvasToTempFilePath({
+                    canvasId: 'comb-img'+i,
+                    success: function (res) {
+                      console.log(res)
+                      let imgArray = that.data.imgSrcArray;
+                      imgArray.push(res.tempFilePath)
+                      that.setData({
+                        imgSrcArray: imgArray
+                      })
+                      that.getCombFont(that,i,true);
+                    }
+                  }, that)
+                })
+              }
+            }
+          })
+
+        },
+      })
+    } else {
+      that.getCombFont(that,i,false);
+    }
+    
+    
+    
+  },
+  getCombFont(that,i,_static) {
+    let fontTouch = null,dataPositionObj = null;
+    if (wx.getStorageSync('madeCupFontData' + i)) {
+      fontTouch = wx.getStorageSync('madeCupFontData' + i);
+      dataPositionObj = util.changeCup(i.toString()).dataPositionObj;
+      const ctx = wx.createCanvasContext('comb-font'+i);
+      ctx.setFontSize(fontTouch.fontSize);
+      ctx.setFillStyle(fontTouch.isColor);
+      // ctx.translate(0, fontTouch.height / 5 * 4);
+      // ctx.save();
+      let movex = fontTouch.x + fontTouch.width / 2;
+      let movey = fontTouch.y + fontTouch.height / 10 * 3;
+      ctx.translate(movex, movey);
+      ctx.rotate(fontTouch.angle * Math.PI / 180);
+      // ctx.translate(movex, movey);
+      // ctx.rotate(fontTouch.angle * Math.PI / 180);
+      ctx.fillText(fontTouch.fontContent, -fontTouch.width / 2, fontTouch.height / 2);
+      // ctx.fillText(fontTouch.fontContent, fontTouch.x, fontTouch.y + fontTouch.height / 5 * 4);
+
+      ctx.draw(false,function () {
+        wx.canvasToTempFilePath({
+          canvasId: 'comb-font'+i,
+          success: function (res) {
+            console.log(res)
+            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)
+      })
+    } else {
+      that.getComb(that, that.data.imgSrcArray, i, _static)
+    }
+    
+  },
+  getComb(that, imgSrcArray,i,_static) {
+    if(_static){
+      let imgTouch = wx.getStorageSync('madeCupImgData' + i);
+      let dataPositionObj = util.changeCup(i.toString()).dataPositionObj;
+      let canvasBg = that.data.obverseImgObject[i];
+      console.log(canvasBg)
+      wx.getSystemInfo({
+        success: function (res) {
+          let rpx = res.windowWidth / 750;
+          that.setData({
+            rpx: rpx
+          });
+          const ctx = wx.createCanvasContext('comb-canvas' + i);
+          ctx.drawImage(canvasBg, 0, 0, 750 * rpx, 588 * rpx);
+          // 设置背景
+          ctx.draw(true)
+          imgSrcArray.forEach((res) => {
+            ctx.drawImage(res, dataPositionObj.left * rpx, dataPositionObj.top * rpx, dataPositionObj.width * rpx, dataPositionObj.height * rpx);
+          })
+          wx.hideLoading()
+          ctx.draw(true, function () {
+            wx.canvasToTempFilePath({
+              canvasId: 'comb-canvas' + i,
+              success: function (res) {
+                console.log(res, "合成成功");
+                let buildSrcArray = that.data.buildSrcArray;
+                buildSrcArray.push(res.tempFilePath);
+                console.log(buildSrcArray, "buildSrcArray")
+                that.setData({
+                  buildSrcArray: buildSrcArray
+                })
+                console.log(that.data.buildSrcArray, "buildSrcArray")
+                if (i < 4) {
+                  i = i + 1
+                  that.getCombImg(that, i);
+                }
+              },
+              fail: function (err) {
+                console.log(err, "合成失败")
+                wx.hideLoading();
+              }
+            }, that)
+          })
+        },
+      })
+    }
+    
+  }
+})

+ 4 - 0
customized/pages/made/comb/comb.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "disableScroll": true
+}

+ 24 - 0
customized/pages/made/comb/comb.wxml

@@ -0,0 +1,24 @@
+<view style="position:fixed;top:999999999999999999999rpx;">
+  <!-- 正面 -->
+  <canvas canvas-id="comb-canvas1" class="comb-content"></canvas>
+  <canvas canvas-id='comb-img1' class='comb-img'></canvas>
+  <canvas canvas-id='comb-font1' class='comb-font'></canvas>
+  <!-- 背面 -->
+  <canvas canvas-id="comb-canvas2" class="comb-content"></canvas>
+  <canvas canvas-id='comb-img2' class='comb-img'></canvas>
+  <canvas canvas-id='comb-font2' class='comb-font'></canvas>
+  <!-- 手柄 -->
+  <canvas canvas-id="comb-canvas3" class="comb-content"></canvas>
+  <canvas canvas-id='comb-img3' class='comb-img3'></canvas>
+  <canvas canvas-id='comb-font3' class='comb-font3'></canvas>
+  <!-- 杯底 -->
+  <canvas canvas-id="comb-canvas4" class="comb-content"></canvas>
+  <canvas canvas-id='comb-img4' class='comb-img4'></canvas>
+  <canvas canvas-id='comb-font4' class='comb-font4'></canvas>
+</view>
+<view class='comb-view-img'>
+  <view wx:for="{{buildSrcArray}}"><image mode="aspectFit" src='{{item}}'></image></view>
+</view>
+<!-- <image src='wxfile://tmp_d29746112b57f9351b02b2907809ed902b4219c2d52293af.png'></image> -->
+
+ <!-- // "disableScroll": true -->

+ 17 - 2
customized/pages/made/combination/combination.wxss

@@ -10,9 +10,24 @@ page{
   width:270rpx;
   height:270rpx;
 }
-.comb-img{
+.comb-img,.comb-img3{
   background:rgb(255, 176, 29);
 }
-.comb-font{
+.comb-font,.comb-font3{
   background:#2e8aec;
+}
+.comb-img3,.comb-font3{
+  width:70rpx;
+  height:268rpx;
+}
+.comb-img4,.comb-font4{
+  width:265rpx;
+  height:265rpx;
+}
+.comb-view-img{
+  width:100%;
+
+}
+.comb-view-img image{
+  width:50%;
 }

+ 0 - 246
customized/pages/made/combination/combination.js

@@ -1,246 +0,0 @@
-// customized/pages/made/combination/combination.js
-Page({
-
-  /**
-   * 页面的初始数据
-   */
-  data: {
-    dataPositionObj: { //正面数据
-      top: 156,
-      left: 286,
-      width: 270,
-      height: 270
-    },
-    imgTouch: {
-      isActive: "1",
-      src: "https://dlz.info666.com//temp/d945bfb0-5cc6-406d-a814-cf63b099041f.jpg",
-      x: -82,
-      y: 17,
-      clientX: 195,
-      clientY: 121,
-      width: 517,
-      height: 208.17866666666666,
-      scale: 2.4834437086092715,
-      angle: 27
-    },
-    fontTouch: {
-      isActive: "1",
-      fontContent: "Gg",
-      isColor: "#ffffff",
-      x: 10,
-      y: 10,
-      angle: 0,
-      fontSize: 100,
-      clientX: 0,
-      clientY: 0,
-      width: 138.34375,
-      height: 132
-    },
-    rpx: 1,
-    obverseImgObject: {
-      '1': '/customized/images/customized/cup_black_big.png',
-      /*正面 */
-      '2': '/customized/images/customized/cup_black_side.png',
-      /*侧面面 */
-      '3': '/customized/images/customized/cup_black_handle.png',
-      /*手柄 */
-      '4': '/customized/images/customized/cup_black_bottom.png',
-      /*底部 */
-    },
-    imgSrcArray: [],
-    buildSrc: '',
-  },
-
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad: function (options) {
-    if (wx.getStorageSync('madeCupImgData1')) {
-      this.setData({
-        imgTouch: wx.getStorageSync('madeCupImgData1')
-      })
-    }
-    if (wx.getStorageSync('madeCupFontData1')) {
-      this.setData({
-        fontTouch: wx.getStorageSync('madeCupFontData1')
-      })
-    }
-
-
-  },
-
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady: function () {
-
-
-  },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow: function () {
-    this.getCombImg(this);
-   
-
-  },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide: function () {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload: function () {
-
-  },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh: function () {
-
-  },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom: function () {
-
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-
-  },
-  getCombImg(that) {
-    let imgTouch = that.data.imgTouch;
-    let dataPositionObj = that.data.dataPositionObj;
-    wx.getSystemInfo({
-      success: function (res) {
-        let rpx = res.windowWidth / 750;
-        that.setData({
-          rpx: rpx
-        });
-        wx.downloadFile({
-          url: imgTouch.src, // 仅为示例,并非真实的资源
-          success(res) {
-            // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
-            console.log(res)
-            if (res.statusCode === 200) {
-              // canvas截图区域与图片的宽度比例
-              let dWidth = dataPositionObj.width / imgTouch.width;
-              // canvas截图区域与图片的高度比例
-              let dHeight = dataPositionObj.height / imgTouch.height;
-              const ctx = wx.createCanvasContext('comb-img');
-              //画布中点坐标转移到图片中心
-              let movex = imgTouch.x + imgTouch.width * rpx / 2;
-              let movey = imgTouch.y + imgTouch.height * rpx / 2;
-              ctx.translate(movex, movey);
-              ctx.rotate(imgTouch.angle * Math.PI / 180);
-              ctx.drawImage(res.tempFilePath, -imgTouch.width * rpx / 2, -imgTouch.height * rpx / 2, imgTouch.width * rpx, imgTouch.height * rpx)
-              ctx.draw(true, function () {
-                wx.canvasToTempFilePath({
-                  canvasId: 'comb-img',
-                  success: function (res) {
-                    console.log(res)
-                    let imgArray = that.data.imgSrcArray;
-                    imgArray.push(res.tempFilePath)
-                    that.setData({
-                      imgSrcArray: imgArray
-                    })
-                    that.getCombFont(that);
-                  }
-                }, that)
-              })
-            }
-          }
-        })
-
-      },
-    })
-  },
-  getCombFont(that) {
-    let fontTouch = that.data.fontTouch;
-    // fontTouch.width = 123;
-    // fontTouch.height=132;
-    let dataPositionObj = that.data.dataPositionObj;
-    const ctx = wx.createCanvasContext('comb-font');
-    ctx.setFontSize(fontTouch.fontSize);
-    ctx.setFillStyle(fontTouch.isColor);
-    // ctx.translate(0, fontTouch.height / 5 * 4);
-    // ctx.save();
-    let movex = fontTouch.x + fontTouch.width / 2;
-    let movey = fontTouch.y + fontTouch.height / 10* 3 ;
-    ctx.translate(movex, movey);
-    ctx.rotate(fontTouch.angle * Math.PI / 180);
-    // ctx.translate(movex, movey);
-    // ctx.rotate(fontTouch.angle * Math.PI / 180);
-    ctx.fillText(fontTouch.fontContent, -fontTouch.width / 2, fontTouch.height / 2);
-    // ctx.fillText(fontTouch.fontContent, fontTouch.x, fontTouch.y + fontTouch.height / 5 * 4);
-    
-    ctx.draw(true, function () {
-      wx.canvasToTempFilePath({
-        canvasId: 'comb-font',
-        success: function (res) {
-          console.log(res)
-          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)
-        }
-      }, that)
-    })
-  },
-  getComb(that, imgSrcArray) {
-    let imgTouch = that.data.imgTouch;
-    let dataPositionObj = that.data.dataPositionObj;
-    wx.getSystemInfo({
-      success: function (res) {
-        let rpx = res.windowWidth / 750;
-        that.setData({
-          rpx: rpx
-        });
-        let canvasBg = that.data.obverseImgObject[1];
-        const ctx = wx.createCanvasContext('comb-canvas');
-        ctx.drawImage(canvasBg, 0, 0, 750 * rpx, 588 * rpx);
-        ctx.draw(true);
-        // 设置背景
-        imgSrcArray.forEach((res) => {
-          ctx.drawImage(res, dataPositionObj.left * rpx, dataPositionObj.top * rpx, dataPositionObj.width * rpx, dataPositionObj.height * rpx);
-        })
-        ctx.draw(true, function () {
-          wx.canvasToTempFilePath({
-            canvasId: 'comb-canvas',
-            success: function (res) {
-              console.log(res, "合成成功")
-              that.setData({
-                buildSrc: res.tempFilePath
-              })
-              // 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)
-            },
-            fail: function (err) {
-              console.log(err, "合成失败")
-            }
-          }, that)
-        })
-      },
-    })
-  }
-})

+ 0 - 4
customized/pages/made/combination/combination.json

@@ -1,4 +0,0 @@
-{
-  "usingComponents": {}
- 
-}

+ 0 - 7
customized/pages/made/combination/combination.wxml

@@ -1,7 +0,0 @@
-<canvas canvas-id="comb-canvas" class="comb-content"></canvas>
-<!-- <view style="position:fixed;top:999999999999999999999rpx;"> -->
-    <canvas canvas-id='comb-img' class='comb-img'  hidden='{{canvasHidden}}'></canvas>
-    <canvas canvas-id='comb-font' class='comb-font'  hidden='{{canvasHidden}}'></canvas>
-<!-- </view> -->
-<image src='{{buildSrc}}'></image>
- <!-- // "disableScroll": true -->

+ 8 - 6
customized/pages/made/made.js

@@ -7,10 +7,10 @@ Page({
    */
   data: {
     dataPositionObj: { //正面数据
-      top: '156rpx',
-      left: '286rpx',
-      width: '',
-      height: ''
+      top: 156,
+      left: 286,
+      width: 270,
+      height: 270,
     },
     propSize: {
       top: '8cm',
@@ -214,7 +214,8 @@ Page({
       if (!designVal) {
         console.log('可以完成')
         wx.navigateTo({
-          url: '/customized/pages/made/combination/combination',
+          // url: '/customized/pages/made/combination/combination',
+          url: '/customized/pages/made/comb/comb'
         })
       } else {
         wx.showModal({
@@ -229,7 +230,8 @@ Page({
               // })
               // that.getBuildImg(that)
               wx.navigateTo({
-                url: '/customized/pages/made/combination/combination',
+                // url: '/customized/pages/made/combination/combination',
+                url:'/customized/pages/made/comb/comb'
               })
             } else {
               console.log('用户点击取消')

+ 4 - 4
customized/pages/made/madeFont/madeFont.js

@@ -7,10 +7,10 @@ Page({
    */
   data: {
     dataPositionObj: { //正面数据
-      top: '156rpx',
-      left: '286rpx',
-      width: '',
-      height: ''
+      top: 156,
+      left: 286,
+      width:270,
+      height: 270
     },
     propSize: {
       top: '8cm',

+ 4 - 4
customized/pages/made/madeImg/madeImg.js

@@ -9,10 +9,10 @@ Page({
    */
   data: {
     dataPositionObj: { //正面数据
-      top: '156rpx',
-      left: '286rpx',
-      width: '',
-      height: '',
+      top: 156,
+      left: 286,
+      width: 270,
+      height: 270,
       
     },
     propSize: {

+ 16 - 16
utils/util.js

@@ -23,10 +23,10 @@ function changeCup(e) {
     case '1':
       // console.log('正面')
       dataPositionObj = { // 正面数据
-        top: '156rpx',
-        left: '286rpx',
-        width: '',
-        height: ''
+        top: 156,
+        left: 286,
+        width: 270,
+        height: 270
       };
       propSize = {
         top: '8cm',
@@ -37,10 +37,10 @@ function changeCup(e) {
       break;
     case '2':
       dataPositionObj = { // 正面数据
-        top: '156rpx',
-        left: '180rpx',
-        width: '',
-        height: ''
+        top: 156,
+        left: 180,
+        width: 270,
+        height: 270
       };
       propSize = {
         top: '8cm',
@@ -52,10 +52,10 @@ function changeCup(e) {
       break;
     case '3':
       dataPositionObj = { // 正面数据
-        top: '150rpx',
-        left: '348rpx',
-        width: '70rpx',
-        height: '268rpx'
+        top: 150,
+        left: 348,
+        width: 70,
+        height: 268
       };
       propSize = {
         top: '1cm',
@@ -67,10 +67,10 @@ function changeCup(e) {
       break;
     case '4':
       dataPositionObj = { // 正面数据
-        top: '160rpx',
-        left: '190rpx',
-        width: '265rpx',
-        height: '265rpx'
+        top: 160,
+        left: 190,
+        width: 265,
+        height: 265
       };
       propSize = {
         top: '6cm',