|
@@ -24,7 +24,15 @@ Component({
|
|
|
cicleList: [],
|
|
|
time: '',
|
|
|
//点赞人
|
|
|
- chickList: ''
|
|
|
+ chickList: '',
|
|
|
+
|
|
|
+ show: false,
|
|
|
+ //
|
|
|
+ inputValue: '', // 用于存储输入的内容
|
|
|
+ textareaHeight: 52 , // 初始高度,单位为 rpx
|
|
|
+ bottomNavHeight:0,
|
|
|
+ //
|
|
|
+ commentList:[],
|
|
|
},
|
|
|
lifetimes: {
|
|
|
|
|
@@ -35,6 +43,8 @@ Component({
|
|
|
// 在组件实例进入页面节点树时执行
|
|
|
this.getcircle()
|
|
|
this.showischick()
|
|
|
+ this.getbottomheight()
|
|
|
+ this.getComment()
|
|
|
},
|
|
|
|
|
|
},
|
|
@@ -210,6 +220,94 @@ Component({
|
|
|
this.setData({
|
|
|
chickList
|
|
|
})
|
|
|
+ },
|
|
|
+ //显示弹出层
|
|
|
+ showPopup() {
|
|
|
+ this.setData({ show: true });
|
|
|
+ this.showgood()
|
|
|
+ },
|
|
|
+
|
|
|
+ onClose() {
|
|
|
+ this.setData({ show: false });
|
|
|
+ },
|
|
|
+ //输入框高度随字体增多而变大
|
|
|
+ onInput: function(event) {
|
|
|
+ const value = event.detail.value; // 获取当前输入的值
|
|
|
+ this.setData({
|
|
|
+ inputValue: value,
|
|
|
+ textareaHeight: this.calculateHeight(value) // 动态计算高度
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ calculateHeight: function(value) {
|
|
|
+ // 计算文本高度的逻辑,返回合适的高度
|
|
|
+ // 这里可以根据实际情况调整
|
|
|
+ const lineHeight = 40; // 设置行高
|
|
|
+ const lines = Math.ceil(value.length / 30); // 假设每行30个字符
|
|
|
+ return Math.max(52, lines * lineHeight); // 确保最小高度为52rpx
|
|
|
+ },
|
|
|
+ // 发送评论
|
|
|
+ async sendComment() {
|
|
|
+ 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("新数据保存成功");
|
|
|
+ } catch (error) {
|
|
|
+ console.error("保存数据时出现错误:", error);
|
|
|
+ }
|
|
|
+ // 处理发送评论的逻辑
|
|
|
+ console.log(this.data.inputValue);
|
|
|
+ // 清空输入框
|
|
|
+ this.setData({
|
|
|
+ inputValue: '',
|
|
|
+ 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(){
|
|
|
+ const systemInfo = wx.getSystemInfoSync();
|
|
|
+ const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
|
|
|
+ this.setData({
|
|
|
+ bottomNavHeight,
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
})
|