...
|
...
|
@@ -35,7 +35,7 @@ function _productAddFlag(productList) { |
|
|
productList.forEach(product => {
|
|
|
if (now < product.startTime * 1000) { // 未开抢
|
|
|
product.wait = true;
|
|
|
} else if (product.secKillStatus === 0) { // 已开抢-已抢光
|
|
|
} else if (product.secKillStatus === 0 || (now > product.endTime * 1000)) { // 确实已抢光, 过了秒杀时间
|
|
|
product.over = true;
|
|
|
}
|
|
|
});
|
...
|
...
|
@@ -56,7 +56,7 @@ let _helpers = { |
|
|
}
|
|
|
},
|
|
|
readaleTime: (unixStamp) => {
|
|
|
return moment.unix(unixStamp).format('MM月DD日 hh:mm');
|
|
|
return moment.unix(unixStamp).format('MM月DD日 HH:mm');
|
|
|
}
|
|
|
};
|
|
|
|
...
|
...
|
@@ -123,7 +123,7 @@ const index = (req, res, next) => { |
|
|
result.activitys[i].focus = true;
|
|
|
break;
|
|
|
}
|
|
|
} while (i < 0);
|
|
|
} while (i >= 0);
|
|
|
|
|
|
// 没有over,全部都是未开抢,则focus第一个
|
|
|
if (i < 0) {
|
...
|
...
|
@@ -137,7 +137,7 @@ const index = (req, res, next) => { |
|
|
|
|
|
// console.log(result);
|
|
|
res.render('seckill', Object.assign({
|
|
|
title: '秒杀',
|
|
|
title: '秒杀活动',
|
|
|
pageHeader: headerData,
|
|
|
pageFooter: true,
|
|
|
width750: true,
|
...
|
...
|
@@ -194,8 +194,61 @@ const remind = (req, res, next) => { |
|
|
});
|
|
|
};
|
|
|
|
|
|
// Middleware:检测 app_version 是否正确
|
|
|
// @param okVersion string "5.1.0" [master_version, minor_version, patch_version]
|
|
|
// TODO: 可以移到 middleware;
|
|
|
const checkAppVer = function(okVersion) {
|
|
|
return (req, res, next) => {
|
|
|
/**
|
|
|
* [比较app版本]
|
|
|
* @param okVersion string '5.1.0'
|
|
|
* @param curVersion string
|
|
|
* @returns -1: 小于, 0 等于, 1大于
|
|
|
*/
|
|
|
|
|
|
let compareVersion = (okVersion, curVersion) => { //eslint-disable-line
|
|
|
let result = 0; // -1: 小于, 0 等于, 1 大于
|
|
|
|
|
|
if (okVersion === curVersion) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
okVersion = okVersion.split('.');
|
|
|
curVersion = curVersion.split('.');
|
|
|
|
|
|
for (var i = 0; i < 3; i++) {
|
|
|
let standard = Number.parseInt(okVersion[i], 10) || 0;
|
|
|
let cur = Number.parseInt(curVersion[i], 10) || 0;
|
|
|
|
|
|
if (cur < standard) {
|
|
|
result = -1;
|
|
|
break;
|
|
|
} else if (cur > standard) {
|
|
|
result = 1;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
};
|
|
|
|
|
|
|
|
|
if (req.yoho.isApp) {
|
|
|
let curVersion = req.query.app_version;
|
|
|
let isOld = compareVersion(okVersion, curVersion) === -1;
|
|
|
|
|
|
if (isOld) {
|
|
|
return res.redirect('/passport/update');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
next();
|
|
|
};
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
index,
|
|
|
getProductList,
|
|
|
remind
|
|
|
remind,
|
|
|
checkAppVer
|
|
|
}; |
...
|
...
|
|