Kaynağa Gözat

Merge remote-tracking branch 'origin' into limengbo

Limengbo 6 yıl önce
ebeveyn
işleme
3590db4e24

+ 1 - 0
app.json

@@ -4,6 +4,7 @@
     "pages/social/works/works",
     "pages/main/class/class",
     "pages/main/books/books",
+    "pages/main/singleBook/singleBook",
     "pages/main/reading/reading",
     "pages/user/myEdit/myEdit",
     "pages/discount-group/discount-group"

+ 0 - 4
app.wxss

@@ -6,10 +6,6 @@ page {
 
 .container {
   height: 100%;
-  display: flex;
-  flex-direction: column;
-  align-items: center;
-  justify-content: space-between;
   padding-top: 80rpx;
   box-sizing: border-box;
 } 

+ 15 - 15
component/group/group.js

@@ -1,16 +1,16 @@
-export const groupInit =  (that) => {
-    that.setData({
-      groupData: {
-        title: '关注'
-      }
-    })
-    //请求数据封装
-    that.more = function () {
-      wx.navigateTo({
-        url: '/pages/discount-group/discount-group'
-      })
-      wx.setNavigationBarTitle({
-        title: '限量优惠团购'
-      })
+export const groupInit = (that) => {
+  that.setData({
+    groupData: {
+      title: '关注'
     }
-  }
+  })
+  //请求数据封装
+  that.more = function () {
+    wx.navigateTo({
+      url: '/pages/discount-group/discount-group'
+    })
+    wx.setNavigationBarTitle({
+      title: '限量优惠团购'
+    })
+  }
+}

+ 9 - 3
component/hot/hot.js

@@ -4,9 +4,9 @@ export const hotInit = (that) => {
       hotData: {
         title: '热门',
         imgUrls: [
-          'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
-          'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
-          'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
+          '../../static/image/timg.jpg',
+          '../../static/image/timg.jpg',
+          '../../static/image/timg.jpg'
         ],
         indicatorDots: true,
         autoplay: true,
@@ -96,6 +96,12 @@ export const hotInit = (that) => {
         console.log(res);
       })
     }
+    // 去全部课本
+    that.goToBooks = () =>{
+      wx.navigateTo({
+        url: `../main/books/books`
+      })
+    }
     that.getIndex(1);
     that.getHotRecommend(1,1,3) 
 }

+ 2 - 1
pages/index/index.js

@@ -1,8 +1,9 @@
 //index.js
 //获取应用实例
 const app = getApp()
-import { groupInit } from '../../component/group/group';
+
 import { hotInit } from '../../component/hot/hot';
+import { groupInit } from '../../component/group/group';
 import { myInit } from '../../component/my/my';
 import { followInit } from '../../component/follow/follow';
 // import '../../utils/hls';

+ 29 - 1
pages/main/books/books.js

@@ -1,7 +1,35 @@
+import httpRequestApi from '../../../utils/APIClient';
 Page({
-    onLoad:function(options){
+    data: {
+        allBooks: []
+    },
+    onLoad: function (options) {
         wx.setNavigationBarTitle({
             title: '全部课本'
+        })
+        httpRequestApi.getAllBooks(1, 1, 10).success((res) => {
+            const books = res.data.data.list;
+            const booksTemp = [];
+            books.forEach(item => {
+                let temp = {};
+                temp.id = item.id;
+                temp.iconImg = item.iconImg;
+                temp.title = item.title.substring(0,5);
+                booksTemp.push(temp);
+            });
+            this.setData({
+                allBooks: booksTemp
+            })
+            console.log(this.data.allBooks)
+        });
+    },
+    goToBook: function(e){
+        console.log(e.currentTarget.dataset)
+        let id = e.currentTarget.dataset.id;
+        let title = e.currentTarget.dataset.title;
+
+        wx.navigateTo({
+            url: `../singleBook/singleBook?id=${id}&title=${title}`
           })
     }
 })

+ 5 - 2
pages/main/books/books.wxml

@@ -1,3 +1,6 @@
-<view >
-    全部书籍
+<view class = 'allBooks' >
+    <view class="book" wx:for="{{allBooks}}" wx:key="{{index}}" data-id="{{item.id}}" data-title="{{item.title}}" bindtap="goToBook">
+        <image src="{{item.iconImg}}" />
+        <text >{{item.title}}</text>
+    </view>
 </view>

+ 27 - 0
pages/main/books/books.wxss

@@ -0,0 +1,27 @@
+.allBooks {
+    margin-top: 44rpx;
+    display: flex;
+    flex-direction: row;
+}
+.book{
+    width: 214rpx;
+    display: flex;
+    text-align: center;
+    flex-direction: column;
+    margin-left: 28rpx;
+}
+.book image{
+    display: block;
+    width: 214rpx;
+    height: 190rpx;
+}
+.book text{
+    margin-top: 20rpx;
+    width: 214rpx;
+    height: 38rpx;
+    font-size: 28rpx;
+    color:#373737;
+    text-overflow: ellipsis;
+    overflow: hidden;
+    white-space: nowrap;
+}

+ 46 - 25
pages/main/class/class.js

@@ -1,90 +1,111 @@
+import httpRequestApi from '../../../utils/APIClient';
 Page({
   data: {
     fullScreenBtn: false,
     playBtn: false,
     gesture: true,
-    works:[
-      {
+    videoUrl: '',
+    title: '',
+    works: [{
         nickName: '萝莉小猫咪',
         time: '10-18 09:56',
         avatar: '../../../static/image/timg.jpg',
-        likes: '1123'
+        likes: '1123',
+        uid: '1'
       },
       {
         nickName: '萝莉小猫咪',
         time: '10-18 09:56',
         avatar: '../../../static/image/timg.jpg',
-        likes: '12332'
+        likes: '1123',
+        uid: '1'
       },
       {
         nickName: '萝莉小猫咪',
         time: '10-18 09:56',
         avatar: '../../../static/image/timg.jpg',
-        likes: '12332'
+        likes: '1123',
+        uid: '1'
       },
       {
         nickName: '萝莉小猫咪',
         time: '10-18 09:56',
         avatar: '../../../static/image/timg.jpg',
-        likes: '12332'
+        likes: '1123',
+        uid: '1'
       },
       {
         nickName: '萝莉小猫咪',
         time: '10-18 09:56',
         avatar: '../../../static/image/timg.jpg',
-        likes: '12332'
+        likes: '1123',
+        uid: '1'
       },
       {
         nickName: '萝莉小猫咪',
         time: '10-18 09:56',
         avatar: '../../../static/image/timg.jpg',
-        likes: '12332'
+        likes: '1123',
+        uid: '1'
       },
       {
         nickName: '萝莉小猫咪',
         time: '10-18 09:56',
         avatar: '../../../static/image/timg.jpg',
-        likes: '12332'
+        likes: '1123',
+        uid: '1'
       },
       {
         nickName: '萝莉小猫咪',
         time: '10-18 09:56',
         avatar: '../../../static/image/timg.jpg',
-        likes: '12332'
+        likes: '1123',
+        uid: '1'
       },
       {
         nickName: '萝莉小猫咪',
         time: '10-18 09:56',
         avatar: '../../../static/image/timg.jpg',
-        likes: '12332'
+        likes: '1123',
+        uid: '1'
       },
 
+
+
     ]
   },
   onLoad: function (option) {
-    if(option.title){
-      wx.setNavigationBarTitle({
-        title: option.title//页面标题为路由参数
-      })
-      this.setData({
-        title: option.title,
-        id: option.id
-      })
-    }
+    wx.setNavigationBarTitle({
+      title: option.title //页面标题为路由参数
+    })
+    this.setData({
+      title: option.title,
+      id: option.id
+    })
+    let uid = 1;
+
+    httpRequestApi.getClassDetail(uid, option.id).success(res => {
+        console.log(res);
+        this.setData({
+          title: res.data.data.title,
+          videoUrl:res.data.data.playUrl
+        })
+    })
   },
 
-  goToReading: function(){
+  goToReading: function () {
     let id = this.data.id;
     let title = this.data.title;
     wx.navigateTo({
       url: `../../main/reading/reading?id=${id}&title=${'战狼撤侨归来'}`
     })
   },
-  goToWorks: function(){
-    // let id = this.data.id;
-    // let title = this.data.title;
+  goToWorks: function (e) {
+    console.log(e);
+    let readId = e.target.dataset.readId;
+    let title = this.data.title;
     wx.navigateTo({
-      url: `../../social/works/works`
+      url: `../../social/works/works?id=${readId}&tilte=${title}`
     })
   }
 })

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

@@ -1,11 +1,11 @@
 <view class="classPage">
-    <video class="videoSection" src="https://efunvideo.ai160.com/vs2m/001/00103075/00103075012/00103075012.m3u8" controls show-fullscreen-btn="{{fullScreenBtn}}" show-play-btn="{{playBtn}}"></video>
+    <video class="videoSection" src="{{videoUrl}}" controls show-fullscreen-btn="{{fullScreenBtn}}" show-play-btn="{{playBtn}}"></video>
     <view class="readWorksSection">
         <view class="peopleNum">
             <image class="peoplesIcon" src="../../../static/image/peoples.png" />
             <view class="title">共有12345人完成了录音</view>
         </view>
-        <view class="workCard" wx:for="{{works}}" wx:key="{{index}}" bindtap="goToWorks">
+        <view class="workCard" wx:for="{{works}}" wx:key="{{index}}" bindtap="goToWorks" data-uid="{{item.readId}}">
             <image class="avatar" src="{{item.avatar}}" />
             <view class="name">
                 <text class="nickName">{{item.nickName}}</text>

+ 3 - 21
pages/main/reading/reading.js

@@ -93,6 +93,7 @@ Page({
             frameSize: 50 制定帧大小
      */
     recordStart: function () {
+        console.log('录音开始');
         const options = {
             duration: 600000,
             sampleRate: 44100,
@@ -120,34 +121,15 @@ Page({
         this.innerAudioContext.play();
     },
     
-    // saveVideo:function(){
-    //     let _this = this;
-    //     wx.downloadFile({
-    //         url: 'https://efunimgs.ai160.com/ott/test/002tPr2Xlx07oP7B4ro40104120022hP0k010.mp4',
-    //         success(res){
-    //            _this.videoComplete(res);
-    //         },
-    //         fail(res){
-    //             _this.videoFail(res);
-    //          }
-    //     })
-    // },
-   
     videoComplete: function(){
-        let videoUrl = 'http://efunvideo.ai160.com/vs2m/001/00103075/00103075012/00103075012.m3u8';
+        let videoUrl = 'http://efunimgs.ai160.com/ott/test/002tPr2Xlx07oP7B4ro40104120022hP0k010.mp4';
         this.setData({
             videoUrl: videoUrl,
             recordFlag: 1
         },()=>{
             this.videoCtx = wx.createVideoContext('myVideo', this);
             this.videoCtx.play();
+            this.recordStart();
         })   
-    },
-    videoPlay: function(res){
-        this.recordStart();
-        console.log('触发回调')
-    },
-    videoFail: function(res){
-        console.log('保存失败',res)
     }
 })

+ 0 - 1
pages/main/reading/reading.wxml

@@ -10,7 +10,6 @@
   enable-progress-gesture="{{gesture}}"
   bindwaiting="{{videoWaiting}}"
   bindended="{{videoCtr}}"
-  bindplay="{{videoPlay}}"
   ></video>
 
   <!-- <audio name="123" author="123" src="{{recordSource}}" id="myAudio" controls loop></audio> -->

+ 43 - 0
pages/main/singleBook/singleBook.js

@@ -0,0 +1,43 @@
+import httpRequestApi from '../../../utils/APIClient';
+Page({
+    data: {
+        titleIcon: '',
+        title: '',
+        bookInfo: '',
+        lessonList: []
+    },
+    onLoad: function (options) {
+        wx.setNavigationBarTitle({
+            title: options.title
+        })
+        httpRequestApi.getBookDetail(1, 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,
+                title: bookInfo.title,
+                bookInfo: bookInfo.description
+            })
+            const lessonTemp = [];
+            lessonList.forEach(item => {
+                const temp = {};
+                temp.id = item.id;
+                temp.title = item.title;
+                // 少个阅读数
+                lessonTemp.push(temp);
+            });
+            this.setData({
+                lessonList: lessonTemp
+            });
+            console.log(this.data.lessonList)
+        });
+    },
+    goToClass: function(e){
+        let id = e.currentTarget.dataset.id;
+        let title = e.currentTarget.dataset.title;
+        wx.navigateTo({
+            url: `../class/class?id=${id}&title=${title}`
+          })
+    }
+})

+ 1 - 0
pages/main/singleBook/singleBook.json

@@ -0,0 +1 @@
+{}

+ 22 - 0
pages/main/singleBook/singleBook.wxml

@@ -0,0 +1,22 @@
+<view class="bookDetail">
+    <view class="headSection">
+        <image class="titleIcon" src="{{titleIcon}}" />
+        <text class="bookName">{{title}}</text>
+        <text class="bookInfo">{{bookInfo}}</text>
+    </view>
+    <view class="dirTag">
+        <!-- <image src="" /> -->
+    </view>
+    <view class="listSection">
+        <view class="classItem" wx:for="{{lessonList}}" wx:key="{{index}}" data-id="{{item.id}}" data-title="{{item.title}}" bindtap="goToClass">
+            <text class="classTitle">{{item.title}}</text>
+            <text class="readingNum">{{item.readingNum}}1232朗读 ></text>
+        </view>
+    </view>
+    <view class="footerSection">
+        <view class="footerBuy">
+            <text class="buyPrice"></text>
+            <text class="buyProduct"></text>
+        </view>
+    </view>
+</view>

+ 62 - 0
pages/main/singleBook/singleBook.wxss

@@ -0,0 +1,62 @@
+.bookDetail{
+    font-size: 32rpx;
+    color: #414141;
+    background: #f0f1f5;
+}
+.headSection{
+    padding-top: 18rpx;
+    width: 100%;
+    background: #fff;
+}
+.headSection .titleIcon{
+    display: block;
+    width: 704rpx;
+    height: 190rpx;
+    margin: 0 auto;
+    background: #fff;
+}
+.headSection .bookName{
+    width: 700rpx;
+    height: 42rpx;
+    line-height: 42rpx;
+    margin: 10rpx 0 12rpx 20rpx;
+}
+.headSection .bookInfo{
+    width: 700rpx;
+    height: auto;
+}
+.dirTag{
+    width: 100%;
+    height: 100rpx;
+    margin-top: 12rpx;
+    background: #fff;
+}
+.listSection{
+    width: 100%;
+    margin-top: 12rpx;
+}
+.listSection .classItem{
+    width: 716rpx;
+    height: 88rpx;
+    margin: 0 auto 8rpx;
+    display: flex;
+    flex-direction: row;
+    justify-content: space-between;
+    background: #fff;
+    border-radius: 14rpx;
+}
+.classItem .classTitle{
+    width: auto;
+    height: 88rpx;
+    font-size: 32rpx;
+    margin-left: 40rpx;
+    line-height: 88rpx;
+}
+.classItem .readingNum{
+    width: auto;
+    height: 88rpx;
+    line-height: 88rpx;
+    margin-right: 40rpx;
+    color: #939393;
+    font-size: 28rpx;
+}

+ 14 - 1
pages/social/works/works.js

@@ -66,7 +66,7 @@ Page({
             })
         }
         let uid = 1;
-        httpRequestApi.getWorksDetail(uid,option.id).success((res)=>{
+        httpRequestApi.getWorksDetail(uid,option.uid).success((res)=>{
             console.log(res);
         });
     },
@@ -86,5 +86,18 @@ Page({
           title: '测试',
           path: '/pages/social/works/works'
         }
+      },
+      follow: function(){
+          let uid = 1;
+          let followUid = 2;
+        httpRequestApi.followUser(uid,followUid).success((res)=>{
+            console.log(res)
+        });
+      },
+      // 去其他用户的作品页
+      goToOthers: function (e){
+        wx.navigateTo({
+            url: `../../main/reading/reading?id=${id}&title=${title}`
+        })
       }
 })

+ 2 - 2
pages/social/works/works.wxml

@@ -8,7 +8,7 @@
             <text class="likeBtn">点赞</text>
         </view>
         <view class="follow">
-            <text class="followBtn">关注</text>
+            <text class="followBtn" bindtap="follow">关注</text>
         </view>
     </view>
     <view class="userSection">
@@ -19,7 +19,7 @@
         <scroll-view scroll-x class="scrollWrapper" scroll-with-animation="true">
             <view class="avatarRow">
                 <view class="userItem" wx:for="{{user}}" wx:key="{{index}}">
-                    <image src="{{item.image}}" />
+                    <image src="{{item.image}}" bindtap="goToOthers" data-uid = "{{item.uid}}" />
                 </view>
             </view>
         </scroll-view>

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

@@ -178,7 +178,7 @@
 }
 
 .commentItem .time {
-    width: 180rpx;
+    width: 200rpx;
     height: 44rpx;
     font-size: 32rpx;
     color: #686868;

+ 33 - 0
utils/APIClient.js

@@ -36,5 +36,38 @@ module.exports = {
 		return request.getInstance().header({
 			uid
 		}).url(url).send();
+	},
+	// 关注用户 
+	followUser(uid, followUid) {
+		let url = getBaseUrl(`wx/fans`);
+		return request.getInstance().header({
+			uid
+		}).url(url).data({
+			"uid": followUid
+		}).method('POST').send();
+	},
+	// 获取全部课本
+	getAllBooks(uid,pageNo,pageSize) {
+		let url = getProductUrl('wx/product');
+		return request.getInstance().header({
+			uid
+		}).url(url).data({
+			pageNo,
+			pageSize
+		}).send();
+	},
+	// 获取课本详情
+	getBookDetail(uid,id) {
+		let url = getProductUrl(`wx/product/${id}`);
+		return request.getInstance().header({
+			uid
+		}).url(url).send();
+	},
+	// 获取单课详情
+	getClassDetail(uid,id) {
+		let url = getProductUrl(`wx/lesson/${id}`);
+		return request.getInstance().header({
+			uid
+		}).url(url).send();
 	}
 }