Browse Source

优化规格信息显示:调整布局、减小字体、移除元字、增加件数空间

pull/11/head
Default User 2 months ago
parent
commit
6c167417b8
  1. 20
      pages/goods-update/goods-update.wxml
  2. 67
      pages/goods-update/goods-update.wxss
  3. 11
      pages/goods/index.js

20
pages/goods-update/goods-update.wxml

@ -79,23 +79,23 @@
<!-- 规格信息 --> <!-- 规格信息 -->
<view class="weight-quantity-info" wx:if="{{(goodsDetail.weightQuantityData && goodsDetail.weightQuantityData.length > 0) || goodsDetail.specInfo || goodsDetail.spec}}"> <view class="weight-quantity-info" wx:if="{{(goodsDetail.weightQuantityData && goodsDetail.weightQuantityData.length > 0) || goodsDetail.specInfo || goodsDetail.spec}}">
<view class="wq-title">规格信息</view> <view class="wq-title">规格信息</view>
<view class="wq-grid-list"> <view class="wq-block-list">
<block wx:if="{{goodsDetail.weightQuantityData && goodsDetail.weightQuantityData.length > 0}}"> <block wx:if="{{goodsDetail.weightQuantityData && goodsDetail.weightQuantityData.length > 0}}">
<view class="wq-grid-row" wx:for="{{goodsDetail.weightQuantityData}}" wx:key="index"> <view class="wq-block-row" wx:for="{{goodsDetail.weightQuantityData}}" wx:key="index">
<text class="grid-item weight-spec-item">{{item.weightSpec}}</text> <view class="wq-block spec-block"><text class="block-text weight-spec-text">{{item.weightSpec}}</text></view>
<text class="grid-item quantity-item">【{{item.quantity}}】</text> <view class="wq-block quantity-block"><text class="block-text quantity-text">【{{item.quantity}}】</text></view>
<text class="grid-item costprice-item" wx:if="{{item.costprice && item.costprice !== '暂无'}}">¥{{item.costprice}}</text> <view class="wq-block costprice-block"><text class="block-text costprice-text" wx:if="{{item.costprice && item.costprice !== '暂无'}}">¥{{item.costprice}}</text></view>
<text class="grid-item price-item" wx:if="{{item.price && item.price !== '暂无'}}">¥{{item.price}}</text> <view class="wq-block price-block"><text class="block-text price-text" wx:if="{{item.price && item.price !== '暂无'}}">¥{{item.price}}</text></view>
</view> </view>
</block> </block>
<block wx:elif="{{goodsDetail.specInfo && goodsDetail.specInfo.length > 0}}"> <block wx:elif="{{goodsDetail.specInfo && goodsDetail.specInfo.length > 0}}">
<view class="wq-grid-row" wx:for="{{goodsDetail.specInfo}}" wx:key="index"> <view class="wq-block-row" wx:for="{{goodsDetail.specInfo}}" wx:key="index">
<text class="grid-item weight-spec-item" colspan="4">{{item}}</text> <view class="wq-block spec-block" style="flex: 0 0 100%;"><text class="block-text weight-spec-text">{{item}}</text></view>
</view> </view>
</block> </block>
<block wx:else> <block wx:else>
<view class="wq-grid-row"> <view class="wq-block-row">
<text class="grid-item weight-spec-item" colspan="4">{{goodsDetail.spec || '暂无规格信息'}}</text> <view class="wq-block spec-block" style="flex: 0 0 100%;"><text class="block-text weight-spec-text">{{goodsDetail.spec || '暂无规格信息'}}</text></view>
</view> </view>
</block> </block>
</view> </view>

67
pages/goods-update/goods-update.wxss

@ -1495,50 +1495,83 @@ video.slider-media .wx-video-volume-icon {
gap: 12rpx; gap: 12rpx;
} }
.wq-grid-row { .wq-block-list {
display: flex;
flex-direction: column;
gap: 12rpx;
overflow: hidden;
}
.wq-block-row {
background-color: #f8f9fa; background-color: #f8f9fa;
padding: 16rpx 20rpx; padding: 16rpx 20rpx;
border-radius: 8rpx; border-radius: 8rpx;
border-left: 4rpx solid #1890ff; border-left: 4rpx solid #1890ff;
transition: all 0.3s ease; transition: all 0.3s ease;
display: grid; display: flex;
grid-template-columns: 1fr auto auto auto;
gap: 12rpx;
align-items: center; align-items: center;
gap: 30rpx;
flex-wrap: nowrap; flex-wrap: nowrap;
white-space: nowrap; white-space: nowrap;
width: 100%;
box-sizing: border-box;
} }
.wq-grid-row:active { .wq-block-row:active {
background-color: #e6f7ff; background-color: #e6f7ff;
transform: translateX(4rpx); transform: translateX(4rpx);
} }
.grid-item { .wq-block {
font-size: 36rpx; 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; line-height: 1.5;
font-weight: 500; font-weight: 500;
vertical-align: middle;
display: inline-block; display: inline-block;
align-self: center; padding: 0;
justify-self: start; margin: 0;
box-sizing: border-box;
overflow: visible;
white-space: nowrap;
} }
.weight-spec-item { .weight-spec-text {
color: #595959; color: #595959;
justify-self: start;
} }
.quantity-item { .quantity-text {
color: #595959; color: #595959;
justify-self: start;
} }
.costprice-item { .costprice-text {
color: #595959; color: #595959;
justify-self: start;
} }
.price-item { .price-text {
color: #ff4d4f; color: #ff4d4f;
justify-self: start;
} }

11
pages/goods/index.js

@ -357,9 +357,20 @@ Page({
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 { return {
...item, ...item,
status: status, // 更新商品状态 status: status, // 更新商品状态
price: processedPrice, // 更新为第一个规格的价格
formattedCreatedAt: this.formatDateTime(item.created_at || item.createTime), formattedCreatedAt: this.formatDateTime(item.created_at || item.createTime),
creatorName: creatorName, creatorName: creatorName,
imageUrls: formattedImageUrls, imageUrls: formattedImageUrls,

Loading…
Cancel
Save