Rorschach 4 years ago
parent
commit
23c6b27ce7

+ 1 - 0
app.js

@@ -2,6 +2,7 @@
 import {
   GetQueryString
 } from 'utils/util'
+
 // const Towxml = require('/towxml/main');
 App({
   onLaunch: function (options) {

+ 2 - 2
app.json

@@ -17,9 +17,9 @@
     "pages/user/myWallet/myWallet",
     "pages/user/mycourse/mycourse",
     "pages/user/myread/myread",
-    "pages/user/mycollection/mycollection",
+    "pages/mycollection/mycollection",
     "pages/user/walletDetails/walletDetails",
-    "pages/user/myworks/myworks",
+    "pages/myworks/myworks",
     "pages/vipPage/vip/vip",
     "pages/vipPage/vipCode/vipCode",
     "pages/vipPage/wechat/wechat",

+ 4 - 0
component/comment/comment.js

@@ -59,6 +59,8 @@ Component({
         this.setData({
           commentList: this.data.commentList,
           commentNum: commentNum
+        },()=>{
+          console.log('评论列表',this.data.commentList)
         })
       });
     },
@@ -87,6 +89,7 @@ Component({
           postsId: this.data.postId,
           content: e.detail.value
         }
+        console.log(321232123123,data)
 
         this.replyComment(data);
       }
@@ -157,6 +160,7 @@ Component({
         commentList.forEach((item, index) => {
           if (index === this.data.postIndex) {
             let replyList = item.replyVOList;
+            
             let str = `commentList[${index}].replyVOList`;
             this.setData({
               [str]: replyList

+ 1 - 2
component/my/my.js

@@ -44,9 +44,8 @@ export const myInit = (that) => {
       });
     },
     that.toMyKeep = e => {
-      let title = e.currentTarget.dataset.title;
       wx.navigateTo({
-        url: `../user/mycollection/mycollection?title=${title}`
+        url: `../mycollection/mycollection`
       });
     },
 

+ 5 - 7
component/share/share.js

@@ -77,9 +77,9 @@ Component({
       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); //插入图片  
+        ctx.drawImage('../../static/image/works_poster.jpg', 0, 0, 1200, 2100, 0, 0, 600, 1050); //插入图片  
       } else {
-        ctx.drawImage('../../../static/image/group_poster.jpg', 0, 0, 1200, 2100, 0, 0, 600, 1050); //插入图片  
+        ctx.drawImage('../../static/image/group_poster.jpg', 0, 0, 1200, 2100, 0, 0, 600, 1050); //插入图片  
       }
       ctx.save()
       ctx.beginPath()
@@ -158,7 +158,7 @@ Component({
             wx.hideLoading()
           },
           fail: (res) => {
-            console.log(res)
+            console.log('史称失败',res)
             wx.hideLoading();
           }
         })
@@ -208,8 +208,7 @@ Component({
           // path: data.path,
           QRData: {
             page: data.path,
-            scene: data.scene,
-            qrCodeId: this.data.shareId
+            scene: data.scene
           }
         })
       }
@@ -225,8 +224,7 @@ Component({
           // path: data.path,
           QRData: {
             page: data.path,
-            scene: data.scene,
-            qrCodeId: this.data.shareId
+            scene: data.scene
           },
           groupPurchaseInfo: data.groupPurchaseInfo,
           groupType: data.groupType

+ 1 - 1
component/share/share.wxml

@@ -20,6 +20,6 @@
            <!-- <image class="PreservationBg" src="../../static/groupImg/Preservation.png"></image> -->
            <!-- <text bindtap="PreservationImg">保存到相册中,快去分享吧</text> -->
            <!-- 保存到相册中,快去分享吧! -->
-       <!-- </cover-view> --> -->
+       <!-- </cover-view> -->
    </cover-view>
 </view>

+ 69 - 16
component/video-swiper/index.js

@@ -55,7 +55,8 @@ Component({
         curQueue: [],
         circular: false,
         // nextMargin: '400rpx',
-        _last: 1,
+        _last: 0,
+        // _last: 1,
         _change: -1,
         _invalidUp: 0,
         _invalidDown: 0,
@@ -81,7 +82,8 @@ Component({
                 this.setData({
                     curQueue: data.nextQueue.splice(0, 3)
                 }, function () {
-                    _this.playCurrent(1);
+                    // _this.playCurrent(1);
+                    _this.playCurrent(0);
                 });
             }
         },
@@ -150,26 +152,42 @@ Component({
             });
         },
         playCurrent: function playCurrent(current) {
-            return; // 注掉自动播放
+            console.log('playCurrent', current)
+            // return; // 注掉自动播放
             this.data._videoContexts.forEach(function (ctx, index) {
                 index !== current ? ctx.pause() : ctx.play();
             });
         },
         onPlay: function onPlay(e) {
-            console.log('播放记录',e)
+            console.log('播放记录', e)
             httpRequestApi.playLogReport({
-                readId: e.currentTarget.dataset.id,
+                userReadId: e.currentTarget.dataset.id,
                 playStopTime: 1000
-            }).success(res=>{
-                console.log('播放记录',res)
+            }).success(res => {
+                console.log('播放记录', res)
             })
             // this.trigger(e, 'play');
         },
+        onPlayList: function onPlayList(e) {
+            console.log('lastVideoId', this.data.lastVideoId);
+            if (this.data.lastVideoId && e.target.id !== this.data.lastVideoId) {
+                const lastVideo = wx.createVideoContext(this.data.lastVideoId, this)
+                lastVideo.pause();
+                this.setData({
+                    lastVideoId: e.target.id
+                })
+            }
+            if (!this.data.lastVideoId) {
+                this.setData({
+                    lastVideoId: e.target.id
+                })
+            }
+        },
         onPause: function onPause(e) {
             this.trigger(e, 'pause');
         },
         onEnded: function onEnded(e) {
-            console.log('播放结束',e)
+            console.log('播放结束', e)
             // this.trigger(e, 'ended');
         },
         onError: function onError(e) {
@@ -206,11 +224,11 @@ Component({
             // this.trigger(e, 'headTap')
             console.log('点击头像', e)
             wx.navigateTo({
-                url: `../../pages/user/myworks/myworks?uid=${uid}`,
+                url: `../../pages/myworks/myworks?uid=${uid}`,
                 fail: (err) => {
                     console.log('跳转错误', err)
                     wx.navigateTo({
-                        url: `../../../pages/user/myworks/myworks?uid=${uid}`
+                        url: `../../../pages/myworks/myworks?uid=${uid}`
                     });
                 }
             });
@@ -235,12 +253,24 @@ Component({
             }
             const index = e.target.dataset.index ? e.target.dataset.index : e.currentTarget.dataset.index;
             console.log('视频index', index);
-            let str = `curQueue[${index}].isFavorite`
-            httpRequestApi.collectClass(data).success((res) => {
-                this.setData({
-                    [str]: true
-                })
-            });
+            if (this.data.curQueue.length <= 0) {
+                let str = `videoList[${index}].isFavorite`
+                httpRequestApi.collectClass(data).success((res) => {
+                    this.setData({
+                        [str]: !this.data.videoList[index].isFavorite
+                    })
+                });
+            } else {
+                let str = `curQueue[${index}].isFavorite`
+                httpRequestApi.collectClass(data).success((res) => {
+                    this.setData({
+                        [str]: !this.data.curQueue[index].isFavorite
+                    })
+                });
+            }
+
+        },
+        collectTapList: function collectTapList(e) {
 
         },
         // 点赞
@@ -294,6 +324,29 @@ Component({
 
             })
         },
+        openShare: function (e) {
+            const obj = e.currentTarget.dataset
+            console.log('分享', obj)
+            console.log('分享', e)
+            if (1) {
+                this.shareDialog = this.selectComponent("#share-dialog");
+                const data = {
+                    avatar: obj.avatar,
+                    author: obj.author,
+                    iconImg: obj.iconImg,
+                    title: obj.title,
+                    path: `pages/index/index`,
+                    scene: obj.id,
+                    productId: 1
+                    // tip: this.data.tip,
+                }
+                // console.log(data)
+                this.setData({
+                    noScroll: 'noScroll'
+                })
+                this.shareDialog.share(data);
+            }
+        },
         trigger: function trigger(e, type) {
             if (!wx.getStorageSync('user').wechatName) {
                 wx.navigateTo({

+ 3 - 1
component/video-swiper/index.json

@@ -1,4 +1,6 @@
 {
     "component": true,
-    "usingComponents": {}
+    "usingComponents": {
+        "shareDialog": "/component/share/share"
+    }
 }

+ 9 - 5
component/video-swiper/index.wxml

@@ -2,7 +2,7 @@
   <swiper 
     wx:if="{{isSwiper}}"
     class="video-swiper" 
-    circular="{{circular}}"
+    circular="{{false}}"
     next-margin="{{nextMargin}}" 
     easing-function="{{easingFunction}}" 
     vertical 
@@ -71,7 +71,7 @@
               <image class="collect_btn_icon" src="{{item.isFavorite ? '../../static/index/star_colored.png' : '../../static/index/star.png'}}" />
               <text>收藏</text>
           </view>
-          <view class="btn share_btn">
+          <view class="btn share_btn" bindtap="openShare" data-index="{{index}}" data-id="{{item.id}}" data-avatar="{{item.avatar}}" data-author="{{item.nickName}}" data-uid="{{item.uid}}" data-icon="{{item.iconImg}}" data-title="{{item.title}}" data-type="{{item.type}}">
               <image class="share_btn_icon" src="../../static/index/share.png" lazy-load="true" />
               <text>分享</text>
           </view>
@@ -100,7 +100,7 @@
   <!-- // 非swiper -->
   <view wx:if="{{!isSwiper}}" class="swiper_item no_swiper" wx:for="{{videoList}}"  data-id="{{item.id}}"  wx:key="*this">
       <view class="head_box">
-        <view class="user_box" catchtap="{{ifHeadTap ? 'headTap' : null}}" data-id="{{item.uid}}">
+        <view class="user_box" catchtap="{{ifHeadTap ? 'headTap' : null}}" data-uid="{{item.uid}}">
           <image class="avatar" lazy-load="true" src="{{item.avatar}}" />
           <view class="user_right">
             <view class="nickname">{{item.nickName}}</view>
@@ -132,6 +132,8 @@
         src="{{item.url}}" 
         object-fit="contain"
         data-index="{{index}}"
+        bindplay="onPlayList"
+        bindended="onEndedList"
       >
       <!--   bindplay="onPlay"
         bindpause="onPause"
@@ -155,7 +157,7 @@
               <image class="collect_btn_icon" src="{{item.isFavorite ? '../../static/index/star_colored.png' : '../../static/index/star.png'}}" />
               <text>收藏</text>
           </view>
-          <view class="btn share_btn" catchtap="likeTap" data-index="{{index}}" data-id="{{item.id}}" data-type="{{item.type}}">
+          <view class="btn share_btn" bindtap="openShare" data-author="{{item.nickName}}" data-index="{{index}}" data-id="{{item.id}}" data-avatar="{{item.avatar}}" data-uid="{{item.uid}}" data-icon="{{item.iconImg}}" data-title="{{item.title}}" data-type="{{item.type}}">
               <image class="share_btn_icon" src="../../static/index/share.png" />
               <text>分享</text>
           </view>
@@ -172,7 +174,7 @@
         </view>
             
       </view>
-      <view class="btn_wrapper" catchtap="goToReading" data-id="{{item.classId}}">
+      <view class="btn_wrapper" wx:if="{{item.noReading}}" catchtap="goToReading" data-id="{{item.classId}}">
         <view class="reading_btn">
           <image src="../../static/index/star.png" />
           <text>我要配音</text>
@@ -181,3 +183,5 @@
     </view>
 </view>
 
+<shareDialog id="share-dialog" shareType='works' bindShareDialogClose="shareDialogClose" shareId="{{id}}" />
+

+ 97 - 25
pages/index/index.js

@@ -113,7 +113,7 @@ Page({
 
     if (!this.data.isLogin) {
       wx.navigateTo({
-        url: `../../pages/login/login`
+        url: `../../pages/login/login?index=${myIndex}`
       });
       return;
     }
@@ -200,25 +200,37 @@ Page({
     }, 2800)
   },
   onLoad: function (options) {
-    this.uid = wx.getStorageSync('uid');
-    let grade = wx.getStorageSync('grade');
+    getOpenidNoLogin((res) => {
+      console.log('getOpenidNoLogin', res)
+      if (!res.data.data.grade) {
+        this.setData({
+          isGradeShow: true,
+          options
+        })
+      }
+      // 登录或注册完成 展示页面
+    }, (error) => {
+      console.log('获取失败', error)
+    });
+
 
-    let user = wx.getStorageSync('user');
-    if (!this.uid || !grade) {
+    if (options.scene) {
       this.setData({
-        isGradeShow: true,
-        options
+        workId: options.scene
       })
-      console.log('没有uid 也不是游客,需要去授权')
-      return;
-    }
-    this.showPage()
-    if (this.uid && !user) {
-      console.log('游客状态')
-    }
-    if (this.uid && user) {
-      console.log('登陆状态')
     }
+    this.uid = wx.getStorageSync('uid');
+    let grade = wx.getStorageSync('grade');
+
+    // if (!this.uid || !grade) {
+    //   this.setData({
+    //     isGradeShow: true,
+    //     options
+    //   })
+    //   console.log('没有uid 也不是游客,需要去授权')
+    //   return;
+    // }
+    this.showPage();
     wx.getSystemInfo({
       success: (res) => {
         console.log('系统', res)
@@ -239,32 +251,52 @@ Page({
     });
 
   },
-  onShow: function (e) {
+  onShow: function () {
     console.log('this.data.workId', this.data.workId)
     if (this.data.workId) {
       // 需要在推荐第一个上插入一条分享或者刚朗读完数据
+      let id = this.data.workId;
       this.setData({
+        workId: null,
         myIndex: 0,
         videoList: [],
         isSwiper: true,
-        recommendTotalNo:1
+        recommendTotalNo: 1
       })
-      httpRequestApi.getClassDetail(this.data.workId).success(res => {
+      httpRequestApi.getClassDetail(id).success(res => {
         console.log('有一条数据', res)
         let tempList = [];
         tempList.push(res.data.data);
-        this.formatWorksList(tempList, true);
-        this.getHotRecommend()
+        this.setData({
+          videoList: [],
+          isSwiper: true,
+          recommendTotalNo: 1
+        }, () => {
+          this.formatWorksList(tempList, true);
+          this.getHotRecommend()
 
+        })
+
+        // this.showPage()
       })
     }
-    console.log('页面显示', e)
     if (this.data.myIndex === 3) {
       this.getUserWorksInfo(1)
     }
     wx.setNavigationBarTitle({
       title: '小学语文朗读配音'
     })
+    console.log('页面返回页面返回', this.data.fromLoginIndex)
+    if (this.data.fromLoginIndex) {
+      console.log('页面返回页面返回', this.data.fromLoginIndex)
+      let index = this.data.fromLoginIndex;
+      this.setData({
+        fromLoginIndex: null
+      }, () => {
+        this.updateData(0)
+
+      })
+    }
     const userInfo = wx.getStorageSync('user')
     if (userInfo.wechatName) {
       this.setData({
@@ -502,7 +534,7 @@ Page({
       }
     })
   },
-  delHideMyWork:function(){
+  delHideMyWork: function () {
     this.getMyRead()
   },
   // 获取我的朗读
@@ -533,7 +565,7 @@ Page({
         temp.status = item.status
         myWorks.push(temp);
       });
-      console.log('myWorks',myWorks)
+      console.log('myWorks', myWorks)
       this.setData({
         videoList: myWorks
       })
@@ -548,6 +580,9 @@ Page({
       })
     }
   },
+  touchMove: function (e) {
+    return
+  },
   // 打开评论
   openComment: function (e) {
     // 
@@ -684,5 +719,42 @@ Page({
       url: `../../pages/reading/reading?id=${id}`
     });
   },
-
+  courseCollectTap: function collectClass(e) {
+    console.log('收藏按钮', e);
+    const data = {
+      targetCode: e.target.dataset.id ? e.target.dataset.id : e.currentTarget.dataset.id,
+      favoritesType: e.target.dataset.type ? e.target.dataset.type : e.currentTarget.dataset.type
+    }
+    const index = e.target.dataset.index ? e.target.dataset.index : e.currentTarget.dataset.index;
+    let str = `coursesData[${index}].isFavorites`
+    httpRequestApi.collectClass(data).success((res) => {
+      console.log('this.data.coursesData[index]', this.data.coursesData[index])
+      this.setData({
+        [str]: !this.data.coursesData[index].isFavorites
+      })
+    });
+  },
+  coursesOpenShare: function coursesOpenShare(e){
+    const obj = e.currentTarget.dataset
+            console.log('分享', obj)
+            console.log('分享', e)
+            if (1) {
+                this.shareDialog = this.selectComponent("#share-dialog");
+                const data = {
+                    avatar: obj.avatar,
+                    author: obj.author,
+                    iconImg: obj.iconImg,
+                    title: obj.title,
+                    path: `pages/index/index`,
+                    scene: obj.id,
+                    productId: 1
+                    // tip: this.data.tip,
+                }
+                // console.log(data)
+                this.setData({
+                    noScroll: 'noScroll'
+                })
+                this.shareDialog.share(data);
+            }
+  }
 })

+ 2 - 1
pages/index/index.json

@@ -5,7 +5,8 @@
         "myPlacerholder": "/component/myPlacerholder/myPlacerholder",
         "VideoSwiper": "../../component/video-swiper/index",
         "Comment": "../../component/comment/comment",
-        "StatusBar": "../../component/statusBar/statusBar"
+        "StatusBar": "../../component/statusBar/statusBar",
+        "shareDialog": "/component/share/share"
     },
     "enablePullDownRefresh": false,
     "window": {

+ 4 - 1
pages/index/index.wxml

@@ -40,7 +40,7 @@
   bindprogress="onProgress"
   bindloadedmetadata="onLoadedMetaData" -->
   </VideoSwiper>
-  <view class="comment_section" catchtap="commentTap" data-type="blank" wx:if="{{commentShow}}">
+  <view class="comment_section" catchtouchmove="touchMove" catchtap="commentTap" data-type="blank" wx:if="{{commentShow}}">
     <Comment data-type="list" commentId="{{commentId}}" commentNum="{{commentNum}}" inputValue="{{inputValue}}" bindsendReply="sendReply" />
   </view>
 </view>
@@ -48,6 +48,9 @@
 <view hidden="{{hide}}">
   <Dialog bindmyevent="jurisdiction" />
 </view>
+<shareDialog id="share-dialog" shareType='works' bindShareDialogClose="shareDialogClose" shareId="{{id}}" />
+
+ <canvas canvas-id="myCanvas" style="width:300px; height: 525px; position: absolute; left: -999rpx; top: -9999rpx;"></canvas>
 <!-- <view class="index-dialog" wx:if="{{indexSignDialog}}">
   <form bindsubmit="signInBtn" report-submit="{{true}}" class="index-dialog-wrapper" >
     <view class="index-dialog-text">签到领取小红花哦</view>

+ 48 - 30
pages/login/login.js

@@ -4,38 +4,56 @@ import {
 } from '../../utils/httpUtil';
 Page({
 
-      /**
-       * 页面的初始数据
-       */
-      data: {
-
-      },
-
-      /**
-       * 生命周期函数--监听页面加载
-       */
-
-      onLoad: function (options) {
-
-      },
-      impower: function (e) {
-        console.log(e)
-        var myEventDetail = {} // detail对象,提供给事件监听函数
-        var myEventOption = {} // 触发事件的选项
-        getOpenidSessionKey((res) => {
-          wx.showToast({
-            title: '登录成功',
-            icon: 'fail',
-            duration: 500
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    index: undefined
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+
+  onLoad: function (options) {
+    if(options.index){
+      this.setData({
+        index: options.index
+      })
+    }
+  },
+  impower: function (e) {
+    console.log(e)
+    var myEventDetail = {} // detail对象,提供给事件监听函数
+    var myEventOption = {} // 触发事件的选项
+    getOpenidSessionKey((res) => {
+      console.log(res)
+      wx.showToast({
+        title: '登录成功',
+        icon: 'fail',
+        duration: 1000,
+        success: () => {
+          const pages = getCurrentPages();
+          const prevPage = pages[pages.length - 2];
+          prevPage.setData({
+              fromLoginIndex: this.data.index, // 有id就塞到第一位
+          }, () => {
+              wx.navigateBack({
+                  delta: 1
+              })
           })
+        }
+      })
+    }, (error) => {
+      wx.showToast({
+        title: '登录失败',
+        icon: 'fail',
+        duration: 1000,
+        success: () => {
           wx.navigateBack()
-        }, (error) => {
-          wx.showToast({
-            title: '登录失败',
-            icon: 'fail',
-            duration: 500
-          })
-      });
+        }
+      })
+    });
   },
   touchMove: function () {
     return false

+ 163 - 0
pages/mycollection/mycollection.js

@@ -0,0 +1,163 @@
+import httpRequestApi from '../../utils/APIClient';
+import {
+  formatDate
+} from '../../utils/util';
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    collection_data: [],
+    line1: '您还没有收藏过哦',
+    line2: '快去收藏自己喜欢的吧',
+    videoList: [],
+    commentShow:false
+  },
+
+  toClass: function (e) {
+    let targetCode = e.currentTarget.dataset.targetcode;
+    let title = e.currentTarget.dataset.title;
+    // wx.navigateTo({
+    //   url: `../../main/class/class?id=${targetCode}&title=${title}`
+    // });
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (option) {
+    console.log(option.title);
+    if (option.title) {
+      wx.setNavigationBarTitle({
+        title: '我的收藏' //页面标题为路由参数
+      });
+      this.setData({
+        title: option.title
+      });
+    }
+    httpRequestApi.myFavorites().success(res => {
+      this.formatWorksList(res.data.data.list)
+    });
+  },
+  formatWorksList(list) {
+    list.forEach(item => {
+      const temp = {};
+      temp.title = item.userRead.title;
+      temp.summary = item.userRead.summary;
+      temp.img = item.userRead.iconImg;
+      temp.plays = item.userRead.playAmount ? item.userRead.playAmount : 0;
+      temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
+      temp.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 0;
+      temp.classId = item.userRead.exampleId ? item.userRead.exampleId : 1605097720036046;
+      temp.time = formatDate(item.userRead.gmtCreated, 3);
+      temp.avatar = item.user.avatar;
+      temp.profession = item.user.profession;
+      temp.uid = item.user.uid;
+      temp.url = item.userRead.videoPath ? item.userRead.videoPath : item.userRead.originVideo;
+      temp.id = item.userRead.id;
+      temp.type = item.userRead.type;
+      temp.nickName = item.user.wechatName;
+      temp.isLike = item.isLike;
+      temp.isFavorite = true;
+      this.data.videoList.push(temp);
+    });
+    this.setData({
+      videoList: this.data.videoList
+    }, () => {
+      console.log(this.data.videoList)
+    })
+
+  },
+
+  // 评论区点击
+  commentTap: function (e) {
+    console.log('点击评论区', e)
+    if (e.target.dataset.type === 'blank') {
+      this.setData({
+        commentShow: false
+      })
+    }
+  },
+   // 打开评论
+   openComment: function (e) {
+    // 
+    console.log('id', e.detail.activeId)
+    this.setData({
+      commentShow: !this.data.commentShow,
+      commentId: e.detail.activeId,
+      // commentList: []
+    });
+    // this.getReply(e.detail.activeId);
+  },
+
+  // 发布回复
+  sendReply: function (e) {
+    console.log('triger', e.detail.content);
+    let data = {
+      columnId: this.data.commentId,
+      colunmNames: 'what',
+      detailDesc: e.detail.content,
+      // productId: this.data.productId
+    }
+    httpRequestApi.postReply(this.uid, data).success(res => {
+      console.log(res)
+      this.setData({
+        pageNo: 1,
+        commentList: []
+      }, () => {
+        this.getReply(this.data.commentId);
+      })
+    });
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 8 - 0
pages/mycollection/mycollection.json

@@ -0,0 +1,8 @@
+{
+    "usingComponents": {
+        "myPlacerholder": "/component/myPlacerholder/myPlacerholder",
+        "VideoSwiper": "/component/video-swiper/index",
+        "Comment": "/component/comment/comment"
+    },
+    "enablePullDownRefresh": false
+}

+ 18 - 0
pages/mycollection/mycollection.wxml

@@ -0,0 +1,18 @@
+<view class='my-collection'>
+  <!-- <view class='collection-article' wx:for="{{ collection_data }}" wx:key="{{ index }}" bindtap='toClass' data-targetCode="{{item.targetCode}}" data-title='{{ item.userRead.title }}'>
+    <view class='video-preview'>
+      <image src='{{ item.userRead.iconImg }}'></image>
+    </view>
+    <view class='content-title'>
+      {{ item.userRead.title }}
+    </view>
+    <view class='content-detail'>
+      <view class='left'>{{ item.userRead.summary }}</view>
+    </view> 
+  </view> -->
+  <VideoSwiper wx:if="{{videoList.length > 0}}" class="video-swiper" video-list="{{videoList}}" nextMargin="{{nextMargin}}" isSwiper="{{isSwiper}}" ifHeadTap="{{true}}" bindopenComment="openComment" bindheadTap="headTapHandler" bindgoToReading="goToReading" binddelHideMyWork="delHideMyWork" bindchange="videoChange" />
+  <!-- <myPlacerholder line1="{{line1}}" line2="{{line2}}" wx:if="{{collection_data.length <= 0}}" /> -->
+  <view class="comment_section" catchtap="commentTap" data-type="blank" wx:if="{{commentShow}}">
+    <Comment data-type="list" commentId="{{commentId}}" commentNum="{{commentNum}}" inputValue="{{inputValue}}" bindsendReply="sendReply" />
+  </view>
+</view>

+ 14 - 2
pages/user/mycollection/mycollection.wxss

@@ -5,7 +5,13 @@
   padding-top: 22rpx;
   /* background: #F0F1F5; */
 }
+.video-swiper {
+  width: 100%;
+  height: 100%;
+  display: block;
+  background: #ffffff;
 
+}
 .collection-article {
   position: relative;
   overflow: hidden;
@@ -56,6 +62,12 @@
 
 }
 
-.left {
-  /* width: 200rpx; */
+.comment_section{
+  position: absolute;
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 98%;
+  background: rgba(0,0,0, .2);
+  overflow: hidden;
 }

+ 20 - 2
pages/user/myworks/myworks.js

@@ -1,8 +1,8 @@
 // pages/user/myworks/myworks.js
-import APIClient from '../../../utils/APIClient.js'
+import APIClient from '../../utils/APIClient.js'
 import {
   formatDate
-} from '../../../utils/util.js'
+} from '../../utils/util.js'
 Page({
 
   /**
@@ -34,6 +34,24 @@ Page({
       url: `../../social/works/works?id=${id}&title=${title}`
     });
   },
+  commentTap: function (e) {
+    console.log('点击评论区', e)
+    if (e.target.dataset.type === 'blank') {
+      this.setData({
+        commentShow: false
+      })
+    }
+  },
+  touchMove: function(e){
+    return
+  },
+  goToReading: function (e) {
+    console.log('去朗读', e)
+    const id = e.detail.activeId ? e.detail.activeId : e.currentTarget.dataset.id;
+    wx.navigateTo({
+      url: `../../pages/reading/reading?id=${id}`
+    });
+  },
   // 关注用户
   follow: function () {
     let followUid = this.data.uid;

pages/user/myworks/myworks.json → pages/myworks/myworks.json


+ 2 - 2
pages/user/myworks/myworks.wxml

@@ -8,7 +8,7 @@
         <text class="avatar-nickname">{{ wareCards.user.wechatName }}</text>
       </view>
       <view class="follow" wx:if="{{!isMyself}}" bindtap="follow">
-        <image src="{{isFans? '../../../static/image/fully_heart.png' : '../../../static/image/empty_heart.png'}}" />
+        <image src="{{isFans? '../../static/image/fully_heart.png' : '../../static/image/empty_heart.png'}}" />
         <text class="followBtn">{{isFans ? '已' : ''}}关注</text>
       </view>
     </view>
@@ -35,6 +35,6 @@
 
   <VideoSwiper wx:if="{{videoList.length > 0}}" class="video-swiper" video-list="{{videoList}}" nextMargin="{{nextMargin}}" isSwiper="{{false}}" bindopenComment="openComment" bindheadTap="headTapHandler" bindgoToReading="goToReading" bindplay="onPlay"></VideoSwiper>
 </scroll-view>
-<view class="comment_section" catchtap="commentTap" data-type="blank" wx:if="{{commentShow}}">
+<view class="comment_section" catchtouchmove="touchMove"  catchtap="commentTap" data-type="blank" wx:if="{{commentShow}}">
     <Comment data-type="list" commentId="{{commentId}}" />
 </view>

+ 10 - 0
pages/user/myworks/myworks.wxss

@@ -4,6 +4,16 @@ page {
   background: #F0F1F5;
 }
 
+.comment_section{
+  position: absolute;
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 98%;
+  background: rgba(0,0,0, .2);
+  overflow: hidden;
+}
+
 .user-works {
   width: 100%;
   box-sizing: border-box;

+ 42 - 26
pages/reading/reading.js

@@ -41,7 +41,10 @@ Page({
         console.log(option);
         this.videoCtx = null;
         const uid = wx.getStorageSync('uid')
-        httpRequestApi.getClassDetail(option.id).success(res => {
+        this.getClassInfo(option.id)
+    },
+    getClassInfo: function (id) {
+        httpRequestApi.getClassDetail(id).success(res => {
             console.log('课程信息', res)
             let reg = /\\n/g
             this.setData({
@@ -54,13 +57,8 @@ Page({
                 grade: res.data.data.userRead.grade,
                 exampleId: res.data.data.userRead.exampleId,
                 summary: res.data.data.userRead.summary
-                // productId: res.data.data.product.id
-
             })
-            console.log(this.data.readingText)
-            console.log(this.data.img)
-            this.getReadInfo(option.id)
-
+            this.getReadInfo(id)
             httpRequestApi.userIntoPage('pages/reading/reading', '朗读页面').success((res) => {
 
             })
@@ -160,6 +158,20 @@ Page({
      *      2 录音结束
      ***/
     audioRecord: function () {
+        /* wx.getSetting({
+            success(res) {
+                if (res.authSetting['scope.record']) {
+                    that.videoComplete();
+                }else {
+                    wx.showToast({
+                        title: 'onError',
+                        icon: 'fail',
+                        duration: 500
+                    })
+                }
+            }
+        }) */
+
         console.log('recordFlag', this.data.recordFlag)
         if (this.data.recordFlag === 0) {
             // this.recordStart();
@@ -176,20 +188,15 @@ Page({
             //     this.innerAudioContext.stop();
             // }
             const that = this;
-            wx.getSetting({
-                success(res) {
-                    if (res.authSetting['scope.record']) {
-                        that.videoComplete();
-                    }
-                    // else {
-                    //     wx.showToast({
-                    //         title: 'onError',
-                    //         icon: 'fail',
-                    //         duration: 500
-                    //     })
-                    // }
-                }
-            })
+            that.videoComplete();
+
+            // wx.getSetting({
+            //     success(res) {
+            //         if (res.authSetting['scope.record']) {
+            //             that.videoComplete();
+            //         }
+            //     }
+            // })
             return;
         }
         // 录音结束后
@@ -339,7 +346,7 @@ Page({
         })
 
         if (this.data.audioPath) {
-            this.shareWorks(uid, this.data.audioPath)
+            this.shareWorks(this.data.audioPath)
         } else {
             const recordSource = this.data.recordSource;
             wx.uploadFile({
@@ -397,12 +404,12 @@ Page({
                             });
                             const pages = getCurrentPages();
                             const prevPage = pages[pages.length - 2];
-                            console.log('上一个页面',prevPage);
+                            console.log('上一个页面', prevPage);
                             console.log('上一个页面', res.data.data.id);
                             prevPage.setData({
                                 workId: res.data.data.id, // 有id就塞到第一位
                             }, () => {
-                            console.log('上一个页面',prevPage);
+                                console.log('上一个页面', prevPage);
                                 wx.navigateBack({
                                     delta: 1
                                 })
@@ -424,7 +431,7 @@ Page({
             pageSize: 3,
             type: 'READ'
         };
-        httpRequestApi.getClassRead(this.uid, data).success(res => {
+        httpRequestApi.getClassRead(data).success(res => {
             const readInfo = res.data.data.list;
             console.log(res)
             readInfo.forEach(item => {
@@ -433,7 +440,7 @@ Page({
                 temp.img = item.userRead.iconImg;
                 temp.plays = item.userRead.playAmount ? item.userRead.playAmount : 0;
                 temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
-                temp.classId = item.userRead.lessonId;
+                temp.classId = item.userRead.exampleId;
                 temp.time = formatDate(item.userRead.gmtCreated, 3);
                 temp.avatar = item.user ? item.user.avatar : '';
                 temp.uid = item.user ? item.user.uid : '';
@@ -441,6 +448,7 @@ Page({
                 // temp.avatar = item.user.avatar;
                 temp.nickName = item.user ? item.user.wechatName : '';
                 temp.id = item.userRead.id;
+                item.noReading = true;
                 // recommendWorks.push(temp);
                 // that.data.hotData.hotWorks.push(temp);
                 this.data.videoList.push(temp);
@@ -479,4 +487,12 @@ Page({
             commentId: e.detail.activeId,
         });
     },
+    goToReading: function(e){
+        this.setData({
+            pageNo: 1,
+            videoList:[]
+        })
+        const id = e.detail.activeId ? e.detail.activeId : e.currentTarget.dataset.id;
+        this.getClassInfo(id)   
+    }
 })

+ 0 - 91
pages/user/mycollection/mycollection.js

@@ -1,91 +0,0 @@
-import httpRequestApi from '../../../utils/APIClient';
-Page({
-
-  /**
-   * 页面的初始数据
-   */
-  data: {
-    collection_data: [],
-    line1: '您还没有收藏过哦',
-    line2: '快去收藏自己喜欢的吧'
-  },
-
-  toClass: function (e) {
-    let targetCode = e.currentTarget.dataset.targetcode;
-    let title = e.currentTarget.dataset.title;
-    wx.navigateTo({
-      url: `../../main/class/class?id=${targetCode}&title=${title}`
-    });
-  },
-
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad: function (option) {
-    console.log(option.title);
-    if (option.title) {
-      wx.setNavigationBarTitle({
-        title: option.title //页面标题为路由参数
-      });
-      this.setData({
-        title: option.title
-      });
-    }
-    httpRequestApi.myFavorites().success(res => {
-      this.setData({
-        collection_data: res.data.data.list
-      }, () => {
-        console.log(this.data.collection_data);
-      });
-    });
-  },
-
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady: function () {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow: function () {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide: function () {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload: function () {
-
-  },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh: function () {
-
-  },
-
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom: function () {
-
-  },
-
-  /**
-   * 用户点击右上角分享
-   */
-  onShareAppMessage: function () {
-
-  }
-})

+ 0 - 6
pages/user/mycollection/mycollection.json

@@ -1,6 +0,0 @@
-{
-    "usingComponents": {
-        "myPlacerholder": "/component/myPlacerholder/myPlacerholder"
-    },
-    "enablePullDownRefresh": false
-}

+ 0 - 14
pages/user/mycollection/mycollection.wxml

@@ -1,14 +0,0 @@
-<view class='my-collection'>
-  <view class='collection-article' wx:for="{{ collection_data }}" wx:key="{{ index }}" bindtap='toClass' data-targetCode="{{item.targetCode}}" data-title='{{ item.title }}'>
-    <view class='video-preview'>
-      <image src='{{ item.iconImg }}'></image>
-    </view>
-    <view class='content-title'>
-      {{ item.title }}
-    </view>
-    <view class='content-detail'>
-      <view class='left'>{{ item.summary }}</view>
-    </view> 
-  </view>
-   <myPlacerholder line1="{{line1}}" line2="{{line2}}" wx:if="{{collection_data.length <= 0}}" />  
-</view>

+ 3 - 3
pages/user/myconcern/myconcern.wxml

@@ -1,6 +1,6 @@
 <!-- <wxs src="../../commonWxs/format.wxs" module="format" /> -->
 <view class='my-concern'>
-  <!-- <view class="concern-center">
+  <view class="concern-center">
     <view class='concern-info' wx:for="{{ fanList }}" wx:key="{{ index }}" bindtap='toUserDetails' data-uid='{{ item.user.uid }}' data-fanId='{{ item.fans.fanId }}'>
       <view class='avatar-box'>
         <image class='avatar-image' src="{{ item.user.avatar }}" />
@@ -23,6 +23,6 @@
         <view class="follow-status">已关注</view>
       </view>
     </view>
-  </view> -->
-  <!-- <myPlacerholder class="placerholder" imageShow="{{imageShow}}" line1="{{line1}}" line2="{{line2}}" wx:if="{{fanList.length <= 1}}" />         -->
+  </view>
+  <myPlacerholder class="placerholder" imageShow="{{imageShow}}" line1="{{line1}}" line2="{{line2}}" wx:if="{{fanList.length <= 1}}" />        
 </view>

+ 2 - 2
templates/courses/courses.wxml

@@ -6,11 +6,11 @@
             <view class="course_info">
                 <text class="course_title">{{item.userRead.title}}</text>
                 <view class="course_btn">
-                    <view class="collect course_btn">
+                    <view class="collect course_btn" data-index="{{index}}" data-id="{{item.userRead.id}}" data-type="{{item.userRead.type}}"  catchtap="courseCollectTap">
                         <image class="collect_icon btn_icon" src="../../static/image/collect.png" />
                         <text class="collect_text btn_text">收藏{{item.isFavorites}}</text>
                     </view>
-                    <view class="share course_btn">
+                    <view class="share course_btn"  catchtap="coursesOpenShare" data-author="{{item.user.nickName}}" data-index="{{index}}" data-id="{{item.userRead.id}}" data-avatar="{{item.user.avatar}}" data-uid="{{item.user.uid}}" data-icon="{{item.userRead.iconImg}}" data-title="{{item.userRead.title}}" data-type="{{item.userRead.type}}">
                         <image class="share_icon btn_icon" src="../../static/image/share.png" />
                         <text class="share_text btn_text">分享</text>
                     </view>

+ 10 - 10
utils/httpUtil.js

@@ -102,16 +102,16 @@ function getLoginSchedule(sessionKey, openId, successcallback, failcallback) {
 
 // 获取原来的 openid 和 session_key
 function getOpenidSessionKey(successcallback, failcallback) {
-    if (wx.getStorageSync('user')) {
-        successcallback(
-            wx.getStorageSync('user'),
-            //分享小程序按钮
-            wx.showShareMenu({
-                withShareTicket: true
-            })
-        );
-        return;
-    }
+    // if (wx.getStorageSync('user')) {
+    //     successcallback(
+    //         wx.getStorageSync('user'),
+    //         //分享小程序按钮
+    //         wx.showShareMenu({
+    //             withShareTicket: true
+    //         })
+    //     );
+    //     return;
+    // }
     wxLogin(function (res) {
         if (res.data.code == 200) {
             let sessionKey = res.data.data.session_key;

+ 20 - 20
utils/httpUtilNoLogin.js

@@ -12,12 +12,12 @@ function genAPIUrl(action) {
 
 // 登录
 function wxLogin(successcallback, failcallback) {
-    wx.showToast({
-        title: '加载中...',
-        icon: 'loading',
-        duration: 1500,
-        mask: true
-    })
+    // wx.showToast({
+    //     title: '加载中...',
+    //     icon: 'loading',
+    //     duration: 1500,
+    //     mask: true
+    // })
     wx.login({
         success: function (res) {
             if (res.code) {
@@ -37,19 +37,19 @@ function wxLogin(successcallback, failcallback) {
 
 // 获取原来的 openid 和 session_key 
 /* 新增参数grade 需要给游客添加grade参数 */
-function getOpenidNoLogin(successcallback, failcallback,grade) {
-    if (wx.getStorageSync('user')) {
-        successcallback(
-            wx.getStorageSync('user'),
-            //分享小程序按钮
-            wx.showShareMenu({
-                withShareTicket: true
-            })
-        );
-        return;
-    }
+function getOpenidNoLogin(successcallback, failcallback, grade) {
+    // if (wx.getStorageSync('user')) {
+    //     successcallback(
+    //         wx.getStorageSync('user'),
+    //         //分享小程序按钮
+    //         wx.showShareMenu({
+    //             withShareTicket: true
+    //         })
+    //     );
+    //     return;
+    // }
     wxLogin(function (res) {
-        console.log('wx.login',res)
+        console.log('wx.login', res)
         if (res.data.code == 200) {
             let sessionKey = res.data.data.session_key;
             let openId = res.data.data.openid;
@@ -60,12 +60,12 @@ function getOpenidNoLogin(successcallback, failcallback,grade) {
                 'content-type': 'application/json'
             }).data({
                 openId,
-                grade: grade? grade : 'PRIMARY_FIRST_GRADE'
+                grade: grade ? grade : null
             }).send().success((res) => {
                 if (res.data.code === 200) {
                     wx.setStorageSync('uid', res.data.data.uid)
                     wx.setStorageSync('grade', res.data.data.grade)
-                    wx.setStorageSync('user',res.data.data)
+                    wx.setStorageSync('user', res.data.data)
                     successcallback(res)
                 }
             }).fail(() => {});