diff --git a/components/diy_serviceCard/diy_serviceCard.js b/components/diy_serviceCard/diy_serviceCard.js index c0d9d34..d30f396 100644 --- a/components/diy_serviceCard/diy_serviceCard.js +++ b/components/diy_serviceCard/diy_serviceCard.js @@ -217,7 +217,8 @@ Component({ // await app.request.get("/api/weshop/serviceCard/page?store_id=" + os.stoid + "&goodsidlist=" + str, { await app.request.get("/api/weshop/serviceCard/page?store_id=" + os.stoid + "&ids=" + str, { data: { - user_id: user_id + user_id: user_id, + pageSize: th.data.goodscount, }, isShowLoading: false, success: function(res) { diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 47ad167..d776868 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -4682,36 +4682,30 @@ Page({ }, - drawPoster(context, unit, img, vpath) { + drawPoster(context, unit, img, vpath, type) { // 1.灰色背景 context.setFillStyle('#f2f1f6'); context.rect(0, 0, 554 * unit, 899 * unit); context.fill(); + // 2.商城名称 let shopName = this.data.sto_sele_name_1; - // let shopNameLen = context.measureText(shopName); - // let x_shopNameLen = (554 - shopNameLen.width)/2*unit; - // console.log('11111111111111',shopNameLen,x_shopNameLen); context.setTextAlign('center'); context.setFontSize(26 * unit); context.setFillStyle('black'); context.fillText(shopName, 277 * unit, 60 * unit); - // // 3.推荐来源 + + // 3.推荐来源 let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; - // let fromTextLen = context.measureText(fromText); - // let x_fromText = (375 - fromTextLen.width)/2; - // console.log('222222',fromTextLen,x_fromText); context.setTextAlign('center'); context.setFontSize(22 * unit); context.setFillStyle('#96959a'); context.fillText(fromText, 277 * unit, 105 * unit); + // 4.海报背景 - // context.beginPath(); - // context.setStrokeStyle('#f2f1f6'); context.setFillStyle('white'); context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit); - // context.stroke(); - // context.fill(); + // 5.商品图片 // 图片的x坐标 let bg_x = 37 * unit @@ -4732,46 +4726,87 @@ Page({ context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI) context.clip() context.drawImage(img, bg_x, bg_y, bg_w, bg_h); - context.restore() + context.restore(); + // 6.强烈推荐 - // context.beginPath(); - let tj_path = "../../../images/share/q_tj.png"; - context.beginPath() - context.drawImage(tj_path, 54 * unit, 648 * unit, 85 * unit, 30 * unit); - context.setFontSize(16 * unit) - context.setLineJoin('round'); //交点设置成圆角 - context.setFillStyle("white") - context.setTextAlign('left'); - context.fillText('强烈推荐', 64 * unit, 668 * unit); + let src = ''; + context.beginPath(); + if(type == 0) { // 普通 + src = '../../../images/share/q_tj.png'; + context.drawImage(src, 54 * unit, 648 * unit, 85 * unit, 30 * unit); + context.setFontSize(16 * unit) + context.setFillStyle("white") + context.setTextAlign('left'); + context.fillText('强烈推荐', 64 * unit, 668 * unit); + }; + if(type == 1) { // 秒杀 + src = '../../../images/share/miao_share.png'; + context.drawImage(src, 54 * unit, 648 * unit, 200 * unit, 36 * unit); + }; + if(type == 2) { // 商家和会员团 + src = '../../../images/share/ct_num.png'; + context.drawImage(src, 54 * unit, 648 * unit, 120 * unit, 30 * unit); + context.setTextAlign('left'); + + let ct_num = self.data.prom_act.ct_num; + context.setFontSize(16 * unit) + context.font = 'normal'; + context.setFillStyle("red") + if (ct_num < 10) { + context.fillText(ct_num + "人拼团", 100 * unit, 670 * unit); + } else { + context.fillText(ct_num + "人拼团", 96 * unit, 670 * unit); + } + context.setFontSize(22 * unit) + context.fillText("已拼" + self.data.prom_act.buy_num + "份", 186 * unit, 672 * unit); + }; + if(type == 3) { // 阶梯团 + let list = self.data.prom_act.ct_rylist; + for (let i = 0; i < list.length; i++) { + let item = list[i]; + let wi = i * 90 * unit; + context.font = 'normal'; + context.setTextAlign('left'); + context.setFontSize(16 * unit) + context.setFillStyle("red") + context.fillText("¥", 50 * unit + wi, 680 * unit); + context.setFontSize(22 * unit) + let pri = parseFloat(item.price).toFixed(2); + context.fillText(pri, 66 * unit + wi, 680 * unit); + context.setFillStyle("gray") + context.fillText("满" + item.rynum + "人", 50 * unit + wi, 716 * unit); + } + }; + // 7.商品价格 - let price = '¥' + this.data.data.shop_price; - - if (this.data.card_field && this.data.data[this.data.card_field]) { - price = '¥' + this.data.data[this.data.card_field]; - } - - - // if (th.data.prom_act) - // pri0 = th.data.prom_act.price; - context.setFontSize(32 * unit); - context.setFillStyle('#DE1117'); - context.fillText(price, 54 * unit, 730 * unit); - // 8.商品标题 - context.setFontSize(20 * unit); - context.setFillStyle('#898989'); - this.draw_Text(context, this.data.data.goods_name, - 54 * unit, 770 * unit, 240 * unit, 240 * unit, unit); + if(type != 3) { + let price = this.data.data.shop_price; + if (this.data.card_field && this.data.data[this.data.card_field]) { + price = this.data.data[this.data.card_field]; + } + if (this.data.prom_act) price = this.data.prom_price; + price = parseFloat(price).toFixed(2); + context.setFontSize(32 * unit); + context.setFillStyle('#DE1117'); + context.fillText('¥' + price, 54 * unit, 730 * unit); + }; + + // 8.商品标题 + context.setFontSize(20 * unit); + context.setFillStyle('#898989'); + this.draw_Text(context, this.data.data.goods_name, 54 * unit, 770 * unit, 240 * unit, 240 * unit, unit); + // 9.小程序码 context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); context.setFontSize(16 * unit); context.setFillStyle('#777'); context.fillText('长按识别二维码', 378 * unit, 810 * unit); + // 10.竖线 context.beginPath(); context.setFillStyle('#eee'); context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit); context.fill(); - }, @@ -4787,13 +4822,12 @@ Page({ if (this.data.share_hidden) { this.setData({share_hidden: false,}); - } - ; + }; //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团 var type = this.data.prom_type; if (type == 2) type = -1; - if (type == 6) type = 2; + if (type == 6) type = 2; // 6拼团 2团购 if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; @@ -4847,18 +4881,17 @@ Page({ // context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); - if (type == 0) { // 如果是普通商品,绘制新海报 - th.drawPoster(context, unit, th.data.share_goods_img, vpath); + if (type == 0 || type == 1 || type == 2 || type == 3) { // 如果是普通商品,绘制新海报 + th.drawPoster(context, unit, th.data.share_goods_img, vpath, type); } else { context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); - } - ; + }; // th.drawPoster(context, unit, th.data.share_goods_img, vpath); //-- 是自定义海报的情况下 -- - if (type != 0) { + if (type != 0 && type != 1 && type != 2 && type != 3) { if (th.data.poster && parseInt(th.data.poster.style) == 2) { //在线上分享人的情况下 @@ -4913,7 +4946,7 @@ Page({ //---产品名称--- //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - if (type != 4 && type != 0) { + if (type != 4 && type != 0 && type != 1 && type != 2 && type != 3) { context.setFillStyle("black"); context.setFontSize(21.3 * unit) th.draw_Text(context, share_title, @@ -4949,7 +4982,7 @@ Page({ context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); context.stroke(); - } else if (type == 4 && type != 0) { + } else if (type == 4 && type != 0 && type != 1 && type != 2 && type != 3) { context.setFillStyle("black"); context.setFontSize(21.3 * unit) th.draw_Text(context, share_title, @@ -4977,7 +5010,7 @@ Page({ } //---中间大图--- - if (type != 0) { + if (type != 0 && type != 1 && type != 2 && type != 3) { context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit); } ; @@ -5068,7 +5101,7 @@ Page({ ; break; - case 1: //秒杀商品的展示 + case -12: //秒杀商品的展示 //---画线--- context.setLineWidth(1 * unit) context.moveTo(32 * unit, 670 * unit) @@ -5101,7 +5134,7 @@ Page({ } break; - case 2: //会员团和商家团的展示 + case -2: //会员团和商家团的展示 //---画线--- context.setLineWidth(1 * unit) context.moveTo(32 * unit, 670 * unit) @@ -5146,7 +5179,7 @@ Page({ context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); } break - case 3: //阶梯团的展示 + case -3: //阶梯团的展示 //---画线--- context.setLineWidth(1 * unit) context.moveTo(32 * unit, 670 * unit)