...
|
...
|
@@ -2,19 +2,64 @@ |
|
|
* @Author: Targaryen
|
|
|
* @Date: 2017-03-23 11:31:51
|
|
|
* @Last Modified by: Targaryen
|
|
|
* @Last Modified time: 2017-04-14 11:17:55
|
|
|
* @Last Modified time: 2017-04-25 11:45:13
|
|
|
*/
|
|
|
|
|
|
/** *****************
|
|
|
* 红人店铺首页
|
|
|
********************/
|
|
|
const Swiper2 = require('yoho-swiper2');
|
|
|
const lazyLoad = require('yoho-jquery-lazyload');
|
|
|
let tip = require('../../plugin/tip');
|
|
|
let $goodsContainer = $('.index-goods-container');
|
|
|
let $indexGoodsContaniner = $('#indexGoodsContainer');
|
|
|
let $collect = $('#collect');
|
|
|
|
|
|
const shopId = $('#shopId').val();
|
|
|
|
|
|
lazyLoad($('.lazy'));
|
|
|
|
|
|
/**
|
|
|
* 异步检测是否已经收藏
|
|
|
*/
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
|
|
|
xhrFields: {
|
|
|
withCredentials: true
|
|
|
},
|
|
|
data: {
|
|
|
shopId: shopId
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.collect) {
|
|
|
$collect.attr('class', 'already-collect pull-left');
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 店铺轮播图
|
|
|
*/
|
|
|
if ($('.shop-swiper')) {
|
|
|
let num = $('.shop-swiper').length;
|
|
|
|
|
|
for (let i = 1; i <= num; i++) {
|
|
|
new Swiper2('.shop-swiper-' + i, {
|
|
|
lazyLoading: true,
|
|
|
lazyLoadingInPrevNext: true,
|
|
|
loop: true,
|
|
|
autoplay: 3000,
|
|
|
slideElement: 'li',
|
|
|
paginationClickable: true,
|
|
|
pagination: $(this).closest('.shop-swiper-' + i).find('.pagination-inner').get(0)
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 异步加载推荐商品
|
|
|
*/
|
...
|
...
|
@@ -47,51 +92,33 @@ $.each($goodsContainer, function(index, elem) { |
|
|
},
|
|
|
data: data,
|
|
|
success: function(result) {
|
|
|
let $result = $(result);
|
|
|
|
|
|
lazyLoad($result.find('img[class=lazy]'));
|
|
|
$(elem).html(result);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 异步检测是否已经收藏
|
|
|
* 异步加载首页全部商品
|
|
|
*/
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: location.protocol + '//m.yohobuy.com/product/index/shopFav',
|
|
|
url: '/product/search/search',
|
|
|
xhrFields: {
|
|
|
withCredentials: true
|
|
|
},
|
|
|
data: {
|
|
|
shopId: shopId
|
|
|
shop_id: shopId
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data.collect) {
|
|
|
$collect.attr('class', 'already-collect pull-left');
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
success: function(result) {
|
|
|
let $result = $(result);
|
|
|
|
|
|
/**
|
|
|
* 店铺轮播图
|
|
|
*/
|
|
|
if ($('.shop-swiper')) {
|
|
|
let num = $('.shop-swiper').length;
|
|
|
|
|
|
for (let i = 1; i <= num; i++) {
|
|
|
new Swiper2('.shop-swiper-' + i, {
|
|
|
lazyLoading: true,
|
|
|
lazyLoadingInPrevNext: true,
|
|
|
loop: true,
|
|
|
autoplay: 3000,
|
|
|
slideElement: 'li',
|
|
|
paginationClickable: true,
|
|
|
pagination: $(this).closest('.shop-swiper-' + i).find('.pagination-inner').get(0)
|
|
|
});
|
|
|
lazyLoad($result.find('img[class=lazy]'));
|
|
|
$indexGoodsContaniner.find('.container').html($result);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 店铺收藏取消收藏操作
|
...
|
...
|
|