|
@@ -56,7 +56,7 @@ Page({
|
|
|
followPageNo: 1,
|
|
|
followPageTotalNo: 1,
|
|
|
myData: {},
|
|
|
- templates: 'hot',
|
|
|
+ templates: '',
|
|
|
title: 'index中的title',
|
|
|
jurisdictionFlag: true,
|
|
|
hotInput: '12345',
|
|
@@ -68,7 +68,12 @@ Page({
|
|
|
indexMissionDialog: false,
|
|
|
unfinishedCount: 0,
|
|
|
videoList: [],
|
|
|
- nextMargin: '400rpx' // 视频下边距
|
|
|
+ nextMargin: '400rpx', // 视频下边距
|
|
|
+ commentShow: false,
|
|
|
+ commentList: [],
|
|
|
+ commentNum: 0,
|
|
|
+ followPageNo: 1,
|
|
|
+ followPageSize: 6
|
|
|
},
|
|
|
jurisdiction: function () {
|
|
|
//隐藏弹框
|
|
@@ -88,37 +93,56 @@ Page({
|
|
|
// 根据index 更新template
|
|
|
updateData: function (index) {
|
|
|
let myIndex = index;
|
|
|
- let templates = this.data.tab[myIndex].templates;
|
|
|
this.setData({
|
|
|
myIndex,
|
|
|
- templates
|
|
|
});
|
|
|
+ // 获取推荐列表
|
|
|
if (myIndex == 0) {
|
|
|
- // groupInit(this);
|
|
|
this.setData({
|
|
|
- followPageNo: 1,
|
|
|
+ videoList: []
|
|
|
+ }, () => {
|
|
|
+ this.getHotRecommend(this.uid);
|
|
|
})
|
|
|
- getOpenidSessionKey((res) => {
|
|
|
- console.log(res)
|
|
|
- myInit(this);
|
|
|
- }, (error) => {
|
|
|
- console.log(error)
|
|
|
- wx.setStorageSync('userSourseType', 'normal')
|
|
|
- this.setData({
|
|
|
- hide: !this.data.hide
|
|
|
- })
|
|
|
- return;
|
|
|
- });
|
|
|
- }
|
|
|
- if (myIndex == 1) {
|
|
|
- // this.setData({
|
|
|
- // recommendPageNo: 0
|
|
|
- // })
|
|
|
- hotInit(this);
|
|
|
+ return;
|
|
|
}
|
|
|
+ // 刷新资源
|
|
|
if (myIndex == 2) {
|
|
|
groupInit(this);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* 关注和我的需要登陆后查看 */
|
|
|
+
|
|
|
+ getOpenidSessionKey((res) => {}, (error) => {
|
|
|
+ console.log('获取信息失败', error)
|
|
|
+ wx.setStorageSync('userSourseType', 'normal')
|
|
|
+ this.setData({
|
|
|
+ hide: !this.data.hide
|
|
|
+ })
|
|
|
+ return;
|
|
|
+ });
|
|
|
+ console.log('继续')
|
|
|
+ // 刷新关注列表
|
|
|
+ if (myIndex == 1) {
|
|
|
+ this.setData({
|
|
|
+ videoList: []
|
|
|
+ }, () => {
|
|
|
+ this.getFollowData()
|
|
|
+ })
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 刷新我的
|
|
|
+ if (myIndex == 3) {
|
|
|
+ this.setData({
|
|
|
+ videoList: [],
|
|
|
+ templates: 'my'
|
|
|
+ }, () => {
|
|
|
+ myInit(this);
|
|
|
+ })
|
|
|
+ return;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
onLoad: function (options) {
|
|
|
this.uid = wx.getStorageSync('uid');
|
|
@@ -176,9 +200,9 @@ Page({
|
|
|
})
|
|
|
// this.init();
|
|
|
getOpenidNoLogin((res) => {
|
|
|
- let winH = this.data.winH * 2;
|
|
|
+ let winH = this.data.winH * this.data.devicePixelRatio;
|
|
|
// let minusNumber = 860;
|
|
|
- let minusNumber = (winH * 860) / 1206;
|
|
|
+ let minusNumber = (winH * 880) / 1206;
|
|
|
|
|
|
// if(winH < 510){
|
|
|
// minusNumber = 400;
|
|
@@ -191,8 +215,7 @@ Page({
|
|
|
this.setData({
|
|
|
nextMargin: nextMargin + 'rpx'
|
|
|
})
|
|
|
- this.getHotRecommend(this.uid);
|
|
|
-
|
|
|
+ this.updateData(0)
|
|
|
// hotInit(this)
|
|
|
}, (error) => {
|
|
|
// console.log(error)
|
|
@@ -207,7 +230,16 @@ Page({
|
|
|
// 从修改信息页面退回
|
|
|
// this.getUserWorksInfo(true);
|
|
|
}
|
|
|
+ this.setData({
|
|
|
+ statusbarobj: {
|
|
|
+ isshowbtn: true, //是否显示按钮
|
|
|
+ title: "小学语文课文朗读", //标题
|
|
|
+ },
|
|
|
+ grade: wx.getStorageSync('grade') ? wx.getStorageSync('grade') : '2'
|
|
|
+
|
|
|
+ })
|
|
|
},
|
|
|
+
|
|
|
onHide: function () {
|
|
|
const str = 'hotData.inputFocus'
|
|
|
this.setData({
|
|
@@ -222,7 +254,6 @@ Page({
|
|
|
).success((res) => {
|
|
|
// 点击切换按钮时 只刷新我的课程和未读消息 官方推荐和热门不加载
|
|
|
const recommendRes = res.data.data;
|
|
|
-
|
|
|
console.log(res)
|
|
|
recommendRes.hotReader.forEach(item => {
|
|
|
const temp = {};
|
|
@@ -237,7 +268,7 @@ Page({
|
|
|
temp.url = item.userRead.originVideo;
|
|
|
// temp.avatar = item.user.avatar;
|
|
|
temp.nickName = item.user ? item.user.wechatName : '';
|
|
|
- temp.id = item.id;
|
|
|
+ temp.id = item.userRead.id;
|
|
|
// recommendWorks.push(temp);
|
|
|
// that.data.hotData.hotWorks.push(temp);
|
|
|
this.data.videoList.push(temp);
|
|
@@ -246,13 +277,6 @@ Page({
|
|
|
videoList: this.data.videoList
|
|
|
})
|
|
|
this.getHotRecommendSecond(this.uid, 1, 5)
|
|
|
- const hotStr = 'hotData.hotWorks'
|
|
|
- const myCourseStr = 'hotData.myCourse'
|
|
|
- const isMessageNormal = 'hotData.isMessageNormal'
|
|
|
- const unReadMessageContent = 'hotData.unReadMessageContent'
|
|
|
- // that.setData({
|
|
|
-
|
|
|
- // })
|
|
|
})
|
|
|
},
|
|
|
// 获取热门作品 算法出来的
|
|
@@ -275,6 +299,7 @@ Page({
|
|
|
temp.profession = item.user.profession;
|
|
|
temp.uid = item.user.uid;
|
|
|
temp.url = item.userRead.originVideo;
|
|
|
+ temp.id = item.userRead.id;
|
|
|
// temp.avatar = item.user.avatar;
|
|
|
temp.nickName = item.user.wechatName;
|
|
|
// recommendWorks.push(temp);
|
|
@@ -308,6 +333,7 @@ Page({
|
|
|
[str]: userLocal
|
|
|
})
|
|
|
httpRequestApi.getUserWorksInfo().success(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) {
|
|
@@ -315,6 +341,9 @@ Page({
|
|
|
}
|
|
|
this.setData({
|
|
|
myData: this.data.myData,
|
|
|
+ userInfo: res.data.data.user
|
|
|
+ },()=>{
|
|
|
+ this.getMyRead()
|
|
|
});
|
|
|
}).fail(error => {
|
|
|
console.log(error)
|
|
@@ -322,35 +351,35 @@ 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);
|
|
|
+ // 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 === 1) {
|
|
|
- console.log(this.data.recommendPageNo)
|
|
|
- console.log(this.data.recommendTotalNo)
|
|
|
- this.setData({
|
|
|
- recommendPageNo: this.data.recommendPageNo + 1
|
|
|
- })
|
|
|
- if (this.data.recommendPageNo <= this.data.recommendTotalNo) {
|
|
|
- this.getHotRecommendSecond(this.uid, this.data.recommendPageNo, 3);
|
|
|
+ // } else {
|
|
|
+ // console.log('没有更多')
|
|
|
+ // this.setData({
|
|
|
+ // ifHaveMore: false
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // // 当前在推荐页面 加载推荐
|
|
|
+ // if (this.data.myIndex === 1) {
|
|
|
+ // console.log(this.data.recommendPageNo)
|
|
|
+ // console.log(this.data.recommendTotalNo)
|
|
|
+ // this.setData({
|
|
|
+ // recommendPageNo: this.data.recommendPageNo + 1
|
|
|
+ // })
|
|
|
+ // if (this.data.recommendPageNo <= this.data.recommendTotalNo) {
|
|
|
+ // this.getHotRecommendSecond(this.uid, this.data.recommendPageNo, 3);
|
|
|
|
|
|
- } else {
|
|
|
- console.log('没有更多')
|
|
|
- }
|
|
|
- }
|
|
|
+ // } else {
|
|
|
+ // console.log('没有更多')
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
},
|
|
|
onPullDownRefresh: function () {
|
|
@@ -427,5 +456,183 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
+ },
|
|
|
+ // 获取我的朗读
|
|
|
+ getMyRead: function(){
|
|
|
+ httpRequestApi.myRead().success(res=>{
|
|
|
+ console.log(res)
|
|
|
+ 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)
|
|
|
+
|
|
|
+ const temp = {};
|
|
|
+ temp.title = item.title;
|
|
|
+ temp.summary = item.summary;
|
|
|
+ temp.img = item.iconImg;
|
|
|
+ temp.plays = item.playAmount;
|
|
|
+ temp.likes = item.likeAmount;
|
|
|
+ temp.classId = item.lessonId;
|
|
|
+ temp.time = formatDate(item.gmtCreated, 3);
|
|
|
+ temp.avatar = this.data.userInfo.avatar;
|
|
|
+ temp.uid = this.uid;
|
|
|
+ temp.url = item.originVideo;
|
|
|
+ temp.id = item.id;
|
|
|
+ // temp.avatar = item.user.avatar;
|
|
|
+ temp.nickName = this.data.userInfo.wechatName;
|
|
|
+ // recommendWorks.push(temp);
|
|
|
+ this.data.videoList.push(temp);
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ videoList: 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);
|
|
|
+ },
|
|
|
+ // 获取评论信息
|
|
|
+ getReply: function (columnId) {
|
|
|
+ // let columnId = this.data.id;
|
|
|
+ console.log(123123123, columnId)
|
|
|
+ // let pageNo = this.data.pageNo;
|
|
|
+ // let pageSize = this.data.pageSize;
|
|
|
+ httpRequestApi.getReply(this.uid, columnId, 1, 10).success((res) => {
|
|
|
+ console.log('reply', res)
|
|
|
+ const commentList = res.data.data.list;
|
|
|
+ const commentNum = res.data.data.totalSize;
|
|
|
+
|
|
|
+ commentList.forEach((item) => {
|
|
|
+ const temp = {};
|
|
|
+ temp.nickName = item.user.wechatName;
|
|
|
+ temp.avatar = item.user.avatar;
|
|
|
+ temp.uid = item.user.uid;
|
|
|
+ temp.text = item.detailDesc;
|
|
|
+ temp.id = item.id;
|
|
|
+ temp.replyCount = item.replyCount;
|
|
|
+ temp.time = formatDate(item.gmtCreated, 3);
|
|
|
+ temp.likes = item.postsAttributeInfo.favors || 0;
|
|
|
+ temp.isLike = item.isLike;
|
|
|
+ temp.replyList = item.replyVOList;
|
|
|
+ this.data.commentList.push(temp);
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ commentList: this.data.commentList,
|
|
|
+ commentNum: commentNum
|
|
|
+ })
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 发布回复
|
|
|
+ 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);
|
|
|
+ })
|
|
|
+ });
|
|
|
+ },
|
|
|
+ gradeTap: function () {
|
|
|
+ // console.log("组件回调,返回上一页");
|
|
|
+ this.setData({
|
|
|
+ isGradeShow: true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 修改年级
|
|
|
+ changeGrade: function (e) {
|
|
|
+ const grade = e.target.dataset.code;
|
|
|
+ wx.setStorageSync('grade', grade)
|
|
|
+ this.setData({
|
|
|
+ isGradeShow: false,
|
|
|
+ grade: grade
|
|
|
+ })
|
|
|
+
|
|
|
+ let gradeText = '一年级';
|
|
|
+ switch (e.target.dataset.code) {
|
|
|
+ case '0':
|
|
|
+ gradeText = '学前班';
|
|
|
+ break;
|
|
|
+ case '1':
|
|
|
+ gradeText = '一年级';
|
|
|
+ break;
|
|
|
+ case '2':
|
|
|
+ gradeText = '二年级';
|
|
|
+ break;
|
|
|
+ case '3':
|
|
|
+ gradeText = '三年级';
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ getFollowData: function () {
|
|
|
+ httpRequestApi.getFollowWorks(this.data.followPageNo, this.data.followPageSize).success(res => {
|
|
|
+ if (res.data.data.totalSize === 0) {
|
|
|
+ this.setData({
|
|
|
+ videoList: []
|
|
|
+ })
|
|
|
+ console.log('没有关注人或关注的人没有发过作品')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ console.log('关注列表', res)
|
|
|
+ const followData = res.data.data.list;
|
|
|
+ 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.id;
|
|
|
+ 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.nickName = item.user ? item.user.wechatName : '';
|
|
|
+ temp.id = item.userRead.id;
|
|
|
+ this.data.videoList.push(temp);
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ videoList: this.data.videoList
|
|
|
+ })
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 点击用户头像区域
|
|
|
+ headTapHandler: function (e) {
|
|
|
+ console.log('点击头像', e)
|
|
|
+ let tapId = e.detail.activeId;
|
|
|
+ // 点击头像既关注 测试
|
|
|
+ httpRequestApi.followUser(this.uid, tapId).success(res => {
|
|
|
+ console.log(res)
|
|
|
+ })
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
})
|