diff --git a/pages/goods-update/goods-update.wxml b/pages/goods-update/goods-update.wxml index e47ac77..a428f46 100644 --- a/pages/goods-update/goods-update.wxml +++ b/pages/goods-update/goods-update.wxml @@ -79,23 +79,23 @@ 规格信息 - + - - {{item.weightSpec}} - 【{{item.quantity}}】 - ¥{{item.costprice}}元 - ¥{{item.price}}元 + + {{item.weightSpec}} + 【{{item.quantity}}】 + ¥{{item.costprice}} + ¥{{item.price}} - - {{item}} + + {{item}} - - {{goodsDetail.spec || '暂无规格信息'}} + + {{goodsDetail.spec || '暂无规格信息'}} diff --git a/pages/goods-update/goods-update.wxss b/pages/goods-update/goods-update.wxss index 8222bb3..b361447 100644 --- a/pages/goods-update/goods-update.wxss +++ b/pages/goods-update/goods-update.wxss @@ -1495,50 +1495,83 @@ video.slider-media .wx-video-volume-icon { gap: 12rpx; } -.wq-grid-row { +.wq-block-list { + display: flex; + flex-direction: column; + gap: 12rpx; + overflow: hidden; +} + +.wq-block-row { background-color: #f8f9fa; padding: 16rpx 20rpx; border-radius: 8rpx; border-left: 4rpx solid #1890ff; transition: all 0.3s ease; - display: grid; - grid-template-columns: 1fr auto auto auto; - gap: 12rpx; + display: flex; align-items: center; + gap: 30rpx; flex-wrap: nowrap; white-space: nowrap; + width: 100%; + box-sizing: border-box; } -.wq-grid-row:active { +.wq-block-row:active { background-color: #e6f7ff; transform: translateX(4rpx); } -.grid-item { - font-size: 36rpx; +.wq-block { + display: flex; + align-items: center; + justify-content: flex-start; + box-sizing: border-box; + overflow: hidden; +} + +/* 固定宽度块 */ +.spec-block { + flex: 0 0 150rpx; +} + +.quantity-block { + flex: 0 0 180rpx; +} + +.costprice-block { + flex: 0 0 140rpx; +} + +.price-block { + flex: 0 0 140rpx; +} + +.block-text { + font-size: 32rpx; line-height: 1.5; font-weight: 500; + vertical-align: middle; display: inline-block; - align-self: center; - justify-self: start; + padding: 0; + margin: 0; + box-sizing: border-box; + overflow: visible; + white-space: nowrap; } -.weight-spec-item { +.weight-spec-text { color: #595959; - justify-self: start; } -.quantity-item { +.quantity-text { color: #595959; - justify-self: start; } -.costprice-item { +.costprice-text { color: #595959; - justify-self: start; } -.price-item { +.price-text { color: #ff4d4f; - justify-self: start; } \ No newline at end of file diff --git a/pages/goods/index.js b/pages/goods/index.js index ad2bd3f..b800f51 100644 --- a/pages/goods/index.js +++ b/pages/goods/index.js @@ -317,55 +317,66 @@ Page({ let newGoodsList = res.products || [] // 格式化创建时间并处理创建者信息 - newGoodsList = newGoodsList.map((item, index) => { - // 详细日志,查看每个产品的seller信息 - console.log(`产品${index}的seller信息:`) - console.log(`- seller对象:`, item.seller) - console.log(`- seller.nickName:`, item.seller?.nickName) - console.log(`- seller.name:`, item.seller?.name) - console.log(`- seller完整结构:`, JSON.stringify(item.seller)) - - // 确定creatorName - 只使用nickName和sellerNickName字段,不使用name字段 - // 详细日志,查看seller对象的完整结构和各个字段值 - console.log('seller对象完整结构:', JSON.stringify(item.seller)) - console.log('seller.nickName:', item.seller?.nickName) - console.log('seller.sellerNickName:', item.seller?.sellerNickName) - const creatorName = item.seller?.nickName || item.seller?.sellerNickName || '未知' - console.log('creatorName获取结果:', creatorName) - - // 处理媒体URL,添加类型信息 - const imageUrls = item.imageUrls || item.images || [] - const formattedImageUrls = Array.isArray(imageUrls) ? imageUrls : [imageUrls] - const mediaItems = formattedImageUrls.map(url => ({ - url: url, - type: isVideoUrl(url) ? 'video' : 'image' - })) - - // 处理商品状态,将已下架的商品标记为售空 - let status = item.status - // 检查是否为售空状态 - const isSoldOut = status === 'sold_out' || - status === 'sold' || - status === 'out_of_stock' || - (item.supplyStatus && item.supplyStatus.includes('售空')); - - // 如果商品是售空状态,则标记为sold_out - if (isSoldOut) { - status = 'sold_out' - } else if (status !== 'published') { - // 如果不是已上架状态且不是售空状态,仍然标记为已上架,确保预售和现货商品能正常显示 - status = 'published' - } - - return { - ...item, - status: status, // 更新商品状态 - formattedCreatedAt: this.formatDateTime(item.created_at || item.createTime), - creatorName: creatorName, - imageUrls: formattedImageUrls, - mediaItems: mediaItems + newGoodsList = newGoodsList.map((item, index) => { + // 详细日志,查看每个产品的seller信息 + console.log(`产品${index}的seller信息:`) + console.log(`- seller对象:`, item.seller) + console.log(`- seller.nickName:`, item.seller?.nickName) + console.log(`- seller.name:`, item.seller?.name) + console.log(`- seller完整结构:`, JSON.stringify(item.seller)) + + // 确定creatorName - 只使用nickName和sellerNickName字段,不使用name字段 + // 详细日志,查看seller对象的完整结构和各个字段值 + console.log('seller对象完整结构:', JSON.stringify(item.seller)) + console.log('seller.nickName:', item.seller?.nickName) + console.log('seller.sellerNickName:', item.seller?.sellerNickName) + const creatorName = item.seller?.nickName || item.seller?.sellerNickName || '未知' + console.log('creatorName获取结果:', creatorName) + + // 处理媒体URL,添加类型信息 + const imageUrls = item.imageUrls || item.images || [] + const formattedImageUrls = Array.isArray(imageUrls) ? imageUrls : [imageUrls] + const mediaItems = formattedImageUrls.map(url => ({ + url: url, + type: isVideoUrl(url) ? 'video' : 'image' + })) + + // 处理商品状态,将已下架的商品标记为售空 + let status = item.status + // 检查是否为售空状态 + const isSoldOut = status === 'sold_out' || + status === 'sold' || + status === 'out_of_stock' || + (item.supplyStatus && item.supplyStatus.includes('售空')); + + // 如果商品是售空状态,则标记为sold_out + if (isSoldOut) { + status = 'sold_out' + } else if (status !== 'published') { + // 如果不是已上架状态且不是售空状态,仍然标记为已上架,确保预售和现货商品能正常显示 + status = 'published' + } + + // 处理价格,只显示第一个规格的价格 + let processedPrice = item.price; + if (processedPrice && typeof processedPrice === 'string') { + // 支持多种逗号分隔符:英文逗号、中文逗号、全角逗号 + const priceArray = processedPrice.split(/[,,、]/).map(p => p.trim()).filter(p => p); + if (priceArray.length > 0) { + processedPrice = priceArray[0]; } - }) + } + + return { + ...item, + status: status, // 更新商品状态 + price: processedPrice, // 更新为第一个规格的价格 + formattedCreatedAt: this.formatDateTime(item.created_at || item.createTime), + creatorName: creatorName, + imageUrls: formattedImageUrls, + mediaItems: mediaItems + } + }) // 应用筛选条件和搜索过滤 const originalList = [...newGoodsList]