From ede1de664a6547d12cb66101737379b8fd6f0f52 Mon Sep 17 00:00:00 2001 From: misworga831 Date: Wed, 7 Jan 2026 16:52:18 +0900 Subject: [PATCH] =?UTF-8?q?feat(=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85):=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=95=86=E5=93=81=E5=8F=82=E6=95=B0=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E5=92=8C=E8=AF=A6=E7=BB=86=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=9A=84=E5=8F=82=E6=95=B0=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im/src/components/chat/panel/OtherLink.vue | 24 +++++++++++++++------- im/src/views/message/index.vue | 18 ++++++++++++++-- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/im/src/components/chat/panel/OtherLink.vue b/im/src/components/chat/panel/OtherLink.vue index ec7a8a3a..9ed46317 100644 --- a/im/src/components/chat/panel/OtherLink.vue +++ b/im/src/components/chat/panel/OtherLink.vue @@ -121,13 +121,23 @@ export default { // }) // }, getGoodsDetail () { - if(this.toUser.storeFlag){ - ServeGetGoodsDetail(this.goodsParams).then(res => { - if (res.success) { - this.goodsDetail = res.result.data - } - }) + // 检查必要参数是否存在 + if (!this.toUser.storeFlag) { + return } + + if (!this.goodsParams || !this.goodsParams.goodsId) { + console.warn('getGoodsDetail: goodsParams 或 goodsId 参数缺失') + return + } + + ServeGetGoodsDetail(this.goodsParams).then(res => { + if (res.success) { + this.goodsDetail = res.result.data + } + }).catch(error => { + console.error('获取商品详情失败:', error) + }) }, getFootPrint() { if (this.toUser.storeFlag) { @@ -284,4 +294,4 @@ export default { /deep/ .el-tabs__header{ margin-bottom: 0; } - \ No newline at end of file + diff --git a/im/src/views/message/index.vue b/im/src/views/message/index.vue index 6b08315e..a2cdc7e9 100644 --- a/im/src/views/message/index.vue +++ b/im/src/views/message/index.vue @@ -289,6 +289,8 @@ export default { beforeRouteUpdate (to, from, next) { let index_name = getCacheIndexName(); if (index_name) this.clickTab(index_name); + // 更新商品参数 + this.initGoodsParams(to.query); next(); }, beforeCreate () { @@ -296,8 +298,10 @@ export default { }, async created () { await this.initialize(); - await this.loadUserSetting(); - /** + await this.loadUserSetting(); + // 初始化商品参数 + this.initGoodsParams(this.$route.query); + /** * 如果说有id 说明是用户点击 “联系客服” 进入的该页面 * 所以创建会话 并请求用户列表 * 如果没有id说明当前商家登录 直接请求用户列表 @@ -317,6 +321,16 @@ export default { // 美化时间格式 beautifyTime, + // 初始化商品参数 + initGoodsParams (query) { + this.goodsParams = { + goodsId: query.goodsId || '', + skuId: query.skuId || '', + }; + + console.log('初始化商品参数:', this.goodsParams); + }, + //创建会话 async createTalk (id) { await ServeCreateTalkList(id);