...
|
...
|
@@ -5,6 +5,10 @@ const yoho = require('js/yoho-app'); |
|
|
const qs = require('yoho-qs');
|
|
|
const cookie = require('yoho-cookie');
|
|
|
const shopTmpl = require('hbs/activity/feature/shop-group.hbs');
|
|
|
const seckillTabTpl = require('hbs/activity/feature/seckill-tab.hbs');
|
|
|
const seckillProductTpl = require('hbs/activity/feature/seckill-product.hbs');
|
|
|
const loading = require('js/plugin/loading');
|
|
|
const tip = require('js/plugin/tip');
|
|
|
|
|
|
require('scss/feature.scss');
|
|
|
|
...
|
...
|
@@ -700,11 +704,68 @@ function miniProgramHandleInit() { |
|
|
}
|
|
|
}
|
|
|
|
|
|
function formatTime(time) {
|
|
|
let date = new Date(time);
|
|
|
|
|
|
return `${date.getMonth() + 1}月${date.getDate()}日`;
|
|
|
}
|
|
|
|
|
|
function viewSeckillProduct(products) {
|
|
|
let $productList = $('.seckill .product-list');
|
|
|
let productParams = {
|
|
|
priceBgColor: $productList.data('priceBgColor'),
|
|
|
brandBgColor: $productList.data('brandBgColor'),
|
|
|
brandFontColor: $productList.data('brandFontColor'),
|
|
|
priceFontColor: $productList.data('priceFontColor')
|
|
|
};
|
|
|
let num = $productList.data('num');
|
|
|
|
|
|
if (products && products.length > num) {
|
|
|
products = products.slice(0, num);
|
|
|
}
|
|
|
|
|
|
if (products.length <= 3) {
|
|
|
$('.out-product-list').addClass('less-than-3');
|
|
|
}
|
|
|
|
|
|
$('.seckill .product-list').html(seckillProductTpl({
|
|
|
list: products,
|
|
|
productStyle: productParams
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
function loadSeckillList() {
|
|
|
let $tab = $('.seckill-tab');
|
|
|
let tabParams = {
|
|
|
tabColor: $tab.data('tabColor'),
|
|
|
tabFontColor: $tab.data('tabFontColor'),
|
|
|
tabSelectColor: $tab.data('tabSelectColor')
|
|
|
};
|
|
|
|
|
|
$.ajax({
|
|
|
url: '/product/seckill/list'
|
|
|
}).done(function(result) {
|
|
|
console.log(result);
|
|
|
let dateList = [];
|
|
|
|
|
|
if (result && result.activitys) {
|
|
|
result.activitys.forEach(item => {
|
|
|
dateList.push(Object.assign({
|
|
|
startTime: item.startTime,
|
|
|
date: formatTime(item.startTime),
|
|
|
time: item.time,
|
|
|
focus: item.focus,
|
|
|
activityId: item.activityId
|
|
|
}, tabParams));
|
|
|
});
|
|
|
|
|
|
$('.seckill .seckill-tab').html(seckillTabTpl({
|
|
|
dateList: dateList
|
|
|
}));
|
|
|
}
|
|
|
|
|
|
if (result && result.products) {
|
|
|
viewSeckillProduct(result.products || []);
|
|
|
}
|
|
|
}).error(function() {
|
|
|
|
|
|
}).always(function() {
|
...
|
...
|
@@ -712,11 +773,40 @@ function loadSeckillList() { |
|
|
});
|
|
|
}
|
|
|
|
|
|
function refreshProductList(activityId, time) {
|
|
|
$.ajax({
|
|
|
url: '/product/seckill/get-product-list',
|
|
|
data: {
|
|
|
uid: yoho.isLogin(), // only app use;
|
|
|
activityId: activityId,
|
|
|
startTime: time
|
|
|
},
|
|
|
success: function(data) {
|
|
|
if (data && data.products) {
|
|
|
viewSeckillProduct(data.products || []);
|
|
|
}
|
|
|
},
|
|
|
error: function() {
|
|
|
tip.show('网络断开连接了~');
|
|
|
}
|
|
|
}).always(function() {
|
|
|
loading.hideLoading();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function seckillInit() {
|
|
|
loadSeckillList();
|
|
|
|
|
|
$(document).on('click', '.seckill-tab .tab-item', function() {
|
|
|
$(this).addClass('actived').siblings().removeClass('actived');
|
|
|
if (!$(this).hasClass('actived')) {
|
|
|
$(this).addClass('actived').css({
|
|
|
background: $(this).parent().data('tabSelectColor')
|
|
|
}).siblings().removeClass('actived').css({
|
|
|
background: $(this).parent().data('tabColor')
|
|
|
});
|
|
|
|
|
|
refreshProductList($(this).data('id'), $(this).data('time'));
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
|