Commit 40496a9d98768ae916f0ef747c08f0b2ffb31403

Authored by 后端研发-苏泰源
1 parent 51096a59

服务卡自定义模版分页大小设置,商品拼团和秒杀分享海报修改

components/diy_serviceCard/diy_serviceCard.js
@@ -217,7 +217,8 @@ Component({ @@ -217,7 +217,8 @@ Component({
217 // await app.request.get("/api/weshop/serviceCard/page?store_id=" + os.stoid + "&goodsidlist=" + str, { 217 // await app.request.get("/api/weshop/serviceCard/page?store_id=" + os.stoid + "&goodsidlist=" + str, {
218 await app.request.get("/api/weshop/serviceCard/page?store_id=" + os.stoid + "&ids=" + str, { 218 await app.request.get("/api/weshop/serviceCard/page?store_id=" + os.stoid + "&ids=" + str, {
219 data: { 219 data: {
220 - user_id: user_id 220 + user_id: user_id,
  221 + pageSize: th.data.goodscount,
221 }, 222 },
222 isShowLoading: false, 223 isShowLoading: false,
223 success: function(res) { 224 success: function(res) {
pages/goods/goodsInfo/goodsInfo.js
@@ -4682,36 +4682,30 @@ Page({ @@ -4682,36 +4682,30 @@ Page({
4682 }, 4682 },
4683 4683
4684 4684
4685 - drawPoster(context, unit, img, vpath) { 4685 + drawPoster(context, unit, img, vpath, type) {
4686 // 1.灰色背景 4686 // 1.灰色背景
4687 context.setFillStyle('#f2f1f6'); 4687 context.setFillStyle('#f2f1f6');
4688 context.rect(0, 0, 554 * unit, 899 * unit); 4688 context.rect(0, 0, 554 * unit, 899 * unit);
4689 context.fill(); 4689 context.fill();
  4690 +
4690 // 2.商城名称 4691 // 2.商城名称
4691 let shopName = this.data.sto_sele_name_1; 4692 let shopName = this.data.sto_sele_name_1;
4692 - // let shopNameLen = context.measureText(shopName);  
4693 - // let x_shopNameLen = (554 - shopNameLen.width)/2*unit;  
4694 - // console.log('11111111111111',shopNameLen,x_shopNameLen);  
4695 context.setTextAlign('center'); 4693 context.setTextAlign('center');
4696 context.setFontSize(26 * unit); 4694 context.setFontSize(26 * unit);
4697 context.setFillStyle('black'); 4695 context.setFillStyle('black');
4698 context.fillText(shopName, 277 * unit, 60 * unit); 4696 context.fillText(shopName, 277 * unit, 60 * unit);
4699 - // // 3.推荐来源 4697 +
  4698 + // 3.推荐来源
4700 let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; 4699 let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`;
4701 - // let fromTextLen = context.measureText(fromText);  
4702 - // let x_fromText = (375 - fromTextLen.width)/2;  
4703 - // console.log('222222',fromTextLen,x_fromText);  
4704 context.setTextAlign('center'); 4700 context.setTextAlign('center');
4705 context.setFontSize(22 * unit); 4701 context.setFontSize(22 * unit);
4706 context.setFillStyle('#96959a'); 4702 context.setFillStyle('#96959a');
4707 context.fillText(fromText, 277 * unit, 105 * unit); 4703 context.fillText(fromText, 277 * unit, 105 * unit);
  4704 +
4708 // 4.海报背景 4705 // 4.海报背景
4709 - // context.beginPath();  
4710 - // context.setStrokeStyle('#f2f1f6');  
4711 context.setFillStyle('white'); 4706 context.setFillStyle('white');
4712 context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit); 4707 context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit);
4713 - // context.stroke();  
4714 - // context.fill(); 4708 +
4715 // 5.商品图片 4709 // 5.商品图片
4716 // 图片的x坐标 4710 // 图片的x坐标
4717 let bg_x = 37 * unit 4711 let bg_x = 37 * unit
@@ -4732,46 +4726,87 @@ Page({ @@ -4732,46 +4726,87 @@ Page({
4732 context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI) 4726 context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI)
4733 context.clip() 4727 context.clip()
4734 context.drawImage(img, bg_x, bg_y, bg_w, bg_h); 4728 context.drawImage(img, bg_x, bg_y, bg_w, bg_h);
4735 - context.restore() 4729 + context.restore();
  4730 +
4736 // 6.强烈推荐 4731 // 6.强烈推荐
4737 - // context.beginPath();  
4738 - let tj_path = "../../../images/share/q_tj.png";  
4739 - context.beginPath()  
4740 - context.drawImage(tj_path, 54 * unit, 648 * unit, 85 * unit, 30 * unit);  
4741 - context.setFontSize(16 * unit)  
4742 - context.setLineJoin('round'); //交点设置成圆角  
4743 - context.setFillStyle("white")  
4744 - context.setTextAlign('left');  
4745 - context.fillText('强烈推荐', 64 * unit, 668 * unit); 4732 + let src = '';
  4733 + context.beginPath();
  4734 + if(type == 0) { // 普通
  4735 + src = '../../../images/share/q_tj.png';
  4736 + context.drawImage(src, 54 * unit, 648 * unit, 85 * unit, 30 * unit);
  4737 + context.setFontSize(16 * unit)
  4738 + context.setFillStyle("white")
  4739 + context.setTextAlign('left');
  4740 + context.fillText('强烈推荐', 64 * unit, 668 * unit);
  4741 + };
  4742 + if(type == 1) { // 秒杀
  4743 + src = '../../../images/share/miao_share.png';
  4744 + context.drawImage(src, 54 * unit, 648 * unit, 200 * unit, 36 * unit);
  4745 + };
  4746 + if(type == 2) { // 商家和会员团
  4747 + src = '../../../images/share/ct_num.png';
  4748 + context.drawImage(src, 54 * unit, 648 * unit, 120 * unit, 30 * unit);
  4749 + context.setTextAlign('left');
  4750 +
  4751 + let ct_num = self.data.prom_act.ct_num;
  4752 + context.setFontSize(16 * unit)
  4753 + context.font = 'normal';
  4754 + context.setFillStyle("red")
  4755 + if (ct_num < 10) {
  4756 + context.fillText(ct_num + "人拼团", 100 * unit, 670 * unit);
  4757 + } else {
  4758 + context.fillText(ct_num + "人拼团", 96 * unit, 670 * unit);
  4759 + }
  4760 + context.setFontSize(22 * unit)
  4761 + context.fillText("已拼" + self.data.prom_act.buy_num + "份", 186 * unit, 672 * unit);
  4762 + };
  4763 + if(type == 3) { // 阶梯团
  4764 + let list = self.data.prom_act.ct_rylist;
  4765 + for (let i = 0; i < list.length; i++) {
  4766 + let item = list[i];
  4767 + let wi = i * 90 * unit;
  4768 + context.font = 'normal';
  4769 + context.setTextAlign('left');
  4770 + context.setFontSize(16 * unit)
  4771 + context.setFillStyle("red")
  4772 + context.fillText("¥", 50 * unit + wi, 680 * unit);
  4773 + context.setFontSize(22 * unit)
  4774 + let pri = parseFloat(item.price).toFixed(2);
  4775 + context.fillText(pri, 66 * unit + wi, 680 * unit);
  4776 + context.setFillStyle("gray")
  4777 + context.fillText("满" + item.rynum + "人", 50 * unit + wi, 716 * unit);
  4778 + }
  4779 + };
  4780 +
4746 // 7.商品价格 4781 // 7.商品价格
4747 - let price = '¥' + this.data.data.shop_price;  
4748 -  
4749 - if (this.data.card_field && this.data.data[this.data.card_field]) {  
4750 - price = '¥' + this.data.data[this.data.card_field];  
4751 - }  
4752 -  
4753 -  
4754 - // if (th.data.prom_act)  
4755 - // pri0 = th.data.prom_act.price;  
4756 - context.setFontSize(32 * unit);  
4757 - context.setFillStyle('#DE1117');  
4758 - context.fillText(price, 54 * unit, 730 * unit);  
4759 - // 8.商品标题  
4760 - context.setFontSize(20 * unit);  
4761 - context.setFillStyle('#898989');  
4762 - this.draw_Text(context, this.data.data.goods_name,  
4763 - 54 * unit, 770 * unit, 240 * unit, 240 * unit, unit); 4782 + if(type != 3) {
  4783 + let price = this.data.data.shop_price;
  4784 + if (this.data.card_field && this.data.data[this.data.card_field]) {
  4785 + price = this.data.data[this.data.card_field];
  4786 + }
  4787 + if (this.data.prom_act) price = this.data.prom_price;
  4788 + price = parseFloat(price).toFixed(2);
  4789 + context.setFontSize(32 * unit);
  4790 + context.setFillStyle('#DE1117');
  4791 + context.fillText('¥' + price, 54 * unit, 730 * unit);
  4792 + };
  4793 +
  4794 + // 8.商品标题
  4795 + context.setFontSize(20 * unit);
  4796 + context.setFillStyle('#898989');
  4797 + this.draw_Text(context, this.data.data.goods_name, 54 * unit, 770 * unit, 240 * unit, 240 * unit, unit);
  4798 +
4764 // 9.小程序码 4799 // 9.小程序码
4765 context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); 4800 context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit);
4766 context.setFontSize(16 * unit); 4801 context.setFontSize(16 * unit);
4767 context.setFillStyle('#777'); 4802 context.setFillStyle('#777');
4768 context.fillText('长按识别二维码', 378 * unit, 810 * unit); 4803 context.fillText('长按识别二维码', 378 * unit, 810 * unit);
  4804 +
4769 // 10.竖线 4805 // 10.竖线
4770 context.beginPath(); 4806 context.beginPath();
4771 context.setFillStyle('#eee'); 4807 context.setFillStyle('#eee');
4772 context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit); 4808 context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit);
4773 context.fill(); 4809 context.fill();
4774 -  
4775 }, 4810 },
4776 4811
4777 4812
@@ -4787,13 +4822,12 @@ Page({ @@ -4787,13 +4822,12 @@ Page({
4787 4822
4788 if (this.data.share_hidden) { 4823 if (this.data.share_hidden) {
4789 this.setData({share_hidden: false,}); 4824 this.setData({share_hidden: false,});
4790 - }  
4791 - ; 4825 + };
4792 4826
4793 //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团 4827 //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团
4794 var type = this.data.prom_type; 4828 var type = this.data.prom_type;
4795 if (type == 2) type = -1; 4829 if (type == 2) type = -1;
4796 - if (type == 6) type = 2; 4830 + if (type == 6) type = 2; // 6拼团 2团购
4797 4831
4798 4832
4799 if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; 4833 if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3;
@@ -4847,18 +4881,17 @@ Page({ @@ -4847,18 +4881,17 @@ Page({
4847 // context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); 4881 // context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit);
4848 4882
4849 4883
4850 - if (type == 0) { // 如果是普通商品,绘制新海报  
4851 - th.drawPoster(context, unit, th.data.share_goods_img, vpath); 4884 + if (type == 0 || type == 1 || type == 2 || type == 3) { // 如果是普通商品,绘制新海报
  4885 + th.drawPoster(context, unit, th.data.share_goods_img, vpath, type);
4852 } else { 4886 } else {
4853 context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); 4887 context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit);
4854 - }  
4855 - ; 4888 + };
4856 4889
4857 // th.drawPoster(context, unit, th.data.share_goods_img, vpath); 4890 // th.drawPoster(context, unit, th.data.share_goods_img, vpath);
4858 4891
4859 4892
4860 //-- 是自定义海报的情况下 -- 4893 //-- 是自定义海报的情况下 --
4861 - if (type != 0) { 4894 + if (type != 0 && type != 1 && type != 2 && type != 3) {
4862 4895
4863 if (th.data.poster && parseInt(th.data.poster.style) == 2) { 4896 if (th.data.poster && parseInt(th.data.poster.style) == 2) {
4864 //在线上分享人的情况下 4897 //在线上分享人的情况下
@@ -4913,7 +4946,7 @@ Page({ @@ -4913,7 +4946,7 @@ Page({
4913 4946
4914 //---产品名称--- 4947 //---产品名称---
4915 //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 4948 //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
4916 - if (type != 4 && type != 0) { 4949 + if (type != 4 && type != 0 && type != 1 && type != 2 && type != 3) {
4917 context.setFillStyle("black"); 4950 context.setFillStyle("black");
4918 context.setFontSize(21.3 * unit) 4951 context.setFontSize(21.3 * unit)
4919 th.draw_Text(context, share_title, 4952 th.draw_Text(context, share_title,
@@ -4949,7 +4982,7 @@ Page({ @@ -4949,7 +4982,7 @@ Page({
4949 context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); 4982 context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit);
4950 context.stroke(); 4983 context.stroke();
4951 4984
4952 - } else if (type == 4 && type != 0) { 4985 + } else if (type == 4 && type != 0 && type != 1 && type != 2 && type != 3) {
4953 context.setFillStyle("black"); 4986 context.setFillStyle("black");
4954 context.setFontSize(21.3 * unit) 4987 context.setFontSize(21.3 * unit)
4955 th.draw_Text(context, share_title, 4988 th.draw_Text(context, share_title,
@@ -4977,7 +5010,7 @@ Page({ @@ -4977,7 +5010,7 @@ Page({
4977 } 5010 }
4978 5011
4979 //---中间大图--- 5012 //---中间大图---
4980 - if (type != 0) { 5013 + if (type != 0 && type != 1 && type != 2 && type != 3) {
4981 context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit); 5014 context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit);
4982 } 5015 }
4983 ; 5016 ;
@@ -5068,7 +5101,7 @@ Page({ @@ -5068,7 +5101,7 @@ Page({
5068 ; 5101 ;
5069 5102
5070 break; 5103 break;
5071 - case 1: //秒杀商品的展示 5104 + case -12: //秒杀商品的展示
5072 //---画线--- 5105 //---画线---
5073 context.setLineWidth(1 * unit) 5106 context.setLineWidth(1 * unit)
5074 context.moveTo(32 * unit, 670 * unit) 5107 context.moveTo(32 * unit, 670 * unit)
@@ -5101,7 +5134,7 @@ Page({ @@ -5101,7 +5134,7 @@ Page({
5101 } 5134 }
5102 break; 5135 break;
5103 5136
5104 - case 2: //会员团和商家团的展示 5137 + case -2: //会员团和商家团的展示
5105 //---画线--- 5138 //---画线---
5106 context.setLineWidth(1 * unit) 5139 context.setLineWidth(1 * unit)
5107 context.moveTo(32 * unit, 670 * unit) 5140 context.moveTo(32 * unit, 670 * unit)
@@ -5146,7 +5179,7 @@ Page({ @@ -5146,7 +5179,7 @@ Page({
5146 context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); 5179 context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit);
5147 } 5180 }
5148 break 5181 break
5149 - case 3: //阶梯团的展示 5182 + case -3: //阶梯团的展示
5150 //---画线--- 5183 //---画线---
5151 context.setLineWidth(1 * unit) 5184 context.setLineWidth(1 * unit)
5152 context.moveTo(32 * unit, 670 * unit) 5185 context.moveTo(32 * unit, 670 * unit)