Rorschach 6 anni fa
parent
commit
55b00b440f

+ 76 - 51
component/share/share.js

@@ -15,7 +15,11 @@ Component({
    */
   data: {
     shareFlag: true,
-    imgUrls: ''
+    imgUrls: '',
+    avatar: '',
+    author: '',
+    iconImg: '',
+    title: '',
   },
 
   /**
@@ -33,44 +37,59 @@ Component({
       ctx.setFillStyle('#fff')
       ctx.fill()
       ctx.arc(185, 48, 37, 0, 2 * Math.PI, false)
-      ctx.clip();//画了圆 再剪切  原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内  
-      ctx.drawImage('../../../static/groupImg/Bitmap1.png', 148, 8, 100, 100);   //插入图片  
+      ctx.clip(); //画了圆 再剪切  原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内  
+      ctx.drawImage(this.data.avatar, 148, 8, 100, 100); //插入图片  
       ctx.restore(); //恢复之前保存的绘图上下文 恢复之前保存的绘图上下午即状态 可以继续绘制
       ctx.setFontSize(20)
-      ctx.setFillStyle('#000')
-      ctx.fillText('喔喔', 166, 115)
+      ctx.setFillStyle('#535353')
+      ctx.fillText(this.data.author, (370 - ctx.measureText(this.data.author).width) / 2, 115)
       ctx.setFillStyle('#FF4400')
-      ctx.fillText('郎朗读书声是世上最美的声音', 50, 138) 
-      ctx.drawImage('../../../static/groupImg/Bitmap1.png', 9, 156, 352, 145);  
-      ctx.setFontSize(18)
-      ctx.setFillStyle('#000')
-      ctx.fillText('一年级语文上学期', 12, 329)
-      ctx.drawImage('../../../static/groupImg/Combined Shape.png', 11, 348, 196, 65);
-      ctx.drawImage('../../../static/groupImg/Rectangle 41.png', 134, 358, 59, 20);
-      ctx.setFontSize(14)  
-      ctx.setFillStyle('#fff')
-      ctx.fillText('五人团', 149, 373) 
-      ctx.setFontSize(16)  
-      ctx.setFillStyle('#A95A00')
-      ctx.fillText('原价', 24, 373)
-      ctx.setStrokeStyle('red')
-      ctx.moveTo(64, 368)
-      ctx.lineTo(114, 368)
-      ctx.stroke()
-      ctx.fillText('¥99元', 64, 373)
-      ctx.setFontSize(18)
-      ctx.fillText('团购价仅需', 20, 403)
-      ctx.fillText('元', 144, 403)
-      ctx.setFontSize(20)  
-      ctx.setFillStyle('red')
-      ctx.fillText('¥1', 109, 403) 
-      ctx.drawImage('../../../static/groupImg/share_bottom.png', 3, 419, 370, 192);  
-      ctx.setFontSize(20)
-      ctx.setFillStyle('red')
-      ctx.fillText('名额有限,售完截止', 9, 467)
-      ctx.setFontSize(18)
-      ctx.setFillStyle('#000')
-      ctx.fillText('长按识别二维码参加团购', 9, 493)
+      if (this.data.shareType === 'works') {
+        ctx.fillText('已使出洪荒之力,声情并茂的为', (370 - ctx.measureText('已使出洪荒之力,声情并茂的为').width) / 2, 138)
+        ctx.fillText(`《${this.data.title}》`, (370 - ctx.measureText(`《${this.data.title}》`).width) / 2, 160)
+        ctx.fillText(`配了一段惊世之作`, (370 - ctx.measureText(`配了一段惊世之作`).width) / 2, 182)
+        ctx.drawImage(this.data.iconImg, 9, 205, 352, 145);
+        ctx.setFontSize(18)
+        ctx.setFillStyle('#000')
+        ctx.drawImage('../../../static/groupImg/share_bottom.png', 3, 419, 370, 192);
+        ctx.setFontSize(20)
+        ctx.setFillStyle('red')
+        ctx.fillText('为TA疯狂打CALL', 9, 467)
+        ctx.setFontSize(18)
+        ctx.setFillStyle('#000')
+        ctx.fillText('长按识别二维码,快去听听', 9, 493)
+
+      } else {
+        ctx.fillText('郎朗读书声是世上最美的声音', 50, 138)
+        ctx.drawImage('../../../static/groupImg/Combined Shape.png', 11, 348, 196, 65);
+        ctx.drawImage('../../../static/groupImg/Rectangle 41.png', 134, 358, 59, 20);
+        ctx.setFontSize(14)
+        ctx.setFillStyle('#fff')
+        ctx.fillText('五人团', 149, 373)
+        ctx.setFontSize(16)
+        ctx.setFillStyle('#A95A00')
+        ctx.fillText('原价', 24, 373)
+        ctx.setStrokeStyle('red')
+        ctx.moveTo(64, 368)
+        ctx.lineTo(114, 368)
+        ctx.stroke()
+        ctx.fillText('¥99元', 64, 373)
+        ctx.setFontSize(18)
+        ctx.fillText('团购价仅需', 20, 403)
+        ctx.fillText('元', 144, 403)
+        ctx.setFontSize(20)
+        ctx.setFillStyle('red')
+        ctx.fillText('¥1', 109, 403)
+        ctx.drawImage('../../../static/groupImg/share_bottom.png', 3, 419, 370, 192);
+        ctx.setFontSize(20)
+        ctx.setFillStyle('red')
+        ctx.fillText('名额有限,售完截止', 9, 467)
+        ctx.setFontSize(18)
+        ctx.setFillStyle('#000')
+        ctx.fillText('长按识别二维码参加团购', 9, 493)
+      }
+
+
       ctx.drawImage('../../../static/groupImg/code.png', 217, 374, 135, 135);
       ctx.draw(true, function (res) {
         wx.canvasToTempFilePath({
@@ -81,30 +100,36 @@ Component({
           destWidth: 370,
           destHeight: 507,
           canvasId: 'myCanvas',
-          success:(res) => {
-              console.log(res.tempFilePath)
-              // wx.saveImageToPhotosAlbum({
-              //   filePath: res.path,
-              //   success(res) {
-              //     console.log(res);
-              //    }
-              // })
-              that.setData({
-                imgUrls: res.tempFilePath
-              })
+          success: (res) => {
+            console.log(res.tempFilePath)
+            // wx.saveImageToPhotosAlbum({
+            //   filePath: res.path,
+            //   success(res) {
+            //     console.log(res);
+            //    }
+            // })
+            that.setData({
+              imgUrls: res.tempFilePath
+            })
           }
         })
       })
     },
-    share: function () {
+    share: function (data) {
+      console.log(this.data)
+      console.log(data)
       this.setData({
-        shareFlag: !this.data.shareFlag
+        shareFlag: !this.data.shareFlag,
+        avatar: data.avatar,
+        author: data.author,
+        iconImg: data.iconImg,
+        title: data.title,
       })
     },
     PreservationImg: function () {
       wx.saveImageToPhotosAlbum({
         filePath: this.data.imgUrls,
-        success(res) { 
+        success(res) {
           console.log('保存成功')
         }
       })
@@ -113,4 +138,4 @@ Component({
       this.triggerEvent('customevent', {})
     }
   }
-})
+})

+ 1 - 1
component/share/share.wxml

@@ -13,7 +13,7 @@
        </view>
    </view>
    <view class="share-img" wx:if="{{imgUrls}}">
-       <image class="img" src="{{imgUrls}}"></image>
+       <cover-image class="img" src="{{imgUrls}}"></cover-image>
        <view class="Preservation">
            <image class="PreservationBg" src="../../static/groupImg/Preservation.png"></image>
            <text bindtap="PreservationImg">点我保存,并分享至朋友圈</text>

+ 1 - 1
component/share/share.wxss

@@ -10,7 +10,7 @@
 }
 
 .btn {
-    position: absolute;
+    position: fixed;
     bottom: 0;
     width: 100%;
     height: 290rpx;

+ 2 - 0
pages/groupPage/collage-details/collage-details.js

@@ -44,6 +44,7 @@ Page({
   },
   //显示分享页 
   share: function () {
+    console.log(this.shareDialog)
     this.shareDialog.share();
   },
   /**
@@ -88,6 +89,7 @@ Page({
    */
   onReady: function () {
     this.shareDialog = this.selectComponent("#share-dialog");
+    
   },
 
   /**

+ 0 - 1
pages/groupPage/collage-details/collage-details.wxml

@@ -63,7 +63,6 @@
 <canvas canvas-id="myCanvas" style="width:370px; height: 507px; position: absolute; left: -99rpx; top: -999rpx;"></canvas>
 <shareDialog id="share-dialog" bindcustomevent="eventListener"/>
 
-<shareDialog id="share-dialog"/>
 <popup
     typeOf="sendSuccess"
     title="报告团长"

+ 28 - 13
pages/main/class/class.js

@@ -1,5 +1,7 @@
 import httpRequestApi from '../../../utils/APIClient';
-import {formatDate} from '../../../utils/util';
+import {
+  formatDate
+} from '../../../utils/util';
 Page({
   data: {
     fullScreenBtn: false,
@@ -12,7 +14,8 @@ Page({
     total: '',
     title: '',
     id: '',
-    iconImg: ''
+    iconImg: '',
+    collectFlag: false,
   },
   onLoad: function (option) {
     console.log(option);
@@ -24,19 +27,29 @@ Page({
       id: option.id
     })
 
-    let uid = wx.getStorageSync('uid');;
+    this.uid = wx.getStorageSync('uid');;
 
-    httpRequestApi.getClassDetail(uid, option.id).success(res => {
+    httpRequestApi.getClassDetail(this.uid, option.id).success(res => {
       console.log(res);
       this.setData({
         title: res.data.data.title,
         videoUrl: res.data.data.playUrl,
         iconImg: res.data.data.iconImg
       })
-      this.getReadInfo(1,10);
+      this.getReadInfo(1, 10);
+      this.checkLike();
+    })
+  },
+  // 检查是否收藏
+  checkLike: function () {
+    httpRequestApi.classIsLike(this.uid, {
+      targetCode: this.data.id
+    }).success(res => {
+      this.setData({
+        collectFlag: res.data.data
+      })
     })
   },
-
   goToReading: function () {
     let id = this.data.id;
     let title = this.data.title;
@@ -55,24 +68,26 @@ Page({
     })
   },
   collect: function (e) {
-    let uid =  wx.getStorageSync('uid');
+    // let uid =  wx.getStorageSync('uid');
     let data = {
       targetCode: this.data.id,
       title: this.data.title,
       iconImg: this.data.iconImg
     }
-    httpRequestApi.collectClass(uid, data).success(res => {
-      console.log(res);
+    httpRequestApi.collectClass(this.uid, data).success(res => {
+      this.setData({
+        collectFlag: !this.data.collectFlag
+      })
     })
   },
-  getReadInfo: function(pageNo,pageSize){
-    const uid =  wx.getStorageSync('uid');
+  getReadInfo: function (pageNo, pageSize) {
+    // const uid =  wx.getStorageSync('uid');
     const data = {
       lessonId: 1,
       pageNo: pageNo,
       pageSize: pageSize
     };
-    httpRequestApi.getClassRead(uid,data).success(res=>{
+    httpRequestApi.getClassRead(this.uid, data).success(res => {
       const readInfo = res.data.data.list;
       const readTemp = [];
       readInfo.forEach(item => {
@@ -92,7 +107,7 @@ Page({
     });
   },
   // 下拉加载
-  scrollUpdate:function(e){
+  scrollUpdate: function (e) {
     console.log(e)
   }
 })

+ 2 - 2
pages/main/class/class.wxml

@@ -20,8 +20,8 @@
     <view class="footSection">
         <image class="blackbord" src="../../../static/image/blackbord.png" />
         <view class="collectBtn footerBtn" bindtap="collect">
-            <image src="../../../static/image/collected.png" />
-            <text>收藏</text>
+            <image src=" {{collectFlag ? '../../../static/image/collected.png' : '../../../static/image/no_collect.png'}}" />
+            <text>{{collectFlag ? '取消收藏' : '收藏'}}</text>
         </view>
         <view class="readingBtn footerBtn" bindtap="goToReading">
             <image class="microphone" src="../../../static/image/microphone.png" />

+ 2 - 1
pages/main/singleBook/singleBook.js

@@ -11,12 +11,13 @@ Page({
             title: options.title
         })
         const uid= wx.getStorageSync('uid');
+        console.log(options.id)
         httpRequestApi.getBookDetail(uid, options.id).success((res) => {
             console.log(res.data.data)
             const bookInfo = res.data.data.product;
             const lessonList = res.data.data.lessonList;
             this.setData({
-                titleIcon: bookInfo.iconImg,
+                titleIcon: bookInfo.bgImg,
                 title: bookInfo.title,
                 bookInfo: bookInfo.description
             })

+ 44 - 15
pages/social/works/works.js

@@ -17,7 +17,9 @@ Page({
         howMuch: '2000',
         moneySelect: 'moneySelect',
         moneyNormal: 'moneyNormal',
-        ifReward: false
+        ifReward: false,
+        id: '',
+        // shareFlag: false
     },
     onLoad: function (option) {
         console.log(option)
@@ -30,11 +32,15 @@ Page({
             title: option.title,
             id: option.id
         })
-        let uid = wx.getStorageSync('uid');
-        this.getWorks(uid, option.id);
+        this.uid = wx.getStorageSync('uid');
+        this.getWorks(this.uid, option.id);
     },
+    // onReady: function () {
+
+    // },
     getWorks: function (uid, id) {
         httpRequestApi.getWorksDetail(uid, id).success((res) => {
+            console.log(res);
             const others = res.data.data.otherRead;
             const author = res.data.data.user;
             const works = res.data.data.userRead;
@@ -51,7 +57,8 @@ Page({
                 authorAvatar: author.avatar,
                 authorUid: author.uid,
                 videoSrc: works.originVideo,
-                audioSrc: works.audioPath
+                audioSrc: works.audioPath,
+                iconImg: works.iconImg
             })
             // 设置音频路径
             this.innerAudioContext = wx.createInnerAudioContext();
@@ -62,8 +69,31 @@ Page({
             this.getReply();
         });
     },
+    likeWorks: function (e) {
+        httpRequestApi.likeWorks(this.uid, this.data.id).success(res => {
+            console.log(this.uid)
+        });
+    },
+    // 弹出分享框
+    openShare: function (e) {
+        // this.setData({
+        //     shareFlag: !this.data.shareFlag
+        // })
+        this.shareDialog = this.selectComponent("#share-dialog");
+        const data = {
+            avatar: this.data.authorAvatar,
+            author: this.data.author,
+            iconImg: this.data.iconImg,
+            title: this.data.title,
+            // tip: this.data.tip,
+        }
+        this.shareDialog.share(data);
+    },
     videoPlay: function () {
         this.innerAudioContext.play();
+        httpRequestApi.playWorks(this.uid, this.data.id).success(res => {
+
+        })
     },
     videoEnd: function () {
         this.innerAudioContext.stop();
@@ -89,19 +119,19 @@ Page({
         }
     },
     follow: function () {
-        let uid = wx.getStorageSync('uid');
+        // let uid = wx.getStorageSync('uid');
         let followUid = 2;
-        httpRequestApi.followUser(uid, followUid).success((res) => {
+        httpRequestApi.followUser(this.uid, followUid).success((res) => {
             console.log(res)
         });
     },
     // 点赞评论
     likeCommend: function (e) {
         console.log(e);
-        let uid = wx.getStorageSync('uid');
+        // let uid = wx.getStorageSync('uid');
         let followUid = e.currentTarget.dataset.id;
         let index = e.currentTarget.dataset.index;
-        httpRequestApi.likeCommend(uid, followUid).success(res => {
+        httpRequestApi.likeCommend(this.uid, followUid).success(res => {
             console.log(res);
             const str = `replyList[${index}].likes`;
             this.setData({
@@ -117,12 +147,11 @@ Page({
     },
     // 查询回复
     getReply: function () {
-        let uid = wx.getStorageSync('uid');
+        // let uid = wx.getStorageSync('uid');
         let columnId = this.data.id;
-        console.log(columnId)
         let pageNo = 1;
         let pageSize = 10;
-        httpRequestApi.getReply(uid, columnId, pageNo, pageSize).success((res) => {
+        httpRequestApi.getReply(this.uid, columnId, pageNo, pageSize).success((res) => {
             console.log(res.data.data.list);
             const replyList = res.data.data.list;
             const replyTemp = [];
@@ -163,13 +192,13 @@ Page({
     sendHandler: function () {
         console.log(this.data.inputValue);
         if (this.data.inputValue !== '') {
-            let uid = wx.getStorageSync('uid');
+            // let uid = wx.getStorageSync('uid');
             let data = {
                 "columnId": this.data.id,
                 colunmNames: 'what',
                 "detailDesc": this.data.inputValue
             }
-            httpRequestApi.postReply(uid, data).success(res => {
+            httpRequestApi.postReply(this.uid, data).success(res => {
                 console.log(res);
             });
         }
@@ -192,8 +221,8 @@ Page({
             targetUid: this.data.authorUid,
             amount: this.data.howMuch
         }
-        let uid = wx.getStorageSync('uid');
-        httpRequestApi.rewardMoney(uid, data).success(res => {
+        // let uid = wx.getStorageSync('uid');
+        httpRequestApi.rewardMoney(this.uid, data).success(res => {
             console.log(res);
             this.payMoneyt(res.data.data);
         })

+ 7 - 1
pages/social/works/works.json

@@ -1 +1,7 @@
-{}
+{
+    "component": true,
+    "usingComponents": {
+        "shareDialog": "/component/share/share",
+        "popup": "/component/popup/popup"
+    }
+}

+ 8 - 4
pages/social/works/works.wxml

@@ -3,7 +3,7 @@
     <view class="readAuthorSection">
         <image class="avatar" src="{{authorAvatar}}" />
         <text class="nickName">{{author}}</text>
-        <view class="like">
+        <view class="like" bindtap="likeWorks">
             <image src="../../../static/image/liked.png" />
             <text class="likeBtn">点赞</text>
         </view>
@@ -57,11 +57,13 @@
             <image class="microphone" src="../../../static/image/microphone.png" />
             <text>我要朗读</text>
         </view>
-        <view class="shareBtn footerBtn">
-            <button open-type="share" plain="true" hover-class="none">
+        <view class="shareBtn footerBtn" bindtap="openShare">
+            <!-- <button open-type="share" plain="true" hover-class="none">
                 <image src="../../../static/image/share.png" />
                 <text>分享</text>
-            </button>
+            </button> -->
+            <image src="../../../static/image/share.png" />
+            <text>分享</text>
         </view>
     </view>
     <!-- 奖励弹窗 -->
@@ -84,4 +86,6 @@
             <cover-view class="rewardBtn" bindtap="rewardMoney">立即奖励</cover-view>
         </cover-view>
     </cover-view>
+    <canvas canvas-id="myCanvas" style="width:370px;z-index=99999; height: 507px; position: absolute; left: -99rpx; top: -999rpx;"></canvas>
+    <shareDialog id="share-dialog" shareType = 'works'/>
 </view>

+ 3 - 3
pages/social/works/works.wxss

@@ -277,7 +277,7 @@
     margin-left: 80rpx
 }
 
-.shareBtn button {
+/* .shareBtn button {
     display: flex;
     flex-direction: column;
     outline: none;
@@ -293,12 +293,12 @@ button::after {
     height: 0;
     top: 0;
     left: 0
-}
+} */
 
 .shareBtn {
     margin-right: 80rpx;
     padding: 0;
-    background: #fff;
+    /* background: #fff; */
 }
 
 .footerBtn image {

+ 7 - 1
project.config.json

@@ -36,7 +36,7 @@
 			"list": []
 		},
 		"miniprogram": {
-			"current": 5,
+			"current": 7,
 			"list": [
 				{
 					"id": 0,
@@ -79,6 +79,12 @@
 					"name": "concern",
 					"pathName": "pages/user/myconcern/myconcern",
 					"query": ""
+				},
+				{
+					"id": -1,
+					"name": "作品页面",
+					"pathName": "pages/social/works/works",
+					"query": "id=1541489786444388&title=铺满色巴掌的水泥道"
 				}
 			]
 		}

BIN
static/image/no_collect.png


+ 29 - 2
utils/APIClient.js

@@ -47,10 +47,10 @@ module.exports = {
 		}).send();
 	},
 	// 获取课本详情
-	getBookDetail(id) {
+	getBookDetail(uid,id) {
 		let url = getProductUrl(`wx/product/${id}`);
 		return request.getInstance().header({
-			uid: wx.getStorageSync('uid')
+			uid
 		}).url(url).send();
 	},
 	// 获取单课详情
@@ -60,6 +60,19 @@ module.exports = {
 			uid
 		}).url(url).send();
 	},
+	// 检查是否收藏过课程
+	classIsLike(uid,data){
+		let url = getProductUrl(`wx/favorites/isLike`);
+		return request.getInstance().header({
+			uid
+		}).url(url).data(data).send();
+	},
+	getClassDetail(uid,id) {
+		let url = getProductUrl(`wx/lesson/${id}`);
+		return request.getInstance().header({
+			uid
+		}).url(url).send();
+	},
 	// 获取单课朗读信息
 	getClassRead(uid,data){
 		let url = getBaseUrl(`wx/userRead`);
@@ -67,6 +80,13 @@ module.exports = {
 			uid
 		}).data(data).url(url).send();
 	},
+	// 作品播放了+1
+	playWorks(uid,readId){
+		let url = getBaseUrl(`wx/userRead/play/${readId}`);
+		return request.getInstance().header({
+			uid
+		}).url(url).send();
+	},
 	// 发布作品
 	postWork(uid, data) {
 		console.log(data);
@@ -75,6 +95,13 @@ module.exports = {
 			uid
 		}).url(url).data(data).method('POST').send();
 	},
+	// 点赞作品
+	likeWorks(uid,readId){
+		let url = getBaseUrl(`wx/userRead/like/${readId}`);
+		return request.getInstance().header({
+			uid
+		}).url(url).send();
+	},
 	// 关注用户 
 	followUser(uid, followUid) {
 		let url = getBaseUrl(`wx/fans`);