|
@@ -32,6 +32,9 @@ import {
|
|
Page({
|
|
Page({
|
|
data: {
|
|
data: {
|
|
tab: [{
|
|
tab: [{
|
|
|
|
+ name: '我的',
|
|
|
|
+ templates: 'my',
|
|
|
|
+ }, {
|
|
name: '推荐',
|
|
name: '推荐',
|
|
templates: 'recommend',
|
|
templates: 'recommend',
|
|
},
|
|
},
|
|
@@ -42,10 +45,6 @@ Page({
|
|
{
|
|
{
|
|
name: '资源',
|
|
name: '资源',
|
|
templates: 'courses',
|
|
templates: 'courses',
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: '我的',
|
|
|
|
- templates: 'my',
|
|
|
|
}
|
|
}
|
|
],
|
|
],
|
|
winH: 568,
|
|
winH: 568,
|
|
@@ -73,7 +72,7 @@ Page({
|
|
commentList: [],
|
|
commentList: [],
|
|
commentNum: 0,
|
|
commentNum: 0,
|
|
followPageNo: 1,
|
|
followPageNo: 1,
|
|
- followPageSize: 6,
|
|
|
|
|
|
+ followPageSize: 3,
|
|
coursePageNo: 1,
|
|
coursePageNo: 1,
|
|
coursesData: [],
|
|
coursesData: [],
|
|
updateId: 0, // 刷新id
|
|
updateId: 0, // 刷新id
|
|
@@ -82,7 +81,9 @@ Page({
|
|
title: "小学语文朗读配音", //标题
|
|
title: "小学语文朗读配音", //标题
|
|
},
|
|
},
|
|
grade: wx.getStorageSync('grade'),
|
|
grade: wx.getStorageSync('grade'),
|
|
- upgradeHide: false
|
|
|
|
|
|
+ noMoreWork: false, // 没有更多作品 已经到底了
|
|
|
|
+ upgradeHide: false,
|
|
|
|
+ gradeActivity: ''
|
|
},
|
|
},
|
|
jurisdiction: function () {
|
|
jurisdiction: function () {
|
|
//隐藏弹框
|
|
//隐藏弹框
|
|
@@ -107,9 +108,10 @@ Page({
|
|
},
|
|
},
|
|
// 根据index 更新template
|
|
// 根据index 更新template
|
|
updateData: function (index) {
|
|
updateData: function (index) {
|
|
- let myIndex = index;
|
|
|
|
|
|
+ let myIndex = parseInt(index);
|
|
this.setData({
|
|
this.setData({
|
|
myIndex,
|
|
myIndex,
|
|
|
|
+ noMoreWork: false
|
|
});
|
|
});
|
|
// 获取推荐列表
|
|
// 获取推荐列表
|
|
if (myIndex == 0) {
|
|
if (myIndex == 0) {
|
|
@@ -118,7 +120,10 @@ Page({
|
|
videoList: [],
|
|
videoList: [],
|
|
isSwiper: false
|
|
isSwiper: false
|
|
}, () => {
|
|
}, () => {
|
|
- this.getHotRecommend(this.uid);
|
|
|
|
|
|
+ // 转为异步
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ this.getHotRecommend(this.uid);
|
|
|
|
+ }, 0)
|
|
})
|
|
})
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -254,6 +259,15 @@ Page({
|
|
workId: options.readId
|
|
workId: options.readId
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
|
|
+ * 活动统计
|
|
|
|
+ */
|
|
|
|
+ if (options.activity) {
|
|
|
|
+ console.log('统计')
|
|
|
|
+ httpRequestApi.shareAddHotAmount(options.readId).success(res => {
|
|
|
|
+ console.log(res)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
|
|
getOpenidNoLogin((res) => {
|
|
getOpenidNoLogin((res) => {
|
|
console.log('getOpenidNoLogin', res)
|
|
console.log('getOpenidNoLogin', res)
|
|
@@ -292,8 +306,6 @@ Page({
|
|
|
|
|
|
|
|
|
|
this.uid = wx.getStorageSync('uid');
|
|
this.uid = wx.getStorageSync('uid');
|
|
- let grade = wx.getStorageSync('grade');
|
|
|
|
-
|
|
|
|
// if (!this.uid || !grade) {
|
|
// if (!this.uid || !grade) {
|
|
// this.setData({
|
|
// this.setData({
|
|
// isGradeShow: true,
|
|
// isGradeShow: true,
|
|
@@ -331,13 +343,16 @@ Page({
|
|
|
|
|
|
},
|
|
},
|
|
onShow: function () {
|
|
onShow: function () {
|
|
|
|
+ let grade = wx.getStorageSync('grade');
|
|
|
|
+ this.setData({
|
|
|
|
+ gradeActivity: grade
|
|
|
|
+ })
|
|
if (this.data.myIndex === 3) {
|
|
if (this.data.myIndex === 3) {
|
|
this.getUserWorksInfo(1)
|
|
this.getUserWorksInfo(1)
|
|
}
|
|
}
|
|
wx.setNavigationBarTitle({
|
|
wx.setNavigationBarTitle({
|
|
title: '小学语文朗读配音'
|
|
title: '小学语文朗读配音'
|
|
})
|
|
})
|
|
- console.log('页面返回页面返回', this.data.fromLoginIndex)
|
|
|
|
if (this.data.fromLoginIndex) {
|
|
if (this.data.fromLoginIndex) {
|
|
console.log('页面返回页面返回', this.data.fromLoginIndex)
|
|
console.log('页面返回页面返回', this.data.fromLoginIndex)
|
|
let index = this.data.fromLoginIndex;
|
|
let index = this.data.fromLoginIndex;
|
|
@@ -355,17 +370,14 @@ Page({
|
|
})
|
|
})
|
|
this.updateData(3)
|
|
this.updateData(3)
|
|
}
|
|
}
|
|
- // const userInfo = wx.getStorageSync('user')
|
|
|
|
- // console.log('userInfo',userInfo)
|
|
|
|
- // if (userInfo.wechatName) {
|
|
|
|
- // this.setData({
|
|
|
|
- // isLogin: true
|
|
|
|
- // })
|
|
|
|
- // } else {
|
|
|
|
- // this.setData({
|
|
|
|
- // isLogin: false
|
|
|
|
- // })
|
|
|
|
- // }
|
|
|
|
|
|
+ // 刷新课程资源的收藏数等
|
|
|
|
+ if (this.data.myIndex === 2) {
|
|
|
|
+ this.refreshCourseAmount()
|
|
|
|
+ }
|
|
|
|
+ this.setData({
|
|
|
|
+ shareImg: '',
|
|
|
|
+ shareId: ''
|
|
|
|
+ })
|
|
},
|
|
},
|
|
|
|
|
|
onHide: function () {
|
|
onHide: function () {
|
|
@@ -384,15 +396,25 @@ Page({
|
|
httpRequestApi.getHotRecommendSecond(grade, pageNo, pageSize).success(res => {
|
|
httpRequestApi.getHotRecommendSecond(grade, pageNo, pageSize).success(res => {
|
|
console.log(res)
|
|
console.log(res)
|
|
const recommendRes = res.data.data.list;
|
|
const recommendRes = res.data.data.list;
|
|
- if (recommendRes.length === 0) return;
|
|
|
|
|
|
+ if (recommendRes.length <= 0) {
|
|
|
|
+ this.setData({
|
|
|
|
+ noMoreWork: true
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ };
|
|
// const recommendWorks = [];
|
|
// const recommendWorks = [];
|
|
this.formatWorksList(recommendRes);
|
|
this.formatWorksList(recommendRes);
|
|
-
|
|
|
|
})
|
|
})
|
|
},
|
|
},
|
|
// 组装list
|
|
// 组装list
|
|
formatWorksList(list, notSet) {
|
|
formatWorksList(list, notSet) {
|
|
// const tempList = [];
|
|
// const tempList = [];
|
|
|
|
+ console.log('列表长度列表长度', list.length)
|
|
|
|
+ if (list.length < 3 || list.length === 0) {
|
|
|
|
+ this.setData({
|
|
|
|
+ noMoreWork: true
|
|
|
|
+ })
|
|
|
|
+ }
|
|
list.forEach((item, index) => {
|
|
list.forEach((item, index) => {
|
|
/* if (index === list.length - 2 && list.length > 2) {
|
|
/* if (index === list.length - 2 && list.length > 2) {
|
|
console.log('设置当前id', item.id)
|
|
console.log('设置当前id', item.id)
|
|
@@ -407,6 +429,8 @@ Page({
|
|
temp.plays = item.userRead.playAmount ? item.userRead.playAmount : 0;
|
|
temp.plays = item.userRead.playAmount ? item.userRead.playAmount : 0;
|
|
temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
|
|
temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
|
|
temp.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 0;
|
|
temp.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 0;
|
|
|
|
+ temp.shareAmount = item.userRead.shareAmount;
|
|
|
|
+ temp.favoritesAmount = item.userRead.favoritesAmount;
|
|
temp.classId = item.userRead.exampleId ? item.userRead.exampleId : 1605097720036046;
|
|
temp.classId = item.userRead.exampleId ? item.userRead.exampleId : 1605097720036046;
|
|
temp.time = formatDate(item.userRead.gmtCreated, 3);
|
|
temp.time = formatDate(item.userRead.gmtCreated, 3);
|
|
temp.avatar = item.user.avatar;
|
|
temp.avatar = item.user.avatar;
|
|
@@ -428,6 +452,7 @@ Page({
|
|
temp.shareImg = item.userRead.shareImg;
|
|
temp.shareImg = item.userRead.shareImg;
|
|
temp.grade = item.userRead.grade;
|
|
temp.grade = item.userRead.grade;
|
|
temp.videoShow = false;
|
|
temp.videoShow = false;
|
|
|
|
+ item.isActivity && (temp.activity = true);
|
|
this.data.videoList.push(temp);
|
|
this.data.videoList.push(temp);
|
|
// tempList.push(temp);
|
|
// tempList.push(temp);
|
|
});
|
|
});
|
|
@@ -653,6 +678,8 @@ Page({
|
|
temp.plays = item.userRead.playAmount ? item.userRead.playAmount : 0;
|
|
temp.plays = item.userRead.playAmount ? item.userRead.playAmount : 0;
|
|
temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
|
|
temp.likes = item.userRead.likeAmount ? item.userRead.likeAmount : 0;
|
|
temp.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 0;
|
|
temp.commentAmount = item.userRead.commentAmount ? item.userRead.commentAmount : 0;
|
|
|
|
+ temp.shareAmount = item.userRead.shareAmount;
|
|
|
|
+ temp.favoritesAmount = item.userRead.favoritesAmount;
|
|
temp.classId = item.userRead.exampleId ? item.userRead.exampleId : 1605097720036046;
|
|
temp.classId = item.userRead.exampleId ? item.userRead.exampleId : 1605097720036046;
|
|
temp.time = formatDate(item.userRead.gmtCreated, 3);
|
|
temp.time = formatDate(item.userRead.gmtCreated, 3);
|
|
temp.avatar = item.user.avatar;
|
|
temp.avatar = item.user.avatar;
|
|
@@ -679,7 +706,8 @@ Page({
|
|
console.log('myWorks', myWorks)
|
|
console.log('myWorks', myWorks)
|
|
if (this.data.myIndex === 3) {
|
|
if (this.data.myIndex === 3) {
|
|
this.setData({
|
|
this.setData({
|
|
- videoList: myWorks
|
|
|
|
|
|
+ videoList: myWorks,
|
|
|
|
+ noMoreWork: true
|
|
})
|
|
})
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -688,6 +716,15 @@ Page({
|
|
commentTap: function (e) {
|
|
commentTap: function (e) {
|
|
console.log('点击评论区', e)
|
|
console.log('点击评论区', e)
|
|
if (e.target.dataset.type === 'blank') {
|
|
if (e.target.dataset.type === 'blank') {
|
|
|
|
+ if (this.data.commentShow && this.data.commentId) {
|
|
|
|
+ httpRequestApi.getClassDetail(this.data.commentId).success(res => {
|
|
|
|
+ console.log('评论回显', res.data.data.userRead.commentAmount)
|
|
|
|
+ let str = `videoList[${this.data.commentIndex}].commentAmount`;
|
|
|
|
+ this.setData({
|
|
|
|
+ [str]: res.data.data.userRead.commentAmount
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ }
|
|
this.setData({
|
|
this.setData({
|
|
commentShow: false
|
|
commentShow: false
|
|
})
|
|
})
|
|
@@ -698,17 +735,20 @@ Page({
|
|
},
|
|
},
|
|
// 打开评论
|
|
// 打开评论
|
|
openComment: function (e) {
|
|
openComment: function (e) {
|
|
- //
|
|
|
|
|
|
+ //
|
|
console.log('id', e.detail.activeId)
|
|
console.log('id', e.detail.activeId)
|
|
|
|
+ console.log('id', e)
|
|
this.setData({
|
|
this.setData({
|
|
commentShow: !this.data.commentShow,
|
|
commentShow: !this.data.commentShow,
|
|
commentId: e.detail.activeId,
|
|
commentId: e.detail.activeId,
|
|
|
|
+ commentIndex: e.detail.activeIndex
|
|
// commentList: []
|
|
// commentList: []
|
|
});
|
|
});
|
|
// this.getReply(e.detail.activeId);
|
|
// this.getReply(e.detail.activeId);
|
|
},
|
|
},
|
|
// 获取评论信息
|
|
// 获取评论信息
|
|
getReply: function (columnId) {
|
|
getReply: function (columnId) {
|
|
|
|
+ debugger
|
|
// let columnId = this.data.id;
|
|
// let columnId = this.data.id;
|
|
console.log(123123123, columnId)
|
|
console.log(123123123, columnId)
|
|
// let pageNo = this.data.pageNo;
|
|
// let pageNo = this.data.pageNo;
|
|
@@ -764,16 +804,12 @@ Page({
|
|
})
|
|
})
|
|
},
|
|
},
|
|
onShareAppMessage: function (res) {
|
|
onShareAppMessage: function (res) {
|
|
- console.log('点击分享按钮', res)
|
|
|
|
- console.log('点击分享按钮', this.data.shareTitle)
|
|
|
|
- console.log('点击分享按钮', this.data.shareId)
|
|
|
|
- console.log('点击分享按钮', this.data.shareImg)
|
|
|
|
|
|
+ console.log('onShareAppMessage>>>>>>>>>>>>')
|
|
if (res.from === 'button') {
|
|
if (res.from === 'button') {
|
|
return {
|
|
return {
|
|
title: '请欣赏我的课文朗读作品,点赞+评论。',
|
|
title: '请欣赏我的课文朗读作品,点赞+评论。',
|
|
path: `/pages/index/index?readId=${this.data.shareId}`,
|
|
path: `/pages/index/index?readId=${this.data.shareId}`,
|
|
imageUrl: this.data.shareImg
|
|
imageUrl: this.data.shareImg
|
|
-
|
|
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
return {
|
|
return {
|
|
@@ -783,11 +819,11 @@ Page({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
openShare: function (e) {
|
|
openShare: function (e) {
|
|
- console.log('用户点击分享按钮123', e)
|
|
|
|
this.setData({
|
|
this.setData({
|
|
shareTitle: e.detail.currentTarget.dataset.title,
|
|
shareTitle: e.detail.currentTarget.dataset.title,
|
|
shareId: e.detail.currentTarget.dataset.id,
|
|
shareId: e.detail.currentTarget.dataset.id,
|
|
- shareImg: e.detail.currentTarget.dataset.shareimg
|
|
|
|
|
|
+ shareImg: e.detail.currentTarget.dataset.shareimg,
|
|
|
|
+ goToShare: true
|
|
})
|
|
})
|
|
},
|
|
},
|
|
// 修改年级
|
|
// 修改年级
|
|
@@ -842,7 +878,6 @@ Page({
|
|
} else {
|
|
} else {
|
|
this.setData({
|
|
this.setData({
|
|
noFollow: false
|
|
noFollow: false
|
|
-
|
|
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
@@ -873,7 +908,8 @@ Page({
|
|
httpRequestApi.getClassRead(data).success(res => {
|
|
httpRequestApi.getClassRead(data).success(res => {
|
|
console.log('资源', this.data.coursesData)
|
|
console.log('资源', this.data.coursesData)
|
|
this.setData({
|
|
this.setData({
|
|
- coursesData: this.data.coursesData.concat(res.data.data.list)
|
|
|
|
|
|
+ coursesData: this.data.coursesData.concat(res.data.data.list),
|
|
|
|
+ noMoreWork: res.data.data.list.length <= 0 ? true : false
|
|
}, () => {
|
|
}, () => {
|
|
console.log(this.data.coursesData)
|
|
console.log(this.data.coursesData)
|
|
})
|
|
})
|
|
@@ -882,10 +918,40 @@ Page({
|
|
goToReading: function (e) {
|
|
goToReading: function (e) {
|
|
console.log('去朗读', e)
|
|
console.log('去朗读', e)
|
|
const id = e.detail.activeId ? e.detail.activeId : e.currentTarget.dataset.id;
|
|
const id = e.detail.activeId ? e.detail.activeId : e.currentTarget.dataset.id;
|
|
|
|
+ const index = e.currentTarget.dataset.index;
|
|
|
|
+ this.setData({
|
|
|
|
+ goToCoursesId: id,
|
|
|
|
+ goToCoursesIndex: index
|
|
|
|
+ })
|
|
wx.navigateTo({
|
|
wx.navigateTo({
|
|
url: `../../pages/reading/reading?id=${id}`
|
|
url: `../../pages/reading/reading?id=${id}`
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ refreshCourseAmount() {
|
|
|
|
+ console.log(this.data.goToCoursesId)
|
|
|
|
+ console.log(this.data.goToCoursesIndex)
|
|
|
|
+ if (this.data.goToCoursesId && (this.data.goToCoursesIndex || this.data.goToCoursesIndex === 0)) {
|
|
|
|
+ httpRequestApi.getClassDetail(this.data.goToCoursesId).success(res => {
|
|
|
|
+ console.log('刷新', res.data.data.userRead)
|
|
|
|
+ let likeStr = `coursesData[${this.data.goToCoursesIndex}].userRead.likeAmount`;
|
|
|
|
+ let commentStr = `coursesData[${this.data.goToCoursesIndex}].userRead.commentAmount`;
|
|
|
|
+ let playStr = `coursesData[${this.data.goToCoursesIndex}].userRead.playAmount`;
|
|
|
|
+ let shareStr = `coursesData[${this.data.goToCoursesIndex}].userRead.shareAmount`;
|
|
|
|
+ let collectStr = `coursesData[${this.data.goToCoursesIndex}].userRead.collectAmount`;
|
|
|
|
+ console.log(1, this.data.coursesData[this.data.goToCoursesIndex].userRead.likeAmount)
|
|
|
|
+ console.log(2, res.data.data.userRead.likeAmount)
|
|
|
|
+ this.setData({
|
|
|
|
+ [likeStr]: res.data.data.userRead.likeAmount,
|
|
|
|
+ [commentStr]: res.data.data.userRead.commentAmount,
|
|
|
|
+ [playStr]: res.data.data.userRead.playAmount,
|
|
|
|
+ [shareStr]: res.data.data.userRead.shareAmount,
|
|
|
|
+ [collectStr]: res.data.data.userRead.collectAmount,
|
|
|
|
+ }, () => {
|
|
|
|
+ console.log(111222333, this.data.coursesData[this.data.goToCoursesIndex])
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
courseCollectTap: function collectClass(e) {
|
|
courseCollectTap: function collectClass(e) {
|
|
console.log('收藏按钮', e);
|
|
console.log('收藏按钮', e);
|
|
const data = {
|
|
const data = {
|
|
@@ -928,11 +994,13 @@ Page({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
collectTap: function (e) {
|
|
collectTap: function (e) {
|
|
- console.log('点击收藏首页', e)
|
|
|
|
const index = e.detail.index;
|
|
const index = e.detail.index;
|
|
- let str = `videoList[${index}].isFavorite`
|
|
|
|
|
|
+ let str = `videoList[${index}].isFavorite`;
|
|
|
|
+ let str2 = `videoList[${index}].favoritesAmount`;
|
|
|
|
+ let favoritesAmount = e.detail.isCollect ? this.data.videoList[index].favoritesAmount + 1 : this.data.videoList[index].favoritesAmount - 1
|
|
this.setData({
|
|
this.setData({
|
|
- [str]: e.detail.isCollect
|
|
|
|
|
|
+ [str]: e.detail.isCollect,
|
|
|
|
+ [str2]: favoritesAmount
|
|
})
|
|
})
|
|
},
|
|
},
|
|
likeTap: function (e) {
|
|
likeTap: function (e) {
|
|
@@ -944,5 +1012,26 @@ Page({
|
|
[likeStr]: true,
|
|
[likeStr]: true,
|
|
[likeNumStr]: this.data.videoList[index].likes + 1
|
|
[likeNumStr]: this.data.videoList[index].likes + 1
|
|
})
|
|
})
|
|
|
|
+ // this.flowerAnimationHandler()
|
|
},
|
|
},
|
|
-})
|
|
|
|
|
|
+ flowerAnimationHandler: function () {
|
|
|
|
+ this.flowerBox = this.selectComponent("#flower-box");
|
|
|
|
+ console.log('this.flower', this.flowerBox)
|
|
|
|
+ this.flowerBox.comeOut();
|
|
|
|
+ },
|
|
|
|
+ addShareAmount: function (e) {
|
|
|
|
+ console.log('+++++1', e)
|
|
|
|
+ let str = `videoList[${e.detail.index}].shareAmount`;
|
|
|
|
+ this.setData({
|
|
|
|
+ [str]: this.data.videoList[e.detail.index].shareAmount + 1
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ /**
|
|
|
|
+ * 跳转到活动页
|
|
|
|
+ */
|
|
|
|
+ goToActivity() {
|
|
|
|
+ wx.navigateTo({
|
|
|
|
+ url: `../activity/index/index`
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+})
|