From 893b2035723e695e6bf993d704bb1395494b987d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?=
<15778543+xufeiyang6017@user.noreply.gitee.com>
Date: Tue, 23 Dec 2025 15:51:38 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=95=86=E5=93=81?=
=?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E7=AB=8B=E5=8D=B3=E5=92=A8=E8=AF=A2?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=8F=82=E8=80=83=E5=AE=A2=E6=9C=8D?=
=?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=88=9B=E5=BB=BA=E8=81=94=E7=B3=BB=E6=96=B9?=
=?UTF-8?q?=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/goods-detail/goods-detail.js | 124 ++++++++++++++++++++++++++-
pages/goods-detail/goods-detail.wxml | 7 +-
pages/goods-detail/goods-detail.wxss | 63 +++++++++-----
3 files changed, 167 insertions(+), 27 deletions(-)
diff --git a/pages/goods-detail/goods-detail.js b/pages/goods-detail/goods-detail.js
index 3e55531..e90019f 100644
--- a/pages/goods-detail/goods-detail.js
+++ b/pages/goods-detail/goods-detail.js
@@ -474,7 +474,128 @@ Page({
}
},
- // 我想要(预约)
+ // 在线聊天
+ onChat(e) {
+ console.log('在线咨询事件:', e);
+ const { id } = e.currentTarget.dataset;
+ if (!id) return;
+
+ // 获取商品联系人信息
+ const contactName = this.data.goodsDetail.product_contact;
+ const contactPhone = this.data.goodsDetail.contact_phone;
+
+ // 检查是否有联系电话
+ if (!contactPhone) {
+ wx.showToast({
+ title: '未找到联系电话',
+ icon: 'none'
+ });
+ return;
+ }
+
+ // 跳转到聊天界面或打开客服窗口
+ wx.showModal({
+ title: '在线咨询',
+ content: `将为您连接到 ${contactName || '客服人员'}`,
+ showCancel: true,
+ cancelText: '取消',
+ confirmText: '立即咨询',
+ success: (res) => {
+ if (res.confirm) {
+ // 获取当前用户的手机号
+ let userPhone = '';
+ try {
+ // 尝试从不同的存储位置获取手机号
+ const userInfo = wx.getStorageSync('userInfo');
+ if (userInfo && userInfo.phoneNumber) {
+ userPhone = userInfo.phoneNumber;
+ } else {
+ // 尝试从其他可能的存储位置获取
+ const users = wx.getStorageSync('users') || {};
+ const userId = wx.getStorageSync('userId');
+ if (userId && users[userId] && users[userId].phoneNumber) {
+ userPhone = users[userId].phoneNumber;
+ } else {
+ userPhone = wx.getStorageSync('phoneNumber');
+ }
+ }
+ // 如果都获取不到,使用默认登录手机号
+ if (!userPhone) {
+ userPhone = '18482694520';
+ }
+ } catch (e) {
+ console.error('获取用户手机号失败:', e);
+ // 如果获取失败,使用默认登录手机号
+ userPhone = '18482694520';
+ }
+
+ console.log('当前用户手机号:', userPhone);
+ console.log('联系人信息:', { contactName, contactPhone });
+
+ // 验证手机号
+ if (!userPhone) {
+ wx.showToast({
+ title: '请先登录获取手机号',
+ icon: 'none'
+ });
+ return;
+ }
+
+ // 验证联系人手机号
+ if (!contactPhone) {
+ console.error('联系人手机号不存在');
+ wx.showToast({
+ title: '联系人信息不完整,请稍后重试',
+ icon: 'none'
+ });
+ return;
+ }
+
+ console.log('联系人手机号:', contactPhone);
+
+ // 显示加载提示
+ wx.showLoading({
+ title: '正在建立聊天...',
+ });
+
+ // 调用API创建聊天记录,确保用户和联系人之间的聊天记录是双向的
+ API.fixChatRecordsPair(userPhone, contactPhone).then(res => {
+ console.log('聊天建立成功:', JSON.stringify(res, null, 2));
+ // 隐藏加载提示
+ wx.hideLoading();
+
+ // 使用联系人手机号作为聊天会话ID
+ const chatSessionId = contactPhone;
+
+ // 跳转到聊天页面,确保正确传递联系人手机号和用户名
+ wx.navigateTo({
+ url: `/pages/chat-detail/index?userId=${chatSessionId}&userName=${encodeURIComponent(contactName || '联系人')}&phone=${contactPhone}&isManager=true`,
+ success: function () {
+ console.log('成功跳转到聊天详情页');
+ },
+ fail: function (error) {
+ console.error('跳转到聊天详情页失败:', error);
+ wx.showToast({
+ title: '聊天功能开发中',
+ icon: 'none'
+ });
+ }
+ });
+ }).catch(err => {
+ console.error('建立聊天失败:', err);
+ // 隐藏加载提示
+ wx.hideLoading();
+ wx.showToast({
+ title: '建立聊天失败,请重试',
+ icon: 'none'
+ });
+ });
+ }
+ }
+ });
+ },
+
+ /* 已移除:我想要(预约)功能
onClickWantInDetail(e) {
console.log('我想要事件:', e);
const { id } = e.currentTarget.dataset;
@@ -539,6 +660,7 @@ Page({
});
});
},
+ */
// 返回上一页
goBack() {
diff --git a/pages/goods-detail/goods-detail.wxml b/pages/goods-detail/goods-detail.wxml
index bcfd377..eddd496 100644
--- a/pages/goods-detail/goods-detail.wxml
+++ b/pages/goods-detail/goods-detail.wxml
@@ -135,12 +135,11 @@
拨打电话
diff --git a/pages/goods-detail/goods-detail.wxss b/pages/goods-detail/goods-detail.wxss
index eee8ecc..342175f 100644
--- a/pages/goods-detail/goods-detail.wxss
+++ b/pages/goods-detail/goods-detail.wxss
@@ -348,6 +348,44 @@
box-shadow: 0 2px 8px rgba(47, 84, 235, 0.2);
}
+.chat-button {
+ padding: 0 24px;
+ height: 36px;
+ line-height: 36px;
+ font-size: 14px;
+ color: #333333;
+ background-color: #e6f7f0;
+ border: 1px solid #52c41a;
+ border-radius: 4px;
+ flex-shrink: 0;
+ box-shadow: 0 2px 8px rgba(82, 196, 26, 0.2);
+}
+
+/* 底部按钮区域样式 */
+.action-buttons {
+ display: flex;
+ justify-content: space-around;
+ align-items: center;
+ padding: 16px;
+ background-color: #ffffff;
+ position: fixed;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
+}
+
+.bottom-button {
+ flex: 1;
+ margin: 0 8px;
+ font-weight: 500;
+}
+
+.bottom-button:active {
+ transform: scale(0.98);
+ opacity: 0.9;
+}
+
.call-button:active {
background-color: #4066ff;
border-color: #4066ff;
@@ -395,33 +433,14 @@
box-shadow: none;
}
-.want-button.bottom-button {
- background: linear-gradient(135deg, #2f54eb 0%, #1d39c4 100%);
- color: #ffffff;
- box-shadow: 0 4px 12px rgba(47, 84, 235, 0.2);
-}
-
.call-button.bottom-button:active {
background-color: #f0f4ff;
transform: scale(0.98);
}
-.want-button.bottom-button:active {
- transform: translateY(2px) scale(0.98);
- box-shadow: 0 2px 6px rgba(47, 84, 235, 0.15);
-}
-
-.want-button.bottom-button[disabled] {
- background: linear-gradient(135deg, #52c41a 0%, #389e0d 100%);
- color: #ffffff !important;
- border: none;
- box-shadow: 0 4px 12px rgba(82, 196, 26, 0.2);
- opacity: 1;
-}
-
-.want-button.bottom-button[disabled]:active {
- transform: none;
- box-shadow: 0 4px 12px rgba(82, 196, 26, 0.3);
+.chat-button.bottom-button:active {
+ background-color: #d6f7e6;
+ transform: scale(0.98);
}
/* 图片预览弹窗 */
From f61ea0e270f0594c1d05c9245a1de4b83d37313c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?=
<15778543+xufeiyang6017@user.noreply.gitee.com>
Date: Tue, 23 Dec 2025 16:00:51 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E7=BE=8E=E5=8C=96=E8=81=8A=E5=A4=A9?=
=?UTF-8?q?=E8=BE=93=E5=85=A5=E5=8C=BA=E5=9F=9F=E5=B9=B6=E8=B0=83=E6=95=B4?=
=?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86=E4=B8=8E=E5=8F=91=E9=80=81=E6=8C=89?=
=?UTF-8?q?=E9=92=AE=E6=AF=94=E4=BE=8B=E4=B8=BA5:1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/chat-detail/index.wxml | 6 ------
pages/chat-detail/index.wxss | 12 ++++++++----
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/pages/chat-detail/index.wxml b/pages/chat-detail/index.wxml
index 1761097..e7c0edf 100644
--- a/pages/chat-detail/index.wxml
+++ b/pages/chat-detail/index.wxml
@@ -1,14 +1,8 @@