|
|
@@ -28,8 +28,8 @@
|
|
|
</view>
|
|
|
<view class="qty-display">
|
|
|
<input
|
|
|
- v-model="numList[item.id]"
|
|
|
- type="digit"
|
|
|
+ v-model.number="item.selectedQty"
|
|
|
+ type="number"
|
|
|
class="qty-input"
|
|
|
@blur="validateQty(item)">
|
|
|
</view>
|
|
|
@@ -69,7 +69,6 @@ export default {
|
|
|
flowerList: [],
|
|
|
scrollHeight: '600upx',
|
|
|
unitPrice:0,
|
|
|
- numList: [],
|
|
|
xjData: []
|
|
|
}
|
|
|
},
|
|
|
@@ -78,20 +77,6 @@ export default {
|
|
|
handler(newData) {
|
|
|
const dataToUse = (newData && newData.length > 0) ? newData : []
|
|
|
this.flowerList = dataToUse
|
|
|
- this.flowerList.forEach(item => {
|
|
|
- this.numList[item.id] = 0
|
|
|
- })
|
|
|
- let saveInfo = uni.getStorageSync("xj")
|
|
|
- if (!this.$util.isEmpty(saveInfo)) {
|
|
|
- saveInfo.forEach((item) => {
|
|
|
- let hasList = item.list ? item.list : []
|
|
|
- if (!this.$util.isEmpty(hasList)) {
|
|
|
- hasList.forEach((hasItem) => {
|
|
|
- this.numList[hasItem.id] = hasItem.num
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
},
|
|
|
deep: true,
|
|
|
immediate: true
|
|
|
@@ -116,33 +101,32 @@ export default {
|
|
|
// 增加数量
|
|
|
increaseQty(item) {
|
|
|
this.$util.hitVoice()
|
|
|
- let currentNum = parseInt(this.numList[item.id]) || 0
|
|
|
- this.$set(this.numList, item.id, currentNum + 1)
|
|
|
+ item.selectedQty = parseInt(item.selectedQty) || 0
|
|
|
+ item.selectedQty++
|
|
|
},
|
|
|
// 减少数量
|
|
|
decreaseQty(item) {
|
|
|
this.$util.hitVoice()
|
|
|
- let currentNum = parseInt(this.numList[item.id]) || 0
|
|
|
- if (currentNum > 0) {
|
|
|
- this.$set(this.numList, item.id, currentNum - 1)
|
|
|
+ item.selectedQty = parseInt(item.selectedQty) || 0
|
|
|
+ if (item.selectedQty > 0) {
|
|
|
+ item.selectedQty--
|
|
|
}
|
|
|
},
|
|
|
// 验证数量输入
|
|
|
validateQty(item) {
|
|
|
- let qty = parseInt(this.numList[item.id]) || 0
|
|
|
+ let qty = parseInt(item.selectedQty) || 0
|
|
|
if (qty < 0) {
|
|
|
- this.$set(this.numList, item.id, 0)
|
|
|
+ item.selectedQty = 0
|
|
|
} else {
|
|
|
- this.$set(this.numList, item.id, qty)
|
|
|
+ item.selectedQty = qty
|
|
|
}
|
|
|
},
|
|
|
confirmClearXj() {
|
|
|
uni.removeStorageSync("xj")
|
|
|
- if (!this.$util.isEmpty(this.numList)) {
|
|
|
- this.numList.forEach((item, index, arr) => {
|
|
|
- arr[index] = 0
|
|
|
+ if (!this.$util.isEmpty(this.flowerList)) {
|
|
|
+ this.flowerList.forEach(item => {
|
|
|
+ item.selectedQty = 0
|
|
|
})
|
|
|
- this.$forceUpdate()
|
|
|
}
|
|
|
this.$emit('globalClearXj', this.customData)
|
|
|
},
|
|
|
@@ -152,9 +136,9 @@ export default {
|
|
|
handleConfirm() {
|
|
|
// 收集选中的花材
|
|
|
let arr = []
|
|
|
- this.numList.forEach((num, id) => {
|
|
|
- if (!this.$util.isEmpty(num) && Number(num) > 0) {
|
|
|
- arr.push({id: id, num: num})
|
|
|
+ this.flowerList.forEach(item => {
|
|
|
+ if (!this.$util.isEmpty(item.selectedQty) && Number(item.selectedQty) > 0) {
|
|
|
+ arr.push({id: item.id, num: item.selectedQty})
|
|
|
}
|
|
|
})
|
|
|
|