| | |
| | | }; |
| | | import {Http} from "../../utils/http-p.js"; |
| | | const Request = new Http(); |
| | | // Object.assign({}, Quantity, |
| | | // Object.assign({}, Quantity, |
| | | Page({ |
| | | |
| | | /** |
| | |
| | | overflow: "auto", |
| | | list: [], |
| | | isPullTelephone: false, |
| | | cltcode: '' |
| | | cltcode: '', |
| | | attrList:[ |
| | | { |
| | | title: '颜色', |
| | | list: [ |
| | | { |
| | | name:'红', |
| | | checked: true |
| | | }, |
| | | { |
| | | name:'黄', |
| | | checked: false |
| | | }, |
| | | |
| | | ] |
| | | }, |
| | | { |
| | | title: '尺寸', |
| | | list: [ |
| | | { |
| | | name:'大', |
| | | checked: false |
| | | }, |
| | | { |
| | | name:'小', |
| | | checked: true |
| | | }, |
| | | |
| | | ] |
| | | } |
| | | ] |
| | | }, |
| | | |
| | | |
| | |
| | | onLoad: function(options) { |
| | | // homeLayoutStyle = options.homeLayoutStyle; |
| | | imgDownloadSum = 0; |
| | | |
| | | |
| | | // this.setData({ |
| | | // homeLayoutStyle: homeLayoutStyle |
| | | // }) |
| | |
| | | that.setData({ |
| | | goodsItem: res.data.list, |
| | | CouponList:res.data.CouponList, |
| | | groupBuyingList:res.data.groupBuyingList, |
| | | SkuParameterList:res.data.SkuParameterList, |
| | | SkuMatCodeList:res.data.SkuMatCodeList, |
| | | title: res.data.list.MatName, |
| | | num: 0, |
| | | description: res.data.list.Description, |
| | |
| | | ['Quantity.quantity']: res.data.list.Mininum||1 |
| | | // price: goodsItem.Price |
| | | }) |
| | | |
| | | |
| | | let { |
| | | Quantity, |
| | | isRestrictQuantity, |
| | |
| | | } |
| | | // WxParse.wxParse('article', 'html', res.data.list.Description, that, 5); |
| | | this.getPosterQrCode(); |
| | | this.handleCurrentGoods(); |
| | | wx.setNavigationBarTitle({ |
| | | title: res.data.list.MatName, |
| | | }) |
| | |
| | | }, |
| | | |
| | | getPosterQrCode(){ |
| | | |
| | | |
| | | wx.request({ |
| | | url: utils.getUrl('/shopping/poster/getQrCodeForPoster.do'), |
| | | header: { |
| | |
| | | this.setData({ |
| | | QrCode:res.data.QrCode |
| | | }) |
| | | |
| | | |
| | | |
| | | }, |
| | | fail: function (errmsg) { |
| | |
| | | }) |
| | | }, |
| | | |
| | | |
| | | |
| | | // downloadFile(){ |
| | | // console.log(app.globalData.cardUserData) |
| | | // console.log('头像',app.globalData.cardUserData.Avatar) |
| | |
| | | // // } else if (res.cancel) { |
| | | // // console.log('用户点击取消') |
| | | // // } |
| | | |
| | | |
| | | // } |
| | | // }) |
| | | |
| | | // }) |
| | | |
| | | |
| | | // }, |
| | | |
| | | // createCanvas(e){ |
| | | |
| | | |
| | | // wx.showToast({ |
| | | // title: '生成中...', |
| | | // icon: 'loading', |
| | | // mask:true, |
| | | // duration: 10000 |
| | | // }); |
| | | |
| | | |
| | | // if (imgDownloadObj.isComplete) { |
| | | // // wx.hideToast() |
| | | // // let posterCreate = this.selectComponent('#posterCreate'); |
| | |
| | | // // wx.hideToast() |
| | | // // let posterCreate = this.selectComponent('#posterCreate'); |
| | | // // posterCreate.formSubmit(e); |
| | | |
| | | |
| | | // }) |
| | | |
| | | |
| | | // } |
| | | |
| | | |
| | | // }, |
| | | |
| | | // sendCommand(e){ |
| | |
| | | // }, |
| | | |
| | | |
| | | |
| | | |
| | | //将canvas转换为图片保存到本地,然后将图片路径传给image图片的src |
| | | // createPoster (e) { |
| | | // let posterCreate = this.selectComponent('#posterCreate'); |
| | |
| | | // // let context = canvas.getContext('2d'); |
| | | // let context = e.detail.context; |
| | | // // let context = wx.createCanvasContext('mycanvas'); |
| | | |
| | | |
| | | // // let path = "../../imgs/gobg.png"; |
| | | // // //不知道是什么原因,手机环境能正常显示 |
| | | // // context.drawImage(path, 0, 0, 375, 183); |
| | |
| | | // context.textAlign='left'; |
| | | // context.fillText("我看上了这款商品", 140, 50); |
| | | // context.stroke(); |
| | | |
| | | |
| | | // context.setFontSize(16); |
| | | // context.fillStyle='#333333'; |
| | | // context.textAlign='left'; |
| | |
| | | // context.beginPath(); |
| | | // context.drawImage(goodsImg, 48, 125, 280, 280); |
| | | // // 商品文字 |
| | | |
| | | |
| | | // context.setFontSize(16); |
| | | // context.fillStyle='#333333'; |
| | | // context.textAlign='left'; |
| | |
| | | // context.fillText(line, 50, lineHeight * index + 435); |
| | | // // context.fillText("商品描述", 50, 445); |
| | | // }); |
| | | |
| | | |
| | | // context.stroke(); |
| | | // context.setFontSize(32); |
| | | // context.fillStyle='#f23232'; |
| | |
| | | // context.fillText("¥1999.00", 45, 505); |
| | | // context.stroke(); |
| | | // context.closePath(); |
| | | |
| | | |
| | | // // 绘制分割线 |
| | | // context.beginPath() |
| | | // context.strokeStyle='#ddd' |
| | |
| | | // //绘制左下角文字背景图 |
| | | // context.beginPath(); |
| | | // context.drawImage(qrCodeImg, 20, 530, 120, 120); |
| | | |
| | | |
| | | // //绘制右下角扫码提示语 |
| | | // // context.drawImage(path5, 248, 578, 90, 25); |
| | | // context.setFontSize(16); |
| | |
| | | // //将生成好的图片保存到本地,需要延迟一会,绘制期间耗时 |
| | | // setTimeout( ()=> { |
| | | |
| | | |
| | | |
| | | // posterCreate.createPoster(canvas); |
| | | // console.log('将生成好的图片保存到本地',avatarImg,goodsImg,qrCodeImg) |
| | | // }, 500); |
| | |
| | | // context.fillText(line, 50, lineHeight * index + 435); |
| | | // // context.fillText("商品描述", 50, 445); |
| | | // }); |
| | | |
| | | |
| | | // context.stroke(); |
| | | // context.setFontSize(32); |
| | | // context.setFillStyle('#f23232'); |
| | |
| | | // context.fillText(goodsItem.CurrencySign+goodsItem.Price, 45, 495); |
| | | // context.stroke(); |
| | | // context.closePath(); |
| | | |
| | | |
| | | // // 绘制分割线 |
| | | // context.beginPath() |
| | | // context.strokeStyle='#ddd' |
| | |
| | | // // context.stroke(); |
| | | // //绘制左下角二维码 |
| | | // context.drawImage(qrCodeImg, 20, 530, 120, 120); |
| | | |
| | | |
| | | // //绘制右下角扫码提示语 |
| | | // // context.drawImage(path5, 248, 578, 90, 25); |
| | | // context.setFontSize(16); |
| | |
| | | |
| | | buyTap: function(event) { |
| | | // 根据按钮不同区分“下一步”触发的事件 |
| | | var name = event.target.dataset.name; |
| | | if (name == "order") { |
| | | let name = event.target.dataset.name || event.detail.name; |
| | | console.log(event); |
| | | this.setData({ |
| | | groupCode:event.detail.groupCode||'', |
| | | }); |
| | | if (name === "order") { |
| | | this.setData({ |
| | | actionType: 'payOrder' |
| | | }) |
| | |
| | | // } |
| | | // } |
| | | // }) |
| | | } else if (name == "cart") { |
| | | } else if (name === "cart") { |
| | | this.setData({ |
| | | actionType: 'addCart' |
| | | }) |
| | | |
| | | |
| | | } |
| | | else if (name === "group") { |
| | | this.setData({ |
| | | actionType: 'groupBuying' |
| | | }) |
| | | |
| | | } |
| | | if (this.data.isShow) { |
| | | this.hideLayer(); |
| | |
| | | } |
| | | }, |
| | | |
| | | handleCurrentGoods(){ |
| | | /* |
| | | * |
| | | * 首先拿到当前商品的所有skuid [],同时也是选中的id |
| | | * 处理所有商品的skuid为字符串 |
| | | * 用户点击sku[i],拼接为字符串与上面的对比 |
| | | * */ |
| | | let SkuParameterList = this.data.SkuParameterList; |
| | | let SkuMatCodeList = this.data.SkuMatCodeList; |
| | | let MatCode = this.data.goodsItem.MatCode; |
| | | let selectedSkuId = []; |
| | | let selectedSkuName = []; |
| | | let skuIdStrings = []; |
| | | SkuMatCodeList.forEach((item,index)=>{ |
| | | let skuIdString = ''; |
| | | for (let i = 1; i < 11; i++) { |
| | | if (item.MatCode === MatCode && item[`skuId${i}`]){ |
| | | selectedSkuId.push(item[`skuId${i}`]) |
| | | selectedSkuName.push(item[`skuName${i}`]) |
| | | } |
| | | if (item[`skuId${i}`]){ |
| | | skuIdString+=item[`skuId${i}`] |
| | | } |
| | | } |
| | | skuIdStrings.push(skuIdString) |
| | | }) |
| | | this.setData({ |
| | | selectedSkuId, |
| | | selectedSkuName, |
| | | skuIdStrings |
| | | }) |
| | | console.log('selectedSkuId',selectedSkuId); |
| | | console.log('selectedSkuName',selectedSkuName); |
| | | console.log('skuIdStrings',skuIdStrings); |
| | | |
| | | }, |
| | | selectGoodsAttr(e){ |
| | | |
| | | console.log(e); |
| | | let attrIndex = e.currentTarget.dataset.i; |
| | | let listIndex = e.currentTarget.dataset.index; |
| | | let skuId = e.currentTarget.dataset.skuId; |
| | | let selectedSkuId = this.data.selectedSkuId; |
| | | selectedSkuId[attrIndex] = skuId; |
| | | let skuIdStrings = this.data.skuIdStrings; |
| | | let hasSkuId = skuIdStrings.includes(selectedSkuId.join('')); |
| | | console.log(skuIdStrings,selectedSkuId.join('')); |
| | | if (skuIdStrings.includes(selectedSkuId.join(''))){ |
| | | this.setData({ |
| | | [`selectedSkuId[${attrIndex}]`]:skuId |
| | | }) |
| | | } else{ |
| | | |
| | | } |
| | | /* |
| | | * 遍历第一列,把没有的标记 |
| | | * 点击第一列可选的项后,遍历剩下所有列,把没有的标记 |
| | | * */ |
| | | // let list = this.data.attrList[attrIndex].list; |
| | | // list.forEach((item,index)=>{ |
| | | // item.checked = index === listIndex; |
| | | // }) |
| | | // this.setData({ |
| | | // [`attrList[${attrIndex}].list`]:list |
| | | // }) |
| | | |
| | | }, |
| | | |
| | | quantityEdit(e){ |
| | | // console.log(e) |
| | | this.setData({ |
| | | ['Quantity.quantity']:parseFloat(e.detail.quantity) |
| | | }) |
| | | // console.log(this.data.Quantity) |
| | | }, |
| | | groupBuying(e){ |
| | | console.log('准备团购'); |
| | | let quantity = this.data.Quantity.quantity; |
| | | let matCode = this.data.goodsItem.MatCode; |
| | | let groupCode = this.data.groupCode; |
| | | let goodsItem = this.data.goodsItem; |
| | | // let eventChannel = this.getOpenerEventChannel(); |
| | | //?quantity=${quantity}&matcode=${matcode}&groupCode=${groupCode} |
| | | wx.navigateTo({ |
| | | url: `../order/order`, |
| | | success(res){ |
| | | res.eventChannel.emit('getSelectedGoods', { |
| | | quantity, |
| | | matCode, |
| | | groupCode, |
| | | goodsItem |
| | | }); |
| | | } |
| | | }) |
| | | }, |
| | | // 加入购物车触发事件 |
| | | addCart: function(e) { |
| | |
| | | var img = this.data.goodsItem.images[0]; |
| | | console.log(this.data.Quantity) |
| | | |
| | | |
| | | |
| | | |
| | | wx.request({ |
| | | url: utils.getUrl('/shopping/cart.do?m=add'), |
| | |
| | | payOrder: function(e) { |
| | | // utils.subscribeMessage({ |
| | | // callback:()=>{ |
| | | |
| | | |
| | | // } |
| | | // }) |
| | | //获取数量,价格,商品名称,id,封面图 |
| | |
| | | // } |
| | | |
| | | wx.navigateTo({ |
| | | url: '../order/order' |
| | | url: '../order/order?selectedCartIds='+res.data.CartId |
| | | }) |
| | | // if(isLogin){ |
| | | // wx.navigateTo({ |
| | |
| | | // // 来自页面内转发按钮 |
| | | // console.log(ops.target) |
| | | // } |
| | | |
| | | |
| | | // console.log('title',utils.getShareTitle()) |
| | | return { |
| | | // title: '我在' + app.globalData.titleName +'发现' + this.data.title + ',赶快来看看吧', |