Commit a3e35e03 by 高淑倩

add: 购物车_加减

parent b4c673c0
......@@ -89,59 +89,37 @@ wxService.page({
},
minusNum: function (e) { // 减少数量
let cartList = this.data.cartList
// let proNum = cartList[e.currentTarget.dataset.index].quantity
console.log('sssse', e.currentTarget.dataset)
// if (proNum > 1) {
// proNum--
// } else {
// wx.showToast({
// title: '数量不能为0',
// icon: 'none'
// })
// return false
// }
// cartList[e.currentTarget.dataset.index].quantity = proNum
// this.setData({
// cartList: cartList
// }, function () {
// this.setTotalFee()
// this.editOk(cartList[e.currentTarget.dataset.index]) //调用完成
// })
},
addNum: function (e) { // 增加数量
var cartList = this.data.cartList
console.log('add', e.currentTarget.dataset)
var choosePro = cartList[e.currentTarget.dataset.index]
console.log(choosePro)
var proNum = choosePro.quantity
if (choosePro.quantityAverage == '0') {
if (proNum < choosePro.selectSku.inventory_num) {
proNum++
} else {
wx.showToast({
title: '不能超过库存',
icon: 'none'
})
}
let proNum = cartList[e.currentTarget.dataset.index].count
console.log('减少数量', proNum)
if (proNum > 1) {
proNum--
} else {
if (proNum < choosePro.quantityAverage) {
proNum++
} else {
wx.showToast({
title: '每人限购' + choosePro.quantityAverage + '件',
icon: 'none'
})
}
wx.showToast({
title: '数量不能为0',
icon: 'none'
})
return false
}
cartList[e.currentTarget.dataset.index].quantity = proNum
cartList[e.currentTarget.dataset.index].count = proNum
this.setData({
cartList: cartList
}, function () {
this.setTotalFee()
this.editOk(cartList[e.currentTarget.dataset.index]) //调用完成
})
},
addNum: function (e) { // 增加数量
var cartList = this.data.cartList
var proNum = cartList[e.currentTarget.dataset.index].count
console.log('增加数量',proNum)
cartList[e.currentTarget.dataset.index].count = proNum
this.setData({
cartList: cartList
}, function () {
this.setTotalFee()
this.editOk(cartList[e.currentTarget.dataset.index]) //调用完成
})
},
blurNum: function (e) {
var newNum = e.detail.value
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment