bayi vor 1 Jahr
Ursprung
Commit
5d01a6c086
3 geänderte Dateien mit 40 neuen und 3 gelöschten Zeilen
  1. 20 0
      pages/index/index.js
  2. 20 3
      pages/score/index.js
  3. BIN
      static/375-300-1.jpg

+ 20 - 0
pages/index/index.js

@@ -59,6 +59,26 @@ Page({
             })
         }
     },
+    // 分享到朋友圈
+    shareImageMessage() {
+        wx.miniapp.shareImageMessage({
+            imagePath: '/static/375-300-1.jpg',
+            thumbPath: '/static/inviteH.png',
+            scene: 1,
+            success(res) {
+                console.log(res);
+                wx.showToast({
+                    title: '成功:分享图片',
+                })
+            },
+            fail(res) {
+                console.log(res);
+                wx.showToast({
+                    title: '失败:分享图片',
+                })
+            }
+        })
+    },
     requestAgain() {
         this.getBannerList()
         this.getResource()

+ 20 - 3
pages/score/index.js

@@ -68,7 +68,6 @@ Page({
             uploadHide: true
         })
     },
-
     creatShare() {
         let video = this.data.readDetail
         return new Promise((resolve, reject) => {
@@ -81,7 +80,7 @@ Page({
                 }).exec((res) => {
                     const canvas = res[0].node;
                     const ctx = canvas.getContext('2d');
-                    const dpr = wx.getSystemInfoSync().pixelRatio;
+                    const dpr = 0.84
                     canvas.width = res[0].width * dpr;
                     canvas.height = res[0].height * dpr;
                     ctx.scale(dpr, dpr);
@@ -145,15 +144,27 @@ Page({
                                                 }
                                             }
                                             setTimeout(() => {
-                                                console.log(wx.getStorageSync('shareVideoId'), 'reading-wx.score');
                                                 wx.canvasToTempFilePath({
                                                     canvas: canvas,
                                                     success(res) {
+                                                        // #if MP
                                                         resolve({
                                                             title: '我的新作品发布啦,快来捧场点赞!',
                                                             path: `/pages/pkPage/index?videoId=${wx.getStorageSync('shareVideoId')}&uid=${wx.getStorageSync('uid')}&isShare=true`,
                                                             imageUrl: res.tempFilePath
                                                         })
+                                                        // #elif ANDROID
+                                                        resolve({
+                                                            title: '我的新作品发布啦,快来捧场点赞!',
+                                                            userName: 'gh_50f61361ad1d',
+                                                            path: `/pages/pkPage/index?videoId=${wx.getStorageSync('shareVideoId')}&uid=${wx.getStorageSync('uid')}&isShare=true`,
+                                                            imagePath: res.tempFilePath,
+                                                            webpageUrl: 'http://www.efunbox.cn',
+                                                            withShareTicket: true,
+                                                            miniprogramType: 1,
+                                                            scene: 0,
+                                                        })
+                                                        // #endif
                                                     },
                                                     fail(res) {
                                                         reject()
@@ -194,6 +205,11 @@ Page({
             }
         }
         // #elif ANDROID
+        const promise = new Promise(resolve => {
+            this.creatShare().then(res => {
+                resolve(res)
+            })
+        })
         return {
             title: '我的新作品发布啦,快来捧场点赞!',
             userName: 'gh_50f61361ad1d',
@@ -203,6 +219,7 @@ Page({
             withShareTicket: true,
             miniprogramType: 1,
             scene: 0,
+            promise
         }
         // #endif
     },

BIN
static/375-300-1.jpg