修改下拉框点击事件

master
于肖磊 2026-02-12 10:03:43 +08:00
parent da373bc72e
commit e4e8df5499
2 changed files with 50 additions and 18 deletions

View File

@ -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>

View File

@ -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;