Commit 2b33e2ac4110468997a20e7b823f0d8eb6a8269e
1 parent
b0dbbbf9
分享任务的优化
Showing
1 changed file
with
236 additions
and
411 deletions
pages/user/assistance/task_assistance.js
... | ... | @@ -46,7 +46,12 @@ Page({ |
46 | 46 | "miniapp/images/friendhelp/check.png", "miniapp/images/friendhelp/unfinished.png", |
47 | 47 | "/public/upload/libao/temp/2019/12-20/51f251f44ea0f67b8efdc5bfa3a434b0.jpg" |
48 | 48 | ], //固的分享图片 |
49 | - dynamic: [], //已助力的微信头像数组 | |
49 | + | |
50 | + dynamic: null, //已助力的微信头像数组 | |
51 | + head_pic_arr:[],//助力的头像 | |
52 | + share_lb_img:"",//分享的礼包图片 | |
53 | + | |
54 | + | |
50 | 55 | is_generate: 0, //是否重复点击拆一拆 |
51 | 56 | already: 0, //已有几人助力 |
52 | 57 | lack: 0, //还差几人助力 |
... | ... | @@ -75,7 +80,7 @@ Page({ |
75 | 80 | th.close(); |
76 | 81 | th.syinfo(); |
77 | 82 | th.imageinfo(); |
78 | - //end | |
83 | + | |
79 | 84 | }, |
80 | 85 | |
81 | 86 | |
... | ... | @@ -207,10 +212,6 @@ Page({ |
207 | 212 | }, |
208 | 213 | |
209 | 214 | |
210 | - | |
211 | - | |
212 | - | |
213 | - | |
214 | 215 | //帮拆记录的 |
215 | 216 | dismantle_record: function(e) { |
216 | 217 | var aitem = this.data.aitem; //任务的数据集 |
... | ... | @@ -572,222 +573,163 @@ Page({ |
572 | 573 | } |
573 | 574 | }) |
574 | 575 | }, |
575 | - //钱 分享图 | |
576 | - imageinfo: function() { | |
577 | - var th = this; | |
578 | - var images = th.data.images; | |
579 | - var iurl = th.data.iurl; | |
580 | - wx.getImageInfo({ | |
581 | - src: iurl + images[0], | |
582 | - success: function(res) { | |
583 | - //res.path是网络图片的本地地址 | |
584 | - images[0] = res.path; | |
585 | - }, | |
586 | - fail: function(res) { | |
587 | - } | |
588 | - }); | |
589 | - wx.getImageInfo({ | |
590 | - src: iurl + images[1], | |
591 | - success: function(res) { | |
592 | - //res.path是网络图片的本地地址 | |
593 | - images[1] = res.path; | |
594 | - }, | |
595 | - fail: function(res) { | |
596 | - } | |
597 | - }); | |
598 | - wx.getImageInfo({ | |
599 | - src: iurl + images[2], | |
600 | - success: function(res) { | |
601 | - //res.path是网络图片的本地地址 | |
602 | - images[2] = res.path; | |
603 | - }, | |
604 | - fail: function(res) { | |
605 | - | |
606 | - } | |
607 | - }); | |
608 | - wx.getImageInfo({ | |
609 | - src: iurl + images[3], | |
610 | - success: function(res) { | |
611 | - //res.path是网络图片的本地地址 | |
612 | - images[3] = res.path; | |
613 | - }, | |
614 | - fail: function(res) { | |
615 | - } | |
616 | - }); | |
617 | - wx.getImageInfo({ | |
618 | - src: iurl + images[4], | |
619 | - success: function(res) { | |
620 | - //res.path是网络图片的本地地址 | |
621 | - images[4] = res.path; | |
622 | - }, | |
623 | - fail: function(res) { | |
624 | - } | |
625 | - }); | |
626 | - wx.getImageInfo({ | |
627 | - src: iurl + images[5], | |
628 | - success: function(res) { | |
629 | - //res.path是网络图片的本地地址 | |
630 | - images[5] = res.path; | |
631 | - }, | |
632 | - fail: function(res) { | |
633 | - } | |
634 | - }); | |
635 | - wx.getImageInfo({ | |
636 | - src: iurl + images[6], | |
637 | - success: function(res) { | |
638 | - //res.path是网络图片的本地地址 | |
639 | - images[6] = res.path; | |
640 | - }, | |
641 | - fail: function(res) { | |
642 | - } | |
643 | - }); | |
644 | - | |
645 | - wx.getImageInfo({ | |
646 | - src: iurl + images[7], | |
647 | - success: function(res) { | |
648 | - //res.path是网络图片的本地地址 | |
649 | - images[7] = res.path; | |
650 | - }, | |
651 | - fail: function(res) { | |
652 | - } | |
653 | - }) | |
654 | - th.setData({ | |
655 | - images: images | |
656 | - }) | |
657 | - | |
658 | - }, | |
659 | - //生成分享图,用于分享给好友帮拆 | |
660 | - demolition: function() { | |
661 | - var th = this; | |
662 | - | |
663 | - | |
664 | - }, | |
576 | + | |
577 | + | |
578 | + | |
665 | 579 | //************************ */ |
666 | - shareFrends: function(e) { | |
667 | - var th = this; | |
668 | - var is_generate = th.data.is_generate; //是否重复提交拆一拆 | |
669 | - if (is_generate == 0) { | |
670 | - th.setData({ | |
671 | - is_generate: 1 | |
672 | - }) | |
673 | - var scene = th.data.gid; | |
674 | - ///二微码 | |
675 | - // var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + | |
676 | - // a.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo"; | |
677 | - var iurl = th.data.iurl; //图片地址前缀 | |
678 | - const ctx = wx.createCanvasContext('share_id'); //绘图上下文 | |
679 | - var unit = th.data.screenWidth / 750 * 1.35; | |
680 | - var numsize = 20 * unit; //几人助力字体大小 | |
681 | - var size = 15 * unit; | |
682 | - var num = th.data.already; //已有几位好友助力 | |
683 | - var q_num = th.data.lack; //还差几位好友助力 | |
684 | - var already = num.toString().length + 1; //已有几位好友助力 | |
685 | - var lack = q_num.toString().length + 1; //还差几位好友助力 | |
686 | - var imagesize = 40 * unit; //助力人的图片大小 | |
687 | - var left = 74 * unit; //助力人头像跟左边的距离 | |
688 | - var spacing = 12 * unit; //助力人图片间距 | |
689 | - var images = th.data.images; | |
690 | - ctx.drawImage(images[0], 0, 0, 445 * unit, 700 * unit); //分享的背景图片 | |
691 | - ctx.drawImage(images[1], 37 * unit, 185 * unit, 370 * unit, 377 * unit); //分享的背景图片 | |
692 | - ctx.drawImage(images[5], 90 * unit, 231 * unit, 266 * unit, 160 * unit); //分享的背景图片 | |
693 | - ctx.setFillStyle("rgb(221,153,116)"); | |
694 | - ctx.setFontSize(size) | |
695 | - ctx.fillText("已有", 77 * unit, 430 * unit); | |
696 | - ctx.setFillStyle("#FF4746"); | |
697 | - ctx.setFontSize(numsize) | |
698 | - ctx.fillText(num + "位", 108 * unit, 430 * unit); | |
699 | - ctx.setFillStyle("rgb(221,153,116)"); | |
700 | - ctx.setFontSize(size) | |
701 | - ctx.fillText("好友助力,还差", 116 * unit + already * numsize * unit, 430 * unit); | |
702 | - ctx.setFillStyle("#FF4746"); | |
703 | - ctx.setFontSize(numsize); | |
704 | - ctx.fillText(q_num + "位", 223 * unit + already * numsize * unit, 430 * unit); | |
705 | - ctx.setFillStyle("rgb(221,153,116)"); | |
706 | - ctx.setFontSize(size); | |
707 | - ctx.fillText("达成助力", 230 * unit + lack * numsize * unit + already * numsize * unit, 430 * unit); | |
708 | - var c = q_num / num; | |
709 | - ctx.drawImage(images[2], 65 * unit, 445 * unit, 320 * unit, 12 * unit); | |
710 | - ctx.drawImage(images[3], 65 * unit, 445 * unit, 320 * unit * c, 12 * unit); | |
711 | - // var dynamic = th.data.dynamic; //助力的微信头像 | |
712 | - for (var i = 0; i < 6; i++) { | |
713 | - if (i < 0) { | |
714 | - // ctx.beginPath(); | |
715 | - // ctx.arc(left + imagesize / 2, 505 * unit, imagesize / 2, 0, 2 * Math.PI); | |
716 | - // ctx.setLineWidth(1); | |
717 | - // ctx.setStrokeStyle('red'); | |
718 | - ctx.save(); | |
719 | - ctx.beginPath(); //开始绘制 | |
720 | - ctx.arc(left + imagesize / 2, 505 * unit, imagesize / 2, 0, 2 * Math.PI); | |
721 | - ctx.setLineWidth(4 * unit); | |
722 | - ctx.setStrokeStyle('red'); | |
723 | - ctx.setFillStyle("white"); | |
724 | - ctx.fill(); | |
725 | - ctx.clip(); | |
726 | - ctx.drawImage(dynamic[i].headPic, left, 505 * unit - imagesize / 2, imagesize, imagesize); | |
727 | - ctx.restore(); //恢复之前保存的绘图上下文 恢复之前保存的绘图上下午即状态 还可以继续绘制 | |
728 | - } else { | |
729 | - // 助力人的头像 | |
730 | - ctx.drawImage(images[4], left, 505 * unit - imagesize / 2, imagesize, imagesize); //分享的背景图片 | |
731 | - | |
732 | - } | |
733 | - left += imagesize + spacing; | |
734 | - } | |
735 | - ctx.setFillStyle("rgb(255,255,255)"); | |
736 | - ctx.setFontSize(size); | |
737 | - ctx.fillText("优惠乐翻天,精彩就在你身边!", 37 * unit, 595 * unit); | |
738 | - ctx.setFillStyle("rgb(255,255,255)"); | |
739 | - ctx.setFontSize(size); | |
740 | - ctx.fillText("2019.06.26 - 2019.07.02!", 37 * unit, 620 * unit); | |
741 | - ctx.setFillStyle("rgb(255,255,255)"); | |
742 | - ctx.setFontSize(size); | |
743 | - ctx.fillText("长按识别二维码,可帮我助力!", 37 * unit, 660 * unit); | |
744 | - ctx.drawImage(images[5], 325 * unit, 585 * unit, 77 * unit, 77 * unit); //分享的背景图片 | |
745 | - ctx.save(); | |
746 | - //读取文件成功则OK-- | |
747 | - // wx.getImageInfo({ | |
748 | - // src: path3, | |
749 | - // success: function (res) { | |
750 | - //把画板内容绘制成图片,并回调 画板图片路径 | |
751 | - ctx.draw(false, function() { | |
752 | - setTimeout(function() { | |
753 | - wx.canvasToTempFilePath({ | |
754 | - x: 0, | |
755 | - y: 0, | |
756 | - width: 300, | |
757 | - height: 500, | |
758 | - destWidth: 400 * 2, | |
759 | - destHeight: 720 * 2, | |
760 | - canvasId: 'share_id', | |
761 | - success: function(res) { | |
762 | - wx.hideLoading(); | |
763 | - var shareImgPath = th.data.shareImgPath; | |
764 | - shareImgPath[0] = res.tempFilePath; | |
765 | - | |
766 | - th.setData({ | |
767 | - shareImgPath: shareImgPath, | |
768 | - canvasHidden: 1, | |
769 | - is_share: 1, | |
770 | - is_generate: 0, | |
771 | - canvasHidden: 1 | |
772 | - }) | |
773 | - if (!res.tempFilePath) { | |
774 | - wx.showModal({ | |
775 | - title: '提示', | |
776 | - content: '图片绘制中,请稍后重试', | |
777 | - showCancel: false | |
778 | - }) | |
779 | - return false; | |
780 | - } | |
781 | - | |
782 | - }, | |
783 | - fail(r) { | |
784 | - | |
785 | - } | |
786 | - }, 500) | |
787 | - }) | |
788 | - }) | |
789 | - } | |
790 | - }, | |
580 | + shareFrends: function(e) { | |
581 | + var th = this; | |
582 | + if(th.data.is_generate) return ; | |
583 | + th.data.is_generate=1; | |
584 | + | |
585 | + var scene = 1; | |
586 | + ///二微码 | |
587 | + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + | |
588 | + os.stoid + "?sceneValue=" + scene + "&pageValue=pages/index/index/index"; | |
589 | + //读取文件成功则OK-- | |
590 | + wx.getImageInfo({ | |
591 | + src: path3, | |
592 | + success: function(res) { | |
593 | + | |
594 | + var ewm_path=res.path; // | |
595 | + //var act_time="2019.06.26 - 2019.07.02"; //活动的时间 | |
596 | + var bg_time=ut.formar_no_full(th.data.dynamic.beginDate); | |
597 | + var end_time=ut.formar_no_full(th.data.dynamic.endDate); | |
598 | + var act_time=bg_time+"-"+end_time; | |
599 | + | |
600 | + | |
601 | + var iurl = th.data.iurl; //图片地址前缀 | |
602 | + const ctx = wx.createCanvasContext('share_id'); //绘图上下文 | |
603 | + var unit = th.data.screenWidth / 750 * 1.35; | |
604 | + var numsize = 20 * unit; //几人助力字体大小 | |
605 | + | |
606 | + var num = th.data.head_pic_arr.length; //已有几位好友助力 | |
607 | + | |
608 | + var aitem = th.data.aitem; //任务的数据集 | |
609 | + var sw_index = th.data.sw_index; //轮播的下标 | |
610 | + //任务id | |
611 | + var help_num = aitem[sw_index].helpNum; | |
612 | + | |
613 | + var q_num = help_num-num; //还差几位好友助力 | |
614 | + var already = num.toString().length + 1; //已有几位好友助力 | |
615 | + var lack = q_num.toString().length + 1; //还差几位好友助力 | |
616 | + | |
617 | + var size=15 * unit; | |
618 | + var imagesize = 40 * unit; //助力人的图片大小 | |
619 | + var left = 74 * unit; //助力人头像跟左边的距离 | |
620 | + var spacing = 12 * unit; //助力人图片间距 | |
621 | + var images = th.data.images; | |
622 | + ctx.drawImage(images[0], 0, 0, 445 * unit, 700 * unit); //分享的背景图片 | |
623 | + ctx.drawImage(images[1], 37 * unit, 185 * unit, 370 * unit, 377 * unit); //分享的背景图片 | |
624 | + | |
625 | + | |
626 | + ctx.drawImage(th.data.share_lb_img, 90 * unit, 231 * unit, 266 * unit, 160 * unit); //分享的礼包的背景图片 | |
627 | + | |
628 | + ctx.setFillStyle("rgb(221,153,116)"); | |
629 | + ctx.setFontSize(size) | |
630 | + ctx.fillText("已有", 77 * unit, 430 * unit); | |
631 | + ctx.setFillStyle("#FF4746"); | |
632 | + ctx.setFontSize(numsize) | |
633 | + ctx.fillText(num + "位", 108 * unit, 430 * unit); | |
634 | + ctx.setFillStyle("rgb(221,153,116)"); | |
635 | + ctx.setFontSize(size) | |
636 | + ctx.fillText("好友助力,还差", 116 * unit + already * numsize * unit, 430 * unit); | |
637 | + ctx.setFillStyle("#FF4746"); | |
638 | + ctx.setFontSize(numsize); | |
639 | + ctx.fillText(q_num + "位", 223 * unit + already * numsize * unit, 430 * unit); | |
640 | + ctx.setFillStyle("rgb(221,153,116)"); | |
641 | + ctx.setFontSize(size); | |
642 | + ctx.fillText("达成助力", 230 * unit + lack * numsize * unit + already * numsize * unit, 430 * unit); | |
643 | + | |
644 | + var c =num / help_num; | |
645 | + ctx.drawImage(images[2], 65 * unit, 445 * unit, 320 * unit, 12 * unit); | |
646 | + ctx.drawImage(images[3], 65 * unit, 445 * unit, 320 * unit * c, 12 * unit); | |
647 | + | |
648 | + | |
649 | + for (var i = 0; i < 6; i++) { | |
650 | + if (i < 0) { | |
651 | + ctx.save(); | |
652 | + ctx.beginPath(); //开始绘制 | |
653 | + ctx.arc(left + imagesize / 2, 505 * unit, imagesize / 2, 0, 2 * Math.PI); | |
654 | + ctx.setLineWidth(4 * unit); | |
655 | + ctx.setStrokeStyle('red'); | |
656 | + ctx.setFillStyle("white"); | |
657 | + ctx.fill(); | |
658 | + ctx.clip(); | |
659 | + ctx.drawImage(head_pic_arr.headPic, left, 505 * unit - imagesize / 2, imagesize, imagesize); | |
660 | + ctx.restore(); //恢复之前保存的绘图上下文 恢复之前保存的绘图上下午即状态 还可以继续绘制 | |
661 | + } else { | |
662 | + // 助力人的头像 | |
663 | + ctx.drawImage(images[4], left, 505 * unit - imagesize / 2, imagesize, imagesize); //分享的背景图片 | |
664 | + | |
665 | + } | |
666 | + left += imagesize + spacing; | |
667 | + } | |
668 | + | |
669 | + | |
670 | + | |
671 | + ctx.setFillStyle("rgb(255,255,255)"); | |
672 | + ctx.setFontSize(size); | |
673 | + ctx.fillText("优惠乐翻天,精彩就在你身边!", 37 * unit, 595 * unit); | |
674 | + ctx.setFillStyle("rgb(255,255,255)"); | |
675 | + ctx.setFontSize(size); | |
676 | + | |
677 | + ctx.fillText(act_time, 37 * unit, 620 * unit); //绘制活动是时间 | |
678 | + ctx.setFillStyle("rgb(255,255,255)"); | |
679 | + ctx.setFontSize(size); | |
680 | + ctx.fillText("长按识别二维码,可帮我助力!", 37 * unit, 660 * unit); | |
681 | + ctx.drawImage(ewm_path, 325 * unit, 585 * unit, 77 * unit, 77 * unit); //分享的背景图片 | |
682 | + ctx.save(); | |
683 | + //读取文件成功则OK-- | |
684 | + // wx.getImageInfo({ | |
685 | + // src: path3, | |
686 | + // success: function (res) { | |
687 | + //把画板内容绘制成图片,并回调 画板图片路径 | |
688 | + ctx.draw(false, function() { | |
689 | + setTimeout(function() { | |
690 | + wx.canvasToTempFilePath({ | |
691 | + x: 0, | |
692 | + y: 0, | |
693 | + width: 300, | |
694 | + height: 500, | |
695 | + destWidth: 400 * 2, | |
696 | + destHeight: 720 * 2, | |
697 | + canvasId: 'share_id', | |
698 | + success: function(res) { | |
699 | + wx.hideLoading(); | |
700 | + var shareImgPath = th.data.shareImgPath; | |
701 | + shareImgPath[0] = res.tempFilePath; | |
702 | + | |
703 | + th.setData({ | |
704 | + shareImgPath: shareImgPath, | |
705 | + canvasHidden: 1, | |
706 | + is_share: 1, | |
707 | + is_generate: 0, | |
708 | + canvasHidden: 1 | |
709 | + }) | |
710 | + if (!res.tempFilePath) { | |
711 | + wx.showModal({ | |
712 | + title: '提示', | |
713 | + content: '图片绘制中,请稍后重试', | |
714 | + showCancel: false | |
715 | + }) | |
716 | + return false; | |
717 | + } | |
718 | + | |
719 | + }, | |
720 | + fail(r) { | |
721 | + | |
722 | + } | |
723 | + }, 500) | |
724 | + }) | |
725 | + }) | |
726 | + } | |
727 | + }) | |
728 | + | |
729 | + | |
730 | + }, | |
731 | + | |
732 | + | |
791 | 733 | preview: function() { |
792 | 734 | var th = this; |
793 | 735 | var shareImgPath = th.data.shareImgPath; |
... | ... | @@ -819,197 +761,80 @@ Page({ |
819 | 761 | } |
820 | 762 | }) |
821 | 763 | }, |
764 | + | |
822 | 765 | //把固定的图片加载到本地 |
823 | - imageinfo: function() { | |
824 | - var th = this; | |
825 | - var images = th.data.images; | |
826 | - var iurl = th.data.iurl; | |
827 | - wx.getImageInfo({ | |
828 | - src: iurl + images[0], | |
829 | - success: function(res) { | |
830 | - //res.path是网络图片的本地地址 | |
831 | - images[0] = res.path; | |
832 | - }, | |
833 | - fail: function(res) { | |
834 | - | |
835 | - } | |
836 | - }); | |
837 | - wx.getImageInfo({ | |
838 | - src: iurl + images[1], | |
839 | - success: function(res) { | |
840 | - //res.path是网络图片的本地地址 | |
841 | - images[1] = res.path; | |
842 | - }, | |
843 | - fail: function(res) { | |
844 | - | |
845 | - } | |
846 | - }); | |
847 | - wx.getImageInfo({ | |
848 | - src: iurl + images[2], | |
849 | - success: function(res) { | |
850 | - //res.path是网络图片的本地地址 | |
851 | - images[2] = res.path; | |
852 | - }, | |
853 | - fail: function(res) { | |
854 | - | |
855 | - } | |
856 | - }); | |
857 | - wx.getImageInfo({ | |
858 | - src: iurl + images[3], | |
859 | - success: function(res) { | |
860 | - | |
861 | - //res.path是网络图片的本地地址 | |
862 | - images[3] = res.path; | |
863 | - }, | |
864 | - fail: function(res) { | |
865 | - | |
866 | - } | |
867 | - }); | |
868 | - wx.getImageInfo({ | |
869 | - src: iurl + images[4], | |
870 | - success: function(res) { | |
871 | - | |
872 | - //res.path是网络图片的本地地址 | |
873 | - images[4] = res.path; | |
874 | - }, | |
875 | - fail: function(res) { | |
876 | - | |
877 | - } | |
878 | - }); | |
879 | - wx.getImageInfo({ | |
880 | - src: iurl + images[5], | |
881 | - success: function(res) { | |
882 | - | |
883 | - //res.path是网络图片的本地地址 | |
884 | - images[5] = res.path; | |
885 | - }, | |
886 | - fail: function(res) { | |
887 | - | |
888 | - } | |
889 | - }); | |
890 | - th.setData({ | |
891 | - images: images | |
892 | - }) | |
893 | - | |
894 | - }, | |
895 | - //好友猜一猜 | |
896 | - save_share: function(e) { | |
897 | - var th = this; | |
898 | - var aitem = this.data.aitem; //任务的数据集 | |
899 | - var sw_index = this.data.sw_index; //轮播的下标 | |
900 | - //任务id | |
901 | - var taskid = aitem[sw_index].id | |
902 | - th.setData({ | |
903 | - is_share: 1 | |
904 | - }) | |
905 | - var url = "/api/weshop/marketing/help/help/task/involve/page"; | |
906 | - getApp().request.promiseGet(url, { | |
907 | - isShowLoading: true, | |
908 | - data: { | |
909 | - storeId: os.stoid, | |
910 | - taskId: taskid, | |
911 | - userId: getApp().globalData.user_id | |
912 | - } | |
913 | - }).then(res => { | |
914 | - if (res.data.code == 0) { | |
915 | - var data = res.data.data.pageData; //帮拆数组 | |
916 | - if (data.length > 0) { | |
917 | - // th.setData({ | |
918 | - // dynamic: data | |
919 | - // }) | |
920 | - // th.info_head(function() { | |
921 | - th.shareFrends(); | |
922 | - // }); | |
923 | - //th.imageinfo(); | |
924 | - | |
925 | - } | |
926 | - } else { | |
927 | - wx.hideLoading(); | |
928 | - getApp().my_warnning(res.data.msg, 0, th); | |
929 | - } | |
930 | - }) | |
931 | - }, | |
932 | - //把已助力好友头像下载到本地 | |
933 | - info_head: function(e) { | |
934 | - var th = this; | |
935 | - var images = th.data.dynamic; | |
936 | - if (images[0] != null && images[0] != "" && images[0] != undefined) { | |
937 | - wx.getImageInfo({ | |
938 | - src: images[0].headPic, | |
939 | - success: function(res) { | |
940 | - //res.path是网络图片的本地地址 | |
941 | - images[0].headPic = res.path; | |
942 | - }, | |
943 | - fail: function(res) { | |
944 | - | |
945 | - } | |
946 | - }); | |
947 | - } | |
948 | - if (images[1] != null && images[1] != "" && images[1] != undefined) { | |
949 | - wx.getImageInfo({ | |
950 | - src: images[1].headPic, | |
951 | - success: function(res) { | |
952 | - //res.path是网络图片的本地地址 | |
953 | - images[1].headPic = res.path; | |
954 | - }, | |
955 | - fail: function(res) { | |
956 | - | |
957 | - } | |
958 | - }); | |
959 | - } | |
960 | - if (images[2] != null && images[2] != "" && images[2] != undefined) { | |
961 | - wx.getImageInfo({ | |
962 | - src: images[2].headPic, | |
963 | - success: function(res) { | |
964 | - //res.path是网络图片的本地地址 | |
965 | - images[2].headPic = res.path; | |
966 | - }, | |
967 | - fail: function(res) { | |
968 | - | |
969 | - } | |
970 | - }); | |
971 | - } | |
972 | - if (images[3] != null && images[3] != "" && images[3] != undefined) { | |
973 | - wx.getImageInfo({ | |
974 | - src: images[3].headPic, | |
975 | - success: function(res) { | |
976 | - //res.path是网络图片的本地地址 | |
977 | - images[3].headPic = res.path; | |
978 | - }, | |
979 | - fail: function(res) { | |
980 | - | |
981 | - } | |
982 | - }); | |
983 | - } | |
984 | - // if (images[4] != null && images[4] != "" && images[4] != undefined) { | |
985 | - // wx.getImageInfo({ | |
986 | - // src: images[4].headPic, | |
987 | - // success: function(res) { | |
988 | - // //res.path是网络图片的本地地址 | |
989 | - // images[4].headPic = res.path; | |
990 | - // }, | |
991 | - // fail: function(res) { | |
992 | - | |
993 | - // } | |
994 | - // }); | |
995 | - // } | |
996 | - // if (images[5] != null && images[5] != "" && images[5] != undefined) { | |
997 | - // wx.getImageInfo({ | |
998 | - // src: images[5].headPic, | |
999 | - // success: function (res) { | |
1000 | - // //res.path是网络图片的本地地址 | |
1001 | - // images[5].headPic = res.path; | |
1002 | - // }, | |
1003 | - // fail: function (res) { | |
1004 | - | |
1005 | - // } | |
1006 | - // }); | |
1007 | - //} | |
1008 | - th.setData({ | |
1009 | - dynamic: images | |
1010 | - }) | |
1011 | - | |
1012 | - }, | |
766 | + imageinfo:async function() { | |
767 | + var th = this; | |
768 | + var images = th.data.images; | |
769 | + var iurl = th.data.iurl; | |
770 | + for(var i in images){ | |
771 | + var img_path=iurl + images[i]; | |
772 | + await getApp().request.promise_downimg(img_path).then(res=>{ | |
773 | + images[i] = res; | |
774 | + }) | |
775 | + } | |
776 | + | |
777 | + th.data.images=images; | |
778 | + }, | |
779 | + | |
780 | + | |
781 | + //好友猜一猜 | |
782 | + save_share: function(e) { | |
783 | + var th = this; | |
784 | + var aitem = this.data.aitem; //任务的数据集 | |
785 | + var sw_index = this.data.sw_index; //轮播的下标 | |
786 | + var sw_item=aitem[sw_index]; | |
787 | + //任务id | |
788 | + var taskid = sw_item.id; | |
789 | + th.setData({ | |
790 | + is_share: 1 | |
791 | + }) | |
792 | + var url = "/api/weshop/marketing/help/help/task/involve/page"; | |
793 | + getApp().request.promiseGet(url, { | |
794 | + isShowLoading: true, | |
795 | + data: { | |
796 | + storeId: os.stoid, | |
797 | + taskId: taskid, | |
798 | + userId: getApp().globalData.user_id | |
799 | + } | |
800 | + }).then(res => { | |
801 | + if (res.data.code == 0) { | |
802 | + var data = res.data.data.pageData; //帮拆数组 | |
803 | + if (data.length > 0) { | |
804 | + th.data.dynamic=data[0]; | |
805 | + var path=th.data.iurl+sw_item.giftBagUrl; | |
806 | + //先获取礼包分享时的本地路径 | |
807 | + getApp().request.promise_downimg(path).then(res=>{ | |
808 | + th.data.share_lb_img= res; | |
809 | + //先获取会员的头像 | |
810 | + th.info_head(th.shareFrends); | |
811 | + }); | |
812 | + } | |
813 | + } else { | |
814 | + wx.hideLoading(); | |
815 | + getApp().my_warnning(res.data.msg, 0, th); | |
816 | + } | |
817 | + }) | |
818 | + }, | |
819 | + | |
820 | + //把已助力好友头像下载到本地 | |
821 | + info_head:async function(func) { | |
822 | + var th = this; | |
823 | + var images = th.data.dynamic.zlHelpUser; | |
824 | + var arr=new Array(); | |
825 | + if (images) { | |
826 | + for(var i in images){ | |
827 | + var img_path=images[i].headPic; | |
828 | + await getApp().request.promise_downimg(img_path).then(res=>{ | |
829 | + th.data.head_pic_arr.push(res); | |
830 | + }) | |
831 | + } | |
832 | + } | |
833 | + func(); | |
834 | + }, | |
835 | + | |
836 | + | |
837 | + | |
1013 | 838 | //礼包的详情 轮播图 |
1014 | 839 | libao_details: function(e) { |
1015 | 840 | var th = this; | ... | ... |