|
|
'use strict';
|
|
|
|
|
|
/**
|
|
|
* 商品详情: 品牌券
|
|
|
*/
|
|
|
/* 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 brandCoupon = {
|
|
|
skn: null,
|
|
|
brandId: null,
|
|
|
$entry: null,
|
|
|
$couponDrawer: null,
|
|
|
|
|
|
template: require('product/detail/coupon-list.hbs'),
|
|
|
|
|
|
init: function(skn, brandId) {
|
|
|
var self = this;
|
|
|
|
|
|
this.skn = skn;
|
|
|
this.brandId = brandId;
|
|
|
|
|
|
if (!(skn && brandId)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
this.fetchCoupons(this.skn, this.brandId)
|
|
|
.done(function(data) {
|
|
|
data = mock_data;
|
|
|
|
|
|
if (data.length) {
|
|
|
self.domInit();
|
|
|
self.render(data);
|
|
|
self.bindEvents();
|
|
|
}
|
|
|
})
|
|
|
.fail();
|
|
|
},
|
|
|
|
|
|
domInit: function() {
|
|
|
this.$entry = $('.brand-coupon');
|
|
|
|
|
|
this.$entry.removeClass('hide');
|
|
|
},
|
|
|
|
|
|
bindEvents: function() {
|
|
|
var self = this;
|
|
|
|
|
|
this.$entry.on('click', function() {
|
|
|
self.$couponDrawer.addClass('open');
|
|
|
});
|
|
|
},
|
|
|
|
|
|
render: function(data) {
|
|
|
this.$couponDrawer = $(this.template(data));
|
|
|
this.$couponDrawer.appendTo('body');
|
|
|
|
|
|
return this;
|
|
|
},
|
|
|
|
|
|
// 获取 品牌券
|
|
|
fetchCoupons: function(skn, brandId) {
|
|
|
return $.get('/product/detail/coupon.json', {
|
|
|
skn: skn,
|
|
|
brandId: brandId
|
|
|
});
|
|
|
},
|
|
|
|
|
|
// 收藏 品牌券
|
|
|
saveCoupons: function() {
|
|
|
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
$(function() {
|
|
|
brandCoupon.init(
|
|
|
$('#productSkn').val(),
|
|
|
$('#brand-id').val()
|
|
|
);
|
|
|
}); |
...
|
...
|
|