|
@@ -28,11 +28,14 @@ Component({
|
|
|
|
|
|
show: false,
|
|
|
//
|
|
|
- inputValue: '', // 用于存储输入的内容
|
|
|
- textareaHeight: 52 , // 初始高度,单位为 rpx
|
|
|
- bottomNavHeight:0,
|
|
|
+ inputValue: '', // 用于存储输入的内容
|
|
|
+ textareaHeight: 52, // 初始高度,单位为 rpx
|
|
|
+ bottomNavHeight: 0,
|
|
|
//
|
|
|
- commentList:[],
|
|
|
+ commentList: [],
|
|
|
+ //
|
|
|
+ poptype: '',
|
|
|
+ userobject: ''
|
|
|
},
|
|
|
lifetimes: {
|
|
|
|
|
@@ -200,9 +203,9 @@ Component({
|
|
|
let moment2 = await AIMomentCommentquery2.find()
|
|
|
let AIMoment1List2 = moment2.map(item => item.toJSON());
|
|
|
this.setData({
|
|
|
- isclick:AIMoment1List2[0].isDeleted
|
|
|
+ isclick: AIMoment1List2[0].isDeleted
|
|
|
})
|
|
|
- console.log('isclick',AIMoment1List2);
|
|
|
+ console.log('isclick', AIMoment1List2);
|
|
|
},
|
|
|
//显示点赞人
|
|
|
async showchick() {
|
|
@@ -223,23 +226,28 @@ Component({
|
|
|
},
|
|
|
//显示弹出层
|
|
|
showPopup() {
|
|
|
- this.setData({ show: true });
|
|
|
+ this.setData({
|
|
|
+ show: true,
|
|
|
+ poptype: 'one' //直接回复
|
|
|
+ });
|
|
|
this.showgood()
|
|
|
- },
|
|
|
-
|
|
|
- onClose() {
|
|
|
- this.setData({ show: false });
|
|
|
- },
|
|
|
- //输入框高度随字体增多而变大
|
|
|
- onInput: function(event) {
|
|
|
+ },
|
|
|
+
|
|
|
+ onClose() {
|
|
|
+ this.setData({
|
|
|
+ show: false
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //输入框高度随字体增多而变大
|
|
|
+ onInput: function (event) {
|
|
|
const value = event.detail.value; // 获取当前输入的值
|
|
|
this.setData({
|
|
|
inputValue: value,
|
|
|
textareaHeight: this.calculateHeight(value) // 动态计算高度
|
|
|
});
|
|
|
},
|
|
|
-
|
|
|
- calculateHeight: function(value) {
|
|
|
+
|
|
|
+ calculateHeight: function (value) {
|
|
|
// 计算文本高度的逻辑,返回合适的高度
|
|
|
// 这里可以根据实际情况调整
|
|
|
const lineHeight = 40; // 设置行高
|
|
@@ -248,13 +256,121 @@ Component({
|
|
|
},
|
|
|
// 发送评论
|
|
|
async sendComment() {
|
|
|
+ //单独发送评论
|
|
|
+ if (this.data.poptype == 'one') {
|
|
|
+ let AIMomentquery = new Parse.Query('AIMoment');
|
|
|
+ AIMomentquery.equalTo('company', company);
|
|
|
+ AIMomentquery.equalTo('objectId', this.data.objectId);
|
|
|
+ AIMomentquery.equalTo('isVisible', true);
|
|
|
+ AIMomentquery.notEqualTo('isDeleted', true)
|
|
|
+ let P = await AIMomentquery.first();
|
|
|
+
|
|
|
+ const currentUser = Parse.User.current();
|
|
|
+ let userquery = new Parse.Query('_User');
|
|
|
+ userquery.equalTo('company', company);
|
|
|
+ userquery.equalTo('objectId', currentUser.id);
|
|
|
+ userquery.notEqualTo('isDeleted', true)
|
|
|
+ let user = await userquery.first();
|
|
|
+
|
|
|
+ let companyPointer = Parse.Object.extend('Company').createWithoutData(company);
|
|
|
+ let Comment = new Parse.Object('AIMomentComment');
|
|
|
+ Comment.set('moment', P.toPointer())
|
|
|
+ Comment.set('company', companyPointer);
|
|
|
+ Comment.set('type', 'coment');
|
|
|
+ Comment.set('isDeleted', false);
|
|
|
+ Comment.set('content', this.data.inputValue);
|
|
|
+ Comment.set('user', user.toPointer());
|
|
|
+ try {
|
|
|
+ let saveDate2 = await Comment.save();
|
|
|
+ console.log(saveDate2);
|
|
|
+ console.log("新数据保存成功");
|
|
|
+ this.getComment()
|
|
|
+ } catch (error) {
|
|
|
+ console.error("保存数据时出现错误:", error);
|
|
|
+ }
|
|
|
+ // 处理发送评论的逻辑
|
|
|
+ console.log(this.data.inputValue);
|
|
|
+ // 清空输入框
|
|
|
+ this.setData({
|
|
|
+ inputValue: '',
|
|
|
+ textareaHeight: 52 // 重置高度
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //回复别人评论
|
|
|
+ if (this.data.poptype == 'two') {
|
|
|
+ console.log('id',this.data.userobject);
|
|
|
+ this.rebackmoment()
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ //获取评论
|
|
|
+ async getComment() {
|
|
|
+ let Momentquery = new Parse.Query('AIMomentComment');
|
|
|
+ Momentquery.equalTo('company', company);
|
|
|
+ Momentquery.equalTo('type', 'coment');
|
|
|
+ Momentquery.equalTo('moment', this.data.objectId);
|
|
|
+ Momentquery.notEqualTo('isDeleted', true);
|
|
|
+ Momentquery.include('user');
|
|
|
+ Momentquery.include('comment.user');
|
|
|
+
|
|
|
+ // 按照创建时间升序排列(从旧到新)
|
|
|
+ Momentquery.ascending('createdAt'); // 或者使用 Momentquery.descending('createdAt') 以降序排列
|
|
|
+
|
|
|
+ let r = await Momentquery.find();
|
|
|
+ let commentList = r.map(item => item.toJSON());
|
|
|
+ console.log('评论', commentList);
|
|
|
+ this.setData({
|
|
|
+ commentList
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //点击评论
|
|
|
+ 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.include('user');
|
|
|
+ let r = await AIMomentCommentquery.find();
|
|
|
+ let commentList = r.map(item => item.toJSON());
|
|
|
+
|
|
|
+ const currentUser = Parse.User.current();
|
|
|
+ let userquery = new Parse.Query('_User');
|
|
|
+ userquery.equalTo('company', company);
|
|
|
+ userquery.equalTo('objectId', currentUser.id);
|
|
|
+ userquery.notEqualTo('isDeleted', true)
|
|
|
+ let R = await userquery.find();
|
|
|
+ let user = R.map(item => item.toJSON());
|
|
|
+
|
|
|
+ if(user[0].objectId!=commentList[0].user.objectId){
|
|
|
+ this.setData({
|
|
|
+ show: true,
|
|
|
+ poptype: 'two',
|
|
|
+ userobject:objectId
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ console.log('点击了自己');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ //回复评论
|
|
|
+ async rebackmoment() {
|
|
|
+ //所属评论
|
|
|
+
|
|
|
+ let AIMomentCommentquery = new Parse.Query('AIMomentComment');
|
|
|
+ AIMomentCommentquery.equalTo('company', company);
|
|
|
+ AIMomentCommentquery.equalTo('objectId', this.data.userobject);
|
|
|
+ AIMomentCommentquery.notEqualTo('isDeleted', true)
|
|
|
+ let Puser = await AIMomentCommentquery.first();
|
|
|
+ //所属动态
|
|
|
let AIMomentquery = new Parse.Query('AIMoment');
|
|
|
AIMomentquery.equalTo('company', company);
|
|
|
AIMomentquery.equalTo('objectId', this.data.objectId);
|
|
|
AIMomentquery.equalTo('isVisible', true);
|
|
|
AIMomentquery.notEqualTo('isDeleted', true)
|
|
|
let P = await AIMomentquery.first();
|
|
|
-
|
|
|
+ //获取用户
|
|
|
const currentUser = Parse.User.current();
|
|
|
let userquery = new Parse.Query('_User');
|
|
|
userquery.equalTo('company', company);
|
|
@@ -266,6 +382,7 @@ Component({
|
|
|
let Comment = new Parse.Object('AIMomentComment');
|
|
|
Comment.set('moment', P.toPointer())
|
|
|
Comment.set('company', companyPointer);
|
|
|
+ Comment.set('comment', Puser.toPointer());
|
|
|
Comment.set('type', 'coment');
|
|
|
Comment.set('isDeleted', false);
|
|
|
Comment.set('content', this.data.inputValue);
|
|
@@ -286,24 +403,8 @@ Component({
|
|
|
textareaHeight: 52 // 重置高度
|
|
|
});
|
|
|
},
|
|
|
- //获取评论
|
|
|
- async getComment(){
|
|
|
- let Momentquery = new Parse.Query('AIMomentComment');
|
|
|
- Momentquery.equalTo('company', company);
|
|
|
- Momentquery.equalTo('type', 'coment');
|
|
|
- Momentquery.equalTo('moment', this.data.objectId);
|
|
|
- Momentquery.notEqualTo('isDeleted', true)
|
|
|
- Momentquery.include('user')
|
|
|
- Momentquery.include('comment.user')
|
|
|
- let r = await Momentquery.find();
|
|
|
- let commentList = r.map(item => item.toJSON());
|
|
|
- console.log('评论',commentList);
|
|
|
- this.setData({
|
|
|
- commentList
|
|
|
- })
|
|
|
- },
|
|
|
//计算底部高度
|
|
|
- getbottomheight(){
|
|
|
+ getbottomheight() {
|
|
|
const systemInfo = wx.getSystemInfoSync();
|
|
|
const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
|
|
|
this.setData({
|