...
|
...
|
@@ -2,11 +2,16 @@ Component({ |
|
|
properties: {
|
|
|
show: {
|
|
|
type: Boolean,
|
|
|
value: false
|
|
|
value: false,
|
|
|
observer: '_show'
|
|
|
},
|
|
|
coupons: {
|
|
|
type: Array,
|
|
|
value: []
|
|
|
},
|
|
|
selectedCode: {
|
|
|
type: String,
|
|
|
value: ''
|
|
|
}
|
|
|
},
|
|
|
data: {
|
...
|
...
|
@@ -47,6 +52,26 @@ Component({ |
|
|
[`coupons[${idx}].isChosen`]: false
|
|
|
});
|
|
|
this.data.chosenIdx = '';
|
|
|
},
|
|
|
_show: function (show) {
|
|
|
if (show) {
|
|
|
if (this.data.selectedCode) {
|
|
|
this.data.coupons.forEach((item, index) => {
|
|
|
if (item.coupon_code === this.data.selectedCode) {
|
|
|
this.setData({
|
|
|
[`coupons[${index}].isChosen`]: true
|
|
|
});
|
|
|
this.data.chosenIdx = index;
|
|
|
} else {
|
|
|
this.setData({
|
|
|
[`coupons[${index}].isChosen`]: false
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
} else {
|
|
|
this.data.chosenIdx = '';
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}); |
...
|
...
|
|