Authored by 郭成尧

shop-collect

... ... @@ -13,7 +13,7 @@
<p class="store-name">{{brand.brand_name}}</p>
<div class="fav-box clearfix">
<div class="favs pull-left">粉丝数: 534 </div>
<div class="not-collect buriedpoint pull-left" id="collect" data-bp-id="shop_branner_collect_1"></div>
<div class="not-collect pull-left" id="collect" data-bp-id="shop_branner_collect_1"></div>
</div>
</div>
{{/if}}
... ...
... ... @@ -2,30 +2,15 @@
* @Author: Targaryen
* @Date: 2017-03-23 11:31:51
* @Last Modified by: Targaryen
* @Last Modified time: 2017-03-28 17:14:11
* @Last Modified time: 2017-03-30 14:51:41
*/
/* 红人店铺首页 */
const Swiper2 = require('yoho-swiper2');
let $shopIntroFolder = $('.shop-intro-folder');
let $shortIntro = $('#shortIntro');
let $shopIntro = $('#shopIntro');
let $shopIntrArrw = $('#shopIntrArrw');
let tip = require('../../plugin/tip');
let $goodsContainer = $('.index-goods-container');
let $collect = $('#collect');
/**
* 店铺介绍展开收起
*/
$shopIntroFolder.on('click', function() {
$shortIntro.toggleClass('hide');
$shopIntro.toggleClass('active');
if ($shopIntro.hasClass('active')) {
$shopIntrArrw.html('&#xe615;');
} else {
$shopIntrArrw.html('&#xe616;');
}
});
const shopId = $('#shopId').val();
/**
* 异步加载人气单品
... ... @@ -64,3 +49,44 @@ if ($('.shop-swiper')) {
});
}
}
/**
* 店铺收藏取消收藏操作
*/
$collect.on('click', function() {
let options = {
id: shopId,
opt: 'ok'
};
if ($collect.hasClass('already-collect')) {
options.opt = 'cancel';
}
$.ajax({
method: 'get',
url: location.protocol + '//m.yohobuy.com/product/opt/favoriteBrand',
xhrFields: {
withCredentials: true
},
data: options,
success: function(result) {
if (result.code === 200) {
if ($collect.hasClass('already-collect')) {
$collect.attr('class', 'not-collect pull-left');
tip.show('店铺取消收藏成功');
} else {
$collect.attr('class', 'already-collect pull-left');
tip.show('店铺收藏成功');
}
}
if (result.code === 400) {
if ($('#jump-login').length <= 0) {
$('body').append('<a href=\'' + result.data + '\'><span id="jump-login"><span></a>');
}
$('#jump-login').click();
}
}
});
});
... ...