diff --git a/pages/chat-detail/index.js b/pages/chat-detail/index.js
index 7e08528..bb0e4e1 100644
--- a/pages/chat-detail/index.js
+++ b/pages/chat-detail/index.js
@@ -362,7 +362,7 @@ Page({
const goodsId = e.currentTarget.dataset.goodsId;
if (goodsId) {
wx.navigateTo({
- url: `/pages/goods-detail/goods-detail?id=${goodsId}`
+ url: `/pages/goods-detail/goods-detail?id=${goodsId}&from=chat-detail`
});
}
},
diff --git a/pages/goods-detail/goods-detail.js b/pages/goods-detail/goods-detail.js
index c1793e1..d4d18d3 100644
--- a/pages/goods-detail/goods-detail.js
+++ b/pages/goods-detail/goods-detail.js
@@ -444,6 +444,7 @@ Page({
data: {
goodsDetail: {}, // 当前商品详情
+ displayRegion: '', // 显示的地区信息(根据来源决定显示完整地区还是仅显示省份)
showImagePreview: false, // 控制图片预览弹窗显示
previewImageUrls: [], // 预览的图片URL列表
previewImageIndex: 0, // 当前预览图片的索引
@@ -495,15 +496,29 @@ Page({
});
}
+ // 3. 检查是否来自聊天详情页面
+ const fromChatDetail = options.from === 'chat-detail';
+ this.setData({
+ fromChatDetail: fromChatDetail
+ });
+ console.log('是否来自聊天详情页面:', fromChatDetail);
+
// 解析传入的商品数据
let goodsData = null;
if (options.goodsData) {
try {
goodsData = JSON.parse(decodeURIComponent(options.goodsData));
console.log('解析后的商品数据:', goodsData);
+ // 根据来源决定显示完整地区还是仅显示省份
+ let displayRegion = goodsData.region || '暂无';
+ if (this.data.fromChatDetail) {
+ displayRegion = extractProvince(displayRegion);
+ }
+
// 优先使用传入的商品数据中的联系人信息
this.setData({
goodsDetail: goodsData,
+ displayRegion: displayRegion,
fromSeller: options.fromSeller === 'true',
isFavorite: goodsData.isFavorite || false // 初始化收藏状态
});
@@ -915,8 +930,15 @@ Page({
console.log('商品状态:', formattedGoods.status);
console.log('weightQuantityData:', formattedGoods.weightQuantityData);
+ // 根据来源决定显示完整地区还是仅显示省份
+ let displayRegion = formattedGoods.region || '暂无';
+ if (this.data.fromChatDetail) {
+ displayRegion = extractProvince(displayRegion);
+ }
+
this.setData({
goodsDetail: formattedGoods,
+ displayRegion: displayRegion,
isFavorite: preloadedFavoriteStatus // 优先使用预加载数据中的收藏状态
});
@@ -1485,26 +1507,54 @@ Page({
goodsData: goodsData
});
- // 发送商品分享消息
- API.sendMessage(userPhone, contactPhone, structuredMessage).then(sendRes => {
- console.log('商品分享消息发送成功:', sendRes);
- // 跳转到聊天页面
- 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'
- });
- }
+ // 检查是否已经发送过该商品消息
+ let sentGoodsMessages = wx.getStorageSync('sentGoodsMessages') || [];
+ const messageKey = `${userPhone}_${contactPhone}_${goodsDetail.id}`;
+ const hasSent = sentGoodsMessages.includes(messageKey);
+
+ if (!hasSent) {
+ // 发送商品分享消息
+ API.sendMessage(userPhone, contactPhone, structuredMessage).then(sendRes => {
+ console.log('商品分享消息发送成功:', sendRes);
+
+ // 记录已发送的消息
+ sentGoodsMessages.push(messageKey);
+ wx.setStorageSync('sentGoodsMessages', sentGoodsMessages);
+
+ // 跳转到聊天页面
+ 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(sendErr => {
+ console.error('发送商品分享消息失败:', sendErr);
+ // 即使发送消息失败,也跳转到聊天页面
+ 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(sendErr => {
- console.error('发送商品分享消息失败:', sendErr);
- // 即使发送消息失败,也跳转到聊天页面
+ } else {
+ console.log('该商品消息已发送过,不再重复发送');
+ // 直接跳转到聊天页面
wx.navigateTo({
url: `/pages/chat-detail/index?userId=${chatSessionId}&userName=${encodeURIComponent(contactName || '联系人')}&phone=${contactPhone}&isManager=true`,
success: function () {
@@ -1518,7 +1568,7 @@ Page({
});
}
});
- });
+ }
}).catch(err => {
console.error('建立聊天失败:', err);
// 隐藏加载提示
diff --git a/pages/goods-detail/goods-detail.wxml b/pages/goods-detail/goods-detail.wxml
index b5aa35a..aad362c 100644
--- a/pages/goods-detail/goods-detail.wxml
+++ b/pages/goods-detail/goods-detail.wxml
@@ -90,7 +90,7 @@
地区
- {{goodsDetail.region || '暂无'}}
+ {{displayRegion}}
@@ -191,6 +191,7 @@
class="chat-button bottom-button"
bindtap="onChat"
data-id="{{goodsDetail.id}}"
+ disabled="{{fromChatDetail}}"
>
💬 在线咨询
diff --git a/pages/settlement/index.wxss b/pages/settlement/index.wxss
index e8f1b6a..432baa0 100644
--- a/pages/settlement/index.wxss
+++ b/pages/settlement/index.wxss
@@ -1622,19 +1622,7 @@ picker {
}
.identity-option.selected::before {
- content: '✓';
- position: absolute;
- top: 24rpx;
- right: 24rpx;
- width: 32rpx;
- height: 32rpx;
- color: transparent;
- font-size: 20rpx;
- font-weight: bold;
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 3;
+ content: none;
}
/* 微信风格的上传区域 */