...
|
...
|
@@ -4,25 +4,57 @@ |
|
|
* @date: 2016/10/17
|
|
|
*/
|
|
|
var $ = require('yoho-jquery'),
|
|
|
tip = require('../plugin/tip'),
|
|
|
Swiper = require('yoho-swiper'),
|
|
|
share = require('../common/share'),
|
|
|
tip = require('../plugin/tip'),
|
|
|
loading = require('../plugin/loading'),
|
|
|
banner = require('../../template/resources/banner-top.hbs'),
|
|
|
tab = require('../../template/activity/single-day/tab.hbs'),
|
|
|
product = require('../../template/activity/single-day/product-list.hbs');
|
|
|
|
|
|
var hash = window.location.hash.replace('#', '');
|
|
|
var $productList = $('.product-list');
|
|
|
var getFlag = false;
|
|
|
|
|
|
share({
|
|
|
title: '有货【会员日】潮集狂欢,限时六大福利,还不快参与起来?!',
|
|
|
link: location.href,
|
|
|
desc: '每月28日,尽情释放!',
|
|
|
imgUrl: 'http://img10.static.yhbimg.com/taobaocms/2016/09/23/18/010ccac2955e7e50ffb66b75110e73e3e1.png'
|
|
|
});
|
|
|
var getProductData = function(index, tabName) {
|
|
|
if (getFlag) {
|
|
|
return;
|
|
|
}
|
|
|
getFlag = true;
|
|
|
loading.showLoadingMask();
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '',
|
|
|
data: {
|
|
|
tab_name: tabName
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data) {
|
|
|
$('.product-tab').eq(index).append(product(data));
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
getFlag = false;
|
|
|
loading.hideLoadingMask();
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
loading.hideLoadingMask();
|
|
|
getFlag = false;
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
var tabName = function(index) {
|
|
|
return $('.swiper-tab li').eq(index).html();
|
|
|
};
|
|
|
|
|
|
var getInitData = function() {
|
|
|
$.ajax({
|
|
|
type: 'GET',
|
|
|
url: '/activity/single-day/getSingleData',
|
|
|
success: function(data) {
|
|
|
var i = 0;
|
|
|
|
|
|
data[1] = ['限定名额', '首发', '热卖', '明星单品'];
|
|
|
if (data[0]) {
|
|
|
$('.banner').append(banner(data[0][0]));
|
|
|
|
...
|
...
|
@@ -41,16 +73,41 @@ $.ajax({ |
|
|
}
|
|
|
|
|
|
if (data[1]) {
|
|
|
$('.product-list').append(product(data[1]));
|
|
|
$('.swiper-tab').append(tab(data[1]));
|
|
|
|
|
|
new Swiper('.swiper-tab', {
|
|
|
slidesPerView: 'auto'
|
|
|
});
|
|
|
|
|
|
for (i; i < data[1].length; i++) {
|
|
|
$productList.append('<ul class="product-tab"></ul>');
|
|
|
}
|
|
|
|
|
|
getProductData(hash, tabName(hash));
|
|
|
|
|
|
$('.swiper-tab li')
|
|
|
.eq(hash)
|
|
|
.addClass('active')
|
|
|
.on('click', function() {
|
|
|
var index = $(this).index();
|
|
|
|
|
|
if ($('.product-tab').eq(index).find('li').length > 0) {
|
|
|
return false;
|
|
|
} else {
|
|
|
getProductData(index, tabName(index));
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
loading.hideLoadingMask();
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$('.swiper-tab li').eq(hash).addClass('active');
|
|
|
});
|
|
|
};
|
|
|
|
|
|
new Swiper('.swiper-tab', {
|
|
|
slidesPerView: 'auto'
|
|
|
$(function() {
|
|
|
loading.showLoadingMask();
|
|
|
getInitData();
|
|
|
}); |
...
|
...
|
|