Commit 56108b29bcc8e531b6cf73e5643e8f5f423745f8
1 parent
d9d09bf3
绘制海报的优化
Showing
5 changed files
with
676 additions
and
423 deletions
packageA/pages/goodsInfo/goodsInfo.js
| ... | ... | @@ -469,7 +469,11 @@ Page({ |
| 469 | 469 | }); |
| 470 | 470 | }; |
| 471 | 471 | |
| 472 | - }; | |
| 472 | + }else{ | |
| 473 | + this.setData({ | |
| 474 | + actList: res.data.data, | |
| 475 | + }); | |
| 476 | + } | |
| 473 | 477 | }); |
| 474 | 478 | }; |
| 475 | 479 | // <---- 秒杀 |
| ... | ... | @@ -776,9 +780,11 @@ Page({ |
| 776 | 780 | // mapurl: t.data.data.listServiceVideos[0].video_url, |
| 777 | 781 | // mapurl_f_img: t.data.data.listServiceVideos[0].video_img, |
| 778 | 782 | //listServiceItem: t.data.data.listServiceItem, |
| 783 | + 'isshow':1 | |
| 784 | + | |
| 779 | 785 | }); |
| 780 | 786 | |
| 781 | - this.getTaohe(); | |
| 787 | + that.getTaohe(); | |
| 782 | 788 | |
| 783 | 789 | // console.log('0xxxxx999999', t.data.data); |
| 784 | 790 | //-----商品详情--- | ... | ... |
packageA/pages/serviceCard_pd/goodsInfo/goodsInfo.js
| ... | ... | @@ -206,7 +206,6 @@ Page({ |
| 206 | 206 | gid = t.goods_id, |
| 207 | 207 | first_leader = t.first_leader; |
| 208 | 208 | |
| 209 | - | |
| 210 | 209 | //-- 自定义海报 -- |
| 211 | 210 | getApp().request.promiseGet("/api/weshop/goods/poster/page", { |
| 212 | 211 | data:{store_id:os.stoid, type:1, is_use:1} |
| ... | ... | @@ -1541,7 +1540,7 @@ Page({ |
| 1541 | 1540 | } |
| 1542 | 1541 | ///二微码 |
| 1543 | 1542 | var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + |
| 1544 | - os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo"; | |
| 1543 | + os.stoid + "?sceneValue=" + scene + "&pageValue=packageA/pages/serviceCard_pd/goodsInfo/goodsInfo"; | |
| 1545 | 1544 | |
| 1546 | 1545 | console.log(path3); |
| 1547 | 1546 | ... | ... |
packageA/pages/serviceCard_pd/team_show/team_show.js
| ... | ... | @@ -134,6 +134,7 @@ Page({ |
| 134 | 134 | th.setData({ bconfig: e,sys_switch:json_d}); |
| 135 | 135 | th.wait_for_store_config(); //获取默认的门店 |
| 136 | 136 | }) |
| 137 | + | |
| 137 | 138 | |
| 138 | 139 | }, |
| 139 | 140 | |
| ... | ... | @@ -974,14 +975,12 @@ Page({ |
| 974 | 975 | |
| 975 | 976 | return { |
| 976 | 977 | path:url, |
| 977 | - title: "商品分类", | |
| 978 | + title: "拼团", | |
| 978 | 979 | imageUrl: img, |
| 979 | 980 | } |
| 980 | 981 | }, |
| 981 | 982 | |
| 982 | - | |
| 983 | - | |
| 984 | - | |
| 983 | + | |
| 985 | 984 | |
| 986 | 985 | closeSpecModal: function() { |
| 987 | 986 | this.setData({ | ... | ... |
packageA/pages/serviceCard_pd/team_success/team_success.js
| ... | ... | @@ -81,7 +81,12 @@ Page({ |
| 81 | 81 | th.setData({poster:json_data}) |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | - }) | |
| 84 | + }) | |
| 85 | + | |
| 86 | + | |
| 87 | + getApp().getConfig(function (e) { | |
| 88 | + th.setData({sto_sele_name_1: e.store_name}) | |
| 89 | + }) | |
| 85 | 90 | }, |
| 86 | 91 | onShow:function () { |
| 87 | 92 | getApp().check_can_share(this); |
| ... | ... | @@ -193,7 +198,8 @@ Page({ |
| 193 | 198 | }).then(res => { |
| 194 | 199 | if(res.data.code==0){ |
| 195 | 200 | teamlist=res.data.data; |
| 196 | - this.setData({ | |
| 201 | + ee.data.prom_act=teamlist; | |
| 202 | + ee.setData({ | |
| 197 | 203 | teamlist:teamlist |
| 198 | 204 | }); |
| 199 | 205 | var nt =ut.gettimestamp(); |
| ... | ... | @@ -437,225 +443,228 @@ Page({ |
| 437 | 443 | var share_title=th.data.teamlist.share_title; |
| 438 | 444 | if(!share_title) |
| 439 | 445 | share_title=th.data.teamlist.title; |
| 440 | - context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | |
| 441 | - | |
| 442 | - //-- 是自定义海报的情况下 -- | |
| 443 | - if(th.data.poster && parseInt(th.data.poster.style)==2){ | |
| 444 | - //在线上分享人的情况下 | |
| 445 | - if(parseInt(th.data.poster.show_headpic)){ | |
| 446 | - //获取坐标 | |
| 447 | - var x=parseFloat(th.data.poster.head_x)*2; | |
| 448 | - var y=parseFloat(th.data.poster.head_y)*2; | |
| 449 | - var x1=(x+90) *unit; | |
| 450 | - var y1=(y+50) *unit; | |
| 451 | - //--昵称--- | |
| 452 | - context.setFontSize(24 * unit) | |
| 453 | - context.setFillStyle("black") | |
| 454 | - context.fillText(app.globalData.userInfo.nickname, x1, y1); | |
| 455 | - var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit; | |
| 456 | - //强烈推荐 改许程 | |
| 457 | - var tj_path = "../../../../images/share/q_tj.png"; | |
| 458 | - context.drawImage(tj_path, x1 + width, y1-22*unit, 85 * unit, 30 * unit); | |
| 459 | - context.setFontSize(16 * unit) | |
| 460 | - context.setLineJoin('round'); //交点设置成圆角 | |
| 461 | - context.setFillStyle("white") | |
| 462 | - context.fillText('强烈推荐', x1 + width+8*unit, y1-1*unit); | |
| 463 | - } | |
| 464 | - | |
| 465 | - }else{ | |
| 466 | - //--昵称--- | |
| 467 | - context.setFontSize(24 * unit) | |
| 468 | - context.setFillStyle("black") | |
| 469 | - context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit); | |
| 470 | - var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; | |
| 471 | - //强烈推荐 | |
| 472 | - var tj_path = "../../../../images/share/q_tj.png"; | |
| 473 | - context.drawImage(tj_path, 152 * unit + width, 54 * unit, 110 * unit, 30 * unit); | |
| 474 | - context.setFontSize(18 * unit) | |
| 475 | - context.setFillStyle("white") | |
| 476 | - context.fillText('强烈推荐', 152 * unit + width + 20 * unit, 76 * unit); | |
| 477 | - } | |
| 478 | - | |
| 479 | 446 | |
| 480 | - //---产品名称--- | |
| 481 | - context.setFontSize(21.3 * unit); | |
| 482 | - context.setFillStyle("black"); | |
| 447 | + var act_time=''; | |
| 448 | + if (!th.data.share_b_img){ // 如果是普通商品,绘制新海报 | |
| 449 | + th.drawPoster(context, unit, th.data.share_img_localpath, vpath, type); | |
| 450 | + } else { | |
| 483 | 451 | |
| 452 | + context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | |
| 453 | + //-- 是自定义海报的情况下 -- | |
| 454 | + if (th.data.poster && parseInt(th.data.poster.style) == 2) { | |
| 455 | + //在线上分享人的情况下 | |
| 456 | + if (parseInt(th.data.poster.show_headpic)) { | |
| 457 | + //获取坐标 | |
| 458 | + var x = parseFloat(th.data.poster.head_x) * 2; | |
| 459 | + var y = parseFloat(th.data.poster.head_y) * 2; | |
| 460 | + var x1 = (x + 90) * unit; | |
| 461 | + var y1 = (y + 50) * unit; | |
| 462 | + //--昵称--- | |
| 463 | + context.setFontSize(24 * unit) | |
| 464 | + context.setFillStyle("black") | |
| 465 | + context.fillText(app.globalData.userInfo.nickname, x1, y1); | |
| 466 | + var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit; | |
| 467 | + //强烈推荐 改许程 | |
| 468 | + var tj_path = "../../../../images/share/q_tj.png"; | |
| 469 | + context.drawImage(tj_path, x1 + width, y1 - 22 * unit, 85 * unit, 30 * unit); | |
| 470 | + context.setFontSize(16 * unit) | |
| 471 | + context.setLineJoin('round'); //交点设置成圆角 | |
| 472 | + context.setFillStyle("white") | |
| 473 | + context.fillText('强烈推荐', x1 + width + 8 * unit, y1 - 1 * unit); | |
| 474 | + } | |
| 484 | 475 | |
| 476 | + } else { | |
| 477 | + //--昵称--- | |
| 478 | + context.setFontSize(24 * unit) | |
| 479 | + context.setFillStyle("black") | |
| 480 | + context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit); | |
| 481 | + var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; | |
| 482 | + //强烈推荐 | |
| 483 | + var tj_path = "../../../../images/share/q_tj.png"; | |
| 484 | + context.drawImage(tj_path, 152 * unit + width, 54 * unit, 110 * unit, 30 * unit); | |
| 485 | + context.setFontSize(18 * unit) | |
| 486 | + context.setFillStyle("white") | |
| 487 | + context.fillText('强烈推荐', 152 * unit + width + 20 * unit, 76 * unit); | |
| 488 | + } | |
| 485 | 489 | |
| 486 | 490 | |
| 487 | - th.draw_Text(context,share_title, | |
| 488 | - 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); | |
| 489 | - //------产品的价格------- | |
| 490 | - context.setFontSize(24 * unit) | |
| 491 | - context.setFillStyle("red") | |
| 491 | + //---产品名称--- | |
| 492 | + context.setFontSize(21.3 * unit); | |
| 493 | + context.setFillStyle("black"); | |
| 494 | + | |
| 495 | + th.draw_Text(context,share_title, | |
| 496 | + 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); | |
| 497 | + //------产品的价格------- | |
| 498 | + context.setFontSize(24 * unit) | |
| 499 | + context.setFillStyle("red") | |
| 500 | + | |
| 501 | + var pri0 = th.data.teamlist.price; | |
| 502 | + pri0=parseFloat(pri0).toFixed(2); | |
| 503 | + var wd1=th.data.screenWidth-ut.measureText(pri0, 31 * unit)-25; | |
| 504 | + context.fillText("¥", wd1-15, 180 * unit); | |
| 505 | + context.setFontSize(31 * unit) | |
| 506 | + context.fillText(pri0, wd1, 180 * unit); | |
| 507 | + | |
| 508 | + //---市场价划掉--- | |
| 509 | + context.setFillStyle("gray") | |
| 510 | + context.setFontSize(22 * unit) | |
| 511 | + pri0= "¥" + parseFloat(th.data.goods.market_price).toFixed(2); | |
| 512 | + var wd2=th.data.screenWidth-ut.measureText(pri0, 22 * unit)-25; | |
| 513 | + context.fillText(pri0, wd2, 210 * unit); | |
| 514 | + | |
| 515 | + context.setStrokeStyle('gray') | |
| 516 | + context.setLineWidth(1 * unit) | |
| 517 | + context.moveTo(wd2-5, 204 * unit) | |
| 518 | + context.lineTo(wd2+ut.measureText(pri0, 22 * unit)+5, 204 * unit) | |
| 519 | + context.stroke(); | |
| 520 | + console.log(th.data.share_img_localpath); | |
| 521 | + | |
| 522 | + | |
| 523 | + //---中间大图--- | |
| 524 | + context.drawImage(th.data.share_img_localpath, 68 * unit, 242 * unit, 410 * unit, 410 * unit); | |
| 525 | + | |
| 526 | + var g_ct=th.data.teamlist.ct_num-th.data.ordertx.length; | |
| 527 | + var wz= ""; | |
| 528 | + if(g_ct>0) wz="还差"+g_ct+"人成团,"; | |
| 529 | + else{ | |
| 530 | + g_ct= th.data.max_num -th.data.ordertx.length; | |
| 531 | + if(g_ct>0){ | |
| 532 | + wz="还差"+g_ct+"人享最低优惠,"; | |
| 533 | + }else{ | |
| 534 | + wz="已享受最优惠,"; | |
| 535 | + } | |
| 536 | + } | |
| 492 | 537 | |
| 493 | - var pri0 = th.data.teamlist.price; | |
| 494 | - pri0=parseFloat(pri0).toFixed(2); | |
| 495 | - var wd1=th.data.screenWidth-ut.measureText(pri0, 31 * unit)-25; | |
| 496 | - context.fillText("¥", wd1-15, 180 * unit); | |
| 497 | - context.setFontSize(31 * unit) | |
| 498 | - context.fillText(pri0, wd1, 180 * unit); | |
| 538 | + //-------大图后面就不一样了----------- | |
| 539 | + switch (type) { | |
| 540 | + case 1://会员团和商家团的展示 | |
| 541 | + //---画线--- | |
| 542 | + context.setLineWidth(1 * unit) | |
| 543 | + context.moveTo(32 * unit, 670 * unit) | |
| 544 | + context.lineTo(520 * unit, 670 * unit) | |
| 545 | + context.stroke(); | |
| 499 | 546 | |
| 500 | - //---市场价划掉--- | |
| 501 | - context.setFillStyle("gray") | |
| 502 | - context.setFontSize(22 * unit) | |
| 503 | - pri0= "¥" + parseFloat(th.data.goods.market_price).toFixed(2); | |
| 504 | - var wd2=th.data.screenWidth-ut.measureText(pri0, 22 * unit)-25; | |
| 505 | - context.fillText(pri0, wd2, 210 * unit); | |
| 547 | + //---文字--- | |
| 548 | + context.setFontSize(22 * unit) | |
| 549 | + context.setFillStyle("black") | |
| 550 | + context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit); | |
| 506 | 551 | |
| 507 | - context.setStrokeStyle('gray') | |
| 508 | - context.setLineWidth(1 * unit) | |
| 509 | - context.moveTo(wd2-5, 204 * unit) | |
| 510 | - context.lineTo(wd2+ut.measureText(pri0, 22 * unit)+5, 204 * unit) | |
| 511 | - context.stroke(); | |
| 512 | - console.log(th.data.share_img_localpath); | |
| 552 | + //绘制成团图片 | |
| 553 | + var ct_img ="../../../../images/share/ct_num.png"; | |
| 554 | + context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); | |
| 555 | + var ct_num = th.data.teamlist.ct_num; | |
| 556 | + context.setFontSize(14 * unit) | |
| 513 | 557 | |
| 558 | + context.setFillStyle("red") | |
| 559 | + if(ct_num<10){ | |
| 560 | + context.fillText(ct_num+"人拼团", 92 * unit, 760 * unit); | |
| 561 | + }else{ | |
| 562 | + context.fillText(ct_num+"人拼团", 86 * unit, 760 * unit); | |
| 563 | + } | |
| 564 | + context.setFontSize(22 * unit) | |
| 565 | + context.fillText("已拼"+th.data.teamlist.buy_num+"份", 166 * unit, 763 * unit); | |
| 566 | + context.setFillStyle("gray") | |
| 567 | + context.fillText(wz+"快来和我一起拼团吧!", 40 * unit, 826 * unit); | |
| 568 | + context.setFillStyle("black") | |
| 569 | + | |
| 570 | + context.setFontSize(22 * unit) | |
| 571 | + context.fillText("长按识别二维码,立即参团", 40 * unit, 856 * unit); | |
| 572 | + //---二维吗图--- | |
| 573 | + //-- 自定义海报 -- | |
| 574 | + if(th.data.poster){ | |
| 575 | + var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
| 576 | + var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
| 577 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
| 578 | + }else{ | |
| 579 | + //---二维吗图--- | |
| 580 | + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
| 581 | + } | |
| 582 | + break | |
| 583 | + case 2://阶梯团的展示 | |
| 584 | + //---画线--- | |
| 585 | + context.setLineWidth(1 * unit) | |
| 586 | + context.moveTo(32 * unit, 670 * unit) | |
| 587 | + context.lineTo(520 * unit, 670 * unit) | |
| 588 | + context.stroke(); | |
| 589 | + //---文字--- | |
| 590 | + context.setFontSize(22 * unit) | |
| 591 | + context.setFillStyle("black") | |
| 592 | + context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit); | |
| 593 | + //---绘制中间阶梯的价格--- | |
| 594 | + var list= JSON.parse(th.data.teamlist.ct_rylist); | |
| 595 | + for(var i=0; i<list.length;i++){ | |
| 596 | + var item=list[i]; | |
| 597 | + var wi=i*90*unit; | |
| 598 | + context.setFontSize(16 * unit) | |
| 599 | + context.setFillStyle("red") | |
| 600 | + context.fillText("¥", 40 * unit+wi, 756 * unit); | |
| 601 | + context.setFontSize(22 * unit) | |
| 602 | + var pri=parseFloat(item.price).toFixed(2); | |
| 603 | + context.fillText(pri, 56 * unit+wi, 756 * unit); | |
| 604 | + context.setFillStyle("gray") | |
| 605 | + context.fillText("满"+item.rynum+"人", 40 * unit+wi, 786 * unit); | |
| 606 | + } | |
| 514 | 607 | |
| 515 | - //---中间大图--- | |
| 516 | - context.drawImage(th.data.share_img_localpath, 68 * unit, 242 * unit, 410 * unit, 410 * unit); | |
| 608 | + //----------------下面部分---------------- | |
| 609 | + context.setFillStyle("gray") | |
| 610 | + context.fillText(wz+"快来和我一起拼团吧!", 40 * unit, 830 * unit); | |
| 611 | + context.setFillStyle("black") | |
| 612 | + context.setFontSize(22 * unit) | |
| 517 | 613 | |
| 518 | - var g_ct=th.data.teamlist.ct_num-th.data.ordertx.length; | |
| 519 | - var wz= ""; | |
| 520 | - if(g_ct>0) wz="还差"+g_ct+"人成团,"; | |
| 521 | - else{ | |
| 522 | - g_ct= th.data.max_num -th.data.ordertx.length; | |
| 523 | - if(g_ct>0){ | |
| 524 | - wz="还差"+g_ct+"人享最低优惠,"; | |
| 525 | - }else{ | |
| 526 | - wz="已享受最优惠,"; | |
| 614 | + context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit); | |
| 615 | + //---二维吗图--- | |
| 616 | + //-- 自定义海报 -- | |
| 617 | + if(th.data.poster){ | |
| 618 | + var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
| 619 | + var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
| 620 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
| 621 | + }else{ | |
| 622 | + //---二维吗图--- | |
| 623 | + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
| 624 | + } | |
| 625 | + break | |
| 527 | 626 | } |
| 528 | - } | |
| 529 | 627 | |
| 530 | - //-------大图后面就不一样了----------- | |
| 531 | - switch (type) { | |
| 532 | - case 1://会员团和商家团的展示 | |
| 533 | - //---画线--- | |
| 534 | - context.setLineWidth(1 * unit) | |
| 535 | - context.moveTo(32 * unit, 670 * unit) | |
| 536 | - context.lineTo(520 * unit, 670 * unit) | |
| 537 | - context.stroke(); | |
| 538 | - | |
| 539 | - //---文字--- | |
| 540 | - context.setFontSize(22 * unit) | |
| 541 | - context.setFillStyle("black") | |
| 542 | - context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit); | |
| 543 | - | |
| 544 | - //绘制成团图片 | |
| 545 | - var ct_img ="../../../../images/share/ct_num.png"; | |
| 546 | - context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); | |
| 547 | - var ct_num = th.data.teamlist.ct_num; | |
| 548 | - context.setFontSize(14 * unit) | |
| 549 | - | |
| 550 | - context.setFillStyle("red") | |
| 551 | - if(ct_num<10){ | |
| 552 | - context.fillText(ct_num+"人拼团", 92 * unit, 760 * unit); | |
| 553 | - }else{ | |
| 554 | - context.fillText(ct_num+"人拼团", 86 * unit, 760 * unit); | |
| 555 | - } | |
| 556 | - context.setFontSize(22 * unit) | |
| 557 | - context.fillText("已拼"+th.data.teamlist.buy_num+"份", 166 * unit, 763 * unit); | |
| 558 | - context.setFillStyle("gray") | |
| 559 | - context.fillText(wz+"快来和我一起拼团吧!", 40 * unit, 826 * unit); | |
| 560 | - context.setFillStyle("black") | |
| 561 | - | |
| 562 | - context.setFontSize(22 * unit) | |
| 563 | - context.fillText("长按识别二维码,立即参团", 40 * unit, 856 * unit); | |
| 564 | - //---二维吗图--- | |
| 565 | - //-- 自定义海报 -- | |
| 566 | - if(th.data.poster){ | |
| 567 | - var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
| 568 | - var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
| 569 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
| 570 | - }else{ | |
| 571 | - //---二维吗图--- | |
| 572 | - context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
| 573 | - } | |
| 574 | - break | |
| 575 | - case 2://阶梯团的展示 | |
| 576 | - //---画线--- | |
| 577 | - context.setLineWidth(1 * unit) | |
| 578 | - context.moveTo(32 * unit, 670 * unit) | |
| 579 | - context.lineTo(520 * unit, 670 * unit) | |
| 580 | - context.stroke(); | |
| 581 | - //---文字--- | |
| 582 | - context.setFontSize(22 * unit) | |
| 583 | - context.setFillStyle("black") | |
| 584 | - context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit); | |
| 585 | - //---绘制中间阶梯的价格--- | |
| 586 | - var list= JSON.parse(th.data.teamlist.ct_rylist); | |
| 587 | - for(var i=0; i<list.length;i++){ | |
| 588 | - var item=list[i]; | |
| 589 | - var wi=i*90*unit; | |
| 590 | - context.setFontSize(16 * unit) | |
| 591 | - context.setFillStyle("red") | |
| 592 | - context.fillText("¥", 40 * unit+wi, 756 * unit); | |
| 593 | - context.setFontSize(22 * unit) | |
| 594 | - var pri=parseFloat(item.price).toFixed(2); | |
| 595 | - context.fillText(pri, 56 * unit+wi, 756 * unit); | |
| 596 | - context.setFillStyle("gray") | |
| 597 | - context.fillText("满"+item.rynum+"人", 40 * unit+wi, 786 * unit); | |
| 628 | + //--- 如果是自定义海报的时候 --- | |
| 629 | + if(th.data.poster && parseInt(th.data.poster.style)==2){ | |
| 630 | + | |
| 631 | + //如果显示会员信息的话 | |
| 632 | + if(parseInt(th.data.poster.show_headpic)){ | |
| 633 | + //获取坐标 | |
| 634 | + var x= parseFloat(th.data.poster.head_x)*2; | |
| 635 | + var y=parseFloat(th.data.poster.head_y)*2; | |
| 636 | + //---绘制圆形要放在最后---- | |
| 637 | + context.save(); | |
| 638 | + context.beginPath(); | |
| 639 | + var h_x = x* unit; | |
| 640 | + var h_y = y * unit; | |
| 641 | + var h_r = 40 * unit; | |
| 642 | + var cx = h_x + h_r; | |
| 643 | + var cy = h_y + h_r; | |
| 644 | + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
| 645 | + context.closePath(); | |
| 646 | + context.fill(); | |
| 647 | + context.clip(); | |
| 648 | + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
| 649 | + context.restore(); | |
| 598 | 650 | } |
| 599 | 651 | |
| 600 | - //----------------下面部分---------------- | |
| 601 | - context.setFillStyle("gray") | |
| 602 | - context.fillText(wz+"快来和我一起拼团吧!", 40 * unit, 830 * unit); | |
| 603 | - context.setFillStyle("black") | |
| 604 | - context.setFontSize(22 * unit) | |
| 605 | - | |
| 606 | - context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit); | |
| 607 | - //---二维吗图--- | |
| 608 | - //-- 自定义海报 -- | |
| 609 | - if(th.data.poster){ | |
| 610 | - var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
| 611 | - var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
| 612 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
| 613 | - }else{ | |
| 614 | - //---二维吗图--- | |
| 615 | - context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
| 616 | - } | |
| 617 | - break | |
| 618 | - } | |
| 619 | - | |
| 620 | - //--- 如果是自定义海报的时候 --- | |
| 621 | - if(th.data.poster && parseInt(th.data.poster.style)==2){ | |
| 622 | - | |
| 623 | - //如果显示会员信息的话 | |
| 624 | - if(parseInt(th.data.poster.show_headpic)){ | |
| 625 | - //获取坐标 | |
| 626 | - var x= parseFloat(th.data.poster.head_x)*2; | |
| 627 | - var y=parseFloat(th.data.poster.head_y)*2; | |
| 628 | - //---绘制圆形要放在最后---- | |
| 629 | - context.save(); | |
| 630 | - context.beginPath(); | |
| 631 | - var h_x = x* unit; | |
| 632 | - var h_y = y * unit; | |
| 633 | - var h_r = 40 * unit; | |
| 634 | - var cx = h_x + h_r; | |
| 635 | - var cy = h_y + h_r; | |
| 636 | - context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
| 637 | - context.closePath(); | |
| 638 | - context.fill(); | |
| 639 | - context.clip(); | |
| 640 | - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
| 641 | - context.restore(); | |
| 642 | - } | |
| 643 | - | |
| 644 | - }else{ | |
| 645 | - //---绘制圆形要放在最后---- | |
| 646 | - context.save(); | |
| 647 | - context.beginPath(); | |
| 648 | - var h_x = 60 * unit; | |
| 649 | - var h_y = 24 * unit; | |
| 650 | - var h_r = 40 * unit; | |
| 651 | - var cx = h_x + h_r; | |
| 652 | - var cy = h_y + h_r; | |
| 653 | - context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
| 654 | - context.closePath(); | |
| 655 | - context.fill(); | |
| 656 | - context.clip(); | |
| 657 | - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
| 658 | - context.restore(); | |
| 652 | + }else{ | |
| 653 | + //---绘制圆形要放在最后---- | |
| 654 | + context.save(); | |
| 655 | + context.beginPath(); | |
| 656 | + var h_x = 60 * unit; | |
| 657 | + var h_y = 24 * unit; | |
| 658 | + var h_r = 40 * unit; | |
| 659 | + var cx = h_x + h_r; | |
| 660 | + var cy = h_y + h_r; | |
| 661 | + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
| 662 | + context.closePath(); | |
| 663 | + context.fill(); | |
| 664 | + context.clip(); | |
| 665 | + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
| 666 | + context.restore(); | |
| 667 | + } | |
| 659 | 668 | } |
| 660 | 669 | |
| 661 | 670 | //把画板内容绘制成图片,并回调 画板图片路径 |
| ... | ... | @@ -991,7 +1000,123 @@ Page({ |
| 991 | 1000 | go_to:function (e) { |
| 992 | 1001 | var url=e.currentTarget.dataset.url; |
| 993 | 1002 | getApp().goto(url); |
| 994 | - } | |
| 1003 | + }, | |
| 1004 | + | |
| 1005 | + //-- 先版绘制 -- | |
| 1006 | + drawPoster(context, unit, img, vpath, type) { | |
| 1007 | + | |
| 1008 | + var self=this; | |
| 1009 | + | |
| 1010 | + // 1.灰色背景 | |
| 1011 | + context.setFillStyle('#f2f1f6'); | |
| 1012 | + context.rect(0, 0, 554 * unit, 899 * unit); | |
| 1013 | + context.fill(); | |
| 1014 | + | |
| 1015 | + // 2.商城名称 | |
| 1016 | + let shopName = this.data.sto_sele_name_1; | |
| 1017 | + context.setTextAlign('center'); | |
| 1018 | + context.setFontSize(26 * unit); | |
| 1019 | + context.setFillStyle('black'); | |
| 1020 | + context.fillText(shopName, 277 * unit, 60 * unit); | |
| 1021 | + | |
| 1022 | + // 3.推荐来源 | |
| 1023 | + let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; | |
| 1024 | + context.setTextAlign('center'); | |
| 1025 | + context.setFontSize(22 * unit); | |
| 1026 | + context.setFillStyle('#96959a'); | |
| 1027 | + context.fillText(fromText, 277 * unit, 105 * unit); | |
| 1028 | + | |
| 1029 | + // 4.海报背景 | |
| 1030 | + context.setFillStyle('white'); | |
| 1031 | + context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit); | |
| 1032 | + | |
| 1033 | + // 5.商品图片 | |
| 1034 | + // 图片的x坐标 | |
| 1035 | + let bg_x = 37 * unit | |
| 1036 | + // 图片的y坐标 | |
| 1037 | + let bg_y = 157 * unit | |
| 1038 | + // 图片宽度 | |
| 1039 | + let bg_w = 480 * unit | |
| 1040 | + // 图片高度 | |
| 1041 | + let bg_h = 474 * unit | |
| 1042 | + // 图片圆角 | |
| 1043 | + let bg_r = 4 | |
| 1044 | + // 绘制海报背景图片圆角 | |
| 1045 | + context.save() | |
| 1046 | + context.beginPath() | |
| 1047 | + context.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5) | |
| 1048 | + context.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2) | |
| 1049 | + context.arc(bg_x + bg_w, bg_y + bg_h, bg_r, 0, Math.PI * 0.5) | |
| 1050 | + context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI) | |
| 1051 | + context.clip() | |
| 1052 | + context.drawImage(img, bg_x, bg_y, bg_w, bg_h); | |
| 1053 | + context.restore(); | |
| 1054 | + | |
| 1055 | + // 6.强烈推荐 | |
| 1056 | + let src = ''; | |
| 1057 | + context.beginPath(); | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + if (type == 1) { // 商家和会员团 | |
| 1061 | + src = '../../../../images/share/ct_num.png'; | |
| 1062 | + context.drawImage(src, 54 * unit, 648 * unit, 120 * unit, 30 * unit); | |
| 1063 | + context.setTextAlign('left'); | |
| 1064 | + | |
| 1065 | + let ct_num = self.data.prom_act.ct_num; | |
| 1066 | + context.setFontSize(16 * unit) | |
| 1067 | + context.font = 'normal'; | |
| 1068 | + context.setFillStyle("red") | |
| 1069 | + if (ct_num < 10) { | |
| 1070 | + context.fillText(ct_num + "人拼团", 100 * unit, 670 * unit); | |
| 1071 | + } else { | |
| 1072 | + context.fillText(ct_num + "人拼团", 96 * unit, 670 * unit); | |
| 1073 | + } | |
| 1074 | + context.setFontSize(22 * unit) | |
| 1075 | + context.fillText("已拼" + self.data.prom_act.buy_num + "份", 186 * unit, 672 * unit); | |
| 1076 | + } | |
| 1077 | + | |
| 1078 | + if (type == 2) { // 阶梯团 | |
| 1079 | + let list = self.data.prom_act.ct_rylist; | |
| 1080 | + for (let i = 0; i < list.length; i++) { | |
| 1081 | + let item = list[i]; | |
| 1082 | + let wi = i * 90 * unit; | |
| 1083 | + context.font = 'normal'; | |
| 1084 | + context.setTextAlign('left'); | |
| 1085 | + context.setFontSize(16 * unit) | |
| 1086 | + context.setFillStyle("red") | |
| 1087 | + context.fillText("¥", 50 * unit + wi, 680 * unit); | |
| 1088 | + context.setFontSize(22 * unit) | |
| 1089 | + let pri = parseFloat(item.price).toFixed(2); | |
| 1090 | + context.fillText(pri, 66 * unit + wi, 680 * unit); | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + context.setFillStyle("gray") | |
| 1094 | + context.fillText("满" + item.rynum + "人", 50 * unit + wi, 716 * unit); | |
| 1095 | + } | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + var wp= 52 * unit; | |
| 1099 | + var hp=755 * unit | |
| 1100 | + self.draw_pos_price(context,wp,hp,self.data.data.market_price,unit); | |
| 1101 | + } | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + // 8.商品标题 | |
| 1105 | + context.setFontSize(20 * unit); | |
| 1106 | + context.setFillStyle('#898989'); | |
| 1107 | + getApp().draw_Text(context, this.data.goods.service_name, 54 * unit, 800 * unit, 240 * unit, 280 * unit, unit, 1); | |
| 1108 | + // 9.小程序码 | |
| 1109 | + context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); | |
| 1110 | + context.setFontSize(16 * unit); | |
| 1111 | + context.setFillStyle('#777'); | |
| 1112 | + context.fillText('长按识别二维码', 378 * unit, 810 * unit); | |
| 1113 | + | |
| 1114 | + // 10.竖线 | |
| 1115 | + context.beginPath(); | |
| 1116 | + context.setFillStyle('#eee'); | |
| 1117 | + context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit); | |
| 1118 | + context.fill(); | |
| 1119 | + }, | |
| 995 | 1120 | |
| 996 | 1121 | }) |
| 997 | 1122 | ... | ... |
pages/team/team_success/team_success.js
| ... | ... | @@ -84,7 +84,11 @@ Page({ |
| 84 | 84 | th.setData({poster:json_data}) |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | - }) | |
| 87 | + }) | |
| 88 | + | |
| 89 | + getApp().getConfig(function (e) { | |
| 90 | + th.setData({sto_sele_name_1: e.store_name}) | |
| 91 | + }) | |
| 88 | 92 | }, |
| 89 | 93 | onShow:function () { |
| 90 | 94 | getApp().check_can_share(); |
| ... | ... | @@ -462,223 +466,227 @@ Page({ |
| 462 | 466 | var share_title=th.data.teamlist.share_title; |
| 463 | 467 | if(!share_title) |
| 464 | 468 | share_title=th.data.teamlist.title; |
| 465 | - context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | |
| 466 | - | |
| 467 | - //-- 是自定义海报的情况下 -- | |
| 468 | - if(th.data.poster && parseInt(th.data.poster.style)==2){ | |
| 469 | - //在线上分享人的情况下 | |
| 470 | - if(parseInt(th.data.poster.show_headpic)){ | |
| 471 | - //获取坐标 | |
| 472 | - var x=parseFloat(th.data.poster.head_x)*2; | |
| 473 | - var y=parseFloat(th.data.poster.head_y)*2; | |
| 474 | - var x1=(x+90) *unit; | |
| 475 | - var y1=(y+50) *unit; | |
| 476 | - //--昵称--- | |
| 477 | - context.setFontSize(24 * unit) | |
| 478 | - context.setFillStyle("black") | |
| 479 | - context.fillText(app.globalData.userInfo.nickname, x1, y1); | |
| 480 | - var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit; | |
| 481 | - //强烈推荐 改许程 | |
| 482 | - var tj_path = "../../../images/share/q_tj.png"; | |
| 483 | - context.drawImage(tj_path, x1 + width, y1-22*unit, 85 * unit, 30 * unit); | |
| 484 | - context.setFontSize(16 * unit) | |
| 485 | - context.setLineJoin('round'); //交点设置成圆角 | |
| 486 | - context.setFillStyle("white") | |
| 487 | - context.fillText('强烈推荐', x1 + width+8*unit, y1-1*unit); | |
| 488 | - } | |
| 489 | - | |
| 490 | - }else{ | |
| 491 | - //--昵称--- | |
| 492 | - context.setFontSize(24 * unit) | |
| 493 | - context.setFillStyle("black") | |
| 494 | - context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit); | |
| 495 | - var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; | |
| 496 | - //强烈推荐 | |
| 497 | - var tj_path = "../../../images/share/q_tj.png"; | |
| 498 | - context.drawImage(tj_path, 152 * unit + width, 54 * unit, 110 * unit, 30 * unit); | |
| 499 | - context.setFontSize(18 * unit) | |
| 500 | - context.setFillStyle("white") | |
| 501 | - context.fillText('强烈推荐', 152 * unit + width + 20 * unit, 76 * unit); | |
| 502 | - } | |
| 503 | - | |
| 504 | - | |
| 505 | - //---产品名称--- | |
| 506 | - context.setFontSize(21.3 * unit); | |
| 507 | - context.setFillStyle("black"); | |
| 508 | - | |
| 509 | - | |
| 510 | - getApp().draw_Text(context,share_title, | |
| 511 | - 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); | |
| 512 | - //------产品的价格------- | |
| 513 | - context.setFontSize(24 * unit) | |
| 514 | - context.setFillStyle("red") | |
| 515 | - | |
| 516 | - var pri0 = th.data.teamlist.price; | |
| 517 | - pri0=parseFloat(pri0).toFixed(2); | |
| 518 | - var wd1=th.data.screenWidth-ut.measureText(pri0, 31 * unit)-25; | |
| 519 | - context.fillText("¥", wd1-15, 180 * unit); | |
| 520 | - context.setFontSize(31 * unit) | |
| 521 | - context.fillText(pri0, wd1, 180 * unit); | |
| 522 | - | |
| 523 | - //---市场价划掉--- | |
| 524 | - context.setFillStyle("gray") | |
| 525 | - context.setFontSize(22 * unit) | |
| 526 | - pri0= "¥" + parseFloat(th.data.goods.market_price).toFixed(2); | |
| 527 | - var wd2=th.data.screenWidth-ut.measureText(pri0, 22 * unit)-25; | |
| 528 | - context.fillText(pri0, wd2, 210 * unit); | |
| 529 | - | |
| 530 | - context.setStrokeStyle('gray') | |
| 531 | - context.setLineWidth(1 * unit) | |
| 532 | - context.moveTo(wd2-5, 204 * unit) | |
| 533 | - context.lineTo(wd2+ut.measureText(pri0, 22 * unit)+5, 204 * unit) | |
| 534 | - context.stroke(); | |
| 535 | - console.log(th.data.share_img_localpath); | |
| 536 | - | |
| 537 | - | |
| 538 | - //---中间大图--- | |
| 539 | - context.drawImage(th.data.share_img_localpath, 68 * unit, 242 * unit, 410 * unit, 410 * unit); | |
| 540 | - | |
| 541 | - var g_ct=th.data.teamlist.ct_num-th.data.ordertx.length; | |
| 542 | - var wz= ""; | |
| 543 | - if(g_ct>0) wz="还差"+g_ct+"人成团,"; | |
| 544 | - else{ | |
| 545 | - g_ct= th.data.max_num -th.data.ordertx.length; | |
| 546 | - if(g_ct>0){ | |
| 547 | - wz="还差"+g_ct+"人享最低优惠,"; | |
| 469 | + | |
| 470 | + if (!th.data.share_b_img){ // 如果是普通商品,绘制新海报 | |
| 471 | + th.drawPoster(context, unit, th.data.share_img_localpath, vpath, type); | |
| 472 | + } else { | |
| 473 | + context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | |
| 474 | + //-- 是自定义海报的情况下 -- | |
| 475 | + if(th.data.poster && parseInt(th.data.poster.style)==2){ | |
| 476 | + //在线上分享人的情况下 | |
| 477 | + if(parseInt(th.data.poster.show_headpic)){ | |
| 478 | + //获取坐标 | |
| 479 | + var x=parseFloat(th.data.poster.head_x)*2; | |
| 480 | + var y=parseFloat(th.data.poster.head_y)*2; | |
| 481 | + var x1=(x+90) *unit; | |
| 482 | + var y1=(y+50) *unit; | |
| 483 | + //--昵称--- | |
| 484 | + context.setFontSize(24 * unit) | |
| 485 | + context.setFillStyle("black") | |
| 486 | + context.fillText(app.globalData.userInfo.nickname, x1, y1); | |
| 487 | + var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit; | |
| 488 | + //强烈推荐 改许程 | |
| 489 | + var tj_path = "../../../images/share/q_tj.png"; | |
| 490 | + context.drawImage(tj_path, x1 + width, y1-22*unit, 85 * unit, 30 * unit); | |
| 491 | + context.setFontSize(16 * unit) | |
| 492 | + context.setLineJoin('round'); //交点设置成圆角 | |
| 493 | + context.setFillStyle("white") | |
| 494 | + context.fillText('强烈推荐', x1 + width+8*unit, y1-1*unit); | |
| 495 | + } | |
| 496 | + | |
| 548 | 497 | }else{ |
| 549 | - wz="已享受最优惠,"; | |
| 498 | + //--昵称--- | |
| 499 | + context.setFontSize(24 * unit) | |
| 500 | + context.setFillStyle("black") | |
| 501 | + context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit); | |
| 502 | + var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; | |
| 503 | + //强烈推荐 | |
| 504 | + var tj_path = "../../../images/share/q_tj.png"; | |
| 505 | + context.drawImage(tj_path, 152 * unit + width, 54 * unit, 110 * unit, 30 * unit); | |
| 506 | + context.setFontSize(18 * unit) | |
| 507 | + context.setFillStyle("white") | |
| 508 | + context.fillText('强烈推荐', 152 * unit + width + 20 * unit, 76 * unit); | |
| 550 | 509 | } |
| 551 | - } | |
| 552 | 510 | |
| 553 | - //-------大图后面就不一样了----------- | |
| 554 | - switch (type) { | |
| 555 | - case 1://会员团和商家团的展示 | |
| 556 | - //---画线--- | |
| 557 | - context.setLineWidth(1 * unit) | |
| 558 | - context.moveTo(32 * unit, 670 * unit) | |
| 559 | - context.lineTo(520 * unit, 670 * unit) | |
| 560 | - context.stroke(); | |
| 561 | - | |
| 562 | - //---文字--- | |
| 563 | - context.setFontSize(22 * unit) | |
| 564 | - context.setFillStyle("black") | |
| 565 | - context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit); | |
| 566 | - | |
| 567 | - //绘制成团图片 | |
| 568 | - var ct_img ="../../../images/share/ct_num.png"; | |
| 569 | - context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); | |
| 570 | - var ct_num = th.data.teamlist.ct_num; | |
| 571 | - context.setFontSize(14 * unit) | |
| 572 | - | |
| 573 | - context.setFillStyle("red") | |
| 574 | - if(ct_num<10){ | |
| 575 | - context.fillText(ct_num+"人拼团", 92 * unit, 760 * unit); | |
| 511 | + | |
| 512 | + //---产品名称--- | |
| 513 | + context.setFontSize(21.3 * unit); | |
| 514 | + context.setFillStyle("black"); | |
| 515 | + | |
| 516 | + | |
| 517 | + getApp().draw_Text(context,share_title, | |
| 518 | + 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); | |
| 519 | + //------产品的价格------- | |
| 520 | + context.setFontSize(24 * unit) | |
| 521 | + context.setFillStyle("red") | |
| 522 | + | |
| 523 | + var pri0 = th.data.teamlist.price; | |
| 524 | + pri0=parseFloat(pri0).toFixed(2); | |
| 525 | + var wd1=th.data.screenWidth-ut.measureText(pri0, 31 * unit)-25; | |
| 526 | + context.fillText("¥", wd1-15, 180 * unit); | |
| 527 | + context.setFontSize(31 * unit) | |
| 528 | + context.fillText(pri0, wd1, 180 * unit); | |
| 529 | + | |
| 530 | + //---市场价划掉--- | |
| 531 | + context.setFillStyle("gray") | |
| 532 | + context.setFontSize(22 * unit) | |
| 533 | + pri0= "¥" + parseFloat(th.data.goods.market_price).toFixed(2); | |
| 534 | + var wd2=th.data.screenWidth-ut.measureText(pri0, 22 * unit)-25; | |
| 535 | + context.fillText(pri0, wd2, 210 * unit); | |
| 536 | + | |
| 537 | + context.setStrokeStyle('gray') | |
| 538 | + context.setLineWidth(1 * unit) | |
| 539 | + context.moveTo(wd2-5, 204 * unit) | |
| 540 | + context.lineTo(wd2+ut.measureText(pri0, 22 * unit)+5, 204 * unit) | |
| 541 | + context.stroke(); | |
| 542 | + console.log(th.data.share_img_localpath); | |
| 543 | + | |
| 544 | + | |
| 545 | + //---中间大图--- | |
| 546 | + context.drawImage(th.data.share_img_localpath, 68 * unit, 242 * unit, 410 * unit, 410 * unit); | |
| 547 | + | |
| 548 | + var g_ct=th.data.teamlist.ct_num-th.data.ordertx.length; | |
| 549 | + var wz= ""; | |
| 550 | + if(g_ct>0) wz="还差"+g_ct+"人成团,"; | |
| 551 | + else{ | |
| 552 | + g_ct= th.data.max_num -th.data.ordertx.length; | |
| 553 | + if(g_ct>0){ | |
| 554 | + wz="还差"+g_ct+"人享最低优惠,"; | |
| 576 | 555 | }else{ |
| 577 | - context.fillText(ct_num+"人拼团", 86 * unit, 760 * unit); | |
| 556 | + wz="已享受最优惠,"; | |
| 578 | 557 | } |
| 579 | - context.setFontSize(22 * unit) | |
| 580 | - context.fillText("已拼"+th.data.teamlist.buy_num+"份", 166 * unit, 763 * unit); | |
| 581 | - context.setFillStyle("gray") | |
| 582 | - context.fillText(wz+"快来和我一起拼团吧!", 40 * unit, 826 * unit); | |
| 583 | - context.setFillStyle("black") | |
| 584 | - | |
| 585 | - context.setFontSize(22 * unit) | |
| 586 | - context.fillText("长按识别二维码,立即参团", 40 * unit, 856 * unit); | |
| 587 | - //---二维吗图--- | |
| 588 | - //-- 自定义海报 -- | |
| 589 | - if(th.data.poster){ | |
| 590 | - var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
| 591 | - var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
| 592 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
| 593 | - }else{ | |
| 594 | - //---二维吗图--- | |
| 595 | - context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
| 596 | - } | |
| 597 | - break | |
| 598 | - case 2://阶梯团的展示 | |
| 599 | - //---画线--- | |
| 600 | - context.setLineWidth(1 * unit) | |
| 601 | - context.moveTo(32 * unit, 670 * unit) | |
| 602 | - context.lineTo(520 * unit, 670 * unit) | |
| 603 | - context.stroke(); | |
| 604 | - //---文字--- | |
| 605 | - context.setFontSize(22 * unit) | |
| 606 | - context.setFillStyle("black") | |
| 607 | - context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit); | |
| 608 | - //---绘制中间阶梯的价格--- | |
| 609 | - var list= JSON.parse(th.data.teamlist.ct_rylist); | |
| 610 | - for(var i=0; i<list.length;i++){ | |
| 611 | - var item=list[i]; | |
| 612 | - var wi=i*90*unit; | |
| 613 | - context.setFontSize(16 * unit) | |
| 558 | + } | |
| 559 | + | |
| 560 | + //-------大图后面就不一样了----------- | |
| 561 | + switch (type) { | |
| 562 | + case 1://会员团和商家团的展示 | |
| 563 | + //---画线--- | |
| 564 | + context.setLineWidth(1 * unit) | |
| 565 | + context.moveTo(32 * unit, 670 * unit) | |
| 566 | + context.lineTo(520 * unit, 670 * unit) | |
| 567 | + context.stroke(); | |
| 568 | + | |
| 569 | + //---文字--- | |
| 570 | + context.setFontSize(22 * unit) | |
| 571 | + context.setFillStyle("black") | |
| 572 | + context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit); | |
| 573 | + | |
| 574 | + //绘制成团图片 | |
| 575 | + var ct_img ="../../../images/share/ct_num.png"; | |
| 576 | + context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); | |
| 577 | + var ct_num = th.data.teamlist.ct_num; | |
| 578 | + context.setFontSize(14 * unit) | |
| 579 | + | |
| 614 | 580 | context.setFillStyle("red") |
| 615 | - context.fillText("¥", 40 * unit+wi, 756 * unit); | |
| 581 | + if(ct_num<10){ | |
| 582 | + context.fillText(ct_num+"人拼团", 92 * unit, 760 * unit); | |
| 583 | + }else{ | |
| 584 | + context.fillText(ct_num+"人拼团", 86 * unit, 760 * unit); | |
| 585 | + } | |
| 616 | 586 | context.setFontSize(22 * unit) |
| 617 | - var pri=parseFloat(item.price).toFixed(2); | |
| 618 | - context.fillText(pri, 56 * unit+wi, 756 * unit); | |
| 587 | + context.fillText("已拼"+th.data.teamlist.buy_num+"份", 166 * unit, 763 * unit); | |
| 619 | 588 | context.setFillStyle("gray") |
| 620 | - context.fillText("满"+item.rynum+"人", 40 * unit+wi, 786 * unit); | |
| 621 | - } | |
| 589 | + context.fillText(wz+"快来和我一起拼团吧!", 40 * unit, 826 * unit); | |
| 590 | + context.setFillStyle("black") | |
| 622 | 591 | |
| 623 | - //----------------下面部分---------------- | |
| 624 | - context.setFillStyle("gray") | |
| 625 | - context.fillText(wz+"快来和我一起拼团吧!", 40 * unit, 830 * unit); | |
| 626 | - context.setFillStyle("black") | |
| 627 | - context.setFontSize(22 * unit) | |
| 628 | - | |
| 629 | - context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit); | |
| 630 | - //---二维吗图--- | |
| 631 | - //-- 自定义海报 -- | |
| 632 | - if(th.data.poster){ | |
| 633 | - var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
| 634 | - var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
| 635 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
| 636 | - }else{ | |
| 637 | - //---二维吗图--- | |
| 638 | - context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
| 639 | - } | |
| 640 | - break | |
| 641 | - } | |
| 592 | + context.setFontSize(22 * unit) | |
| 593 | + context.fillText("长按识别二维码,立即参团", 40 * unit, 856 * unit); | |
| 594 | + //---二维吗图--- | |
| 595 | + //-- 自定义海报 -- | |
| 596 | + if(th.data.poster){ | |
| 597 | + var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
| 598 | + var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
| 599 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
| 600 | + }else{ | |
| 601 | + //---二维吗图--- | |
| 602 | + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
| 603 | + } | |
| 604 | + break | |
| 605 | + case 2://阶梯团的展示 | |
| 606 | + //---画线--- | |
| 607 | + context.setLineWidth(1 * unit) | |
| 608 | + context.moveTo(32 * unit, 670 * unit) | |
| 609 | + context.lineTo(520 * unit, 670 * unit) | |
| 610 | + context.stroke(); | |
| 611 | + //---文字--- | |
| 612 | + context.setFontSize(22 * unit) | |
| 613 | + context.setFillStyle("black") | |
| 614 | + context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit); | |
| 615 | + //---绘制中间阶梯的价格--- | |
| 616 | + var list= JSON.parse(th.data.teamlist.ct_rylist); | |
| 617 | + for(var i=0; i<list.length;i++){ | |
| 618 | + var item=list[i]; | |
| 619 | + var wi=i*90*unit; | |
| 620 | + context.setFontSize(16 * unit) | |
| 621 | + context.setFillStyle("red") | |
| 622 | + context.fillText("¥", 40 * unit+wi, 756 * unit); | |
| 623 | + context.setFontSize(22 * unit) | |
| 624 | + var pri=parseFloat(item.price).toFixed(2); | |
| 625 | + context.fillText(pri, 56 * unit+wi, 756 * unit); | |
| 626 | + context.setFillStyle("gray") | |
| 627 | + context.fillText("满"+item.rynum+"人", 40 * unit+wi, 786 * unit); | |
| 628 | + } | |
| 629 | + | |
| 630 | + //----------------下面部分---------------- | |
| 631 | + context.setFillStyle("gray") | |
| 632 | + context.fillText(wz+"快来和我一起拼团吧!", 40 * unit, 830 * unit); | |
| 633 | + context.setFillStyle("black") | |
| 634 | + context.setFontSize(22 * unit) | |
| 635 | + | |
| 636 | + context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit); | |
| 637 | + //---二维吗图--- | |
| 638 | + //-- 自定义海报 -- | |
| 639 | + if(th.data.poster){ | |
| 640 | + var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
| 641 | + var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
| 642 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
| 643 | + }else{ | |
| 644 | + //---二维吗图--- | |
| 645 | + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
| 646 | + } | |
| 647 | + break | |
| 648 | + } | |
| 649 | + | |
| 650 | + //--- 如果是自定义海报的时候 --- | |
| 651 | + if(th.data.poster && parseInt(th.data.poster.style)==2){ | |
| 652 | + | |
| 653 | + //如果显示会员信息的话 | |
| 654 | + if(parseInt(th.data.poster.show_headpic)){ | |
| 655 | + //获取坐标 | |
| 656 | + var x= parseFloat(th.data.poster.head_x)*2; | |
| 657 | + var y=parseFloat(th.data.poster.head_y)*2; | |
| 658 | + //---绘制圆形要放在最后---- | |
| 659 | + context.save(); | |
| 660 | + context.beginPath(); | |
| 661 | + var h_x = x* unit; | |
| 662 | + var h_y = y * unit; | |
| 663 | + var h_r = 40 * unit; | |
| 664 | + var cx = h_x + h_r; | |
| 665 | + var cy = h_y + h_r; | |
| 666 | + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
| 667 | + context.closePath(); | |
| 668 | + context.fill(); | |
| 669 | + context.clip(); | |
| 670 | + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
| 671 | + context.restore(); | |
| 672 | + } | |
| 642 | 673 | |
| 643 | - //--- 如果是自定义海报的时候 --- | |
| 644 | - if(th.data.poster && parseInt(th.data.poster.style)==2){ | |
| 645 | - | |
| 646 | - //如果显示会员信息的话 | |
| 647 | - if(parseInt(th.data.poster.show_headpic)){ | |
| 648 | - //获取坐标 | |
| 649 | - var x= parseFloat(th.data.poster.head_x)*2; | |
| 650 | - var y=parseFloat(th.data.poster.head_y)*2; | |
| 651 | - //---绘制圆形要放在最后---- | |
| 652 | - context.save(); | |
| 653 | - context.beginPath(); | |
| 654 | - var h_x = x* unit; | |
| 655 | - var h_y = y * unit; | |
| 656 | - var h_r = 40 * unit; | |
| 657 | - var cx = h_x + h_r; | |
| 658 | - var cy = h_y + h_r; | |
| 659 | - context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
| 660 | - context.closePath(); | |
| 661 | - context.fill(); | |
| 662 | - context.clip(); | |
| 663 | - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
| 664 | - context.restore(); | |
| 665 | - } | |
| 666 | - | |
| 667 | - }else{ | |
| 668 | - //---绘制圆形要放在最后---- | |
| 669 | - context.save(); | |
| 670 | - context.beginPath(); | |
| 671 | - var h_x = 60 * unit; | |
| 672 | - var h_y = 24 * unit; | |
| 673 | - var h_r = 40 * unit; | |
| 674 | - var cx = h_x + h_r; | |
| 675 | - var cy = h_y + h_r; | |
| 676 | - context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
| 677 | - context.closePath(); | |
| 678 | - context.fill(); | |
| 679 | - context.clip(); | |
| 680 | - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
| 681 | - context.restore(); | |
| 674 | + }else{ | |
| 675 | + //---绘制圆形要放在最后---- | |
| 676 | + context.save(); | |
| 677 | + context.beginPath(); | |
| 678 | + var h_x = 60 * unit; | |
| 679 | + var h_y = 24 * unit; | |
| 680 | + var h_r = 40 * unit; | |
| 681 | + var cx = h_x + h_r; | |
| 682 | + var cy = h_y + h_r; | |
| 683 | + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
| 684 | + context.closePath(); | |
| 685 | + context.fill(); | |
| 686 | + context.clip(); | |
| 687 | + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
| 688 | + context.restore(); | |
| 689 | + } | |
| 682 | 690 | } |
| 683 | 691 | |
| 684 | 692 | //把画板内容绘制成图片,并回调 画板图片路径 |
| ... | ... | @@ -885,6 +893,122 @@ Page({ |
| 885 | 893 | |
| 886 | 894 | }, |
| 887 | 895 | |
| 896 | + //-- 先版绘制 -- | |
| 897 | + drawPoster(context, unit, img, vpath, type) { | |
| 898 | + | |
| 899 | + var self=this; | |
| 900 | + self.data.prom_act=this.data.teamlist; | |
| 901 | + | |
| 902 | + // 1.灰色背景 | |
| 903 | + context.setFillStyle('#f2f1f6'); | |
| 904 | + context.rect(0, 0, 554 * unit, 899 * unit); | |
| 905 | + context.fill(); | |
| 906 | + | |
| 907 | + // 2.商城名称 | |
| 908 | + let shopName = this.data.sto_sele_name_1; | |
| 909 | + context.setTextAlign('center'); | |
| 910 | + context.setFontSize(26 * unit); | |
| 911 | + context.setFillStyle('black'); | |
| 912 | + context.fillText(shopName, 277 * unit, 60 * unit); | |
| 913 | + | |
| 914 | + // 3.推荐来源 | |
| 915 | + let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; | |
| 916 | + context.setTextAlign('center'); | |
| 917 | + context.setFontSize(22 * unit); | |
| 918 | + context.setFillStyle('#96959a'); | |
| 919 | + context.fillText(fromText, 277 * unit, 105 * unit); | |
| 920 | + | |
| 921 | + // 4.海报背景 | |
| 922 | + context.setFillStyle('white'); | |
| 923 | + context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit); | |
| 924 | + | |
| 925 | + // 5.商品图片 | |
| 926 | + // 图片的x坐标 | |
| 927 | + let bg_x = 37 * unit | |
| 928 | + // 图片的y坐标 | |
| 929 | + let bg_y = 157 * unit | |
| 930 | + // 图片宽度 | |
| 931 | + let bg_w = 480 * unit | |
| 932 | + // 图片高度 | |
| 933 | + let bg_h = 474 * unit | |
| 934 | + // 图片圆角 | |
| 935 | + let bg_r = 4 | |
| 936 | + // 绘制海报背景图片圆角 | |
| 937 | + context.save() | |
| 938 | + context.beginPath() | |
| 939 | + context.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5) | |
| 940 | + context.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2) | |
| 941 | + context.arc(bg_x + bg_w, bg_y + bg_h, bg_r, 0, Math.PI * 0.5) | |
| 942 | + context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI) | |
| 943 | + context.clip() | |
| 944 | + context.drawImage(img, bg_x, bg_y, bg_w, bg_h); | |
| 945 | + context.restore(); | |
| 946 | + | |
| 947 | + // 6.强烈推荐 | |
| 948 | + let src = ''; | |
| 949 | + context.beginPath(); | |
| 950 | + | |
| 951 | + | |
| 952 | + if (type == 1) { // 商家和会员团 | |
| 953 | + src = '../../../images/share/ct_num.png'; | |
| 954 | + context.drawImage(src, 54 * unit, 648 * unit, 120 * unit, 30 * unit); | |
| 955 | + context.setTextAlign('left'); | |
| 956 | + | |
| 957 | + let ct_num = self.data.prom_act.ct_num; | |
| 958 | + context.setFontSize(16 * unit) | |
| 959 | + context.font = 'normal'; | |
| 960 | + context.setFillStyle("red") | |
| 961 | + if (ct_num < 10) { | |
| 962 | + context.fillText(ct_num + "人拼团", 100 * unit, 670 * unit); | |
| 963 | + } else { | |
| 964 | + context.fillText(ct_num + "人拼团", 96 * unit, 670 * unit); | |
| 965 | + } | |
| 966 | + context.setFontSize(22 * unit) | |
| 967 | + context.fillText("已拼" + self.data.prom_act.buy_num + "份", 186 * unit, 672 * unit); | |
| 968 | + } | |
| 969 | + | |
| 970 | + if (type == 2) { // 阶梯团 | |
| 971 | + let list = self.data.prom_act.ct_rylist; | |
| 972 | + for (let i = 0; i < list.length; i++) { | |
| 973 | + let item = list[i]; | |
| 974 | + let wi = i * 90 * unit; | |
| 975 | + context.font = 'normal'; | |
| 976 | + context.setTextAlign('left'); | |
| 977 | + context.setFontSize(16 * unit) | |
| 978 | + context.setFillStyle("red") | |
| 979 | + context.fillText("¥", 50 * unit + wi, 680 * unit); | |
| 980 | + context.setFontSize(22 * unit) | |
| 981 | + let pri = parseFloat(item.price).toFixed(2); | |
| 982 | + context.fillText(pri, 66 * unit + wi, 680 * unit); | |
| 983 | + | |
| 984 | + | |
| 985 | + context.setFillStyle("gray") | |
| 986 | + context.fillText("满" + item.rynum + "人", 50 * unit + wi, 716 * unit); | |
| 987 | + } | |
| 988 | + | |
| 989 | + | |
| 990 | + var wp= 52 * unit; | |
| 991 | + var hp=755 * unit | |
| 992 | + self.draw_pos_price(context,wp,hp,self.data.data.market_price,unit); | |
| 993 | + } | |
| 994 | + | |
| 995 | + | |
| 996 | + // 8.商品标题 | |
| 997 | + context.setFontSize(20 * unit); | |
| 998 | + context.setFillStyle('#898989'); | |
| 999 | + getApp().draw_Text(context, this.data.goods.goods_name, 54 * unit, 800 * unit, 240 * unit, 280 * unit, unit, 1); | |
| 1000 | + // 9.小程序码 | |
| 1001 | + context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); | |
| 1002 | + context.setFontSize(16 * unit); | |
| 1003 | + context.setFillStyle('#777'); | |
| 1004 | + context.fillText('长按识别二维码', 378 * unit, 810 * unit); | |
| 1005 | + | |
| 1006 | + // 10.竖线 | |
| 1007 | + context.beginPath(); | |
| 1008 | + context.setFillStyle('#eee'); | |
| 1009 | + context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit); | |
| 1010 | + context.fill(); | |
| 1011 | + }, | |
| 888 | 1012 | |
| 889 | 1013 | |
| 890 | 1014 | ... | ... |