bayi 2 年 前
コミット
3f61877a63

+ 1 - 1
components/uploadFile/index.js

@@ -96,5 +96,5 @@ Component({
       }
       console.log(res, '嘎2');
     },
-  }
+  },
 })

+ 2 - 1
components/uploadFile/index.wxml

@@ -7,7 +7,8 @@
   </view>
 </view>
 <!-- 上传成功 -->
-<view class="uploadBox successBox" wx:if="{{uploadSuccess}}" catchtap="cancelMask">
+<!-- <view class="uploadBox successBox" wx:if="{{uploadSuccess}}" catchtap="cancelMask"> -->
+<view class="uploadBox successBox" catchtap="cancelMask">
   <view class="success" catchtap="true">
     <image src="/static/lan.png" class="icon" mode="" />
     <view class="tips1">作品上传成功</view>

+ 4 - 5
mixins/share.js

@@ -7,7 +7,7 @@ module.exports = Behavior({
     }) {
       if (from == 'button') {
         let video = target.dataset.info
-        console.log(video);
+        console.log(video,'info,,.,.');
         const promise = new Promise(resolve => {
           this.creatShare(video).then(res => {
             resolve(res)
@@ -22,13 +22,12 @@ module.exports = Behavior({
       } else {
         return {
           title: '课文朗读,从未如此有趣。',
-          path: `/pages/index/index?&uid=${wx.getStorageSync('uid')}`,
+          path: `/pages/index/index?uid=${wx.getStorageSync('uid')}`,
           imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/shareContent.png'
         }
       }
     },
     creatShare(video) {
-      console.log(video);
       return new Promise((resolve, reject) => {
         let context = wx.createSelectorQuery();
         context
@@ -70,13 +69,13 @@ module.exports = Behavior({
                   dz.src = video.isLike ? '/static/heart_colored.png' : '/static/heart.png'
                   dz.onload = () => {
                     ctx.drawImage(dz, 228, 222, 22, 22)
-                    ctx.fillText(video.userRead.likeAmount, 254, 238)
+                    ctx.fillText(video.userRead.likeAmount||0, 254, 238)
                     // 评论
                     let pl = canvas.createImage();
                     pl.src = '/static/comment.png'
                     pl.onload = () => {
                       ctx.drawImage(pl, 318, 222, 22, 22)
-                      ctx.fillText(video.userRead.commentAmount, 340, 238)
+                      ctx.fillText(video.userRead.commentAmount||0, 340, 238)
                       setTimeout(() => {
                         wx.canvasToTempFilePath({
                           canvas: canvas,

+ 4 - 4
pages/pkResult/index.js

@@ -208,7 +208,7 @@ Page({
                     success(res) {
                       resolve({
                         title: '请欣赏我的课文朗读作品,点赞+评论。',
-                        path: `/pages/pkResult/index?&uid=${wx.getStorageSync('uid')}`,
+                        path: `/pages/pkResult/index?uid=${wx.getStorageSync('uid')}`,
                         imageUrl: res.tempFilePath
                       })
                     },
@@ -225,7 +225,7 @@ Page({
                     success(res) {
                       resolve({
                         title: '请欣赏我的课文朗读作品,点赞+评论。',
-                        path: `/pages/pkResult/index?&uid=${wx.getStorageSync('uid')}`,
+                        path: `/pages/pkResult/index?uid=${wx.getStorageSync('uid')}`,
                         imageUrl: res.tempFilePath
                       })
                     },
@@ -252,14 +252,14 @@ Page({
       })
       return {
         title: '课文朗读,从未如此有趣。',
-        path: `/pages/index/index?&uid=${wx.getStorageSync('uid')}`,
+        path: `/pages/index/index?uid=${wx.getStorageSync('uid')}`,
         imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/shareContent.png',
         promise
       }
     } else {
       return {
         title: '课文朗读,从未如此有趣。',
-        path: `/pages/index/index?&uid=${wx.getStorageSync('uid')}`,
+        path: `/pages/index/index?uid=${wx.getStorageSync('uid')}`,
         imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/shareContent.png'
       }
     }

+ 1 - 0
pages/reading/index.js

@@ -300,6 +300,7 @@ Page({
       tempFilePath: this.data.tempFilePath,
       title: this.data.videoInfo.userRead.title,
       id: this.data.videoInfo.userRead.exampleId,
+      coverImg:this.data.videoInfo.userRead.coverImg,
       originVideo: this.data.videoInfo.userRead.originVideo
     }
     this.setReadDetail(detail)

+ 105 - 4
pages/score/index.js

@@ -5,7 +5,6 @@ import {
   store
 } from '~/store/index'
 Page({
-
   /**
    * 页面的初始数据
    */
@@ -42,7 +41,109 @@ Page({
       url: `/pages/reading/index?videoId=${this.data.score.id}&reset=true`,
     })
   },
-  onShareAppMessage() {
-
-  }
+  creatShare() {
+    let video = this.data.readDetail
+    console.log(video);
+    return new Promise((resolve, reject) => {
+      let context = wx.createSelectorQuery();
+      context
+        .select('#share')
+        .fields({
+          node: true,
+          size: true
+        }).exec((res) => {
+          const canvas = res[0].node;
+          const ctx = canvas.getContext('2d');
+          const dpr = wx.getSystemInfoSync().pixelRatio;
+          canvas.width = res[0].width * dpr;
+          canvas.height = res[0].height * dpr;
+          ctx.scale(dpr, dpr);
+          ctx.font = '14px PingFang';
+          let pic = canvas.createImage();
+          pic.src = video.coverImg; //可以是本地,也可以是网络图片
+          pic.onload = () => {
+            ctx.drawImage(pic, 0, 0, 375, 211);
+          }
+          let peiyin = canvas.createImage();
+          peiyin.src = '/static/peiyin.jpg';
+          peiyin.onload = () => {
+            ctx.drawImage(peiyin, 0, 211, 375, 89);
+            //分享
+            let fx = canvas.createImage();
+            fx.src = '/static/share.png'
+            fx.onload = () => {
+              ctx.drawImage(fx, 12, 220, 20, 20)
+              ctx.fillText('分享', 36, 238)
+              // 收藏,一个一个渲染
+              let sc = canvas.createImage();
+              sc.src = '/static/no_collect.png'
+              sc.onload = () => {
+                ctx.drawImage(sc, 110, 220, 19, 19)
+                ctx.fillText('收藏', 134, 238)
+                //点赞
+                let dz = canvas.createImage();
+                dz.src = '/static/heart.png'
+                dz.onload = () => {
+                  ctx.drawImage(dz, 228, 222, 22, 22)
+                  ctx.fillText(0, 254, 238)
+                  // 评论
+                  let pl = canvas.createImage();
+                  pl.src = '/static/comment.png'
+                  pl.onload = () => {
+                    ctx.drawImage(pl, 318, 222, 22, 22)
+                    ctx.fillText( 0, 340, 238)
+                    setTimeout(() => {
+                      wx.canvasToTempFilePath({
+                        canvas: canvas,
+                        success(res) {
+                          resolve({
+                            title: '请欣赏我的课文朗读作品,点赞+评论。',
+                            path: `/pages/index?readId=${video.id}&uid=${wx.getStorageSync('uid')}`,
+                            imageUrl: res.tempFilePath
+                          })
+                        },
+                        fail(res) {
+                          reject()
+                        }
+                      }, this)
+                    }, 500)
+                  }
+                }
+              }
+            }
+          }
+        })
+    })
+  },
+  onShareAppMessage({
+    from,
+    target
+  }) {
+    if (from == 'button') {
+      const promise = new Promise(resolve => {
+        this.creatShare().then(res => {
+          resolve(res)
+        })
+      })
+      return {
+        title: '请欣赏我的课文朗读作品,点赞+评论。',
+        path: `/pages/index/index?uid=${wx.getStorageSync('uid')}`,
+        imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/shareContent.png',
+        promise
+      }
+    } else {
+      return {
+        title: '课文朗读,从未如此有趣。',
+        path: `/pages/index/index?uid=${wx.getStorageSync('uid')}`,
+        imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/shareContent.png'
+      }
+    }
+  },
+  /*   onShareAppMessage() {
+      return {
+        title: '课文朗读,从未如此有趣。',
+        path: `/pages/pkPage/index?uid=${wx.getStorageSync('uid')}&videoId=${this.data.readDetail.id}`,
+        imageUrl: this.data.readDetail.coverImg
+      }
+    }, */
 })

+ 1 - 0
pages/score/index.wxml

@@ -58,4 +58,5 @@
     <view class="stBtn" bindtap="backReading">试听</view>
     <uploadFile readingType='{{readingType}}' />
   </view>
+  <canvas id='share' type="2d"> </canvas>
 </view>