This commit is contained in:
Leo
2026-02-03 15:14:24 +08:00
parent 41078c63e6
commit 4c2803d911
2 changed files with 56 additions and 2 deletions

View File

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

View File

@@ -55,6 +55,7 @@
<el-form-item v-if="!expanded">
<el-button type="primary" icon="el-icon-search" size="small" @click="handleJdQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="small" @click="resetJdQuery">重置</el-button>
<el-button type="warning" icon="el-icon-upload2" size="small" :loading="jdFetchLoading" @click="handleJdFetchComments">获取评论</el-button>
<el-button type="success" icon="el-icon-download" size="small" @click="handleJdExport">导出</el-button>
</el-form-item>
</el-form>
@@ -71,6 +72,7 @@
<!-- 桌面端按钮组 -->
<div class="desktop-action-buttons desktop-only">
<el-button type="warning" icon="el-icon-upload2" size="small" :loading="jdFetchLoading" @click="handleJdFetchComments">获取评论</el-button>
<el-button type="success" icon="el-icon-download" size="small" @click="handleJdExport">导出</el-button>
</div>
@@ -184,6 +186,7 @@
<el-form-item v-if="!expanded">
<el-button type="primary" icon="el-icon-search" size="small" @click="handleTbQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="small" @click="resetTbQuery">重置</el-button>
<el-button type="warning" icon="el-icon-upload2" size="small" :loading="tbFetchLoading" @click="handleTbFetchComments">获取评论</el-button>
<el-button type="success" icon="el-icon-download" size="small" @click="handleTbExport">导出</el-button>
</el-form-item>
</el-form>
@@ -200,6 +203,7 @@
<!-- 桌面端按钮组 -->
<div class="desktop-action-buttons desktop-only">
<el-button type="warning" icon="el-icon-upload2" size="small" :loading="tbFetchLoading" @click="handleTbFetchComments">获取评论</el-button>
<el-button type="success" icon="el-icon-download" size="small" @click="handleTbExport">导出</el-button>
</div>
@@ -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