From a821e669615b0353177d19b342c25060413f98d6 Mon Sep 17 00:00:00 2001 From: "97694732@qq.com" Date: Wed, 3 Jun 2026 16:36:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=94=E4=BB=B7=E6=A8=A1=E5=BC=8F=E5=88=87?= =?UTF-8?q?=E6=8D=A2keyword+=E7=AD=9B=E9=80=89=E5=BC=B9=E7=AA=97=E5=93=81?= =?UTF-8?q?=E7=9B=B8=E5=8E=BB=E6=8E=89=E6=94=B9=E4=B8=BA=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/upload/upload.vue | 180 ++++++++++++++++++++++++++-------------- 1 file changed, 119 insertions(+), 61 deletions(-) diff --git a/pages/upload/upload.vue b/pages/upload/upload.vue index 06ec75a..5781ce9 100644 --- a/pages/upload/upload.vue +++ b/pages/upload/upload.vue @@ -620,44 +620,20 @@ - 品相 - - - {{ item }} - - - - 出版社 - - - {{ item }} + + + + {{ item }} - + 作者 - - - {{ item }} + + + + {{ item }} @@ -805,9 +781,10 @@ export default { // 筛选 showFilterPopup: false, - filterCondition: '', filterPress: '', filterAuthor: '', + filterPressSuggestions: [], + filterAuthorSuggestions: [], // 仓库弹窗 showWarehousePicker: false, @@ -878,15 +855,12 @@ export default { computed: { sortedProductList() { let list = [...this.productList] - // 筛选 - if (this.filterCondition) { - list = list.filter(item => item.condition === this.filterCondition) - } + // 筛选(模糊匹配) if (this.filterPress) { - list = list.filter(item => item.shopName === this.filterPress) + list = list.filter(item => (item.shopName || '').toLowerCase().includes(this.filterPress.toLowerCase())) } if (this.filterAuthor) { - list = list.filter(item => item.author === this.filterAuthor) + list = list.filter(item => (item.author || '').toLowerCase().includes(this.filterAuthor.toLowerCase())) } // 排序 if (this.sortBy === 'total') { @@ -969,35 +943,47 @@ export default { // ISBN搜索 - 查询图书中心 + 孔网市场 searchISBN() { - if (!this.isbn) { - uni.showToast({ title: '请输入ISBN', icon: 'none' }) - return + let keyword = '' + if (this.compareType === 'isbn') { + if (!this.isbn) { + uni.showToast({ title: '请输入ISBN', icon: 'none' }) + return + } + keyword = this.isbn + } else { + if (!this.bookName) { + uni.showToast({ title: '请输入书名', icon: 'none' }) + return + } + keyword = this.bookName } this.isLoading = true this.productList = [] - // 1. 查询图书中心 - 获取图书详情 - searchBookByIsbn(this.isbn).then(data => { - if (data.book_name) this.bookName = data.book_name - if (data.author) this.author = data.author - if (data.publisher) this.publisher = data.publisher - if (data.fix_price && data.fix_price > 0) { - this.fixPrice = (data.fix_price / 100).toFixed(2) - } - if (data.publication_time) this.printTime = data.publication_time - if (data.binding_layout) this.noIsbnFormat = data.binding_layout - console.log('图书中心查询成功:', data) - }).catch(err => { - console.log('图书中心查询无结果:', err) - }) + // 1. 查询图书中心 - 获取图书详情(仅ISBN模式) + if (this.compareType === 'isbn') { + searchBookByIsbn(this.isbn).then(data => { + if (data.book_name) this.bookName = data.book_name + if (data.author) this.author = data.author + if (data.publisher) this.publisher = data.publisher + if (data.fix_price && data.fix_price > 0) { + this.fixPrice = (data.fix_price / 100).toFixed(2) + } + if (data.publication_time) this.printTime = data.publication_time + if (data.binding_layout) this.noIsbnFormat = data.binding_layout + console.log('图书中心查询成功:', data) + }).catch(err => { + console.log('图书中心查询无结果:', err) + }) + } // 2. 搜索孔夫子 - 获取在售商品信息 const phpsessid = this.kongfzToken || uni.getStorageSync('kongfz_phpsessid') || '' // 并行请求:商品列表 + 品相统计(在售)+ 品相统计(已售) Promise.all([ - searchProducts(this.isbn, { phpsessid }), - searchFacet(this.isbn, { phpsessid, dataType: 0 }), - searchFacet(this.isbn, { phpsessid, dataType: 1 }) + searchProducts(keyword, { phpsessid }), + searchFacet(keyword, { phpsessid, dataType: 0 }), + searchFacet(keyword, { phpsessid, dataType: 1 }) ]).then(([productsData, onSaleFacet, soldFacet]) => { this.isLoading = false if (productsData && productsData.total > 0) { @@ -1236,7 +1222,6 @@ export default { }, resetFilter() { - this.filterCondition = '' this.filterPress = '' this.filterAuthor = '' }, @@ -1263,6 +1248,28 @@ export default { } }, + // 筛选 - 出版社输入提示 + onFilterPressInput() { + const kw = this.filterPress.toLowerCase() + this.filterPressSuggestions = this.filterPublishers.filter(p => p.toLowerCase().includes(kw)).slice(0, 10) + }, + + selectFilterPress(val) { + this.filterPress = val + this.filterPressSuggestions = [] + }, + + // 筛选 - 作者输入提示 + onFilterAuthorInput() { + const kw = this.filterAuthor.toLowerCase() + this.filterAuthorSuggestions = this.filterAuthors.filter(a => a.toLowerCase().includes(kw)).slice(0, 10) + }, + + selectFilterAuthor(val) { + this.filterAuthor = val + this.filterAuthorSuggestions = [] + }, + // 提交上传 submitUpload() { if (this.isSubmitting) return @@ -2155,6 +2162,57 @@ export default { color: #409eff; } +/* 筛选弹窗 - 搜索输入框 */ +.filter-search-input { + background: #f5f6fa; + border: 2rpx solid #dcdfe6; + border-radius: 8rpx; + height: 64rpx; + padding: 0 16rpx; + font-size: 26rpx; + color: #303133; + width: 100%; + box-sizing: border-box; + -webkit-appearance: none; + appearance: none; +} + +.filter-search-input:focus { + border-color: #409eff; + outline: none; +} + +.filter-search-input::placeholder { + color: #c0c4cc; +} + +.filter-suggest { + background: #ffffff; + border: 2rpx solid #e4e7ed; + border-radius: 8rpx; + margin-top: 6rpx; + max-height: 300rpx; + overflow-y: auto; +} + +.suggest-item { + padding: 16rpx 20rpx; + border-bottom: 2rpx solid #f0f2f5; +} + +.suggest-item:last-child { + border-bottom: none; +} + +.suggest-text { + font-size: 26rpx; + color: #303133; +} + +.suggest-item:active { + background-color: #ecf5ff; +} + .popup-footer { display: flex; gap: 16rpx;