Authored by 陈轩

Merge remote-tracking branch 'origin/release/5.1' into seckil-refactor

... ... @@ -352,4 +352,4 @@ exports.receiveCoupon = (receiveData, uid) => {
}
return returnData;
});
};
\ No newline at end of file
};
... ...
... ... @@ -210,7 +210,7 @@ const remind = (req, res, next) => {
}
return seckillModel.remind({
on_off: req.body.on_off,
on_off: req.body.on_off === 'true' ? true : false,
activity_id: Number.parseInt(req.body.activity_id, 10),
product_skn: Number.parseInt(req.body.product_skn, 10),
uid: Number.parseInt(req.body.uid, 10),
... ...
... ... @@ -16,7 +16,7 @@ module.exports = {
siteUrl: '//m.yohobuy.com',
assetUrl: '//localhost:5001',
domains: {
api: 'http://api.yoho.cn/',
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service.yoho.cn/',
liveApi: 'http://api.live.yoho.cn/',
singleApi: 'http://single.yoho.cn/'
... ...
... ... @@ -14,7 +14,7 @@
<div class="item-foot">
{{# if wait}}
<div class="item-time" data-start="{{startTime}}"><span><i class="iconfont">&#xe603;</i><time>{{readaleTime startTime}}</time>开始</span></div>
<div class="item-time" data-start="{{startTime}}"><span><i class="iconfont">&#xe603;</i><time>{{@root.readaleTime startTime}}</time>开始</span></div>
{{else}}
<div class="item-price">
<ins>¥{{secKillPrice}}</ins><del>¥{{marketPrice}}</del>
... ...
module.exports = function(url, width, height, mode) {
mode = !isNaN(mode) ? mode : 2;
url = url || '';
url = url.replace(/{width}/g, width).replace(/{height}/g, height).replace(/{mode}/g, mode);
if (url.indexOf('imageView2') > 0) {
url += '/q/70';
}
return url.replace('http:', '');
};
... ...
... ... @@ -239,6 +239,7 @@ seckillObj = {
success: function(data) {
$('.product-list').html(data);
lazyload('img.lazy');
window.rePosFooter();
},
error: function(data) {
tip.show('网络断开连接了~');
... ... @@ -264,27 +265,31 @@ seckillObj = {
time = $(elem).find('input.date').val() / 1000;
}
offsetTime = time - nowTime;
that.startTick(elem, offsetTime);
that.startTick(elem, offsetTime, nowTime);
},
/**
* [开始倒计时]
*/
startTick: function(elem, offsetTime) {
startTick: function(elem, offsetTime, nowTime) {
var that = this,
$el = this.el,
hour = parseInt(offsetTime / (60 * 60), 10),
minute = parseInt(offsetTime % (60 * 60) / 60, 10),
second = offsetTime % 60;
$(elem).find('.tick.hour').text(hour < 0 ? '00' : (hour < 10 ? ('0' + hour) : hour));
$(elem).find('.tick.minute').text(minute < 0 ? '00' : (minute < 10 ? ('0' + minute) : minute));
$(elem).find('.tick.second').text(second < 0 ? '00' : (second < 10 ? ('0' + second) : second));
if (offsetTime <= 0) { // 结束倒计时刷新状态
that.refreshList(elem);
} else {
$(elem).find('.tick.hour').text(hour < 0 ? '00' : (hour < 10 ? ('0' + hour) : hour));
$(elem).find('.tick.minute').text(minute < 0 ? '00' : (minute < 10 ? ('0' + minute) : minute));
$(elem).find('.tick.second').text(second < 0 ? '00' : (second < 10 ? ('0' + second) : second));
$el.currentTick = setTimeout(function() {
that.startTick(elem, --offsetTime);
var curSec = Math.floor(Date.now() / 1000);
offsetTime = offsetTime - (curSec - nowTime);
that.startTick(elem, offsetTime, curSec);
}, 1000);
}
},
... ... @@ -379,7 +384,9 @@ seckillObj = {
return $.get('/product/seckill')
.done(function(result) {
self.$container.html(
self.pageTemplate($.extend(result, _helpers))
self.pageTemplate($.extend(result, _helpers, {
isApp: yoho.isApp
}))
);
})
.error(function() {
... ...
... ... @@ -26,7 +26,12 @@ var dateText = 0,
newHour = 0,
newMinus = 0;
var skuFlag;
var skuFlag,
hideNum,
hideIndex;
var oneIndex = 0,
twoIndex = 0;
require('../common');
... ... @@ -64,10 +69,11 @@ $(
$('.cart-bar').hide();
$('.current-price').hide();
var ajaxUrl = '/product/detail/seckillData/' + $('#productSkn').val();
var timestamp = Date.parse(new Date());
$.ajax({
type: 'GET',
url: ajaxUrl,
url: ajaxUrl + '?tamp=' + timestamp,
success: function(data) {
// 秒杀是否结束
if (data.status !== 1 && data.status !== 2) {
... ... @@ -112,23 +118,29 @@ $(
// 如果秒杀库存为0
if (data.secKillSku[i].storageNum === 0) {
skuFlag = 0;
$(this).addClass('zero-stock');
oneIndex = $(this).index() + 1;
twoIndex = $(this).parent('ul').index() - 2;
$('.chose-panel .color-list ul:eq(' + oneIndex + ') li:eq(' + twoIndex + ')').addClass('zero-stock');
}
} else {
// alert("没有匹配");
}
}
if (skuFlag === 0) {
$(this).addClass('zero-stock').attr('data-num', '1');
var oneIndex = $(this).index() + 1;
var twoIndex = $(this).parent('ul').index() - 2;
$(this).addClass('zero-stock').attr('data-num', '0').addClass('hide');
oneIndex = $(this).index() + 1;
twoIndex = $(this).parent('ul').index() - 2;
$('.chose-panel .color-list ul:eq(' + oneIndex + ') li:eq(' + twoIndex + ')').addClass('zero-stock');
$('.chose-panel .color-list ul:eq(' + oneIndex + ') li:eq(' + twoIndex + ')').addClass('zero-stock').addClass('hide');
}
}
);
seckHide();// 非秒杀库存置灰
$('.price-date').append(
'<div class="seckill-time seckill-time-border">' +
'<span>距结束&nbsp</span>' +
... ... @@ -199,3 +211,47 @@ $(
}
);
function seckHide() {
$('.chose-panel .size-list ul').each(
function() {
hideNum = 0;
$(this).find('li').each(
function() {
if ($(this).hasClass('hide')) {
oneIndex = $(this).index() + 1;
twoIndex = $(this).parent('ul').index() - 2;
$('.color-list ul:eq(' + oneIndex + ') li:eq(' + twoIndex + ')').hide();
} else {
hideNum++;
}
}
);
if (hideNum === 0) {
hideIndex = $(this).index() - 2;
$('.color-list ul:first li:eq(' + hideIndex + ')').hide();
}
}
);
$('.chose-panel .color-list ul').each(
function() {
hideNum = 0;
$(this).find('li').each(
function() {
if ($(this).hasClass('hide')) {
oneIndex = $(this).index() + 1;
twoIndex = $(this).parent('ul').index() - 2;
$('.size-list ul:eq(' + oneIndex + ') li:eq(' + twoIndex + ')').hide();
} else {
hideNum++;
}
}
);
if (hideNum === 0) {
hideIndex = $(this).index() - 2;
$('.size-list ul:first li:eq(' + hideIndex + ')').hide();
}
}
);
}
... ...
... ... @@ -51,10 +51,11 @@ module.exports = {
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract(['css?-url'])
}, {
test: /\.hbs$/,
loader: 'handlebars'
}]
}, {test: /\.hbs$/, loader: 'handlebars-loader', query: {
helperDirs: [
path.join(__dirname, '/js/common/helpers')
]
}}]
},
resolve: {
modulesDirectories: ['node_modules', './vue', './hbs', './scss', './js'],
... ...