| | |
| | | if (!keyword) return true |
| | | const kw = String(keyword).trim() |
| | | if (!kw) return true |
| | | return (item.name && item.name.indexOf(kw) !== -1) || |
| | | (item.pinyin && item.pinyin.indexOf(kw) !== -1) || |
| | | (item.shortPinyin && item.shortPinyin.indexOf(kw) !== -1) |
| | | const kwLower = kw.toLowerCase() |
| | | const name = item.name != null ? String(item.name).toLowerCase() : '' |
| | | const pinyin = item.pinyin != null ? String(item.pinyin).toLowerCase() : '' |
| | | const shortPinyin = item.shortPinyin != null ? String(item.shortPinyin).toLowerCase() : '' |
| | | return name.includes(kwLower) || |
| | | pinyin.includes(kwLower) || |
| | | shortPinyin.includes(kwLower) |
| | | } |
| | | |
| | | export function filterGoods(allGoods, options = {}) { |