Authored by 李奇

选择交互优化

... ... @@ -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 = '';
}
}
}
}
});
... ...
... ... @@ -36,6 +36,6 @@
</view>
</view>
</view>
<couponSelect bindconfirmselect="confirmSelectCoupon" show="{{selectingCoupon}}"
<couponSelect bindconfirmselect="confirmSelectCoupon" show="{{selectingCoupon}}" selected-code="{{selectCouponCode}}"
bindcancel="cancelSelectCoupon" coupons="{{coupons}}"></couponSelect>
<checkstore id="check" storeId="{{storeId}}" productId="{{product_id}}"></checkstore>
... ...