Commit 2abc3a971e27c54ea739d15855de3d60c3ed4df5

Authored by yvan.ni
1 parent aa559957

1. 自定义海报

pages/goods/goodsInfo/goodsInfo.js
... ... @@ -3330,7 +3330,7 @@ Page({
3330 3330  
3331 3331 //-- 如果有自定义海报的时候,判断背景的图片 --
3332 3332 if(th.data.share_b_img){
3333   - //pg_path=th.data.share_b_img;
  3333 + pg_path=th.data.share_b_img;
3334 3334 }
3335 3335 context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit);
3336 3336  
... ...
pages/team/team_success/team_success.js
... ... @@ -56,7 +56,34 @@ Page({
56 56 })
57 57 var pay_f = t.payf, order_sn = t.ordersn;
58 58 this.setData({ pay_f: pay_f, order_sn: order_sn}),
59   - this.init(order_sn)
  59 + this.init(order_sn);
  60 +
  61 + //-- 自定义海报 --
  62 + getApp().request.promiseGet("/api/weshop/goods/poster/page",{
  63 + data:{store_id:os.stoid, type:1, is_user:1 }
  64 + }).then(res=>{
  65 + if(res.data.code==0){
  66 +
  67 + var poster_data=res.data.data.pageData[0];
  68 + var json_str=poster_data.jsonStr;
  69 + if(json_str){
  70 + var json_data=JSON.parse(json_str);
  71 + if(json_data.bg_img){
  72 +
  73 + //-- 把图片那到本地 --
  74 + wx.getImageInfo({
  75 + src:json_data.bg_img,
  76 + success: function(res) {
  77 + var path= res.path;
  78 + th.setData({share_b_img:path})
  79 + },
  80 + fail: function(res) {}
  81 + });
  82 + }
  83 + th.setData({poster:json_data})
  84 + }
  85 + }
  86 + })
60 87 },
61 88 //关闭展开列表
62 89 click:function(e){
... ... @@ -377,19 +404,53 @@ Page({
377 404 console.log(vpath);
378 405  
379 406 //先画背景
380   - var pg_path = "../../../images/share/share_bg.png";
  407 + var pg_path = "../../../images/share/share_bg.png";
  408 + //-- 如果有自定义海报的时候,判断背景的图片 --
  409 + if(th.data.share_b_img){
  410 + pg_path=th.data.share_b_img;
  411 + }
  412 +
381 413 context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit);
382   - //--昵称---
383   - context.setFontSize(24 * unit)
384   - context.setFillStyle("black")
385   - context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit);
386   - var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit;
387   - //强烈推荐
388   - var tj_path = "../../../images/share/q_tj.png";
389   - context.drawImage(tj_path, 152 * unit + width, 54 * unit, 110 * unit, 30 * unit);
390   - context.setFontSize(18 * unit)
391   - context.setFillStyle("white")
392   - context.fillText('强烈推荐', 152 * unit + width + 20 * unit, 76 * unit);
  414 +
  415 + //-- 是自定义海报的情况下 --
  416 + if(th.data.poster){
  417 + //在线上分享人的情况下
  418 + if(parseInt(th.data.poster.show_headpic)){
  419 + //获取坐标
  420 + var x=parseFloat(th.data.poster.head_x)*2;
  421 + var y=parseFloat(th.data.poster.head_y)*2;
  422 + var x1=(x+90) *unit;
  423 + var y1=(y+50) *unit;
  424 + //--昵称---
  425 + context.setFontSize(24 * unit)
  426 + context.setFillStyle("black")
  427 + context.fillText(app.globalData.userInfo.nickname, x1, y1);
  428 + var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit;
  429 + //强烈推荐 改许程
  430 + var tj_path = "../../../images/share/q_tj.png";
  431 + context.drawImage(tj_path, x1 + width, y1-22*unit, 85 * unit, 30 * unit);
  432 + context.setFontSize(16 * unit)
  433 + context.setLineJoin('round'); //交点设置成圆角
  434 + context.setFillStyle("white")
  435 + context.fillText('强烈推荐', x1 + width+8*unit, y1-1*unit);
  436 + }
  437 +
  438 + }else{
  439 + //--昵称---
  440 + context.setFontSize(24 * unit)
  441 + context.setFillStyle("black")
  442 + context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit);
  443 + var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit;
  444 + //强烈推荐
  445 + var tj_path = "../../../images/share/q_tj.png";
  446 + context.drawImage(tj_path, 152 * unit + width, 54 * unit, 110 * unit, 30 * unit);
  447 + context.setFontSize(18 * unit)
  448 + context.setFillStyle("white")
  449 + context.fillText('强烈推荐', 152 * unit + width + 20 * unit, 76 * unit);
  450 + }
  451 +
  452 +
  453 +
393 454  
394 455 //---产品名称---
395 456 context.setFontSize(21.3 * unit);
... ... @@ -468,7 +529,15 @@ Page({
468 529 context.setFontSize(22 * unit)
469 530 context.fillText("长按识别二维码,立即参团", 40 * unit, 856 * unit);
470 531 //---二维吗图---
471   - context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
  532 + //-- 自定义海报 --
  533 + if(th.data.poster){
  534 + var erm_x= parseFloat(th.data.poster.ewm_x)*2;
  535 + var erm_y= parseFloat(th.data.poster.ewm_y)*2;
  536 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
  537 + }else{
  538 + //---二维吗图---
  539 + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
  540 + }
472 541 break
473 542 case 2://阶梯团的展示
474 543 //---画线---
... ... @@ -503,24 +572,58 @@ Page({
503 572  
504 573 context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit);
505 574 //---二维吗图---
506   - context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
  575 + //-- 自定义海报 --
  576 + if(th.data.poster){
  577 + var erm_x= parseFloat(th.data.poster.ewm_x)*2;
  578 + var erm_y= parseFloat(th.data.poster.ewm_y)*2;
  579 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit);
  580 + }else{
  581 + //---二维吗图---
  582 + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit);
  583 + }
507 584 break
508 585 }
509 586  
510   - //---绘制圆形要放在最后----
511   - context.save();
512   - context.beginPath();
513   - var h_x = 60 * unit;
514   - var h_y = 24 * unit;
515   - var h_r = 40 * unit;
516   - var cx = h_x + h_r;
517   - var cy = h_y + h_r;
518   - context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
519   - context.closePath();
520   - context.fill();
521   - context.clip();
522   - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
523   - context.restore();
  587 + //--- 如果是自定义海报的时候 ---
  588 + if(th.data.poster){
  589 +
  590 + //如果显示会员信息的话
  591 + if(parseInt(th.data.poster.show_headpic)){
  592 + //获取坐标
  593 + var x= parseFloat(th.data.poster.head_x)*2;
  594 + var y=parseFloat(th.data.poster.head_y)*2;
  595 + //---绘制圆形要放在最后----
  596 + context.save();
  597 + context.beginPath();
  598 + var h_x = x* unit;
  599 + var h_y = y * unit;
  600 + var h_r = 40 * unit;
  601 + var cx = h_x + h_r;
  602 + var cy = h_y + h_r;
  603 + context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
  604 + context.closePath();
  605 + context.fill();
  606 + context.clip();
  607 + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
  608 + context.restore();
  609 + }
  610 +
  611 + }else{
  612 + //---绘制圆形要放在最后----
  613 + context.save();
  614 + context.beginPath();
  615 + var h_x = 60 * unit;
  616 + var h_y = 24 * unit;
  617 + var h_r = 40 * unit;
  618 + var cx = h_x + h_r;
  619 + var cy = h_y + h_r;
  620 + context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
  621 + context.closePath();
  622 + context.fill();
  623 + context.clip();
  624 + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
  625 + context.restore();
  626 + }
524 627  
525 628 //把画板内容绘制成图片,并回调 画板图片路径
526 629 context.draw(false, function () {
... ...