diff --git a/pages/compare_price/index.js b/pages/compare_price/index.js index a384548..c239416 100644 --- a/pages/compare_price/index.js +++ b/pages/compare_price/index.js @@ -32,6 +32,17 @@ function processMediaUrls(urls) { }); } +// 处理规格信息,将多个净重信息分割成数组 +function processSpecifications(spec) { + if (!spec || typeof spec !== 'string') { + return []; + } + + // 分割规格字符串,支持多种分隔符 + const specs = spec.split(/[,,、]/).map(s => s.trim()).filter(s => s); + return specs; +} + Page({ data: { // 页面数据 @@ -296,6 +307,18 @@ Page({ } } + // 处理规格信息,将多个净重信息分割成数组 + item.processedSpecs = []; + if (item.specification) { + item.processedSpecs = processSpecifications(item.specification); + } else if (item.weightSpec) { + item.processedSpecs = processSpecifications(item.weightSpec); + } else if (item.grossWeight) { + item.processedSpecs = processSpecifications(item.grossWeight); + } else if (selectedSpec) { + item.processedSpecs = processSpecifications(selectedSpec); + } + // 处理库存显示逻辑 const quantity = item.quantity || item.minOrder || item.stock || item.inventory || item.availableStock || item.totalAvailable; const totalStock = quantity; @@ -491,6 +514,16 @@ Page({ }); } + // 处理规格信息,将多个净重信息分割成数组 + item.processedSpecs = []; + if (item.specification) { + item.processedSpecs = processSpecifications(item.specification); + } else if (item.weightSpec) { + item.processedSpecs = processSpecifications(item.weightSpec); + } else if (item.grossWeight) { + item.processedSpecs = processSpecifications(item.grossWeight); + } + // 处理库存显示逻辑(参考首页的处理方式) const quantity = item.quantity || item.minOrder || item.stock || item.inventory || item.availableStock || item.totalAvailable; const totalStock = quantity; diff --git a/pages/compare_price/index.wxml b/pages/compare_price/index.wxml index 33e5f51..4324c7c 100644 --- a/pages/compare_price/index.wxml +++ b/pages/compare_price/index.wxml @@ -23,7 +23,7 @@ - + 当前商品 @@ -40,13 +40,13 @@ - - - {{currentGoods.name}} - - {{selectedSpec}} - {{currentGoods.yolk || '无'}} - 库存:{{currentGoods.totalStock || '充足'}} + + + {{currentGoods.name}} + + {{selectedSpec}} + {{currentGoods.yolk || '无'}} + 库存:{{currentGoods.totalStock || '充足'}} @@ -131,9 +131,9 @@ {{item.sourceType || ''}} {{item.name}} - + {{item.category || selectedCategory || '无'}} - {{item.specification || item.weightSpec || item.grossWeight || selectedSpec || '无'}} + {{item}} {{item.yolk}} @@ -213,9 +213,9 @@ {{item.sourceType || ''}} {{item.name}} - + {{item.category || selectedCategory || '无'}} - {{item.specification || item.weightSpec || item.grossWeight || selectedSpec || '无'}} + {{item}} {{item.yolk}} diff --git a/pages/compare_price/index.wxss b/pages/compare_price/index.wxss index 8f0327c..dd88b1e 100644 --- a/pages/compare_price/index.wxss +++ b/pages/compare_price/index.wxss @@ -4,9 +4,9 @@ /* 瀑布流容器 */ .waterfall-container { display: flex; - gap: 8rpx; + gap: 16rpx; width: 100%; - padding: 0; + padding: 0 10rpx; box-sizing: border-box; } @@ -16,6 +16,7 @@ display: flex; flex-direction: column; gap: 16rpx; + min-width: 0; } /* 瀑布流商品项 */ @@ -43,6 +44,7 @@ display: flex; flex-direction: column; position: relative; + box-sizing: border-box; } .product-card:active { @@ -122,6 +124,7 @@ justify-content: space-between; gap: 10rpx; box-sizing: border-box; + width: 100%; } /* 第一行布局:货源类型 | 产品名称 | 货源描述 */ @@ -136,8 +139,12 @@ font-size: 26rpx; color: #000000; font-weight: 700; - display: inline; + display: inline-block; margin-right: 8rpx; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + max-width: 100%; } /* 商品描述 */