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