|
@@ -52,7 +52,7 @@ Page({
|
|
|
myIndex: 0,
|
|
|
followData: [],
|
|
|
recommendPageNo: 1,
|
|
|
- recommendPageSize: 6,
|
|
|
+ recommendPageSize: 12,
|
|
|
recommendTotalNo: 1,
|
|
|
myData: {},
|
|
|
templates: '',
|
|
@@ -75,6 +75,7 @@ Page({
|
|
|
followPageSize: 6,
|
|
|
coursePageNo: 1,
|
|
|
coursesData: [],
|
|
|
+ updateId: 0
|
|
|
|
|
|
},
|
|
|
jurisdiction: function () {
|
|
@@ -200,13 +201,35 @@ Page({
|
|
|
}, 2800)
|
|
|
},
|
|
|
onLoad: function (options) {
|
|
|
+ console.log('onload', options);
|
|
|
getOpenidNoLogin((res) => {
|
|
|
console.log('getOpenidNoLogin', res)
|
|
|
if (!res.data.data.grade) {
|
|
|
+
|
|
|
+ if (res.data.data.wechatName) {
|
|
|
+ this.setData({
|
|
|
+ isGradeShow: true,
|
|
|
+ options,
|
|
|
+ isLogin: true,
|
|
|
+ oldUser: true
|
|
|
+ })
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.setData({
|
|
|
isGradeShow: true,
|
|
|
- options
|
|
|
+ options,
|
|
|
+ isLogin: false,
|
|
|
+ workId: options.scene ? options.scene : options.readId ? options.readId : undefined
|
|
|
})
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ if (res.data.data.wechatName) {
|
|
|
+ this.setData({
|
|
|
+ isLogin: true
|
|
|
+ }, () => {
|
|
|
+ this.showPage();
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}, (error) => {
|
|
@@ -219,6 +242,11 @@ Page({
|
|
|
workId: options.scene
|
|
|
})
|
|
|
}
|
|
|
+ if (options.readId) {
|
|
|
+ this.setData({
|
|
|
+ workId: options.readId
|
|
|
+ })
|
|
|
+ }
|
|
|
this.uid = wx.getStorageSync('uid');
|
|
|
let grade = wx.getStorageSync('grade');
|
|
|
|
|
@@ -230,7 +258,6 @@ Page({
|
|
|
|
|
|
|
|
|
|
|
|
- this.showPage();
|
|
|
wx.getSystemInfo({
|
|
|
success: (res) => {
|
|
|
console.log('系统', res)
|
|
@@ -289,24 +316,28 @@ Page({
|
|
|
console.log('页面返回页面返回', this.data.fromLoginIndex)
|
|
|
if (this.data.fromLoginIndex) {
|
|
|
console.log('页面返回页面返回', this.data.fromLoginIndex)
|
|
|
+
|
|
|
let index = this.data.fromLoginIndex;
|
|
|
+ let userInfo = wx.getStorageSync('user');
|
|
|
this.setData({
|
|
|
- fromLoginIndex: null
|
|
|
+ fromLoginIndex: null,
|
|
|
+ isLogin: userInfo.wechatName ? true : false
|
|
|
}, () => {
|
|
|
this.updateData(0)
|
|
|
|
|
|
})
|
|
|
}
|
|
|
- const userInfo = wx.getStorageSync('user')
|
|
|
- if (userInfo.wechatName) {
|
|
|
- this.setData({
|
|
|
- isLogin: true
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.setData({
|
|
|
- isLogin: false
|
|
|
- })
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
|
|
|
onHide: function () {
|
|
@@ -333,7 +364,14 @@ Page({
|
|
|
},
|
|
|
|
|
|
formatWorksList(list, notSet) {
|
|
|
- list.forEach(item => {
|
|
|
+ const tempList = [];
|
|
|
+ list.forEach((item,index) => {
|
|
|
+ if(index === 1){
|
|
|
+ console.log('设置当前id',item.id)
|
|
|
+ this.setData({
|
|
|
+ updateId: item.userRead.id
|
|
|
+ })
|
|
|
+ }
|
|
|
const temp = {};
|
|
|
temp.title = item.userRead.title;
|
|
|
temp.summary = item.userRead.summary;
|
|
@@ -352,11 +390,12 @@ Page({
|
|
|
temp.nickName = item.user.wechatName;
|
|
|
temp.isLike = item.isLike;
|
|
|
temp.isFavorite = item.isFavorites;
|
|
|
- this.data.videoList.push(temp);
|
|
|
+
|
|
|
+ tempList.push(temp);
|
|
|
});
|
|
|
if (!notSet) {
|
|
|
this.setData({
|
|
|
- videoList: this.data.videoList
|
|
|
+ videoList: tempList
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -412,10 +451,15 @@ Page({
|
|
|
return userInfo;
|
|
|
},
|
|
|
videoChange: function (e) {
|
|
|
+ console.log('到了底部到了底部', e)
|
|
|
console.log('到了底部到了底部', e.detail.index)
|
|
|
console.log('到了底部到了底部', e.detail._last)
|
|
|
- console.log('到了底部到了底部', e.detail.nextQueue)
|
|
|
- if (e.detail.nextQueue.length === 1) {
|
|
|
+ console.log('到了底部到了底部', e.detail.direction)
|
|
|
+
|
|
|
+ console.log('当前ID',e.detail.activeId);
|
|
|
+ console.log('目标ID',this.data.updateId);
|
|
|
+ if (e.detail.activeId === this.data.updateId) {
|
|
|
+ console.log('应该刷新')
|
|
|
if (this.data.myIndex === 1) {
|
|
|
this.setData({
|
|
|
followPageNo: this.data.followPageNo + 1
|
|
@@ -423,12 +467,20 @@ Page({
|
|
|
this.getFollowData()
|
|
|
})
|
|
|
}
|
|
|
+ if (this.data.myIndex === 0) {
|
|
|
+ console.log('首页加载第二页')
|
|
|
+ this.setData({
|
|
|
+ recommendPageNo: this.data.recommendPageNo + 1
|
|
|
+ }, () => {
|
|
|
+ this.getHotRecommend()
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
},
|
|
|
|
|
|
onReachBottom: function () {
|
|
|
- console.log('到了底部到了底部', this.data.myIndex)
|
|
|
if (this.data.myIndex === 2) {
|
|
|
this.setData({
|
|
|
coursePageNo: this.data.coursePageNo + 1
|
|
@@ -436,13 +488,7 @@ Page({
|
|
|
this.getCoursesList()
|
|
|
})
|
|
|
}
|
|
|
- if (this.data.myIndex === 0) {
|
|
|
- this.setData({
|
|
|
- recommendPageNo: this.data.recommendPageNo + 1
|
|
|
- }, () => {
|
|
|
- this.getHotRecommend()
|
|
|
- })
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -544,25 +590,31 @@ Page({
|
|
|
console.log('mydata', this.data.myData)
|
|
|
const myList = res.data.data;
|
|
|
if (myList.length === 0) return;
|
|
|
+
|
|
|
|
|
|
const myWorks = [];
|
|
|
myList.forEach(item => {
|
|
|
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.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;
|
|
|
temp.showMyBtn = true;
|
|
|
temp.nickName = this.data.myData.userInfo.wechatName;
|
|
|
- temp.status = item.status
|
|
|
+ temp.status = item.userRead.status
|
|
|
myWorks.push(temp);
|
|
|
});
|
|
|
console.log('myWorks', myWorks)
|
|
@@ -650,16 +702,62 @@ Page({
|
|
|
isGradeShow: true
|
|
|
})
|
|
|
},
|
|
|
+ onShareAppMessage: function (res) {
|
|
|
+ console.log('点击分享按钮', res)
|
|
|
+ console.log('点击分享按钮', this.data.shareTitle)
|
|
|
+ console.log('点击分享按钮', this.data.shareId)
|
|
|
+ console.log('点击分享按钮', this.data.shareImg)
|
|
|
+ if (res.from === 'button') {
|
|
|
+ return {
|
|
|
+ title: this.data.shareTitle,
|
|
|
+ path: `/pages/index/index?readId=${this.data.shareId}`,
|
|
|
+ imageUrl: this.data.shareImg
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return {
|
|
|
+ title: '快来听我的朗读作品吧',
|
|
|
+ path: '/pages/index/index'
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ openShare: function (e) {
|
|
|
+ console.log('用户点击分享按钮', e)
|
|
|
+ this.setData({
|
|
|
+ shareTitle: e.detail.currentTarget.dataset.title,
|
|
|
+ shareId: e.detail.currentTarget.dataset.id,
|
|
|
+ shareImg: e.detail.currentTarget.dataset.img
|
|
|
+ })
|
|
|
+ },
|
|
|
|
|
|
changeGrade: function (e) {
|
|
|
const grade = e.target.dataset.code;
|
|
|
+
|
|
|
wx.setStorageSync('grade', grade)
|
|
|
this.setData({
|
|
|
isGradeShow: false,
|
|
|
})
|
|
|
+ if (this.data.oldUser) {
|
|
|
+ let data = {
|
|
|
+ grade: e.target.dataset.code
|
|
|
+ };
|
|
|
+ httpRequestApi.settingUserInfo(data).success(res => {
|
|
|
+
|
|
|
+ })
|
|
|
+ };
|
|
|
getOpenidNoLogin((res) => {
|
|
|
console.log('getOpenidNoLogin', res)
|
|
|
|
|
|
+ if (res.data.data.wechatName) {
|
|
|
+ this.setData({
|
|
|
+ isLogin: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ isLogin: false
|
|
|
+ })
|
|
|
+ }
|
|
|
this.showPage()
|
|
|
}, (error) => {
|
|
|
console.log('获取失败')
|
|
@@ -734,27 +832,27 @@ Page({
|
|
|
})
|
|
|
});
|
|
|
},
|
|
|
- coursesOpenShare: function coursesOpenShare(e){
|
|
|
+ coursesOpenShare: function coursesOpenShare(e) {
|
|
|
const obj = e.currentTarget.dataset
|
|
|
- console.log('分享', obj)
|
|
|
- console.log('分享', e)
|
|
|
- if (1) {
|
|
|
- this.shareDialog = this.selectComponent("#share-dialog");
|
|
|
- const data = {
|
|
|
- avatar: obj.avatar,
|
|
|
- author: obj.author,
|
|
|
- iconImg: obj.iconImg,
|
|
|
- title: obj.title,
|
|
|
- path: `pages/index/index`,
|
|
|
- scene: obj.id,
|
|
|
- productId: 1
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- this.setData({
|
|
|
- noScroll: 'noScroll'
|
|
|
- })
|
|
|
- this.shareDialog.share(data);
|
|
|
- }
|
|
|
+ console.log('分享', obj)
|
|
|
+ console.log('分享', e)
|
|
|
+ if (1) {
|
|
|
+ this.shareDialog = this.selectComponent("#share-dialog");
|
|
|
+ const data = {
|
|
|
+ avatar: obj.avatar,
|
|
|
+ author: obj.author,
|
|
|
+ iconImg: obj.iconImg,
|
|
|
+ title: obj.title,
|
|
|
+ path: `pages/index/index`,
|
|
|
+ scene: obj.id,
|
|
|
+ productId: 1
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ noScroll: 'noScroll'
|
|
|
+ })
|
|
|
+ this.shareDialog.share(data);
|
|
|
+ }
|
|
|
}
|
|
|
})
|