Browse Source

修复结算页面符号动画问题,实现商品卡片点击导航,处理API 404错误,防止重复发送消息,禁用在线咨询按钮防止循环导航,优化地区显示

pull/11/head
Default User 2 months ago
parent
commit
c9fac1d7a0
  1. 2
      pages/chat-detail/index.js
  2. 50
      pages/goods-detail/goods-detail.js
  3. 3
      pages/goods-detail/goods-detail.wxml
  4. 14
      pages/settlement/index.wxss

2
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`
});
}
},

50
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,9 +1507,20 @@ Page({
goodsData: goodsData
});
// 检查是否已经发送过该商品消息
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`,
@ -1519,6 +1552,23 @@ Page({
}
});
});
} else {
console.log('该商品消息已发送过,不再重复发送');
// 直接跳转到聊天页面
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);
// 隐藏加载提示

3
pages/goods-detail/goods-detail.wxml

@ -90,7 +90,7 @@
<text class="info-label">地区</text>
</view>
<view class="info-value-container">
<text class="info-value">{{goodsDetail.region || '暂无'}}</text>
<text class="info-value">{{displayRegion}}</text>
</view>
</view>
@ -191,6 +191,7 @@
class="chat-button bottom-button"
bindtap="onChat"
data-id="{{goodsDetail.id}}"
disabled="{{fromChatDetail}}"
>
💬 在线咨询
</button>

14
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;
}
/* 微信风格的上传区域 */

Loading…
Cancel
Save