...
|
...
|
@@ -3,39 +3,9 @@ |
|
|
/**
|
|
|
* 商品详情: 品牌券
|
|
|
*/
|
|
|
/* eslint-disable */
|
|
|
var mock_data = [{
|
|
|
"couponName": "有效期20161017未到,10*2",
|
|
|
"amount": 10,
|
|
|
"acquireStatus": 3,
|
|
|
"createTime": 1476358043,
|
|
|
"startTime": 1476633600,
|
|
|
"lifeTime": "2016.10.17-2016.10.28",
|
|
|
"endTime": 1477584000,
|
|
|
"couponId": 14200
|
|
|
}, {
|
|
|
"couponName": "有效的nike券",
|
|
|
"amount": 22,
|
|
|
"acquireStatus": 3,
|
|
|
"createTime": 1475152374,
|
|
|
"startTime": 1474992000,
|
|
|
"lifeTime": "2016.09.28-2016.11.17",
|
|
|
"endTime": 1479312000,
|
|
|
"couponId": 14144
|
|
|
}, {
|
|
|
"couponName": "有效期内优惠券15*3倍",
|
|
|
"amount": 15,
|
|
|
"acquireStatus": 3,
|
|
|
"createTime": 1476358258,
|
|
|
"startTime": 1476115200,
|
|
|
"lifeTime": "2016.10.11-2016.11.18",
|
|
|
"endTime": 1479398400,
|
|
|
"couponId": 14202
|
|
|
}];
|
|
|
/* eslint-enable */
|
|
|
|
|
|
var tip = require('plugin/tip');
|
|
|
var $ = require('yoho-jquery');
|
|
|
var $body = $(document.body);
|
|
|
|
|
|
var brandCoupon = {
|
|
|
skn: null,
|
...
|
...
|
@@ -57,11 +27,9 @@ var brandCoupon = { |
|
|
|
|
|
this.fetchCoupons(this.skn, this.brandId)
|
|
|
.done(function(data) {
|
|
|
data = mock_data;
|
|
|
|
|
|
if (data.length) {
|
|
|
self.domInit();
|
|
|
self.render(data);
|
|
|
self.domInit();
|
|
|
self.bindEvents();
|
|
|
}
|
|
|
})
|
...
|
...
|
@@ -69,22 +37,26 @@ var brandCoupon = { |
|
|
},
|
|
|
|
|
|
domInit: function() {
|
|
|
this.$entry = $('.brand-coupon');
|
|
|
|
|
|
this.$entry.removeClass('hide');
|
|
|
this.$entry = $('.brand-coupon').removeClass('hide');
|
|
|
},
|
|
|
|
|
|
bindEvents: function() {
|
|
|
var self = this;
|
|
|
|
|
|
this.$entry.on('click', function() {
|
|
|
self.$couponDrawer.addClass('open');
|
|
|
self.toggleDrawer(true);
|
|
|
});
|
|
|
|
|
|
this.$couponDrawer
|
|
|
.on('click', '.coupon-drawer-mask', $.proxy(this.toggleDrawer, this, false))
|
|
|
.on('click', '.coupon-btn-valid', $.proxy(this.saveCouponHandler, this));
|
|
|
},
|
|
|
|
|
|
render: function(data) {
|
|
|
this.$couponDrawer = $(this.template(data));
|
|
|
this.$couponDrawer.appendTo('body');
|
|
|
this.$couponDrawer = $(this.template({
|
|
|
coupons: data
|
|
|
}));
|
|
|
this.$couponDrawer.appendTo('.good-detail-page');
|
|
|
|
|
|
return this;
|
|
|
},
|
...
|
...
|
@@ -97,9 +69,34 @@ var brandCoupon = { |
|
|
});
|
|
|
},
|
|
|
|
|
|
saveCoupon: function(couponId, callback) {
|
|
|
$.post('/product/detail/coupon/save.json', {
|
|
|
couponId: couponId
|
|
|
}).done(function(res) {
|
|
|
tip.show(res.message);
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
callback(); // eslint-disable-line
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
|
|
|
// 收藏 品牌券
|
|
|
saveCoupons: function() {
|
|
|
saveCouponHandler: function(event) {
|
|
|
var $btn = $(event.target);
|
|
|
var couponId = $btn.closest('.coupon').data('coupon');
|
|
|
|
|
|
this.saveCoupon(couponId, function() {
|
|
|
$btn.prop('disabled', true)
|
|
|
.text('已领取');
|
|
|
});
|
|
|
|
|
|
event.stopPropagation();
|
|
|
},
|
|
|
|
|
|
toggleDrawer: function(bool) {
|
|
|
this.$couponDrawer.toggleClass('open', bool);
|
|
|
$body.toggleClass('coupon-drawer-open', bool);
|
|
|
}
|
|
|
};
|
|
|
|
...
|
...
|
|