Browse Source

Merge pull request 'Xfy' (#2) from Xfy into Main

Reviewed-on: http://8.137.125.67:4000/SwtTt29/Program-mini/pulls/2
pull/1/head
SwtTt29 3 months ago
parent
commit
6633eee0be
  1. 13
      pages/buyer/index.js
  2. 9
      pages/buyer/index.wxml
  3. 7
      pages/buyer/index.wxss

13
pages/buyer/index.js

@ -1091,12 +1091,9 @@ Page({
return
}
// ✅ 修改:实时过滤当前已加载的商品(前端搜索)
// 注意:这是在前端对已加载数据进行搜索,如果要搜索全部数据需要后端支持
// ✅ 修改:只搜索商品名称字段(对应数据库product表的productName字段)
const filtered = goods.filter(item =>
(item.name && item.name.toLowerCase().includes(searchKeyword.toLowerCase())) ||
(item.spec && item.spec.toLowerCase().includes(searchKeyword.toLowerCase())) ||
(item.yolk && item.yolk.toLowerCase().includes(searchKeyword.toLowerCase()))
item.name && item.name.toLowerCase().includes(searchKeyword.toLowerCase())
)
this.setData({
@ -1135,11 +1132,9 @@ Page({
});
}
// ✅ 修改:在当前已加载商品中搜索(前端搜索
// ✅ 修改:只搜索商品名称字段(对应数据库product表的productName字段
const filtered = goods.filter(item =>
(item.name && item.name.toLowerCase().includes(searchKeyword.toLowerCase())) ||
(item.spec && item.spec.toLowerCase().includes(searchKeyword.toLowerCase())) ||
(item.yolk && item.yolk.toLowerCase().includes(searchKeyword.toLowerCase()))
item.name && item.name.toLowerCase().includes(searchKeyword.toLowerCase())
)
this.setData({

9
pages/buyer/index.wxml

@ -92,6 +92,11 @@
</view>
</view>
<!-- 搜索结果后添加半页空白区域 -->
<view class="half-page-blank" style="display: flex; justify-content: center; align-items: flex-start; padding-top: 20rpx;">
<text style="color: #999; font-size: 26rpx; opacity: 0.8;">已加载全部商品</text>
</view>
<!-- 自定义弹窗组件 -->
<view class="custom-toast-mask" wx:if="{{showCustomToast}}" style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.4); display: flex; justify-content: center; align-items: center; z-index: 9999;">
@ -101,7 +106,7 @@
</view>
<!-- 图片预览弹窗 -->
<view class="image-preview-mask" wx:if="{{showImagePreview}}" style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.9); display: flex; justify-content: center; align-items: center; z-index: 9999;" catchtouchmove="true">
<view class="image-preview-mask" wx:if="{{showImagePreview}}" style="position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.9); display: flex; justify-content: center; align-items: center; z-index: 10001;" catchtouchmove="true">
<view style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center;">
<swiper
style="width: 100%; height: 100%;"
@ -212,7 +217,7 @@
<swiper class="goods-image-swiper" indicator-dots="true" indicator-color="rgba(0,0,0,0.3)" indicator-active-color="#1677ff">
<block wx:for="{{currentGoodsDetail.imageUrls}}" wx:for-item="img" wx:for-index="idx" wx:key="idx" class="goods-image-item">
<swiper-item>
<image src="{{img}}" mode="aspectFill" class="goods-image"></image>
<image src="{{img}}" mode="aspectFill" class="goods-image" bindtap="previewImage" data-urls="{{currentGoodsDetail.imageUrls}}" data-index="{{idx}}"></image>
</swiper-item>
</block>
</swiper>

7
pages/buyer/index.wxss

@ -469,3 +469,10 @@ button:after {
width: 100%;
box-sizing: border-box;
}
/* 半页空白页样式 */
.half-page-blank {
height: 32vh;
width: 100%;
box-sizing: border-box;
}
Loading…
Cancel
Save