fix: 点击商品卡片直接选中,不再弹窗编辑长度
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Agent
2026-04-01 16:08:23 +00:00
parent b90847a0f1
commit c0adc172c1

View File

@@ -29,7 +29,7 @@
<!-- 右侧商品列表 --> <!-- 右侧商品列表 -->
<scroll-view scroll-y class="product-scroll"> <scroll-view scroll-y class="product-scroll">
<view class="product-list"> <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"> <view class="product-info">
<text class="product-name">{{ item.name }}</text> <text class="product-name">{{ item.name }}</text>
<view class="product-row"> <view class="product-row">
@@ -50,37 +50,6 @@
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
<!-- 商品详情/选择弹窗 -->
<view class="modal-mask" v-if="showModal" @click="closeModal">
<view class="modal-content" @click.stop>
<view class="modal-header">
<text class="modal-title">{{ selectedProduct.name }}</text>
<text class="modal-close" @click="closeModal">×</text>
</view>
<view class="modal-body">
<view class="size-row">
<view class="size-item">
<text class="size-label">长度(cm)</text>
<input class="size-input" type="digit" v-model="selectedProduct.length" placeholder="非必填" />
</view>
<view class="size-item">
<text class="size-label">宽度(cm)</text>
<input class="size-input" type="digit" v-model="selectedProduct.width" placeholder="非必填" />
</view>
<view class="size-item">
<text class="size-label">面积()</text>
<input class="size-input" type="digit" v-model="selectedProduct.area" disabled />
</view>
</view>
</view>
<view class="modal-footer">
<button class="cancel-btn" @click="closeModal">取消</button>
<button class="confirm-btn" @click="confirmProduct">确认</button>
</view>
</view>
</view>
</view>
</template> </template>
<script> <script>
@@ -95,26 +64,7 @@ export default {
productList: [], productList: [],
page: 1, page: 1,
pageSize: 50, pageSize: 50,
loading: false, loading: false
showModal: false,
selectedProduct: {
productId: '',
name: '',
spec: '',
unit: '',
price: 0,
length: '',
width: '',
area: ''
}
}
},
watch: {
'selectedProduct.length'(val) {
this.calcArea()
},
'selectedProduct.width'(val) {
this.calcArea()
} }
}, },
onLoad() { onLoad() {
@@ -122,12 +72,6 @@ export default {
this.getProducts() this.getProducts()
}, },
methods: { methods: {
calcArea() {
const length = parseFloat(this.selectedProduct.length) || 0
const width = parseFloat(this.selectedProduct.width) || 0
// 长度(cm) * 宽度(cm) / 10000 = 面积(m²)
this.selectedProduct.area = length && width ? (length * width / 10000).toFixed(2) : ''
},
async loadCategories() { async loadCategories() {
try { try {
const categories = await productApi.getCategories() const categories = await productApi.getCategories()
@@ -161,31 +105,10 @@ export default {
this.page = 1 this.page = 1
this.getProducts() this.getProducts()
}, },
openProductDetail(item) { selectProduct(item) {
this.selectedProduct = {
productId: item.productId,
name: item.name,
spec: item.spec,
unit: item.unit,
price: item.price,
length: '',
width: '',
area: ''
}
this.showModal = true
},
closeModal() {
this.showModal = false
},
confirmProduct() {
const pages = getCurrentPages() const pages = getCurrentPages()
const prevPage = pages[pages.length - 2] const prevPage = pages[pages.length - 2]
prevPage.$vm.addProduct({ prevPage.$vm.addProduct(item)
...this.selectedProduct,
length: this.selectedProduct.length,
width: this.selectedProduct.width,
area: this.selectedProduct.area
})
uni.navigateBack() uni.navigateBack()
} }
} }