Authored by 王水玲

修改时间获取方式

... ... @@ -221,3 +221,7 @@ exports.tplPraiseToggle = function(req, res, next) {
res.jsonp(result);
}).catch(next);
};
exports.getServerTimes = function(req, res) {
res.jsonp(Math.round(new Date() / 1000));
};
... ...
... ... @@ -284,6 +284,7 @@ router.get('/feature/goods', feature.goods); // 批量获取商品信息
router.get('/feature/goods/detail', feature.goodsDetail); // 获取商品详情
router.get('/feature/floors/praise', feature.tplPraiseInfo); // 楼层点赞信息
router.get('/feature/floors/togglepraise', feature.tplPraiseToggle); // 楼层点赞/取消
router.get('/feature/getServerTimes', feature.getServerTimes); // 获取服务段时间
// 2016 年度账单
router.get('/annual-account', annualAccount.index);
... ...
... ... @@ -828,53 +828,57 @@ function activityPlan() {
let templateId = $('.template-id').val();
if (atlBo) {
let curTime = Math.round(new Date() / 1000);
let showTimes = [];
let planTimes = [];
let localUrl = '';
let query = '';
$.ajax({
url: '//m.yohobuy.com/activity/feature/getServerTimes',
dataType: 'jsonp'
}).then(function(curTime) {
let showTimes = [];
let planTimes = [];
let localUrl = '';
let query = '';
qs.timeStamp = curTime;
qs.timeStamp = curTime || Math.round(new Date() / 1000);
Object.keys(qs).map((key, index) => {
if (index === 0) {
query += `${key}=${qs[key]}`;
} else {
query += `&${key}=${qs[key]}`;
}
return query;
});
localUrl = `${location.origin}${location.pathname}?${query}`;
Object.keys(qs).map((key, index) => {
if (index === 0) {
query += `${key}=${qs[key]}`;
} else {
query += `&${key}=${qs[key]}`;
}
return query;
});
atlBo = JSON.parse(atlBo);
atlBo.forEach(t => {
if (t.showTime <= curTime) {
showTimes.push(t);
} else {
planTimes.push(t);
}
});
localUrl = `${location.origin}${location.pathname}?${query}`;
showTimes = showTimes.sort((a, b) => {
return b.showTime - a.showTime;
});
atlBo = JSON.parse(atlBo);
atlBo.forEach(t => {
if (t.showTime <= curTime) {
showTimes.push(t);
} else {
planTimes.push(t);
}
});
planTimes = planTimes.sort((a, b) => {
return a.showTime - b.showTime;
});
showTimes = showTimes.sort((a, b) => {
return b.showTime - a.showTime;
});
if (showTimes && showTimes[0] && showTimes[0].templateId !== +templateId) {
location.href = localUrl;
}
planTimes = planTimes.sort((a, b) => {
return a.showTime - b.showTime;
});
if (planTimes && planTimes[0] && planTimes[0].showTime) {
let time = (planTimes[0].showTime - curTime) * 1000;
let countDown = setTimeout(function() {
if (showTimes && showTimes[0] && showTimes[0].templateId !== +templateId) {
location.href = localUrl;
clearTimeout(countDown);
}, time);
}
}
if (planTimes && planTimes[0] && planTimes[0].showTime) {
let time = (planTimes[0].showTime - curTime) * 1000;
let countDown = setTimeout(function() {
location.href = localUrl;
clearTimeout(countDown);
}, time);
}
});
}
}
... ...