|
@@ -51,7 +51,8 @@ Page({
|
|
|
winH: 568,
|
|
|
myIndex: 0,
|
|
|
followData: [],
|
|
|
- recommendPageNo: 0,
|
|
|
+ recommendPageNo: 1,
|
|
|
+ recommendPageSize: 6,
|
|
|
recommendTotalNo: 1,
|
|
|
myData: {},
|
|
|
templates: '',
|
|
@@ -72,7 +73,9 @@ Page({
|
|
|
commentNum: 0,
|
|
|
followPageNo: 1,
|
|
|
followPageSize: 6,
|
|
|
- coursesData: []
|
|
|
+ coursePageNo: 1,
|
|
|
+ coursesData: [],
|
|
|
+
|
|
|
},
|
|
|
jurisdiction: function () {
|
|
|
//隐藏弹框
|
|
@@ -131,7 +134,9 @@ Page({
|
|
|
if (myIndex == 2) {
|
|
|
this.setData({
|
|
|
videoList: [],
|
|
|
- templates: 'courses'
|
|
|
+ coursesData: [],
|
|
|
+ templates: 'courses',
|
|
|
+ coursePageNo: 1
|
|
|
}, () => {
|
|
|
this.getCoursesList();
|
|
|
})
|
|
@@ -235,8 +240,28 @@ Page({
|
|
|
|
|
|
},
|
|
|
onShow: function (e) {
|
|
|
+ console.log('this.data.workId', this.data.workId)
|
|
|
+ if (this.data.workId) {
|
|
|
+ // 需要在推荐第一个上插入一条分享或者刚朗读完数据
|
|
|
+ this.setData({
|
|
|
+ myIndex: 0,
|
|
|
+ videoList: [],
|
|
|
+ isSwiper: true,
|
|
|
+ recommendTotalNo:1
|
|
|
+ })
|
|
|
+ httpRequestApi.getClassDetail(this.data.workId).success(res => {
|
|
|
+ console.log('有一条数据', res)
|
|
|
+ let tempList = [];
|
|
|
+ tempList.push(res.data.data);
|
|
|
+ this.formatWorksList(tempList, true);
|
|
|
+ this.getHotRecommend()
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
console.log('页面显示', e)
|
|
|
- this.getUserWorksInfo(1)
|
|
|
+ if (this.data.myIndex === 3) {
|
|
|
+ this.getUserWorksInfo(1)
|
|
|
+ }
|
|
|
wx.setNavigationBarTitle({
|
|
|
title: '小学语文朗读配音'
|
|
|
})
|
|
@@ -260,75 +285,49 @@ Page({
|
|
|
},
|
|
|
/* 两个接口维护同一个数组,手动的结束后添加算法的 */
|
|
|
// 推荐页信息 获取消息和手动推荐内容
|
|
|
- getHotRecommend: function (uid) {
|
|
|
- httpRequestApi.getHotRecommend(
|
|
|
- uid
|
|
|
- ).success((res) => {
|
|
|
- // 点击切换按钮时 只刷新我的课程和未读消息 官方推荐和热门不加载
|
|
|
- /* const recommendRes = res.data.data;
|
|
|
- console.log(res)
|
|
|
- recommendRes.hotReader.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.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 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.type = item.userRead.type;
|
|
|
- // temp.avatar = item.user.avatar;
|
|
|
- temp.nickName = item.user ? item.user.wechatName : '';
|
|
|
- temp.id = item.userRead.id;
|
|
|
- temp.isLike = item.isLike;
|
|
|
- temp.isFavorite = item.isFavorites;
|
|
|
- this.data.videoList.push(temp);
|
|
|
- });
|
|
|
- this.setData({
|
|
|
- videoList: this.data.videoList
|
|
|
- }) */
|
|
|
- this.getHotRecommendSecond(1, 5)
|
|
|
- })
|
|
|
- },
|
|
|
// 获取热门作品 算法出来的
|
|
|
- getHotRecommendSecond: function (pageNo, pageSize) {
|
|
|
+ getHotRecommend: function () {
|
|
|
let grade = wx.getStorageSync('grade')
|
|
|
+ let pageNo = this.data.recommendPageNo;
|
|
|
+ let pageSize = this.data.recommendPageSize;
|
|
|
httpRequestApi.getHotRecommendSecond(grade, pageNo, pageSize).success(res => {
|
|
|
console.log(res)
|
|
|
const recommendRes = res.data.data.list;
|
|
|
if (recommendRes.length === 0) return;
|
|
|
// const recommendWorks = [];
|
|
|
- recommendRes.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.avatar = item.user.avatar;
|
|
|
- temp.nickName = item.user.wechatName;
|
|
|
- temp.isLike = item.isLike;
|
|
|
- temp.isFavorite = item.isFavorites;
|
|
|
- // recommendWorks.push(temp);
|
|
|
- this.data.videoList.push(temp);
|
|
|
+ this.formatWorksList(recommendRes);
|
|
|
|
|
|
- });
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 组装list
|
|
|
+ formatWorksList(list, notSet) {
|
|
|
+ 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 = item.isFavorites;
|
|
|
+ this.data.videoList.push(temp);
|
|
|
+ });
|
|
|
+ if (!notSet) {
|
|
|
this.setData({
|
|
|
videoList: this.data.videoList
|
|
|
})
|
|
|
- })
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
// 获取用户信息
|
|
|
getUserWorksInfo: function (flag) {
|
|
@@ -398,20 +397,20 @@ Page({
|
|
|
// 触底加载
|
|
|
onReachBottom: function () {
|
|
|
console.log('到了底部到了底部', this.data.myIndex)
|
|
|
- // if (this.data.myIndex === 0) {
|
|
|
- // this.setData({
|
|
|
- // followPageNo: this.data.followPageNo + 1
|
|
|
- // })
|
|
|
- // if (this.data.followPageNo <= this.data.followPageTotalNo) {
|
|
|
- // this.getFollowWorks(this.data.followPageNo, 3);
|
|
|
-
|
|
|
- // } else {
|
|
|
- // console.log('没有更多')
|
|
|
- // this.setData({
|
|
|
- // ifHaveMore: false
|
|
|
- // })
|
|
|
- // }
|
|
|
- // }
|
|
|
+ if (this.data.myIndex === 2) {
|
|
|
+ this.setData({
|
|
|
+ coursePageNo: this.data.coursePageNo + 1
|
|
|
+ }, () => {
|
|
|
+ this.getCoursesList()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (this.data.myIndex === 0) {
|
|
|
+ this.setData({
|
|
|
+ recommendPageNo: this.data.recommendPageNo + 1
|
|
|
+ }, () => {
|
|
|
+ this.getHotRecommend()
|
|
|
+ })
|
|
|
+ }
|
|
|
// // 当前在推荐页面 加载推荐
|
|
|
// if (this.data.myIndex === 1) {
|
|
|
// console.log(this.data.recommendPageNo)
|
|
@@ -503,6 +502,9 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ delHideMyWork:function(){
|
|
|
+ this.getMyRead()
|
|
|
+ },
|
|
|
// 获取我的朗读
|
|
|
getMyRead: function () {
|
|
|
httpRequestApi.myRead().success(res => {
|
|
@@ -511,29 +513,29 @@ Page({
|
|
|
const myList = res.data.data;
|
|
|
if (myList.length === 0) return;
|
|
|
// const recommendWorks = [];
|
|
|
+ const myWorks = [];
|
|
|
myList.forEach(item => {
|
|
|
- console.log('mydata', this.data.myData)
|
|
|
- console.log('mydata', this.data.myData.userInfo.user)
|
|
|
-
|
|
|
const temp = {};
|
|
|
temp.title = item.title;
|
|
|
temp.summary = item.summary;
|
|
|
temp.img = item.iconImg;
|
|
|
temp.plays = item.playAmount;
|
|
|
temp.likes = item.likeAmount;
|
|
|
+ temp.commentAmount = item.commentAmount;
|
|
|
temp.classId = item.exampleId ? item.exampleId : 1605097720036046;
|
|
|
temp.time = formatDate(item.gmtCreated, 3);
|
|
|
temp.avatar = this.data.myData.userInfo.avatar;
|
|
|
temp.uid = this.uid;
|
|
|
temp.url = item.videoPath;
|
|
|
temp.id = item.id;
|
|
|
- // temp.avatar = item.user.avatar;
|
|
|
+ temp.showMyBtn = true;
|
|
|
temp.nickName = this.data.myData.userInfo.wechatName;
|
|
|
- // recommendWorks.push(temp);
|
|
|
- this.data.videoList.push(temp);
|
|
|
+ temp.status = item.status
|
|
|
+ myWorks.push(temp);
|
|
|
});
|
|
|
+ console.log('myWorks',myWorks)
|
|
|
this.setData({
|
|
|
- videoList: this.data.videoList
|
|
|
+ videoList: myWorks
|
|
|
})
|
|
|
})
|
|
|
},
|
|
@@ -644,25 +646,8 @@ Page({
|
|
|
}
|
|
|
console.log('关注列表', res)
|
|
|
const followData = res.data.data.list;
|
|
|
- const videoList = [];
|
|
|
- followData.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.exampleId ? item.userRead.exampleId : 1605097720036046;
|
|
|
- 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.videoPath ? item.userRead.videoPath : item.userRead.originVideo;
|
|
|
- temp.nickName = item.user ? item.user.wechatName : '';
|
|
|
- temp.id = item.userRead.id;
|
|
|
- videoList.push(temp);
|
|
|
- });
|
|
|
- this.setData({
|
|
|
- videoList: videoList
|
|
|
- })
|
|
|
+ // const videoList = [];
|
|
|
+ this.formatWorksList(followData);
|
|
|
});
|
|
|
},
|
|
|
// 点击用户头像区域
|
|
@@ -677,13 +662,16 @@ Page({
|
|
|
getCoursesList: function () {
|
|
|
const grade = wx.getStorageSync('grade');
|
|
|
const data = {
|
|
|
+ pageNo: this.data.coursePageNo,
|
|
|
+ pageSize: 6,
|
|
|
grade,
|
|
|
type: 'EXAMPLE'
|
|
|
- }
|
|
|
+ };
|
|
|
+ console.log('资源', data)
|
|
|
httpRequestApi.getClassRead(data).success(res => {
|
|
|
- console.log('资源', res)
|
|
|
+ console.log('资源', this.data.coursesData)
|
|
|
this.setData({
|
|
|
- coursesData: res.data.data.list
|
|
|
+ coursesData: this.data.coursesData.concat(res.data.data.list)
|
|
|
}, () => {
|
|
|
console.log(this.data.coursesData)
|
|
|
})
|
|
@@ -693,7 +681,7 @@ Page({
|
|
|
console.log('去朗读', e)
|
|
|
const id = e.detail.activeId ? e.detail.activeId : e.currentTarget.dataset.id;
|
|
|
wx.navigateTo({
|
|
|
- url: `../../pages/main/reading/reading?id=${id}`
|
|
|
+ url: `../../pages/reading/reading?id=${id}`
|
|
|
});
|
|
|
},
|
|
|
|