Authored by 郭成尧

collectOrNotShop

... ... @@ -3,16 +3,16 @@
{{# shopInfo}}
<div id="brand-header" class="brand-header" data-id={{shops_id}} data-isbaseshop="{{isBaseShop}}">
<img src={{image2 banner q=60}}>
<a class="btn-intro" href="javascript:void(0);">
<a class="btn-intro" id="shopIntroBtn" href="javascript:void(0);">
店铺介绍
</a>
<a class="btn-col" href="javascript:void(0);">
<a id="collectShop" class="btn-col" href="javascript:void(0);">
<span class="iconfont">&#xe622;</span>
<span class="txt"></span>
</a>
</div>
<div id="intro-box" class="brand-intro-box hide">
<div id="brand-intro" class="brand-intro">
<div id="introBox" class="brand-intro-box hide">
<div id="shopIntro" class="brand-intro">
<h2>店铺介绍</h2>
<div class="con">
{{{shop_intro}}}
... ... @@ -21,7 +21,7 @@
<span class="iconfont">&#xe629;</span>
100%品牌授权正品
</p>
<span class="iconfont close-intro">&#xe623;</span>
<span id="closeIntroBtn" class="iconfont close-intro">&#xe623;</span>
</div>
</div>
{{/ shopInfo}}
... ...
require('product/shop/shop.page.css');
let ProductListWithFilter = require('product/list/product-list-with-filter');
const $ = require('yoho-jquery');
const tip = require('plugin/tip');
const ProductListWithFilter = require('product/list/product-list-with-filter');
const $shopIntroBtn = $('#shopIntroBtn');
const $introBox = $('#introBox');
const $closeIntroBtn = $('#closeIntroBtn');
const $collectShopIcon = $('#collectShop');
const shopId = $('#shopId').val();
let productListWithFilterModel =
const productListWithFilterModel =
new ProductListWithFilter({
shop_id: shopId,
page: 2, // 首页服务端已经渲染
... ... @@ -11,3 +18,66 @@ let productListWithFilterModel =
}, 'product/search/shop/goods');
productListWithFilterModel.getFilter();
/**
* 添加或者取消收藏处理
* @param {*} opt
*/
function collectOrNotShop(opt) {
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/opt/favoriteBrand',
data: {
id: shopId,
opt: opt,
type: 'shop'
},
xhrFields: {
withCredentials: true
},
success: function(data) {
if (data.code === 200) {
$collectShopIcon.toggleClass('coled');
// 提示
if (opt === 'ok') {
tip.show('添加收藏成功');
} else {
tip.show('取消收藏成功');
}
} else if (data.code === 400) {
location.href = data.data;// 未登录跳转登录页
} else {
tip.show(data.message);
}
},
error: function() {
tip.show('网络断开连接了~');
}
});
}
/**
* 打开店铺介绍
*/
$shopIntroBtn.on('click', () => {
$introBox.removeClass('hide');
});
/**
* 关闭店铺介绍
*/
$closeIntroBtn.on('click', () => {
$introBox.addClass('hide');
});
/**
* 添加或者取消收藏操作
*/
$collectShopIcon.on('click', () => {
if ($collectShopIcon.hasClass('coled')) {
collectOrNotShop();
} else {
collectOrNotShop('ok');
}
});
... ...
... ... @@ -222,7 +222,7 @@
position: relative;
box-sizing: border-box;
width: 85%;
margin: 0 7.5%;
margin: 40px 7.5% 0;
background: #fff;
padding: 20px 8%;
}
... ...