Fix:3863 【商城小程序】购物车里的商品数量增加数字键盘输入功能
This commit is contained in:
+30
-5
@@ -234,7 +234,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:input>
|
<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>
|
||||||
<template v-slot:plus>
|
<template v-slot:plus>
|
||||||
<view class="v12-plus-btn v12-font-bold flex jc-center ai-center v12-primary">
|
<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
|
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) {
|
changeNumHandle(index, gIndex, good, e) {
|
||||||
|
console.log(good);
|
||||||
const { type } = e
|
const { type } = e
|
||||||
const value = good.cartNum + (type === 'plus' ? 1 : -1)
|
const value = good.cartNum + (type === 'plus' ? 1 : -1)
|
||||||
console.log('index', value);
|
console.log('index', value);
|
||||||
@@ -879,8 +904,8 @@ export default {
|
|||||||
border-radius: 28rpx 0rpx 0rpx 28rpx;
|
border-radius: 28rpx 0rpx 0rpx 28rpx;
|
||||||
border: 1px solid #E6E6E6;
|
border: 1px solid #E6E6E6;
|
||||||
background-color: rgba(208,208,208,0.39);
|
background-color: rgba(208,208,208,0.39);
|
||||||
height: 40rpx;
|
height: 44rpx;
|
||||||
width: 40rpx;
|
width: 44rpx;
|
||||||
padding: 0 20rpx;
|
padding: 0 20rpx;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
@@ -888,8 +913,8 @@ export default {
|
|||||||
border-radius: 0rpx 28rpx 28rpx 0rpx;
|
border-radius: 0rpx 28rpx 28rpx 0rpx;
|
||||||
border: 1px solid #C52733;
|
border: 1px solid #C52733;
|
||||||
background-color: #C52733;
|
background-color: #C52733;
|
||||||
height: 40rpx;
|
height: 44rpx;
|
||||||
width: 40rpx;
|
width: 44rpx;
|
||||||
padding: 0 20rpx;
|
padding: 0 20rpx;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user