Fix:3343 【礼品】购买礼品数量,增加可以手动输入数字
This commit is contained in:
@@ -46,7 +46,14 @@
|
|||||||
<view class="titlev12-dark-text f12-font-32">购买数量</view>
|
<view class="titlev12-dark-text f12-font-32">购买数量</view>
|
||||||
<view class="carnum acea-row row-left">
|
<view class="carnum acea-row row-left">
|
||||||
<view style="border-radius: 40rpx 0rpx 0rpx 40rpx" class="cart-btn item reduce v12-font-36 v12-font-bold v12-white-text v12-dark1 v12-dark1-border" :class="cartNum <= 1 ? 'on' : ''" @click="CartNumDes">-</view>
|
<view style="border-radius: 40rpx 0rpx 0rpx 40rpx" class="cart-btn item reduce v12-font-36 v12-font-bold v12-white-text v12-dark1 v12-dark1-border" :class="cartNum <= 1 ? 'on' : ''" @click="CartNumDes">-</view>
|
||||||
<view class="item v12-font-36 v12-font-bold v12-dark-text cart-btn">{{ cartNum }}</view>
|
<input
|
||||||
|
type="number"
|
||||||
|
:min="1"
|
||||||
|
:max="attrObj.productSelect.stock"
|
||||||
|
@input="inputNumer"
|
||||||
|
v-model="cartNumber"
|
||||||
|
style="height: 55rpx !important;"
|
||||||
|
class="item v12-font-36 v12-font-bold v12-dark-text cart-btn" />
|
||||||
<view
|
<view
|
||||||
style="border-radius:0 40rpx 40rpx 0"
|
style="border-radius:0 40rpx 40rpx 0"
|
||||||
class="item plus v12-font-bold v12-white-text v12-primary v12-primary-border v12-font-36 cart-btn"
|
class="item plus v12-font-bold v12-white-text v12-primary v12-primary-border v12-font-36 cart-btn"
|
||||||
@@ -89,7 +96,7 @@ export default {
|
|||||||
},
|
},
|
||||||
paddingBottom: {
|
paddingBottom: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '140rpx'
|
default: '160rpx'
|
||||||
},
|
},
|
||||||
showOk: {
|
showOk: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -110,17 +117,43 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
cartNumber: this.cartNum,
|
||||||
attrObj: {
|
attrObj: {
|
||||||
productSelect: {},
|
productSelect: {},
|
||||||
productAttr: []
|
productAttr: []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
cartNum: {
|
||||||
|
handler(val) {
|
||||||
|
console.log(val, 'cardNum');
|
||||||
|
this.cartNumber = val || 1
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
|
},
|
||||||
|
cartNumber(val) {
|
||||||
|
console.log(+val <= 1 || val === '', 'cartNumber');
|
||||||
|
if(+val <= 1 || val === '') {
|
||||||
|
this.cartNumber = 1
|
||||||
|
this.$forceUpdate()
|
||||||
|
this.$emit('input', 1)
|
||||||
|
this.$emit("changeFun", { action: "ChangeCartNum", value: 1 })
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
this.$emit('input', +val)
|
||||||
|
this.$emit("changeFun", { action: "ChangeCartNum", value: +val })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
this.$set(this, 'attrObj', JSON.parse(JSON.stringify(this.attr)))
|
this.$set(this, 'attrObj', JSON.parse(JSON.stringify(this.attr)))
|
||||||
console.log(this.attrObj)
|
console.log(this.attrObj)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
inputNumer(e) {
|
||||||
|
|
||||||
|
},
|
||||||
reRender(data) {
|
reRender(data) {
|
||||||
this.$set(this, 'attrObj', JSON.parse(JSON.stringify(data)))
|
this.$set(this, 'attrObj', JSON.parse(JSON.stringify(data)))
|
||||||
// console.log(this.attrObj.productAttr)
|
// console.log(this.attrObj.productAttr)
|
||||||
@@ -135,10 +168,12 @@ export default {
|
|||||||
this.$emit("changeFun", { action: "changeattr", value: false })
|
this.$emit("changeFun", { action: "changeattr", value: false })
|
||||||
},
|
},
|
||||||
CartNumDes() {
|
CartNumDes() {
|
||||||
this.$emit("changeFun", { action: "ChangeCartNum", value: false })
|
this.cartNumber--
|
||||||
|
this.$emit("changeFun", { action: "ChangeCartNum", value: this.cartNumber })
|
||||||
},
|
},
|
||||||
CartNumAdd() {
|
CartNumAdd() {
|
||||||
this.$emit("changeFun", { action: "ChangeCartNum", value: 1 })
|
this.cartNumber++
|
||||||
|
this.$emit("changeFun", { action: "ChangeCartNum", value: this.cartNumber })
|
||||||
},
|
},
|
||||||
tapAttr(index, subIndex, subItem) {
|
tapAttr(index, subIndex, subItem) {
|
||||||
// 缺货的点击了没效果
|
// 缺货的点击了没效果
|
||||||
|
|||||||
@@ -276,7 +276,11 @@ export default {
|
|||||||
let stock = productSelect.stock || 0
|
let stock = productSelect.stock || 0
|
||||||
let num = this.attr.productSelect
|
let num = this.attr.productSelect
|
||||||
if (changeValue) {
|
if (changeValue) {
|
||||||
num.cart_num++
|
if(changeValue > 1) {
|
||||||
|
num.cart_num = changeValue
|
||||||
|
} else {
|
||||||
|
num.cart_num++
|
||||||
|
}
|
||||||
if (num.cart_num > stock) {
|
if (num.cart_num > stock) {
|
||||||
if(stock < 1) {
|
if(stock < 1) {
|
||||||
this.$set(this.attr.productSelect, 'cart_num', 1)
|
this.$set(this.attr.productSelect, 'cart_num', 1)
|
||||||
@@ -291,7 +295,7 @@ export default {
|
|||||||
this.$set(this, 'cart_num', 1)
|
this.$set(this, 'cart_num', 1)
|
||||||
} else {
|
} else {
|
||||||
this.$set(this.attr.productSelect, 'cart_num', num.cart_num)
|
this.$set(this.attr.productSelect, 'cart_num', num.cart_num)
|
||||||
this.$set(this, 'cart_num', num.cart_num)
|
// this.$set(this, 'cart_num', num.cart_num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1244,7 +1244,12 @@ export default {
|
|||||||
let stock = productSelect.stock || 0
|
let stock = productSelect.stock || 0
|
||||||
let num = this.attr.productSelect
|
let num = this.attr.productSelect
|
||||||
if (changeValue) {
|
if (changeValue) {
|
||||||
num.cart_num++
|
console.log(changeValue);
|
||||||
|
if(changeValue > 1) {
|
||||||
|
num.cart_num = changeValue
|
||||||
|
} else {
|
||||||
|
num.cart_num++
|
||||||
|
}
|
||||||
if (num.cart_num > stock) {
|
if (num.cart_num > stock) {
|
||||||
if(stock < 1) {
|
if(stock < 1) {
|
||||||
this.$set(this.attr.productSelect, 'cart_num', 1)
|
this.$set(this.attr.productSelect, 'cart_num', 1)
|
||||||
@@ -1259,7 +1264,7 @@ export default {
|
|||||||
this.$set(this, 'cart_num', 1)
|
this.$set(this, 'cart_num', 1)
|
||||||
} else {
|
} else {
|
||||||
this.$set(this.attr.productSelect, 'cart_num', num.cart_num)
|
this.$set(this.attr.productSelect, 'cart_num', num.cart_num)
|
||||||
this.$set(this, 'cart_num', num.cart_num)
|
// this.$set(this, 'cart_num', num.cart_num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user