Rorschach 6 years ago
parent
commit
79efbe29cb
2 changed files with 43 additions and 25 deletions
  1. 36 24
      component/share/share.js
  2. 7 1
      project.config.json

+ 36 - 24
component/share/share.js

@@ -42,7 +42,7 @@ Component({
       return false
     },
     poster: function () {
-      const ctx = wx.createCanvasContext('myCanvas');
+      
       const that = this;
       wx.showLoading({
         title: '海报生成中',
@@ -55,32 +55,15 @@ Component({
           success: res => {
             this.setData({
               QRCodeImagePath: res.tempFilePath
+            },()=>{
+              this.saveAvatar();
             })
           }
         });
-        wx.downloadFile({
-          url: that.data.avatar,
-          success: res => {
-            this.setData({
-              avatar: res.tempFilePath
-            })
-          }
-        });
-        // 下载icon
-        if (this.data.shareType === 'works') {
-          wx.downloadFile({
-            url: that.data.iconImg,
-            success: res => {
-              this.setData({
-                iconImg: res.tempFilePath
-              })
-            }
-          });
-        }
-        this.makeImage(ctx);
       })
     },
-    makeImage: function (ctx) {
+    makeImage: function () {
+      const ctx = wx.createCanvasContext('myCanvas');
       // 画出背景和相同内容
       if (this.data.shareType === 'works') {
         ctx.drawImage('../../../static/image/works_poster.jpg', 0, 0, 1200, 2100, 0, 0, 600, 1050); //插入图片  
@@ -143,7 +126,8 @@ Component({
         ctx.fillText('朗朗读书声,是世界上最美妙的声音', (300 - ctx.measureText('朗朗读书声,是世界上最美妙的声音').width) / 2, 327.5)
       }
       console.log('花二维码')
-      console.log(this.data.QRCodeImagePath)
+      console.log(this.data)
+      console.log(this.data.avatar)
       ctx.drawImage(this.data.QRCodeImagePath, 35, 353, 90, 90);
       ctx.draw();
       setTimeout(() => {
@@ -166,9 +150,37 @@ Component({
             wx.hideLoading();
           }
         })
-      }, 200)
+      }, 400)
 
     },
+    saveIcon: function(){
+      wx.downloadFile({
+        url: this.data.iconImg,
+        success: res => {
+          this.setData({
+            iconImg: res.tempFilePath
+          },()=>{
+            this.makeImage();
+          })
+        }
+      });
+    },
+    saveAvatar: function(){
+      wx.downloadFile({
+        url: this.data.avatar,
+        success: res => {
+          this.setData({
+            avatar: res.tempFilePath
+          },()=>{
+            if (this.data.shareType === 'works'){
+              this.saveIcon();
+            } else {
+              this.makeImage();
+            }
+          })
+        }
+      });
+    },
     share: function (data) {
       console.log(data)
       if (this.data.shareType === 'works') {

+ 7 - 1
project.config.json

@@ -36,7 +36,7 @@
 			"list": []
 		},
 		"miniprogram": {
-			"current": 1,
+			"current": 2,
 			"list": [
 				{
 					"id": -1,
@@ -50,6 +50,12 @@
 					"pathName": "pages/social/works/works",
 					"query": "id=1544868253444507&title=【课文1】秋天",
 					"scene": "1012"
+				},
+				{
+					"id": -1,
+					"name": "自己发团",
+					"pathName": "pages/groupPage/collage-details/collage-details",
+					"query": "orderId=1547518873633105"
 				}
 			]
 		}