修改举报内容显示

master
于肖磊 2026-03-10 17:14:01 +08:00
parent afa7fe1937
commit cbb6bbe7f2
1 changed files with 46 additions and 8 deletions

View File

@ -6,11 +6,16 @@
<text class="comment-user">{{ propComment.user.user_name_view }}</text>
<view class="pr" style="margin-left: 20rpx;">
<!-- 直接实现下拉菜单 -->
<view class="comment-option" @tap.stop="toggle_dropdown">
<view :id="'comment-option-' + propId" class="comment-option" @tap.stop="toggle_dropdown">
<u-icon propName="ellipsis" propColor="#999" propSize="28rpx"></u-icon>
</view>
<!-- 下拉菜单 -->
<view v-if="drop_down_visible && dropdownOptions && Array.isArray(dropdownOptions)" class="dropdown-menu" @tap.stop>
<!-- #ifdef APP-NVUE -->
<view v-if="drop_down_visible && dropdownOptions && Array.isArray(dropdownOptions)" class="dropdown-menu" :style="dropdownMenuStyle" @tap.stop>
<!-- #endif -->
<!-- #ifndef APP-NVUE -->
<view v-if="drop_down_visible && dropdownOptions && Array.isArray(dropdownOptions)" class="dropdown-menu" @tap.stop></view>
<!-- #endif -->
<view v-for="(item, index) in dropdownOptions.filter(item => (propComment.is_can_delete == 1 && item.type == 'delete') || (propComment.is_can_report == 1 && item.type == 'report'))" :key="index" class="dropdown-item" :data-value="item" @tap="handle_dropdown_item_click">
<text>{{ item.label }}</text>
</view>
@ -73,7 +78,9 @@
data() {
return {
//
dropdownOptions: []
dropdownOptions: [],
//
dropdownMenuTop: 0
};
},
mounted() {
@ -83,14 +90,21 @@
// 使computedprops
drop_down_visible() {
return this.propDropDownVisible;
},
//
dropdownMenuStyle() {
return `top: ${this.dropdownMenuTop}px;`
}
},
methods: {
isEmpty,
init() {
const label1 = $t('common.delete');
const label2 = $t('common.report');
console.log(label1, label2);
this.dropdownOptions = [
{ label: '删除', type: 'delete' },
{ label: '举报', type: 'report' }
{ label: label1, type: 'delete' },
{ label: label2, type: 'report' }
]
},
//
@ -118,11 +132,37 @@
},
//
toggle_dropdown(e) {
// comment-option
this.getDropdownPosition();
//
this.$emit('toggle_dropdown', this.propId);
e.stopPropagation();
},
//
getDropdownPosition() {
try {
// #ifdef APP-NVUE
// nvue 使 dom
const dom = weex.requireModule('dom');
const commentOptionEl = document.getElementById(`comment-option-${this.propId}`);
if (commentOptionEl) {
dom.getComponentRect(commentOptionEl, (res) => {
if (res && res.size) {
const { top, left, width } = res.size;
//
this.dropdownMenuTop = top;
}
});
}
// #endif
} catch (error) {
console.error('getDropdownPosition error:', error);
}
},
//
handle_dropdown_item_click(e) {
if (!app.globalData.is_single_page_check()) {
@ -184,7 +224,7 @@
/* 下拉菜单样式 */
.dropdown-menu {
/* #ifndef APP-NVUE */
position: absolute;
position: fixed;
/* #endif */
/* #ifdef APP-NVUE */
position: fixed;
@ -195,8 +235,6 @@
border: 1rpx solid #e5e5e5;
min-width: 160rpx;
z-index: 9999;
top: 100%;
right: 0;
margin-top: 8rpx;
padding: 10rpx 0;
}