修改下拉框点击事件
parent
da373bc72e
commit
e4e8df5499
|
|
@ -55,7 +55,7 @@
|
|||
type: String,
|
||||
default: '回复'
|
||||
},
|
||||
// 新增props:控制下拉菜单显示状态
|
||||
// 控制下拉菜单显示状态
|
||||
propDropDownVisible: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
|
|
@ -95,20 +95,17 @@
|
|||
// 切换下拉菜单
|
||||
toggle_dropdown() {
|
||||
// 通知父组件切换当前组件的下拉菜单状态
|
||||
this.$emit('toggle-dropdown', this.propId);
|
||||
this.$emit('toggle_dropdown', this.propId);
|
||||
},
|
||||
// 处理下拉菜单项点击
|
||||
handle_dropdown_item_click(e) {
|
||||
const item = e.currentTarget.dataset.value || {};
|
||||
console.log('点击:', item.label);
|
||||
uni.showToast({ title: item.label, icon: 'none' });
|
||||
// uni.showToast({ title: item.label, icon: 'none' });
|
||||
// 通知父组件关闭下拉菜单
|
||||
this.$emit('close-dropdown', this.propId);
|
||||
this.$emit('dropdown-item-click', { command: item.command, label: item.label });
|
||||
// this.$emit('close-dropdown', this.propId);
|
||||
this.$emit('dropdown_item_click', this.propId, item);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
console.log('CommentInfo 组件已挂载');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -97,12 +97,12 @@
|
|||
<scroll-view class="comment-list" scroll-y show-scrollbar="false" @scrolltolower="handle_comment_to_lower_scroll" @scroll="handle_comment_scroll">
|
||||
<view class="comment-scroll">
|
||||
<view class="comment-item flex-col" v-for="(comment_item, index) in active_comments" :key="index">
|
||||
<commentInfoComponent class="wh-auto ht-auto" :propComment="comment_item" :propId="comment_item.id" :propDropDownVisible="active_dropdown_id === comment_item.id" @comment_reply="comment_reply" @comment_like="comment_like" @toggle-dropdown="handle_toggle_dropdown" @close-dropdown="handle_close_dropdown"></commentInfoComponent>
|
||||
<commentInfoComponent class="wh-auto ht-auto" :propComment="comment_item" :propId="comment_item.id" :propDropDownVisible="active_dropdown_id == comment_item.id" @comment_reply="comment_reply" @comment_like="comment_like" @toggle_dropdown="handle_toggle_dropdown" @dropdown_item_click="handle_dropdown_item_click"></commentInfoComponent>
|
||||
<!-- 子评论 -->
|
||||
<view class="sub-comment flex-col jc-c gap-10 mt-10">
|
||||
<view v-if="comment_item.sub_comments && comment_item.sub_comments.length > 0 && comment_item.show_sub_comment" class="sub-comment-list flex-col jc-c">
|
||||
<view class="sub-comment-item flex-row align-s gap-10" v-for="(sub_comment_item, sub_comment_index) in comment_item.sub_comments" :key="sub_comment_index">
|
||||
<commentInfoComponent class="wh-auto ht-auto" :propComment="sub_comment_item" :propId="sub_comment_item.id" :propDropDownVisible="active_dropdown_id === sub_comment_item.id" @comment_reply="comment_reply" @comment_like="comment_like" @toggle-dropdown="handle_toggle_dropdown" @close-dropdown="handle_close_dropdown"></commentInfoComponent>
|
||||
<commentInfoComponent class="wh-auto ht-auto" :propComment="sub_comment_item" :propId="sub_comment_item.id" :propDropDownVisible="active_dropdown_id == sub_comment_item.id" @comment_reply="comment_reply" @comment_like="comment_like" @toggle_dropdown="handle_toggle_dropdown" @dropdown_item_click="handle_dropdown_item_click"></commentInfoComponent>
|
||||
</view>
|
||||
</view>
|
||||
<template v-if="comment_item.comments_count > 0">
|
||||
|
|
@ -151,6 +151,7 @@
|
|||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 分享弹窗 -->
|
||||
<component-share-popup ref="share"></component-share-popup>
|
||||
</view>
|
||||
|
|
@ -166,6 +167,7 @@
|
|||
import componentSharePopup from '@/components/share-popup/share-popup';
|
||||
import componentNoData from '@/components/no-data/no-data';
|
||||
import componentBottomLine from '@/components/bottom-line/bottom-line';
|
||||
import componentPopup from '@/components/popup/popup';
|
||||
// 状态栏高度
|
||||
var bar_height = parseInt(app.globalData.get_system_info('statusBarHeight', 0));
|
||||
// #ifdef MP-TOUTIAO || H5
|
||||
|
|
@ -179,7 +181,8 @@
|
|||
searchComponent,
|
||||
componentSharePopup,
|
||||
componentNoData,
|
||||
componentBottomLine
|
||||
componentBottomLine,
|
||||
componentPopup
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
|
@ -1220,24 +1223,56 @@
|
|||
console.error('清理视频资源时出错:', error);
|
||||
}
|
||||
},
|
||||
// 新增方法:处理下拉菜单切换
|
||||
// 处理下拉菜单切换
|
||||
handle_toggle_dropdown(comment_id) {
|
||||
// 如果点击的是同一个组件,则切换状态;否则关闭其他组件并打开当前组件
|
||||
if (this.active_dropdown_id === comment_id) {
|
||||
if (this.active_dropdown_id == comment_id) {
|
||||
this.active_dropdown_id = null;
|
||||
} else {
|
||||
this.active_dropdown_id = comment_id;
|
||||
}
|
||||
},
|
||||
|
||||
// 新增方法:关闭下拉菜单
|
||||
handle_close_dropdown(comment_id) {
|
||||
if (this.active_dropdown_id === comment_id) {
|
||||
// 关闭下拉菜单
|
||||
handle_dropdown_item_click(id, data) {
|
||||
if (this.active_dropdown_id == comment_id) {
|
||||
this.active_dropdown_id = null;
|
||||
}
|
||||
// 处理不同操作
|
||||
if (data.action == 'delete') {
|
||||
// 确认删除
|
||||
uni.showModal({
|
||||
title: '确认删除',
|
||||
content: '确定删除此评论吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// 调用删除接口
|
||||
this.delete_comment(id);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (data.action == 'report') {
|
||||
// 举报评论
|
||||
}
|
||||
},
|
||||
|
||||
// 新增方法:处理全局点击事件
|
||||
// 删除评论
|
||||
delete_comment(comment_id) {
|
||||
// 调用删除接口
|
||||
this.$http.post(this.delete_comment_url, {
|
||||
comment_id: comment_id
|
||||
}).then((res) => {
|
||||
if (res.data.code == 200) {
|
||||
// 删除成功,刷新评论列表
|
||||
this.get_comment_list();
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.data.msg || '删除失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
// 处理全局点击事件
|
||||
handle_global_click(e) {
|
||||
// 检查点击目标是否在下拉菜单相关元素内
|
||||
const target = e.target || e.srcElement;
|
||||
|
|
|
|||
Loading…
Reference in New Issue