Authored by lijing

Merge branch 'release/5.1' of http://git.yoho.cn/fe/yohobuywap-node into release/5.1

... ... @@ -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
};
... ...
... ... @@ -83,7 +83,7 @@ router.get('/recommend-for-you/userCenter', recommendForYou.userCenter);
router.get('/recommend-for-you/cart', recommendForYou.cart);
router.get('/seckill', seckill.index); // 秒杀列表页
router.get('/seckill', seckill.checkAppVer('5.1.0'), seckill.index); // 秒杀列表页
router.post('/seckill/remind', seckill.remind); // only app; 秒杀提醒
router.get('/seckill/get-product-list', seckill.getProductList); // 秒杀列表根据活动id获取商品列表
... ...
... ... @@ -30,14 +30,14 @@
<button class="btn btn-remind-off" data-remind data-action="cancel" {{#unless remindFlag}}style="display: none;"{{/unless}}>取消提醒</button>
<button class="btn btn-remind-on" data-remind data-action="add" {{#if remindFlag}}style="display: none;"{{/if}}>提醒我</button>
{{else}}
<a href='/product/show_{{productSkn}}.html?seckill=1' class="btn btn-buy">即将开抢</a>
<a href='/product/show_{{productSkn}}.html' class="btn btn-buy">即将开抢</a>
{{/if}}
{{else}}
<a href='/product/show_{{productSkn}}.html?seckill=1{{#if @root.isApp}}&openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"{{productSkn}}"}}{{/if}}' class="btn btn-buy">去抢购</a>
<a href='/product/show_{{productSkn}}.html{{#if @root.isApp}}?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"{{productSkn}}"}}{{/if}}' class="btn btn-buy">去抢购</a>
{{/if}}
</div>
</div>
</div>
<a class="item-link" href='/product/show_{{{productSkn}}}?{{#unless over}}seckill=1{{/unless}}{{#if @root.isApp}}&openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"{{productSkn}}"}}{{/if}}'></a>
<a class="item-link" href='/product/show_{{{productSkn}}}{{#if @root.isApp}}?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"{{productSkn}}"}}{{/if}}'></a>
</div>
\ No newline at end of file
... ...