|
@@ -1,5 +1,7 @@
|
|
// customized/pages/made/combination/combination.js
|
|
// customized/pages/made/combination/combination.js
|
|
import * as util from '../../../../utils/util.js'
|
|
import * as util from '../../../../utils/util.js'
|
|
|
|
+let app = getApp();
|
|
|
|
+let host = app.globalData.servsers; // 请求的url
|
|
Page({
|
|
Page({
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -57,6 +59,7 @@ Page({
|
|
'4':'底部',
|
|
'4':'底部',
|
|
},
|
|
},
|
|
buildSrcArray: [],
|
|
buildSrcArray: [],
|
|
|
|
+ customGoodsImg:"",
|
|
|
|
|
|
},
|
|
},
|
|
|
|
|
|
@@ -84,46 +87,42 @@ Page({
|
|
*/
|
|
*/
|
|
onReady: function () {
|
|
onReady: function () {
|
|
|
|
|
|
|
|
+ wx.showLoading({
|
|
|
|
+ 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);
|
|
|
|
+ result = false
|
|
|
|
+ } else if (wx.getStorageSync('madeCupImgData4') || wx.getStorageSync('madeCupFontData4')) {
|
|
|
|
+ that.getCombImg(that, 4);
|
|
|
|
+ result = false
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ if (result) {
|
|
|
|
+ wx.hideLoading();
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
*/
|
|
onShow: function () {
|
|
onShow: function () {
|
|
- // this.getCombImg(this);
|
|
|
|
- // if (this.buildSrcArray.length === 0){
|
|
|
|
- wx.showLoading({
|
|
|
|
- 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);
|
|
|
|
- result = false
|
|
|
|
- }else if (wx.getStorageSync('madeCupImgData4') || wx.getStorageSync('madeCupFontData4')) {
|
|
|
|
- that.getCombImg(that, 4);
|
|
|
|
- result = false
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if (result){
|
|
|
|
- wx.hideLoading();
|
|
|
|
- }
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -282,24 +281,27 @@ Page({
|
|
wx.canvasToTempFilePath({
|
|
wx.canvasToTempFilePath({
|
|
canvasId: 'comb-canvas' + i,
|
|
canvasId: 'comb-canvas' + i,
|
|
success: function (res) {
|
|
success: function (res) {
|
|
- console.log(res, "合成成功");
|
|
|
|
- let buildSrcArray = that.data.buildSrcArray;
|
|
|
|
|
|
+ that.uploadFile(res.tempFilePath,that,function(data){
|
|
|
|
+ console.log(res, "合成成功");
|
|
|
|
+ let buildSrcArray = that.data.buildSrcArray;
|
|
|
|
|
|
- buildSrcArray.push({
|
|
|
|
- src:res.tempFilePath,
|
|
|
|
- isActive:i,
|
|
|
|
|
|
+ buildSrcArray.push({
|
|
|
|
+ src: res.tempFilePath,
|
|
|
|
+ isActive: i,
|
|
});
|
|
});
|
|
- console.log(buildSrcArray, "buildSrcArray")
|
|
|
|
- that.setData({
|
|
|
|
- buildSrcArray: buildSrcArray
|
|
|
|
|
|
+ console.log(buildSrcArray, "buildSrcArray")
|
|
|
|
+ that.setData({
|
|
|
|
+ buildSrcArray: buildSrcArray,
|
|
|
|
+ })
|
|
|
|
+ console.log(that.data.buildSrcArray, "buildSrcArray")
|
|
|
|
+ if (i < 4) {
|
|
|
|
+ i = i + 1
|
|
|
|
+ that.getCombImg(that, i);
|
|
|
|
+ } else {
|
|
|
|
+ wx.hideLoading()
|
|
|
|
+ }
|
|
})
|
|
})
|
|
- console.log(that.data.buildSrcArray, "buildSrcArray")
|
|
|
|
- if (i < 4) {
|
|
|
|
- i = i + 1
|
|
|
|
- that.getCombImg(that, i);
|
|
|
|
- } else {
|
|
|
|
- wx.hideLoading()
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
},
|
|
},
|
|
fail: function (err) {
|
|
fail: function (err) {
|
|
console.log(err, "合成失败")
|
|
console.log(err, "合成失败")
|
|
@@ -318,5 +320,68 @@ Page({
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ },
|
|
|
|
+ addImgRouter(){ // add car
|
|
|
|
+ let that = this;
|
|
|
|
+ console.log(that.data.customGoodsImg,"that.data.customGoodsImg")
|
|
|
|
+
|
|
|
|
+ wx.request({
|
|
|
|
+ url: host + '/addShopCar',
|
|
|
|
+ method:'post',
|
|
|
|
+ header: {
|
|
|
|
+ 'content-type': 'application/x-www-form-urlencoded'
|
|
|
|
+ },
|
|
|
|
+ data:{
|
|
|
|
+ customGoodsImg: that.data.customGoodsImg.substring(0, that.data.customGoodsImg.length-1),
|
|
|
|
+ customGoodsName:'奶缸-黑色 350ml',
|
|
|
|
+ customGoodsNum: 1,
|
|
|
|
+ userId: app.globalData.user_id,
|
|
|
|
+ },
|
|
|
|
+ success:function(res){
|
|
|
|
+ console.log(res,"加入购物车")
|
|
|
|
+ if(res.data ==='success'){
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: '提示',
|
|
|
|
+ content: '加入购物车成功,是否去购物车结算商品?',
|
|
|
|
+
|
|
|
|
+ success:function(res){
|
|
|
|
+ if (res.confirm) {
|
|
|
|
+ console.log('用户点击确定')
|
|
|
|
+ wx.redirectTo({
|
|
|
|
+ url: '/customized/pages/made/car/car',
|
|
|
|
+ })
|
|
|
|
+ } else if (res.cancel) {
|
|
|
|
+ console.log('用户点击取消')
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ uploadFile(path,that,cb){
|
|
|
|
+ let customGoodsImg = that.data.customGoodsImg;
|
|
|
|
+ wx.uploadFile({
|
|
|
|
+ url: host + 'fileUpload',
|
|
|
|
+ filePath: path,
|
|
|
|
+ name: 'file',
|
|
|
|
+ formData: {
|
|
|
|
+ file: path,
|
|
|
|
+ userId: app.globalData.user_id,
|
|
|
|
+ imgStatus: 1,// 表示合成
|
|
|
|
+ },
|
|
|
|
+ success: function (res) {
|
|
|
|
+ console.log(res, "rrrr");
|
|
|
|
+ customGoodsImg += res.data+',';
|
|
|
|
+ that.setData({
|
|
|
|
+ customGoodsImg: customGoodsImg
|
|
|
|
+ })
|
|
|
|
+ cb(true)
|
|
|
|
+ },
|
|
|
|
+ fail: function (res) {
|
|
|
|
+ cb(false)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
+
|
|
})
|
|
})
|