Authored by 郝肖肖

去除废弃代码

... ... @@ -6,4 +6,4 @@
require('./search/list');
require('../common/footer');
require('./shop/shop-coupon');
require('./shop/coupon');
... ...
require('./shop/shop');
require('./shop/shop-coupon');
require('./shop/coupon');
... ...
var $ = require('yoho-jquery'),
Swiper = require('yoho-swiper'),
tip = require('../../plugin/tip');
require('../../common');
var brandCoupon = {};
brandCoupon = {
common: {
appVersion: window.queryString.app_version || window.queryString.appVersion,
uid: window.queryString.uid,
brandId: $('.brand-header').data('id'),
couponTemplate: require('product/shop/coupon.hbs')
},
init: function() {
this.getShopCouponsList();
},
getShopCouponsList: function() {
var that = this;
$.ajax({
method: 'GET',
url: location.protocol + '//m.yohobuy.com/product/index/getBrandCouponsList',
data: {
brandId: that.common.brandId,
uid: that.common.uid
},
xhrFields: {
withCredentials: true
},
success: function(result) {
$('.coupon-group').html(that.common.couponTemplate(result));
new Swiper('.coupon-content', {
slideElement: '.coupon-small',
slidesPerView: 'auto',
watchSlidesVisibility: true
});
that.userCoupon();
}
});
},
userCoupon: function() {
var $self = this;
$('.coupon-content .receive-btn').closest('.swiper-slide').on('click', function() {
var that = this,
code = $(this).data('id') || '';
if (that.isCouponClick === false) {
return false;
}
that.isCouponClick = false;
$.ajax({
method: 'POST',
url: location.protocol + '//m.yohobuy.com/product/index/userCoupon',
data: {
couponID: code,
uid: $self.common.uid
},
xhrFields: {
withCredentials: true
},
success: function(data) {
that.isCouponClick = true;
if (data.code === 200) {
tip.show('领取成功');
$(that).find('.receive-btn').html('已领取');
return true;
} else if (data.code === 4401) {
$('#shop-login').remove();
$('body').append('<a href=\'' + data.url + '\'><span id="shop-login"><span></a>');
$('#shop-login').click();
} else if (data.code === 401) {
tip.show('已领取过');
} else {
tip.show(data.message);
}
},
error: function() {
tip.show('网络断开连接了~');
that.isCouponClick = true;
}
});
});
}
};
$(function() {
brandCoupon.init();
});
... ... @@ -18,7 +18,8 @@ shopCoupon = {
this.getShopCouponsList();
},
getShopCouponsList: function() {
var that = this, _url = location.protocol + '//m.yohobuy.com';
var that = this,
_url = location.protocol + '//m.yohobuy.com';
if (that.common.shopId === '') {
_url += '/product/index/getBrandCouponsList';
... ... @@ -101,4 +102,4 @@ shopCoupon = {
$(function() {
shopCoupon.init();
});
});
\ No newline at end of file
... ...