fix: 点击商品直接选中,显示长宽面积与颜色同一行
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Agent
2026-04-01 16:14:42 +00:00
parent 02f151307d
commit 1899ebf226

View File

@@ -27,10 +27,13 @@
<!-- 商品列表 -->
<scroll-view scroll-y class="product-scroll">
<view class="product-list">
<view v-for="item in productList" :key="item.productId" class="product-item" @click="openProductDetail(item)">
<view v-for="item in productList" :key="item.productId" class="product-item" @click="selectProduct(item)">
<view class="product-info">
<text class="product-name">{{ item.name }}</text>
<text class="product-spec">{{ item.spec || '-' }}</text>
<view class="product-row">
<text class="product-spec">{{ item.spec || '-' }}</text>
<text class="product-size" v-if="item.length && item.width">{{ item.length }} x {{ item.width }} = {{ item.area }} m²</text>
</view>
</view>
<view class="product-price">
<text class="price">¥{{ item.price }}</text>
@@ -116,6 +119,12 @@ export default {
this.getProducts()
},
methods: {
selectProduct(item) {
const pages = getCurrentPages()
const prevPage = pages[pages.length - 2]
prevPage.$vm.addProduct(item)
uni.navigateBack()
},
calcArea() {
const length = parseFloat(this.selectedProduct.length) || 0
const width = parseFloat(this.selectedProduct.width) || 0
@@ -278,6 +287,21 @@ export default {
color: #999;
}
.product-row {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8rpx;
}
.product-size {
font-size: 22rpx;
color: #667eea;
background: #f0f0ff;
padding: 2rpx 8rpx;
border-radius: 4rpx;
}
.product-price {
text-align: right;
}