From 2c0df1a74dcb2dd0a9a4bc2a6019cccb7b54c2c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com>
Date: Tue, 10 Mar 2026 18:01:33 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9nvue=E9=A1=B5=E9=9D=A2?=
=?UTF-8?q?=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
locale/index.js | 1 +
.../plugins/video/components/comment-info.vue | 74 +++++++++++--------
pages/plugins/video/detail/detail.nvue | 38 +++++-----
3 files changed, 67 insertions(+), 46 deletions(-)
diff --git a/locale/index.js b/locale/index.js
index 7b1392a8..e43a71cf 100644
--- a/locale/index.js
+++ b/locale/index.js
@@ -9,6 +9,7 @@ let i18nConfig = {
silentTranslationWarn: true,
messages: {
"zh": zh,
+ "zh-Hans": zh,
"en": en
}
}
diff --git a/pages/plugins/video/components/comment-info.vue b/pages/plugins/video/components/comment-info.vue
index 48f707ab..45d5e150 100644
--- a/pages/plugins/video/components/comment-info.vue
+++ b/pages/plugins/video/components/comment-info.vue
@@ -6,7 +6,7 @@
-
@@ -48,17 +48,24 @@
const app = getApp();
//#ifdef APP-NVUE
import i18n from '@/locale/index.js';
+ const dom = weex.requireModule('dom');
+ // nvue页面在方法中使用时的处理
+ import { initVueI18n } from '@dcloudio/uni-i18n';
+ import en from '@/locale/en.json'
+ import zhHans from '@/locale/zh.json'
+ const messages = { en, 'zh-Hans': zhHans }
+ const { t } = initVueI18n(messages)
//#endif
- import { isEmpty } from '@/common/js/common/common.js';
- export default {
+ import { isEmpty } from '@/common/js/common/common.js';
+ export default {
//#ifdef APP-NVUE
- i18n,
+ i18n,
//#endif
props: {
propComment: {
type: Object,
default: () => {
- return {};
+ return {};
},
},
propId: {
@@ -76,48 +83,53 @@
}
},
data() {
- return {
+ return {
// 下拉菜单选项数据
dropdownOptions: [],
// 下拉菜单位置信息
- dropdownMenuTop: 0
+ dropdownMenuTop: 0,
+ dropdownMenuLeft: 0
};
},
mounted() {
this.init();
},
computed: {
- // 使用computed属性映射props状态
+ // 使用 computed 属性映射 props 状态
drop_down_visible() {
- return this.propDropDownVisible;
+ return this.propDropDownVisible;
},
// 下拉菜单样式
dropdownMenuStyle() {
- return `top: ${this.dropdownMenuTop}px;`
+ return `top: ${this.dropdownMenuTop}px;`;
}
},
- methods: {
+ methods: {
isEmpty,
init() {
- const label1 = $t('common.delete');
- const label2 = $t('common.report');
- console.log(label1, label2);
+ //#ifdef APP-NVUE
this.dropdownOptions = [
- { label: label1, type: 'delete' },
- { label: label2, type: 'report' }
+ { label: t('common_delete'), type: 'delete' },
+ { label: t('common_complaint'), type: 'report' }
]
+ //#endif
+ //#ifndef APP-NVUE
+ this.dropdownOptions = [
+ { label: $t('common.delete'), type: 'delete' },
+ { label: $t('common.complaint'), type: 'report' }
+ ]
+ //#endif
},
// 回复
comment_reply(e) {
- console.log('124545');
this.$emit('comment_reply', this.propComment, e);
},
// 点赞
comment_like(e) {
if (!app.globalData.is_single_page_check()) {
- return false;
+ return false;
}
- var user = app.globalData.get_user_info(this, 'comment_like', e);
+ var user= app.globalData.get_user_info(this, 'comment_like', e);
if (user != false) {
this.$emit('comment_like', this.propId, e);
}
@@ -145,34 +157,35 @@
getDropdownPosition() {
try {
// #ifdef APP-NVUE
- // nvue 环境使用 dom 模块
- const dom = weex.requireModule('dom');
- const commentOptionEl = document.getElementById(`comment-option-${this.propId}`);
+ // nvue 环境使用 dom 模块的 getComponentRect 方法
+ const commentOptionEl = this.$refs.commentOption;
if (commentOptionEl) {
dom.getComponentRect(commentOptionEl, (res) => {
if (res && res.size) {
const { top, left, width } = res.size;
// 计算菜单位置:在触发元素下方,右侧对齐
- this.dropdownMenuTop = top;
+ this.dropdownMenuTop = top + 20;
}
});
}
// #endif
-
} catch (error) {
- console.error('getDropdownPosition error:', error);
+ console.error('获取下拉菜单位置失败:', error);
}
},
+
// 处理下拉菜单项点击
handle_dropdown_item_click(e) {
if (!app.globalData.is_single_page_check()) {
- return false;
+ e.stopPropagation();
+ return false;
}
var user = app.globalData.get_user_info(this, 'comment_like', e);
if (user != false) {
const item = e.currentTarget.dataset.value || {};
this.$emit('dropdown_item_click', this.propId, item);
}
+ e.stopPropagation();
}
}
}
@@ -224,10 +237,12 @@
/* 下拉菜单样式 */
.dropdown-menu {
/* #ifndef APP-NVUE */
- position: fixed;
+ position: absolute;
+ right: 0;
/* #endif */
/* #ifdef APP-NVUE */
position: fixed;
+ right: 30rpx;
/* #endif */
background: #ffffff;
border-radius: 8rpx;
@@ -235,6 +250,7 @@
border: 1rpx solid #e5e5e5;
min-width: 160rpx;
z-index: 9999;
+ top: 100%;
margin-top: 8rpx;
padding: 10rpx 0;
}
diff --git a/pages/plugins/video/detail/detail.nvue b/pages/plugins/video/detail/detail.nvue
index 265354e3..36f87acf 100644
--- a/pages/plugins/video/detail/detail.nvue
+++ b/pages/plugins/video/detail/detail.nvue
@@ -147,8 +147,8 @@
-
-
+
+
@@ -167,12 +167,6 @@
-
-
@@ -212,8 +206,8 @@
-
- is_add_comment = false" @confirm="send_comment" />
+
+ is_add_comment = false" @confirm="send_comment" />
@@ -248,7 +242,13 @@
import componentCommon from '@/components/common/common';
// 多语言
//#ifdef APP-NVUE
- import i18n from '@/locale/index.js';
+ import i18n from '@/locale/index.js';
+ // nvue页面在方法中使用时的处理
+ import { initVueI18n } from '@dcloudio/uni-i18n';
+ import en from '@/locale/en.json'
+ import zhHans from '@/locale/zh.json'
+ const messages = { en, 'zh-Hans': zhHans }
+ const { t } = initVueI18n(messages)
//#endif
// 状态栏高度
var bar_height = parseInt(app.globalData.get_system_info('statusBarHeight', 0));
@@ -1705,9 +1705,11 @@
// 处理不同操作
if (obj.type == 'delete') {
// 确认删除
+ const tips = t('common.warm_tips');
+ const content = t('common.delete_confirm_tips');
uni.showModal({
- title: $t('common.warm_tips'),
- content: $t('common.delete_confirm_tips'),
+ title: tips,
+ content: content,
success: (res) => {
if (res.confirm) {
// 调用删除接口
@@ -1914,8 +1916,10 @@
// 键盘显示时,切换输入框
add_comment() {
try {
- this.show_comment_modal = true;
- this.move_distance = 0;
+ //#ifndef H5
+ this.is_add_comment = true;
+ this.active_dropdown_id = null;
+ //#endif
} catch (error) {
console.error('add_comment error:', error);
}
@@ -2200,9 +2204,9 @@
.comment-input {
flex: 1;
font-size: 28rpx;
- height: 50rpx;
+ height: 82rpx;
padding: 16rpx;
- box-sizing: content-box;
+ box-sizing: border-box;
}
.comment-input-content {