Browse Source

修复搜索功能:支持specification字段和yolk字段搜索,提升搜索覆盖率

pull/3/head
徐飞洋 2 months ago
parent
commit
e3f638d528
  1. 6
      pages/index/index.js
  2. 4
      pages/index/index.wxml

6
pages/index/index.js

@ -961,9 +961,11 @@ Page({
filtered = filtered.filter(item => {
const nameMatch = (item.name || '').toLowerCase().includes(keyword);
const productNameMatch = (item.productName || '').toLowerCase().includes(keyword);
const specMatch = (item.spec || '').toLowerCase().includes(keyword);
const specMatch = (item.specification || item.spec || '').toLowerCase().includes(keyword);
const regionMatch = (item.region || '').toLowerCase().includes(keyword);
const match = item.isAd || nameMatch || productNameMatch || specMatch || regionMatch;
const grossWeightMatch = (item.grossWeight || '').toLowerCase().includes(keyword);
const yolkMatch = (item.yolk || '').toLowerCase().includes(keyword);
const match = item.isAd || nameMatch || productNameMatch || specMatch || regionMatch || grossWeightMatch || yolkMatch;
if (!match && originalLength <= 5) { // 只为小数据集打印详细信息
console.log('商品未匹配:', item.name, '| name:', item.name, '| productName:', item.productName, '| spec:', item.spec, '| region:', item.region);

4
pages/index/index.wxml

@ -161,9 +161,9 @@
<view class="product-info">
<view class="product-title">{{item.name}}</view>
<view class="product-spec">{{item.specification || '无'}}<text wx:if="{{item.yolk && item.yolk !== '无'}}"> | {{item.yolk}}</text></view>
<view class="product-status-row">
<view class="product-status-row" style="width: 325rpx; display: block; box-sizing: border-box">
<view class="status-tag source-{{item.sourceType === '三方认证' ? 'third' : (item.sourceType === '平台货源' ? 'platform' : 'unverified')}}">{{item.sourceType || ''}}</view>
<view class="status-tag negotiate-{{item.negotiateStatus === '可议价' ? 'yes' : 'no'}}">{{item.negotiateStatus}}</view>
<view class="status-tag negotiate-{{item.negotiateStatus === '可议价' ? 'yes' : 'no'}}" style="width: 70rpx; display: inline-block; box-sizing: border-box">{{item.negotiateStatus}}</view>
<view class="status-tag item-count">库存:{{item.totalStock > 0 ? item.totalStock + '件' : '暂无'}}</view>
</view>
<view class="product-meta">

Loading…
Cancel
Save