|
@@ -37,7 +37,9 @@ Component({
|
|
|
poptype: '',
|
|
|
userobject: '',
|
|
|
|
|
|
- commenttext:"评论"
|
|
|
+ commenttext: "评论",
|
|
|
+ focusedCommentId: null,
|
|
|
+ isCommentFocused: false
|
|
|
},
|
|
|
lifetimes: {
|
|
|
|
|
@@ -52,8 +54,10 @@ Component({
|
|
|
this.getComment()
|
|
|
},
|
|
|
|
|
|
+
|
|
|
},
|
|
|
|
|
|
+
|
|
|
|
|
|
* 组件的方法列表
|
|
|
*/
|
|
@@ -231,7 +235,7 @@ Component({
|
|
|
this.setData({
|
|
|
show: true,
|
|
|
poptype: 'one',
|
|
|
- commenttext:'评论'
|
|
|
+ commenttext: '评论'
|
|
|
});
|
|
|
this.showgood()
|
|
|
},
|
|
@@ -301,12 +305,12 @@ Component({
|
|
|
}
|
|
|
|
|
|
if (this.data.poptype == 'two') {
|
|
|
- console.log('id',this.data.userobject);
|
|
|
+ console.log('id', this.data.userobject);
|
|
|
this.rebackmoment()
|
|
|
}
|
|
|
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
async getComment() {
|
|
|
let Momentquery = new Parse.Query('AIMomentComment');
|
|
|
Momentquery.equalTo('company', company);
|
|
@@ -315,24 +319,30 @@ Component({
|
|
|
Momentquery.notEqualTo('isDeleted', true);
|
|
|
Momentquery.include('user');
|
|
|
Momentquery.include('comment.user');
|
|
|
-
|
|
|
+
|
|
|
|
|
|
Momentquery.ascending('createdAt');
|
|
|
-
|
|
|
+
|
|
|
let r = await Momentquery.find();
|
|
|
- let commentList = r.map(item => item.toJSON());
|
|
|
+ let commentList = r.map(item => {
|
|
|
+ let comment = item.toJSON();
|
|
|
+
|
|
|
+ comment.showdeletid = false;
|
|
|
+ return comment;
|
|
|
+ });
|
|
|
console.log('评论', commentList);
|
|
|
this.setData({
|
|
|
commentList
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
- async showpop(e) {
|
|
|
- const objectId = e.currentTarget.dataset.id
|
|
|
+
|
|
|
+
|
|
|
+ async showpop(e) {
|
|
|
+ const objectId = e.currentTarget.dataset.id;
|
|
|
let AIMomentCommentquery = new Parse.Query('AIMomentComment');
|
|
|
AIMomentCommentquery.equalTo('company', company);
|
|
|
AIMomentCommentquery.equalTo('objectId', objectId);
|
|
|
- AIMomentCommentquery.notEqualTo('isDeleted', true)
|
|
|
+ AIMomentCommentquery.notEqualTo('isDeleted', true);
|
|
|
AIMomentCommentquery.include('user');
|
|
|
let r = await AIMomentCommentquery.find();
|
|
|
let commentList = r.map(item => item.toJSON());
|
|
@@ -341,27 +351,62 @@ Component({
|
|
|
let userquery = new Parse.Query('_User');
|
|
|
userquery.equalTo('company', company);
|
|
|
userquery.equalTo('objectId', currentUser.id);
|
|
|
- userquery.notEqualTo('isDeleted', true)
|
|
|
+ userquery.notEqualTo('isDeleted', true);
|
|
|
let R = await userquery.find();
|
|
|
let user = R.map(item => item.toJSON());
|
|
|
|
|
|
- if(user[0].objectId!=commentList[0].user.objectId){
|
|
|
+
|
|
|
+ if (user[0].objectId != commentList[0].user.objectId) {
|
|
|
this.setData({
|
|
|
show: true,
|
|
|
poptype: 'two',
|
|
|
- userobject:objectId,
|
|
|
- commenttext:`回复${commentList[0].user.nickname}`
|
|
|
+ userobject: objectId,
|
|
|
+ commenttext: `回复${commentList[0].user.nickname}`
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+
|
|
|
+ const updatedCommentList = this.data.commentList.map(comment => {
|
|
|
+ if (comment.objectId === objectId) {
|
|
|
+ return {
|
|
|
+ ...comment,
|
|
|
+ showdeletid: true
|
|
|
+ };
|
|
|
+
|
|
|
+ }
|
|
|
+ return comment;
|
|
|
+
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ commentList: updatedCommentList
|
|
|
});
|
|
|
- }else{
|
|
|
console.log('点击了自己');
|
|
|
}
|
|
|
+ console.log(this.data.commentList);
|
|
|
+ },
|
|
|
|
|
|
+
|
|
|
+ onTapOutside() {
|
|
|
+ if (!this.data.isCommentFocused) {
|
|
|
+ const updatedCommentList = this.data.commentList.map(comment => ({
|
|
|
+ ...comment,
|
|
|
+ showdeletid: false
|
|
|
+ }));
|
|
|
|
|
|
+ this.setData({
|
|
|
+ commentList: updatedCommentList,
|
|
|
+ focusedCommentId: null
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ onTouchStart() {
|
|
|
+ this.onTapOutside();
|
|
|
},
|
|
|
+
|
|
|
|
|
|
async rebackmoment() {
|
|
|
|
|
|
-
|
|
|
+
|
|
|
let AIMomentCommentquery = new Parse.Query('AIMomentComment');
|
|
|
AIMomentCommentquery.equalTo('company', company);
|
|
|
AIMomentCommentquery.equalTo('objectId', this.data.userobject);
|