Browse Source

'自动播放'

Rorschach 4 years ago
parent
commit
2d4a6c94d8

+ 8 - 11
component/video-swiper/index.js

@@ -26,7 +26,7 @@ Component({
         },
         easingFunction: {
             type: String,
-            value: 'default'
+            value: 'easeInOutCubic' // easeInCubic 缓入 easeOutCubic 缓出  easeInOutCubic 缓入缓出 default linear
         },
         loop: {
             type: Boolean,
@@ -36,7 +36,6 @@ Component({
             type: Array,
             value: [],
             observer: function observer() {
-                console.log('this.isSwiper', this.data.isSwiper)
                 if (!this.data.isSwiper) return;
                 var newVal = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
 
@@ -82,8 +81,8 @@ Component({
                 this.setData({
                     curQueue: data.nextQueue.splice(0, 3)
                 }, function () {
-                    // _this.playCurrent(1);
-                    _this.playCurrent(0);
+                    _this.playCurrent(1);
+                    // _this.playCurrent(0);
                 });
             }
         },
@@ -100,15 +99,13 @@ Component({
             if (diff === 0) return;
             this.data._last = current;
             this.playCurrent(current);
-           
-            var direction = diff === 1 || diff === -2 ? 'up' : 'down';
             this.triggerEvent('change', {
                 activeId: curQueue[current].id,
-                index: current,
-                _last,
-                nextQueue,
-                direction
+                // index: current,
+                // _last,
+                // nextQueue,
             });
+            var direction = diff === 1 || diff === -2 ? 'up' : 'down';
             if (direction === 'up') {
                 if (this.data._invalidDown === 0) {
                     var change = (_change + 1) % 3;
@@ -289,7 +286,7 @@ Component({
             const id = e.target.dataset.id ? e.target.dataset.id : e.currentTarget.dataset.id;
             const index = e.target.dataset.index ? e.target.dataset.index : e.currentTarget.dataset.index;
             console.log('视频index', index);
-            if (this.isSwiper) {
+            if (this.data.isSwiper) {
                 let likeStr = `curQueue[${index}].isLike`;
                 let likeNumStr = `curQueue[${index}].likes`;
                 httpRequestApi.likeWorks(id).success((res) => {

+ 16 - 1
component/video-swiper/index.less

@@ -30,6 +30,14 @@
             box-sizing: border-box;
             padding-right: 20rpx;
 
+            .tag_icon{
+                width: 66rpx;
+                height: 34rpx;
+                position: absolute;
+                right: 0;
+                top: 0;
+            }
+
             .user_box {
                 width: 400rpx;
                 height: 100%;
@@ -46,11 +54,18 @@
 
                 .user_right {
                     margin-left: 16rpx;
-
+                    display: flex;
+                    align-items: center;
                     .nickname {
                         font-size: 30rpx;
                         color: rgba(0, 0, 0, 0.60);
                     }
+
+                    .efun_tag{
+                        width: 68rpx;
+                        height: 30rpx;
+                        margin-left: 4rpx;
+                    }
                 }
 
             }

+ 7 - 3
component/video-swiper/index.wxml

@@ -3,20 +3,22 @@
     wx:if="{{isSwiper}}"
     class="video-swiper" 
     circular="{{circular}}"
-    next-margin="{{nextMargin}}" 
     easing-function="{{easingFunction}}" 
     vertical 
     current="0"
     duration="{{duration}}" 
+    next-margin="{{nextMargin}}" 
     bindanimationfinish="animationfinish">
     <!-- curQueue 循环会导致video重新插入,objectFit 不可变更 -->
         
     <swiper-item class="swiper_item" wx:for="{{curQueue}}"  data-id="{{item.id}}"  wx:key="*this">
       <view class="head_box">
+        <image class="tag_icon" wx:if="{{item.hasTag}}" src="{{item.tagUrl}}" />
         <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>
+            <image class="efun_tag" src="../../static/index/efun_tag.png" wx:if="{{item.isEfun}}"></image>
           </view>
             
         </view>
@@ -78,7 +80,7 @@
         </view>
         <view class="foot_right">
           <view class="btn flower_btn" catchtap="{{item.isLike ?  null : 'likeTap'}}" data-index="{{index}}" data-id="{{item.id}}" data-islike="{{item.isLike}}">
-              <image class="flower_btn_icon" src="{{item.isLike ? '../../static/index/heart.png' : '../../static/index/heart.png'}}" />
+              <image class="flower_btn_icon" src="{{item.isLike ? '../../static/index/heart_colored.png' : '../../static/index/heart.png'}}" />
               <text>{{item.likes}}</text>
           </view>
           <view class="btn comment_btn" catchtap="openComment" data-id="{{item.id}}">
@@ -100,10 +102,12 @@
   <!-- // 非swiper -->
   <view wx:if="{{!isSwiper}}" class="swiper_item no_swiper" wx:for="{{videoList}}"  data-id="{{item.id}}"  wx:key="*this">
       <view class="head_box">
+        <image class="tag_icon" wx:if="{{item.hasTag}}" src="{{item.tagUrl}}" />
         <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>
+            <image class="efun_tag" src="../../static/index/efun_tag.png" wx:if="{{item.isEfun}}"></image>
           </view>
             
         </view>
@@ -164,7 +168,7 @@
         </view>
           <view class="foot_right">
           <view class="btn flower_btn" catchtap="{{item.isLike ?  null : 'likeTap'}}" data-index="{{index}}" data-id="{{item.id}}" data-islike="{{item.isLike}}">
-              <image class="flower_btn_icon" src="{{item.isLike ? '../../static/index/heart.png' : '../../static/index/heart.png'}}" />
+              <image class="flower_btn_icon" src="{{item.isLike ? '../../static/index/heart_colored.png' : '../../static/index/heart.png'}}" />
               <text>{{item.likes}}</text>
           </view>
           <view class="btn comment_btn" catchtap="openComment" data-id="{{item.id}}">

+ 14 - 0
component/video-swiper/index.wxss

@@ -24,6 +24,13 @@
   box-sizing: border-box;
   padding-right: 20rpx;
 }
+.swiper_container .swiper_item .head_box .tag_icon {
+  width: 66rpx;
+  height: 34rpx;
+  position: absolute;
+  right: 0;
+  top: 0;
+}
 .swiper_container .swiper_item .head_box .user_box {
   width: 400rpx;
   height: 100%;
@@ -38,11 +45,18 @@
 }
 .swiper_container .swiper_item .head_box .user_box .user_right {
   margin-left: 16rpx;
+  display: flex;
+  align-items: center;
 }
 .swiper_container .swiper_item .head_box .user_box .user_right .nickname {
   font-size: 30rpx;
   color: rgba(0, 0, 0, 0.6);
 }
+.swiper_container .swiper_item .head_box .user_box .user_right .efun_tag {
+  width: 68rpx;
+  height: 30rpx;
+  margin-left: 4rpx;
+}
 .swiper_container .swiper_item .head_box .time {
   display: flex;
   align-items: center;

+ 65 - 60
pages/index/index.js

@@ -52,7 +52,7 @@ Page({
     myIndex: 0,
     followData: [],
     recommendPageNo: 1,
-    recommendPageSize: 12,
+    recommendPageSize: 3,
     recommendTotalNo: 1,
     myData: {},
     templates: '',
@@ -72,7 +72,7 @@ Page({
     commentList: [],
     commentNum: 0,
     followPageNo: 1,
-    followPageSize: 6,
+    followPageSize: 3,
     coursePageNo: 1,
     coursesData: [],
     updateId: 0 // 刷新id
@@ -102,6 +102,7 @@ Page({
     // 获取推荐列表
     if (myIndex == 0) {
       this.setData({
+        recommendPageNo:1,
         videoList: [],
         isSwiper: true
       }, () => {
@@ -159,6 +160,33 @@ Page({
   },
   showPage: function () {
     let options = this.data.options;
+    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
+      })
+      httpRequestApi.getClassDetail(id).success(res => {
+        console.log('有一条数据', res)
+        let tempList = [];
+        tempList.push(res.data.data);
+        this.setData({
+          videoList: [],
+          isSwiper: true,
+          recommendTotalNo: 1
+        }, () => {
+          this.formatWorksList(tempList, true);
+          this.getHotRecommend();
+          // return;
+        })
+        // this.showPage()
+      })
+    }
     if (options && options.index) {
       this.updateData(options.index)
     } else {
@@ -202,6 +230,17 @@ Page({
   },
   onLoad: function (options) {
     console.log('onload', options);
+    if (options.scene) {
+      this.setData({
+        workId: options.scene
+      })
+    }
+    if (options.readId) {
+      this.setData({
+        workId: options.readId
+      })
+    }
+
     getOpenidNoLogin((res) => {
       console.log('getOpenidNoLogin', res)
       if (!res.data.data.grade) {
@@ -237,16 +276,7 @@ Page({
     });
 
 
-    if (options.scene) {
-      this.setData({
-        workId: options.scene
-      })
-    }
-    if (options.readId) {
-      this.setData({
-        workId: options.readId
-      })
-    }
+
     this.uid = wx.getStorageSync('uid');
     let grade = wx.getStorageSync('grade');
 
@@ -262,8 +292,16 @@ Page({
       success: (res) => {
         console.log('系统', res)
 
-        let winH = res.windowHeight * res.pixelRatio;
-        let minusNumber = (winH * 920) / 1206;
+        console.log('nextMargin', res.pixelRatio)
+        console.log('windowHeight', res.windowHeight)
+        console.log('windowWidth', res.windowWidth)
+        // let ratio = res.pixelRatio;
+        let ratio = (res.screenHeight / res.screenWidth) * 1.1;
+        console.log('比例系数', ratio)
+        let winH = res.windowHeight * ratio;
+        let x1 = 465 * ratio;
+        let x2 = 603 * ratio;
+        let minusNumber = (winH * x1) / x2;
         let nextMargin = parseInt(winH - minusNumber);
         app.globalData.nextMargin = nextMargin;
 
@@ -279,34 +317,6 @@ Page({
 
   },
   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
-      })
-      httpRequestApi.getClassDetail(id).success(res => {
-        console.log('有一条数据', res)
-        let tempList = [];
-        tempList.push(res.data.data);
-        this.setData({
-          videoList: [],
-          isSwiper: true,
-          recommendTotalNo: 1
-        }, () => {
-          this.formatWorksList(tempList, true);
-          this.getHotRecommend()
-
-        })
-
-        // this.showPage()
-      })
-    }
     if (this.data.myIndex === 3) {
       this.getUserWorksInfo(1)
     }
@@ -316,7 +326,6 @@ Page({
     console.log('页面返回页面返回', this.data.fromLoginIndex)
     if (this.data.fromLoginIndex) {
       console.log('页面返回页面返回', this.data.fromLoginIndex)
-
       let index = this.data.fromLoginIndex;
       let userInfo = wx.getStorageSync('user');
       this.setData({
@@ -324,7 +333,6 @@ Page({
         isLogin: userInfo.wechatName ? true : false
       }, () => {
         this.updateData(0)
-
       })
     }
     // const userInfo = wx.getStorageSync('user')
@@ -365,9 +373,9 @@ Page({
   // 组装list
   formatWorksList(list, notSet) {
     const tempList = [];
-    list.forEach((item,index) => {
-      if(index === 1){
-        console.log('设置当前id',item.id)
+    list.forEach((item, index) => {
+      if (index === list.length - 2 && list.length > 2) {
+        console.log('设置当前id', item.id)
         this.setData({
           updateId: item.userRead.id
         })
@@ -390,14 +398,18 @@ Page({
       temp.nickName = item.user.wechatName;
       temp.isLike = item.isLike;
       temp.isFavorite = item.isFavorites;
-      // this.data.videoList.push(temp);
+      temp.isEfun = item.user.profession === '官方' ? true : false;
+      temp.hasTag = item.userRead.tag && item.userRead.tag !== 'EXAMPLE' ? true : false;
+      temp.tagUrl = item.userRead.tag ? item.userRead.tag === 'HOT' ? '../../static/index/hot_tag.png' :  '../../static/index/new_tag.png' : ''
+      this.data.videoList.push(temp);
       tempList.push(temp);
     });
-    if (!notSet) {
-      this.setData({
-        videoList: tempList
-      })
-    }
+    console.log('当前list', this.data.videoList)
+    // if (!notSet) {
+    this.setData({
+      videoList: tempList
+    })
+    // }
 
   },
   // 获取用户信息
@@ -451,13 +463,6 @@ Page({
     return userInfo;
   },
   videoChange: function (e) {
-    console.log('到了底部到了底部', e)
-    console.log('到了底部到了底部', e.detail.index)
-    console.log('到了底部到了底部', e.detail._last)
-    console.log('到了底部到了底部', e.detail.direction)
-    // if (e.detail.nextQueue.length === 1) {
-    console.log('当前ID',e.detail.activeId);
-    console.log('目标ID',this.data.updateId);
     if (e.detail.activeId === this.data.updateId) {
       console.log('应该刷新')
       if (this.data.myIndex === 1) {

BIN
static/index/efun_tag.png


BIN
static/index/hot_tag.png


BIN
static/index/new_tag.png