|
@@ -22,7 +22,9 @@ Page({
|
|
|
id: '',
|
|
|
path: '',
|
|
|
replyModal: false,
|
|
|
- totalRead: 0
|
|
|
+ totalRead: 0,
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 2
|
|
|
// shareFlag: false
|
|
|
},
|
|
|
onLoad: function (option) {
|
|
@@ -33,11 +35,13 @@ Page({
|
|
|
title: option.title //页面标题为路由参数
|
|
|
})
|
|
|
|
|
|
+
|
|
|
+ this.uid = wx.getStorageSync('uid');
|
|
|
this.setData({
|
|
|
title: option.title,
|
|
|
- id
|
|
|
+ id,
|
|
|
+ myUid: this.uid
|
|
|
})
|
|
|
- this.uid = wx.getStorageSync('uid');
|
|
|
this.getWorks(this.uid, id);
|
|
|
},
|
|
|
onHide: function () {
|
|
@@ -85,9 +89,18 @@ Page({
|
|
|
// 播放音频失败的回调
|
|
|
})
|
|
|
this.innerAudioContext.src = this.data.audioSrc; // 这里可以是录音的临时路径
|
|
|
- this.getReply();
|
|
|
+
|
|
|
});
|
|
|
},
|
|
|
+ onShow() {
|
|
|
+ this.setData({
|
|
|
+ replyList: [],
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 2
|
|
|
+ }, () => {
|
|
|
+ this.getReply();
|
|
|
+ })
|
|
|
+ },
|
|
|
likeWorks: function (e) {
|
|
|
if (this.data.isLike) {
|
|
|
wx.showToast({
|
|
@@ -236,12 +249,12 @@ Page({
|
|
|
getReply: function () {
|
|
|
// let uid = wx.getStorageSync('uid');
|
|
|
let columnId = this.data.id;
|
|
|
- let pageNo = 1;
|
|
|
- let pageSize = 10;
|
|
|
+ let pageNo = this.data.pageNo;
|
|
|
+ let pageSize = this.data.pageSize;
|
|
|
httpRequestApi.getReply(this.uid, columnId, pageNo, pageSize).success((res) => {
|
|
|
console.log(res.data.data.list);
|
|
|
const replyList = res.data.data.list;
|
|
|
- const replyTemp = [];
|
|
|
+ // const replyTemp = [];
|
|
|
replyList.forEach((item) => {
|
|
|
const temp = {};
|
|
|
temp.nickName = item.user.wechatName;
|
|
@@ -252,11 +265,12 @@ Page({
|
|
|
temp.time = formatDate(item.gmtModified, 3);
|
|
|
temp.likes = item.postsAttributeInfo.favors || 0;
|
|
|
console.log(temp.time)
|
|
|
- replyTemp.push(temp);
|
|
|
+ this.data.replyList.push(temp);
|
|
|
});
|
|
|
this.setData({
|
|
|
- replyList: replyTemp,
|
|
|
- total: res.data.data.totalSize
|
|
|
+ replyList: this.data.replyList,
|
|
|
+ total: res.data.data.totalSize,
|
|
|
+ totalPage: res.data.data.totalNo
|
|
|
})
|
|
|
});
|
|
|
},
|
|
@@ -287,15 +301,35 @@ Page({
|
|
|
}
|
|
|
httpRequestApi.postReply(this.uid, data).success(res => {
|
|
|
console.log(res);
|
|
|
+ this.setData({
|
|
|
+ inputValue: ''
|
|
|
+ })
|
|
|
+ this.getReply();
|
|
|
});
|
|
|
+ // 评论成功后刷新数据
|
|
|
+
|
|
|
}
|
|
|
},
|
|
|
+ // 触底加载
|
|
|
+ onReachBottom: function () {
|
|
|
+ // 当前在推荐页面 加载推荐
|
|
|
+ if (this.data.pageNo <= this.data.totalPage) {
|
|
|
+ this.setData({
|
|
|
+ pageNo: this.data.pageNo + 1
|
|
|
+ }, () => {
|
|
|
+ this.getReply();
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
// 设置点击时的id
|
|
|
setSBId: function (e) {
|
|
|
console.log(e)
|
|
|
this.setData({
|
|
|
replySBId: e.currentTarget.dataset.id,
|
|
|
- replyModal: true
|
|
|
+ replyModal: true,
|
|
|
+ replyIndex: e.currentTarget.dataset.index
|
|
|
})
|
|
|
},
|
|
|
// 回复某个评论
|
|
@@ -305,8 +339,13 @@ Page({
|
|
|
content: this.data.inputSBValue
|
|
|
}
|
|
|
httpRequestApi.postReplyComment(this.uid, data).success(res => {
|
|
|
+ console.log(res)
|
|
|
+ const replyWho = this.data.replyList[this.data.replyIndex];
|
|
|
+ const indexStr = `replyList[${this.data.replyIndex}]`;
|
|
|
+ replyWho.replyCount++;
|
|
|
this.setData({
|
|
|
- replyModal: false
|
|
|
+ replyModal: false,
|
|
|
+ [indexStr]: replyWho
|
|
|
})
|
|
|
});
|
|
|
},
|