From 4c2803d91162c41b8407d5554bc6ec89cebd0581 Mon Sep 17 00:00:00 2001 From: Leo Date: Tue, 3 Feb 2026 15:14:24 +0800 Subject: [PATCH] 1 --- src/api/jarvis/comment.js | 11 +++++++ src/views/system/comment/index.vue | 47 ++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/api/jarvis/comment.js b/src/api/jarvis/comment.js index 75686b8..343cd59 100644 --- a/src/api/jarvis/comment.js +++ b/src/api/jarvis/comment.js @@ -118,6 +118,17 @@ export function getTbProductTypeMap() { }) } +// 获取评论(调用外部接口,按商品ID/SKU拉取评论) +const FETCH_COMMENTS_BASE = 'http://192.168.8.60:5008' +export function fetchComments(productId) { + return request({ + url: FETCH_COMMENTS_BASE + '/fetch_comments', + method: 'get', + params: { product_id: productId }, + headers: { isToken: false } + }) +} + // 获取当前IP地址(公开接口) export function getCurrentIP() { return request({ diff --git a/src/views/system/comment/index.vue b/src/views/system/comment/index.vue index 1168854..5c066f2 100644 --- a/src/views/system/comment/index.vue +++ b/src/views/system/comment/index.vue @@ -55,6 +55,7 @@ 搜索 重置 + 获取评论 导出 @@ -71,6 +72,7 @@
+ 获取评论 导出
@@ -184,6 +186,7 @@ 搜索 重置 + 获取评论 导出 @@ -200,6 +203,7 @@
+ 获取评论 导出
@@ -335,7 +339,7 @@ import { listJdComment, getJdComment, updateJdComment, delJdComment, resetJdCommentByProductId, listTbComment, getTbComment, updateTbComment, delTbComment, resetTbCommentByProductId, - getCommentStatistics, getJdProductTypeMap, getTbProductTypeMap + getCommentStatistics, getJdProductTypeMap, getTbProductTypeMap, fetchComments } from '@/api/jarvis/comment' import { mapGetters } from 'vuex' import MobileSearchForm from '@/components/MobileSearchForm' @@ -386,7 +390,10 @@ export default { }, // 图片查看 imageDialogVisible: false, - imageList: [] + imageList: [], + // 获取评论 loading + jdFetchLoading: false, + tbFetchLoading: false } }, computed: { @@ -402,11 +409,13 @@ export default { }, jdActionButtons() { return [ + { key: 'fetchComments', label: '获取评论', type: 'warning', icon: 'el-icon-upload2', handler: () => this.handleJdFetchComments(), disabled: this.jdFetchLoading }, { key: 'export', label: '导出', type: 'success', icon: 'el-icon-download', handler: () => this.handleJdExport(), disabled: false } ] }, tbActionButtons() { return [ + { key: 'fetchComments', label: '获取评论', type: 'warning', icon: 'el-icon-upload2', handler: () => this.handleTbFetchComments(), disabled: this.tbFetchLoading }, { key: 'export', label: '导出', type: 'success', icon: 'el-icon-download', handler: () => this.handleTbExport(), disabled: false } ] } @@ -458,6 +467,23 @@ export default { ...this.jdQueryParams }, `jd_comment_${new Date().getTime()}.xlsx`) }, + /** 京东:调用获取评论接口,使用商品ID(SKU) 作为 product_id */ + handleJdFetchComments() { + const productId = (this.jdQueryParams.productId || '').toString().trim() + if (!productId) { + this.$modal.msgWarning('请先输入商品ID(SKU)') + return + } + this.jdFetchLoading = true + fetchComments(productId).then(() => { + this.$modal.msgSuccess('获取评论请求已发送') + this.getJdList() + }).catch(e => { + this.$modal.msgError(e && (e.message || e.msg) || '获取评论失败') + }).finally(() => { + this.jdFetchLoading = false + }) + }, // 淘宝评论相关 getTbList() { this.tbLoading = true @@ -499,6 +525,23 @@ export default { ...this.tbQueryParams }, `tb_comment_${new Date().getTime()}.xlsx`) }, + /** 淘宝:调用获取评论接口,使用商品ID(SKU) 作为 product_id */ + handleTbFetchComments() { + const productId = (this.tbQueryParams.productId || '').toString().trim() + if (!productId) { + this.$modal.msgWarning('请先输入商品ID(SKU)') + return + } + this.tbFetchLoading = true + fetchComments(productId).then(() => { + this.$modal.msgSuccess('获取评论请求已发送') + this.getTbList() + }).catch(e => { + this.$modal.msgError(e && (e.message || e.msg) || '获取评论失败') + }).finally(() => { + this.tbFetchLoading = false + }) + }, // 统计信息相关 getStatistics() { this.statLoading = true