Browse Source

更新了收藏页面状态逻辑和其他相关文件

pull/2/head
Default User 2 months ago
parent
commit
85bc5bc36f
  1. 0
      images/招商图片.jpg
  2. 2
      pages/cooperation/index.wxml
  3. 14
      pages/favorites/index.js
  4. 2
      pages/goods-detail/goods-detail.wxml

0
images/9e590639954f2598a54eddf72b7d1fa.jpg → images/招商图片.jpg

Before

Width:  |  Height:  |  Size: 251 KiB

After

Width:  |  Height:  |  Size: 251 KiB

2
pages/cooperation/index.wxml

@ -6,7 +6,7 @@
<!-- 设计展示区域 --> <!-- 设计展示区域 -->
<view class="design-section"> <view class="design-section">
<image class="design-image" src="/images/9e590639954f2598a54eddf72b7d1fa.jpg" mode="aspectFit"></image> <image class="design-image" src="/images/招商图片.jpg" mode="aspectFit"></image>
</view> </view>
<!-- 招商广告区域 --> <!-- 招商广告区域 -->

14
pages/favorites/index.js

@ -227,6 +227,7 @@ Page({
let contact_phone = ''; let contact_phone = '';
let fullRegion = ''; let fullRegion = '';
let province = ''; let province = '';
let status = 'pending_review'; // 默认状态
// 优先从商品列表中获取联系人信息和地区信息 // 优先从商品列表中获取联系人信息和地区信息
if (matchingProduct) { if (matchingProduct) {
@ -236,6 +237,8 @@ Page({
fullRegion = matchingProduct.fullRegion || matchingProduct.region || ''; fullRegion = matchingProduct.fullRegion || matchingProduct.region || '';
// 提取省份 // 提取省份
province = extractProvince(fullRegion); province = extractProvince(fullRegion);
// 获取商品状态
status = matchingProduct.status || 'pending_review';
} }
// 然后尝试从收藏数据中获取 // 然后尝试从收藏数据中获取
else if (item.Product) { else if (item.Product) {
@ -245,6 +248,8 @@ Page({
fullRegion = item.Product.region || ''; fullRegion = item.Product.region || '';
// 提取省份 // 提取省份
province = extractProvince(fullRegion); province = extractProvince(fullRegion);
// 获取商品状态
status = item.Product.status || 'pending_review';
} }
// 更新item对象,确保联系人信息和地区信息同时存在于顶层和Product对象中 // 更新item对象,确保联系人信息和地区信息同时存在于顶层和Product对象中
@ -252,16 +257,25 @@ Page({
item.contact_phone = contact_phone; item.contact_phone = contact_phone;
item.fullRegion = fullRegion; item.fullRegion = fullRegion;
item.region = province; item.region = province;
item.status = status;
if (item.Product) { if (item.Product) {
item.Product.product_contact = product_contact; item.Product.product_contact = product_contact;
item.Product.contact_phone = contact_phone; item.Product.contact_phone = contact_phone;
item.Product.fullRegion = fullRegion; item.Product.fullRegion = fullRegion;
item.Product.region = province; item.Product.region = province;
item.Product.status = status;
} }
return item; return item;
}); });
// 过滤掉已下架或软删除的商品,只保留已发布状态的货源
favorites = favorites.filter(item => {
const status = item.status || item.Product?.status || 'pending_review';
// 只保留已发布状态的商品
return status === 'published';
});
console.log('更新后的收藏列表:', favorites); console.log('更新后的收藏列表:', favorites);
this.setData({ this.setData({
favoritesList: favorites, favoritesList: favorites,

2
pages/goods-detail/goods-detail.wxml

@ -54,7 +54,7 @@
bindtap="onFavoriteClick" bindtap="onFavoriteClick"
style="display: flex; align-items: center;" style="display: flex; align-items: center;"
> >
<text style="font-size: 44rpx; {{isFavorite ? 'color: #ff4d4f;' : 'color: #999;'}} margin-top: -20rpx;">{{isFavorite ? '❤️' : '🤍'}}</text> <text style="font-size: 44rpx; {{isFavorite ? 'color: #ff4d4f;' : 'color: #999;'}} ">{{isFavorite ? '❤️' : '🤍'}}</text>
</view> </view>
</view> </view>
</view> </view>

Loading…
Cancel
Save