favorite.js
881 Bytes
/**
* 品牌或店铺收藏
* @author: jiangfeng<jeff.jiang@yoho.cn>
* @date: 16/7/19
*/
function _favBack(data) {
if (data && data.code === 200) {
$('#brand-fav').toggleClass('coled');
} else if (data && data.data && data.data.refer) {
location.href = data.data.refer;
}
}
// function _favShop(shopId, isAdd) {
// $.post('/product/shop/togglecollect', {shopId: shopId, type: isAdd ? '' : 'add'}, function(data) {
// _favBack(data);
// });
// }
function _favBrand(brandId, isAdd) {
$.post('/product/brand/togglecollect', {brandId: brandId, type: isAdd ? '' : 'add'}, function(data) {
_favBack(data);
});
}
$('#brand-fav').click(function() {
var $banner = $(this).parents('.brand-banner');
var brandId = $banner.data('brand');
var isAdd = $(this).hasClass('coled');
_favBrand(brandId, isAdd);
});