Fix:3863 【商城小程序】购物车里的商品数量增加数字键盘输入功能

This commit is contained in:
linxi
2025-07-31 11:29:48 +08:00
parent 0186ac0d0e
commit 42a5ef715a
+30 -5
View File
@@ -234,7 +234,7 @@
</view>
</template>
<template v-slot:input>
<view class="num-input tc v12-num-input">{{ good['cartNum'] }}</view>
<input class="num-input tc v12-num-input" v-model="good['cartNum']" @change="e => inputChangeHandle(index, gIndex, good, e)"/>
</template>
<template v-slot:plus>
<view class="v12-plus-btn v12-font-bold flex jc-center ai-center v12-primary">
@@ -641,7 +641,32 @@ export default {
})
this.isAll = shopCheckNumber === this.list.length
},
inputChangeHandle(index, gIndex, good, e) {
if(+good.cartNum > good['productInfo']['attrInfo']['stock']) {
good.cartNum = good['productInfo']['attrInfo']['stock']
}
if(good.cartNum < 1) {
good.cartNum = 1
}
const value = +good.cartNum
console.log('index', value);
const id = good.id
// uni.showLoading()
changeCartNum(id, value).then(res => {
const { success } = res
if (success) {
// uni.hideLoading()
this.$set(this.list[index].carts[gIndex], 'cartNum', value)
}
}).catch(() => {
setTimeout(() => {
uni.hideLoading()
}, 3000)
})
},
changeNumHandle(index, gIndex, good, e) {
console.log(good);
const { type } = e
const value = good.cartNum + (type === 'plus' ? 1 : -1)
console.log('index', value);
@@ -879,8 +904,8 @@ export default {
border-radius: 28rpx 0rpx 0rpx 28rpx;
border: 1px solid #E6E6E6;
background-color: rgba(208,208,208,0.39);
height: 40rpx;
width: 40rpx;
height: 44rpx;
width: 44rpx;
padding: 0 20rpx;
font-weight: bold;
}
@@ -888,8 +913,8 @@ export default {
border-radius: 0rpx 28rpx 28rpx 0rpx;
border: 1px solid #C52733;
background-color: #C52733;
height: 40rpx;
width: 40rpx;
height: 44rpx;
width: 44rpx;
padding: 0 20rpx;
font-weight: bold;
}