...
|
...
|
@@ -4,6 +4,10 @@ Component({ |
|
|
pickerData: {
|
|
|
type: Object,
|
|
|
value: null,
|
|
|
observer: function (value) {
|
|
|
if (!value.sourceType)
|
|
|
this.setData({pickerData: value})
|
|
|
}
|
|
|
},
|
|
|
isloadingForPayment: {
|
|
|
type: Boolean,
|
...
|
...
|
@@ -17,10 +21,10 @@ Component({ |
|
|
}
|
|
|
}
|
|
|
},
|
|
|
data: {_show: false},
|
|
|
data: {_show: false, colorSelected: false, storageNumber: 0, selectedSKU: '', pickerData: null},
|
|
|
methods: {
|
|
|
colorTap(event) {
|
|
|
var that = this
|
|
|
var that = this;
|
|
|
var tempData = that.data.pickerData;
|
|
|
//先遍历将所有颜色、尺码置为未选中状态
|
|
|
// console.log('color')
|
...
|
...
|
@@ -56,12 +60,12 @@ Component({ |
|
|
|
|
|
tempData.view.minusButtonEnable = false
|
|
|
//将购买数量设为初始状态
|
|
|
tempData.view.buyNumber = 1
|
|
|
this.triggerEvent('colorTap', {colorSelected, tempData})
|
|
|
tempData.view.buyNumber = 1;
|
|
|
this.setData({pickerData: tempData, colorSelected});
|
|
|
},
|
|
|
|
|
|
sizeTap(event) {
|
|
|
var that = this
|
|
|
var that = this;
|
|
|
var tempData = that.data.pickerData
|
|
|
|
|
|
//现遍历将所有尺码置为未选中状态
|
...
|
...
|
@@ -89,35 +93,92 @@ Component({ |
|
|
|
|
|
tempData.view.buyButtonEnable = false
|
|
|
}
|
|
|
this.triggerEvent('sizeTap', {tempData, tempItem})
|
|
|
this.setData({
|
|
|
pickerData: tempData,
|
|
|
storageNumber: tempItem.storage_number,
|
|
|
selectedSKU: tempItem.storage_number > 0 ? tempItem.product_sku : 0
|
|
|
});
|
|
|
},
|
|
|
show() {
|
|
|
this.setData({_show: true});
|
|
|
this.triggerEvent('showChange')
|
|
|
this.triggerEvent('showChange');
|
|
|
},
|
|
|
hide(event) {
|
|
|
if (event.target.id === "picker-bg") {
|
|
|
this.setData({_show: true})
|
|
|
this.triggerEvent('showChange')
|
|
|
this.setData({_show: true});
|
|
|
this.triggerEvent('showChange');
|
|
|
}
|
|
|
},
|
|
|
bindMinus(event) {
|
|
|
this.triggerEvent('bindMinus', {pickerData: this.data.pickerData})
|
|
|
},
|
|
|
bindMinus() {
|
|
|
let pickerData = this.data.pickerData;
|
|
|
let buyNumber = parseInt(pickerData.view.buyNumber);
|
|
|
if (buyNumber > 1) {
|
|
|
buyNumber = buyNumber - 1;
|
|
|
}
|
|
|
pickerData.view.buyNumber = buyNumber;
|
|
|
|
|
|
bindPlus(event) {
|
|
|
this.triggerEvent('bindPlus', {pickerData: this.data.pickerData})
|
|
|
},
|
|
|
if (buyNumber === 1) {
|
|
|
pickerData.view.minusButtonEnable = false;
|
|
|
} else {
|
|
|
pickerData.view.minusButtonEnable = true;
|
|
|
}
|
|
|
|
|
|
goPayment() {
|
|
|
this.triggerEvent('goPayment')
|
|
|
if (buyNumber < this.data.storageNumber) {
|
|
|
pickerData.view.plusButtonEnable = true;
|
|
|
}
|
|
|
this.setData({pickerData});
|
|
|
},
|
|
|
|
|
|
catchtouchmove() {
|
|
|
this.triggerEvent('catchtouchmove')
|
|
|
bindPlus() {
|
|
|
if (!this.data.colorSelected) {
|
|
|
this.wetoast.toast({
|
|
|
title: '请选择颜色',
|
|
|
titleClassName: 'wetoast-title',
|
|
|
duration: 1000
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (!this.data.selectedSKU) {
|
|
|
this.wetoast.toast({
|
|
|
title: '请选择尺码',
|
|
|
titleClassName: 'wetoast-title',
|
|
|
duration: 1000
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
let pickerData = this.data.pickerData;
|
|
|
let buyNumber = pickerData.view.buyNumber;
|
|
|
|
|
|
if (buyNumber >= this.data.storageNumber) {
|
|
|
this.plusReachedMaxAction();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
if (buyNumber < this.data.storageNumber) {
|
|
|
pickerData.view.plusButtonEnable = true;
|
|
|
buyNumber = parseInt(buyNumber) + 1;
|
|
|
}
|
|
|
|
|
|
if (buyNumber >= this.data.storageNumber) {
|
|
|
pickerData.view.plusButtonEnable = false;
|
|
|
}
|
|
|
|
|
|
if (buyNumber > 1) {
|
|
|
pickerData.view.minusButtonEnable = true;
|
|
|
}
|
|
|
|
|
|
pickerData.view.buyNumber = buyNumber;
|
|
|
this.setData({pickerData});
|
|
|
},
|
|
|
goPayment() {
|
|
|
this.triggerEvent('goPayment', this.data)
|
|
|
},
|
|
|
addShopCart() {
|
|
|
this.triggerEvent('addShopCart')
|
|
|
this.triggerEvent('addShopCart', this.data)
|
|
|
}
|
|
|
}
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|