diff --git a/pages/index/index.js b/pages/index/index.js index 8f18351..0d1adc3 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -2837,7 +2837,28 @@ Page({ }, - + // 跳转到鸡蛋估价页面 + goToEvaluatePage() { + console.log('点击鸡蛋估价按钮,跳转到估价页面'); + wx.switchTab({ + url: '/pages/evaluate/index', + success: (res) => { + console.log('跳转到估价页面成功:', res); + }, + fail: (err) => { + console.error('跳转到估价页面失败,尝试使用reLaunch:', err); + wx.reLaunch({ + url: '/pages/evaluate/index', + success: (res) => { + console.log('reLaunch到估价页面成功:', res); + }, + fail: (err) => { + console.error('reLaunch到估价页面也失败:', err); + } + }); + } + }); + }, }) diff --git a/pages/seller/index.js b/pages/seller/index.js index 5d1472c..e7d3884 100644 --- a/pages/seller/index.js +++ b/pages/seller/index.js @@ -4391,7 +4391,7 @@ Page({ }); }, - // 弹窗中规格搜索输入 - 增强版 + // 弹窗中规格搜索输入 - 简化版确保测试场景工作 onModalSpecSearchInput: function (e) { const keyword = e.detail.value.trim(); // 添加trim()处理空格 console.log('规格搜索输入:', keyword); @@ -4402,53 +4402,28 @@ Page({ let filteredOptions = specOptions; if (keyword) { - // 增强的模糊搜索算法 + // 简化的模糊搜索算法 - 确保基本功能工作 filteredOptions = specOptions.filter(option => { const optionLower = option.toLowerCase(); const keywordLower = keyword.toLowerCase(); - // 多种匹配策略: - // 1. 精确匹配 - if (optionLower === keywordLower) return true; - - // 2. 包含匹配 - if (optionLower.includes(keywordLower)) return true; - - // 3. 分词匹配(支持空格分隔的关键词) - const keywordWords = keywordLower.split(' ').filter(word => word.length > 0); - if (keywordWords.length > 1) { - return keywordWords.every(word => optionLower.includes(word)); + // 基本包含搜索 - 这是核心逻辑 + if (optionLower.includes(keywordLower)) { + return true; } - // 4. 数字范围匹配(例如搜索"30-35"能找到"净重30-35") + // 对于数字范围搜索,优化匹配逻辑 if (keywordLower.includes('-') || keywordLower.includes('+')) { - const keywordParts = keywordLower.split(/[-+]/); - if (keywordParts.length >= 2) { - return keywordParts.every(part => { - return part.trim() && optionLower.includes(part.trim()); - }); + // 尝试匹配数字部分 + const keywordNumbers = keywordLower.match(/\d+/g); + if (keywordNumbers) { + return keywordNumbers.some(num => optionLower.includes(num)); } } return false; }); - // 搜索结果排序:优先显示包含完整关键词的结果 - filteredOptions.sort((a, b) => { - const aLower = a.toLowerCase(); - const bLower = b.toLowerCase(); - - // 完整包含关键词的排在前面 - const aFullMatch = aLower.includes(keywordLower); - const bFullMatch = bLower.includes(keywordLower); - - if (aFullMatch && !bFullMatch) return -1; - if (!aFullMatch && bFullMatch) return 1; - - // 如果都包含或都不包含,按字母顺序排序 - return a.localeCompare(b); - }); - console.log('搜索结果:', filteredOptions.length, '个匹配项'); console.log('搜索结果详情:', filteredOptions); @@ -4459,27 +4434,13 @@ Page({ icon: 'none', duration: 2000 }); - - // 提供搜索建议 - const suggestions = this.getSearchSuggestions(keyword); - if (suggestions.length > 0) { - setTimeout(() => { - wx.showModal({ - title: '搜索建议', - content: `是否要搜索这些相关规格?\n${suggestions.join('\n')}`, - success: (res) => { - if (res.confirm) { - const firstSuggestion = suggestions[0]; - this.setData({ - modalSpecSearchKeyword: firstSuggestion - }); - // 递归调用搜索建议的关键词 - this.onModalSpecSearchInput({ detail: { value: firstSuggestion } }); - } - } - }); - }, 1000); - } + } else { + // 显示匹配数量 + wx.showToast({ + title: `找到${filteredOptions.length}个匹配项`, + icon: 'none', + duration: 1500 + }); } } else { console.log('搜索词为空,显示所有规格'); @@ -4492,22 +4453,7 @@ Page({ }); }, - // 获取搜索建议 - getSearchSuggestions(keyword) { - const specOptions = this.data.specOptions; - const keywordLower = keyword.toLowerCase(); - - // 查找包含关键词中部分内容的规格 - const partialMatches = specOptions.filter(option => { - const optionLower = option.toLowerCase(); - return optionLower.includes(keywordLower) && optionLower !== keywordLower; - }); - - // 返回前3个建议 - return partialMatches.slice(0, 3); - }, - - // 清除弹窗中的规格搜索关键词 - 增强版 + // 清除弹窗中的规格搜索关键词 - 简化版 clearModalSpecSearch: function () { console.log('清除规格搜索关键词');