Browse Source

'简版开发'

Rorschach 4 years ago
parent
commit
faf139e7b3

+ 1 - 1
component/my/my.wxss

@@ -1,6 +1,6 @@
 .mine-container {
   width: 100%;
-  height: 1136rpx;
+  /* height: 1136rpx; */
   position: relative;
   background: #faf7fa;
   display: flex;

+ 6 - 0
component/statusBar/statusBar.js

@@ -69,6 +69,12 @@ Component({
     gradeTap: function () {
       console.log("点击年级");
       this.triggerEvent('gradeTap', 'false');
+    },
+    prePageTap: function(){
+      console.log('点击返回')
+      wx.navigateBack({
+        delta: 1
+      })
     }
   }
 })

+ 4 - 1
component/statusBar/statusBar.wxml

@@ -1,6 +1,9 @@
 <!-- 没有按钮的情况 -->
 <view class="custom flex_center" style="padding-top:{{statusBarHeight}}px" wx:if="{{!isshowbtn}}">
-    <view class='custom titlev'>{{title}}</view>
+    <view class='custom iconv' bindtap="prePageTap">
+        <image class="back" src="../../static/image/reset.png"  />
+    </view>
+    <view class='custom title'>{{title}}</view>
 </view>
 <!-- 显示按钮的情况 -->
 <view class="custom flex_center" style="padding-top:{{statusBarHeight}}px" wx:else>

+ 5 - 0
component/statusBar/statusBar.wxss

@@ -22,6 +22,11 @@
     padding: 0 10rpx;
 }
 
+.custom .iconv .back{
+    width: 17rpx;
+    height: 30rpx;
+}
+
 .custom .iconv .text {
     color: #fff;
     font-size: 30rpx;

+ 5 - 1
component/video-swiper/index.js

@@ -38,7 +38,7 @@ Component({
         nextQueue: [],
         prevQueue: [],
         curQueue: [],
-        circular: false,
+        circular: true,
         // nextMargin: '400rpx',
         _last: 1,
         _change: -1,
@@ -169,6 +169,10 @@ Component({
         headTap: function headTap(e){
             this.trigger(e,'headTap')
         },
+        // 去朗读
+        goToReading: function goToReading(e){
+            this.trigger(e,'goToReading')
+        },
         trigger: function trigger(e, type) {
             var ext = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
 

+ 1 - 1
component/video-swiper/index.wxml

@@ -81,7 +81,7 @@
         </view>
             
       </view>
-      <view class="btn_wrapper">
+      <view class="btn_wrapper" catchtap="goToReading" data-id="{{item.classId}}">
         <view class="reading_btn">
           <image src="../../static/index/star.png" />
           <text>我要配音</text>

+ 31 - 12
pages/index/index.js

@@ -107,7 +107,13 @@ Page({
     }
     // 刷新资源
     if (myIndex == 2) {
-      groupInit(this);
+      this.setData({
+        videoList: [],
+        templates: 'coursestao'
+      }, () => {
+        this.getCoursesList();
+
+      })
       return;
     }
 
@@ -215,6 +221,7 @@ Page({
       this.setData({
         nextMargin: nextMargin + 'rpx'
       })
+      app.globalData.nextMargin = nextMargin;
       this.updateData(0)
       // hotInit(this)
     }, (error) => {
@@ -261,7 +268,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.id;
+        temp.classId = item.userRead.lessonId;
         temp.time = formatDate(item.userRead.gmtCreated, 3);
         temp.avatar = item.user ? item.user.avatar : '';
         temp.uid = item.user ? item.user.uid : '';
@@ -293,7 +300,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.id;
+        temp.classId = item.userRead.lessonId;
         temp.time = formatDate(item.userRead.gmtCreated, 3);
         temp.avatar = item.user.avatar;
         temp.profession = item.user.profession;
@@ -333,7 +340,7 @@ Page({
       [str]: userLocal
     })
     httpRequestApi.getUserWorksInfo().success(res => {
-      console.log('getUserWorksInfo',res)
+      console.log('getUserWorksInfo', res)
       this.data.myData.user = res.data.data;
       httpRequestApi.userIntoPage('pages/index/index', '首页我的').success((res) => {})
       if (this.data.myData.user.myRead) {
@@ -342,7 +349,7 @@ Page({
       this.setData({
         myData: this.data.myData,
         userInfo: res.data.data.user
-      },()=>{
+      }, () => {
         this.getMyRead()
       });
     }).fail(error => {
@@ -458,16 +465,16 @@ Page({
     })
   },
   // 获取我的朗读
-  getMyRead: function(){
-    httpRequestApi.myRead().success(res=>{
+  getMyRead: function () {
+    httpRequestApi.myRead().success(res => {
       console.log(res)
-      console.log('mydata',this.data.myData)
+      console.log('mydata', this.data.myData)
       const myList = res.data.data.list;
       if (myList.length === 0) return;
       // const recommendWorks = [];
       myList.forEach(item => {
-      console.log('mydata',this.data.myData)
-      console.log('mydata',this.data.userInfo.user)
+        console.log('mydata', this.data.myData)
+        console.log('mydata', this.data.userInfo.user)
 
         const temp = {};
         temp.title = item.title;
@@ -632,7 +639,19 @@ Page({
     httpRequestApi.followUser(this.uid, tapId).success(res => {
       console.log(res)
     })
-  }
-
+  },
+  getCoursesList: function () {
+    httpRequestApi.getSearchResult('PRESCHOOL', 1, 10).success(res => {
+      console.log('资源', res)
+      this.setData({
+        coursesData: res.data.data.list
+      })
+    })
+  },
+  goToReading: function (e) {
+    wx.navigateTo({
+      url: `../../pages/main/reading/reading?id=${e.detail.activeId}`
+    });
+  },
 
 })

+ 3 - 1
pages/index/index.wxml

@@ -28,8 +28,9 @@
   <!-- <import src="/component/hot/hot.wxml" /> -->
   <!-- <import src="/component/follow/follow.wxml" /> -->
   <import src="/component/my/my.wxml" />
+  <import src="/templates/courses/courses.wxml" />
   <!-- 调用组件 -->
-  <template is="{{templates}}" data="{{groupData: groupData, hotData: hotData, followData: followData, myData: myData}}"></template>
+  <template is="{{templates}}" wx:if="{{myIndex === 3}}" data="{{myData: myData,coursesData:coursesData}}"></template>
   <!-- 顶部导航 -->
   <view class="top-tab">
     <block wx:for="{{tab}}" wx:key="{{index}}">
@@ -46,6 +47,7 @@
 
   bindopenComment="openComment"
   bindheadTap="headTapHandler"
+  bindgoToReading="goToReading"
   >
     <!-- bindplay="onPlay"
   bindpause="onPause"

+ 1 - 0
pages/index/index.wxss

@@ -7,6 +7,7 @@
 /* @import "/component/follow/follow.wxss"; */
 /*我的*/
 @import "/component/my/my.wxss";
+@import "/templates/courses/courses.wxss";
 
 .container {
   background: rgba(242, 242, 242, 1);

+ 55 - 12
pages/main/reading/reading.js

@@ -1,4 +1,7 @@
 import httpRequestApi from '../../../utils/APIClient';
+import {
+    formatDate
+  } from '../../../utils/util';
 Page({
     data: {
         title: '',
@@ -18,7 +21,10 @@ Page({
         microphonePng: '../../../static/image/microphone.png',
         recordingGif: '../../../static/image/readingNow.gif',
         videoUrl: '',
-        readingText: ''
+        readingText: '',
+        videoList: [],
+        pageNo: 1,
+        nextMargin: getApp().globalData.nextMargin
     },
     onLoad: function (option) {
         console.log(option);
@@ -26,9 +32,6 @@ Page({
         const uid = wx.getStorageSync('uid')
         httpRequestApi.getClassDetail(uid, option.id).success(res => {
             console.log(res)
-            wx.setNavigationBarTitle({
-                title: res.data.data.title //页面标题为路由参数
-            })
             let reg = /\\n/g
             this.setData({
                 title: res.data.data.lesson.title,
@@ -42,11 +45,11 @@ Page({
             })
             console.log(this.data.readingText)
             console.log(this.data.img)
-            httpRequestApi.userIntoPage('pages/main/reading/reading','朗读页面').success((res)=>{
-        
+            httpRequestApi.userIntoPage('pages/main/reading/reading', '朗读页面').success((res) => {
+
             })
         })
-        
+        this.getReadInfo()
         this.recorderManager = wx.getRecorderManager();
 
 
@@ -99,7 +102,7 @@ Page({
                         dialogFlag = false;
                         setTimeout(() => {
                             dialogFlag = true;
-                        },1000)
+                        }, 1000)
                     }
                     // else {
                     //     wx.showToast({
@@ -152,9 +155,14 @@ Page({
             this.innerAudioContext.stop();
         }
     },
-    // onShow:function(){
-
-    // },
+    onShow: function () {
+        this.setData({
+            statusbarobj: {
+                isshowbtn: false, //是否显示按钮
+                title: "小学语文课文朗读", //标题
+            },
+        })
+    },
     // 视频缓冲
     // videoWaiting: function () {
     //     this.recorderManager.pause();
@@ -345,5 +353,40 @@ Page({
 
             })
         };
-    }
+    },
+
+    // 获取本课朗读内容
+    getReadInfo: function (pageNo, pageSize) {
+        // const uid =  wx.getStorageSync('uid');
+        const data = {
+            lessonId: this.data.id,
+            pageNo: this.data.pageNo,
+            pageSize: 10
+        };
+        httpRequestApi.getClassRead(this.uid, data).success(res => {
+            const readInfo = res.data.data.list;
+            console.log(res)
+            readInfo.forEach(item => {
+                const temp = {};
+                temp.title = item.userRead ? item.userRead.title : '';
+                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.time = formatDate(item.userRead.gmtCreated, 3);
+                temp.avatar = item.user ? item.user.avatar : '';
+                temp.uid = item.user ? item.user.uid : '';
+                temp.url = item.userRead.originVideo;
+                // temp.avatar = item.user.avatar;
+                temp.nickName = item.user ? item.user.wechatName : '';
+                temp.id = item.userRead.id;
+                // recommendWorks.push(temp);
+                // that.data.hotData.hotWorks.push(temp);
+                this.data.videoList.push(temp);
+            });
+            this.setData({
+                videoList: this.data.videoList
+            })
+        });
+    },
 })

+ 5 - 0
pages/main/reading/reading.json

@@ -1,3 +1,8 @@
 {
+    "usingComponents": {
+        "VideoSwiper": "../../../component/video-swiper/index",
+        "Comment": "../../../component/comment/comment",
+        "StatusBar": "../../../component/statusBar/statusBar"
+    },
     "enablePullDownRefresh": false
 }

+ 38 - 21
pages/main/reading/reading.wxml

@@ -1,27 +1,22 @@
+<StatusBar receiveData="{{statusbarobj}}" grade="{{grade}}" bindgradeTap="gradeTap" />
 <view class="readingPage">
     <!-- <view class="videoSection" wx:if="{{!isIOS}}">
         <image wx:if="{{!videoLoad}}" class="videoIcon" src="{{iconImg}}" />
     </view> -->
-  <video
-  id="myVideo"
-  class="videoSection"
-  src="{{videoUrl}}"
-  show-fullscreen-btn="{{fullScreenBtn}}"
-  show-play-btn="{{playBtn}}"
-  show-center-play-btn="{{centerBtn}}"
-  muted="{{muted}}"
-  enable-progress-gesture="{{gesture}}"
-  bindended="recordingVideoEnd"
-  ></video>
-  <!-- bindwaiting="videoWaiting"
+    <video id="myVideo" class="videoSection" src="{{videoUrl}}" show-fullscreen-btn="{{fullScreenBtn}}" show-play-btn="{{playBtn}}" show-center-play-btn="{{centerBtn}}" muted="{{muted}}" enable-progress-gesture="{{gesture}}" bindended="recordingVideoEnd"></video>
+    <!-- bindwaiting="videoWaiting"
   bindplay="videoPlay" -->
-  <!-- <audio name="123" author="123" src="{{recordSource}}" id="myAudio" controls loop></audio> -->
-<scroll-view class="textSection" scroll-y="true">
-   <text class="textContent">
-       {{readingText}}
-   </text>
-</scroll-view>
-    <view class="footSection">
+    <!-- <audio name="123" author="123" src="{{recordSource}}" id="myAudio" controls loop></audio> -->
+    <scroll-view class="textSection" scroll-y="true">
+        <view class="btn_wrapper" bindtap="audioRecord">
+            <view class="reading_btn">
+                <image src="../../../static/index/star.png" />
+                <text>我要配音</text>
+            </view>
+        </view>
+        <text class="textContent">{{readingText}}</text>
+    </scroll-view>
+   <!--  <view class="footSection">
         <image class="blackbord" src="../../../static/image/blackbord.png" />
         <view class="collectBtn footerBtn" wx:if="{{btnFlag}}" bindtap="audioPlay">
             <image src="../../../static/image/listen.png" />
@@ -35,5 +30,27 @@
             <image src="../../../static/image/upload.png" />
             <text>上传</text>
         </view>
-    </view>
-</view>
+    </view> -->
+
+      <VideoSwiper 
+  wx:if="{{videoList.length > 0}}"
+  class="video-swiper" 
+  video-list="{{videoList}}" 
+  nextMargin="{{nextMargin}}"
+
+  bindopenComment="openComment"
+  bindheadTap="headTapHandler"
+  bindgoToReading="goToReading"
+  bindplay="onPlay"
+  >
+    <!-- bindplay="onPlay"
+  bindpause="onPause"
+  bindtimeupdate="onTimeUpdate"
+  bindended="onEnded"
+  binderror="onError"
+  bindwaiting="onWaiting"
+  bindprogress="onProgress"
+  bindloadedmetadata="onLoadedMetaData" -->
+  </VideoSwiper>
+</view>
+

+ 44 - 11
pages/main/reading/reading.wxss

@@ -1,4 +1,4 @@
-.readingPage{
+.readingPage {
     height: 100%;
     overflow: hidden;
 }
@@ -15,25 +15,58 @@ audio {
     position: fixed;
     bottom: 200rpx;
 }
-.textSection{
+
+.textSection {
     width: 100%;
-    height: 50%;
-    padding-bottom: 200rpx;
+    height: 500rpx;
+    /* padding-bottom: 200rpx; */
     overflow: visible;
 }
-.textSection .textContent{
+
+.textSection .btn_wrapper {
+    width: 100%;
+    height: 110rpx;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+
+.btn_wrapper .reading_btn {
+    width: 271rpx;
+    height: 80rpx;
+    background: #14c962;
+    border-radius: 100rpx;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+
+.btn_wrapper .reading_btn image {
+    width: 39rpx;
+    height: 50rpx;
+    margin-right: 20rpx;
+}
+
+.btn_wrapper .reading_btn text {
+    color: #fff;
+    font-size: 30rpx;
+}
+
+.textSection .textContent {
     font-size: 32rpx;
     line-height: 56rpx;
-    text-align: center; 
+    text-align: center;
     display: block;
     margin: 0 50rpx;
     color: #444;
 }
-::-webkit-scrollbar{
+
+::-webkit-scrollbar {
     width: 0;
     height: 0;
     color: transparent;
 }
+
 /**底部按钮区域**/
 .footSection {
     width: 750rpx;
@@ -96,10 +129,10 @@ audio {
 }
 
 .footSection .microphone {
-   display:block;
-margin:-12rpx auto 8rpx;
-width:108rpx;
-height:106rpx;
+    display: block;
+    margin: -12rpx auto 8rpx;
+    width: 108rpx;
+    height: 106rpx;
 
 }
 

+ 0 - 0
templates/courses/courses.js


+ 4 - 0
templates/courses/courses.less

@@ -0,0 +1,4 @@
+.courses_container{
+    width: 100%;
+    height: 100%;
+}

+ 21 - 0
templates/courses/courses.wxml

@@ -0,0 +1,21 @@
+<!-- <wxs src="../../pages/commonWxs/format.wxs" module="format" /> -->
+<template name="courses">
+    <view class="courses_container">
+        <view class="course_item" wx:for="{{coursesData}}" wx:key="{{index}}">
+            <image class="course_icon" src="{{item.iconImg}}" lazy-load="true" />
+            <view class="course_info">
+                <text class="course_title">{{item.title}}</text>
+                <view class="course_btn">
+                    <view class="collect">
+                        <image class="collect_icon" src="../../static/image/collect.png" />
+                        <text class="collect_text">收藏</text>
+                    </view>
+                    <view class="share">
+                        <image class="share_icon" src="../../static/image/share.png" />
+                        <text class="share_text">分享</text>
+                    </view>
+                </view>
+            </view>
+        </view>
+    </view>
+</template>

+ 4 - 0
templates/courses/courses.wxss

@@ -0,0 +1,4 @@
+.courses_container {
+  width: 100%;
+  height: 100%;
+}

+ 4 - 4
utils/APIClient.js

@@ -143,13 +143,13 @@ module.exports = {
     }).send();
   },
   // 搜索
-  getSearchResult(uid, key, pageNo, pageSize) {
+  getSearchResult(grade,pageNo, pageSize) {
     let url = getProductUrl(`wx/lesson`);
     return request.getInstance().header({
-      uid
+      uid:wx.getStorageSync('uid')
     }).url(url).data({
-      title: key,
-      productId: '',
+      title:'',
+      gradeClassify: grade,
       pageNo: pageNo,
       pageSize: pageSize
     }).send();