Authored by lijing

秒杀详情页

... ... @@ -259,3 +259,17 @@ exports.consultsubmit = (req, res, next) => {
return res.json(data);
}).catch(next);
};
exports.getSeckillData = (req, res) => {
detailModel.getSeckillData({
productskn: req.params.productskn
}, req).then(result => {
return res.json(result);
});
};
... ...
... ... @@ -975,7 +975,7 @@ const _getCommonConsult = () => {
/**
* 获取秒杀列表
*/
const _getSeckillData = (productSkn) => {
const getSeckillData = (productSkn) => {
let params = {
method: 'app.seckill.data',
product_skn: productSkn
... ... @@ -991,27 +991,27 @@ const _getSeckillData = (productSkn) => {
}
data = {
'productSkn': 512581470,
'activityId': 4,
'startTime': 1375192655,
'endTime': 1475558971,
'formatSecKillPrice': '¥50.00',
'secKillPrice': 50,
'status': 1,
'secKillSku': [
productSkn: 512581470,
activityId: 4,
startTime: 1475192655,
endTime: 1475558971,
formatSecKillPrice: '¥50.00',
secKillPrice: 50,
status: 1,
secKillSku: [
{
'activityId': 4,
'id': 1,
'productSkn': 512581470,
'productSku': 1384138,
'storageNum': 10
activityId: 4,
id: 1,
productSkn: 512581470,
productSku: 1384138,
storageNum: 10
},
{
'activityId': 4,
'id': 2,
'productSkn': 512581470,
'productSku': 1384140,
'storageNum': 5
activityId: 4,
id: 2,
productSkn: 512581470,
productSku: 1384140,
storageNum: 5
}
]
};
... ... @@ -1020,7 +1020,6 @@ const _getSeckillData = (productSkn) => {
});
};
let getProductData = (data) => {
let finalResult;
let params = {
... ... @@ -1063,7 +1062,7 @@ let getProductData = (data) => {
}),
_getCommonConsult(),
comment.getConsults(result.productId, 1, 2),
_getSeckillData(result.productSkn)
getSeckillData(result.productSkn)
]).then((info) => {
result.promotionBoList = info[1];
finalResult = _detailDataPkg(result, data.uid, data.vipLevel, data.ua);
... ... @@ -1073,7 +1072,8 @@ let getProductData = (data) => {
Object.assign(finalResult.feedbacks, info[2]);
// 判断是否是秒杀
let is_secKill = result.isSecKill || true;
// let is_secKill = result.isSecKill === 'Y' ? true : false;
let is_secKill = true;// TODO
// 秒杀详情页
if (is_secKill && info[5]) {
... ... @@ -1098,8 +1098,10 @@ let getProductData = (data) => {
isSecKill: {
notStart: notStart,
startIng: startIng,
startTime: info[5].startTime,
endTime: info[5].endTime,
// startTime: info[5].startTime,
// endTime: info[5].endTime,
productSkn: data.productSkn,
secKillPrice: info[5].formatSecKillPrice,
noneLeft: leftCount === 0 ? true : false
}
... ... @@ -1136,5 +1138,6 @@ let getProductData = (data) => {
module.exports = {
getProductData,
getUserProfile: _getUserProfile
getUserProfile: _getUserProfile,
getSeckillData
};
... ...
... ... @@ -39,6 +39,7 @@ router.get('/detail/consults', detail.consults); // 商品咨询页
router.get('/detail/consultform', auth, detail.consultform); // 商品咨询表单页
router.get('/detail/comments', detail.comments); // 商品评价
router.post('/detail/consultsubmit', auth, detail.consultsubmit); // 商品咨询提交接口
router.get('/detail/seckillData/:productskn', detail.getSeckillData); // 秒杀数据接口
router.post('/detail/consultupvote', detail.consultUpvoteOrUseful); // 商品咨询提交接口
router.post('/detail/consultuseful', detail.consultUpvoteOrUseful); // 商品咨询提交接口
... ...
... ... @@ -267,7 +267,6 @@
</div>
{{# isSecKill}}
<input type="hidden" class="start-time-text" value={{startTime}} />
<input type="hidden" class="end-time-text" value={{endTime}} />
<input type="hidden" class="productSkn-text" value={{productSkn}} />
{{/isSecKill}}
{{/ result}}
... ...
... ... @@ -3,11 +3,9 @@
* author: 陈峰<feng.chen@yoho.cn>
* date: 2016/09/08
*/
var $ = require('yoho-jquery'),
IScroll = require('yoho-iscroll'),
tip = require('../plugin/tip'),
seckillObj = {};
require('../common');
var timeObj = '';
... ... @@ -15,17 +13,18 @@ var offsetTime = 0;
var nowTime = Date.parse(new Date()) / 1000;
var startTime = $('.start-time-text').val();
var startTime = 0;
var endTime = $('.end-time-text').val();
var endTime = 0;
if (startTime > nowTime) {
offsetTime = startTime - nowTime;
timeObj = $('.seckill-count-num');
} else if (nowTime > startTime && nowTime < endTime) {
offsetTime = endTime - nowTime;
timeObj = $('.end-time');
}
var dateText = 0,
newDate = 0,
newMonth = 0,
newDay = 0,
newHour = 0,
newMinus = 0;
require('../common');
seckillObj = {
el: {
... ... @@ -33,7 +32,6 @@ seckillObj = {
currentTick: null
},
startTick: function(elem, offsetTime) {
var that = this,
$el = this.el,
... ... @@ -57,21 +55,38 @@ seckillObj = {
}
};
seckillObj.startTick(timeObj, offsetTime);
$(
function() {
var dateText = Number($('.start-time-text').val() * 1000);
var newDate = new Date(dateText);
var newMonth = newDate.getMonth() + 1;
var newDay = newDate.getDate();
var newHour = newDate.getHours();
var newMinus = newDate.getMinutes();
$('.notStart').find('.seckill-time-c').text(newMonth + '月' + newDay + '日' + newHour + ':' + newMinus);
$('.go-pay').click(
function() {
alert('去付款');
var ajaxUrl = '/product/detail/seckillData/' + $('.productSkn-text').val();
$.ajax({
type: 'GET',
url: ajaxUrl,
success: function(data) {
startTime = data.startTime;
endTime = data.endTime;
if (startTime > nowTime) {
offsetTime = startTime - nowTime;
timeObj = $('.seckill-count-num');
} else if (nowTime > startTime && nowTime < endTime) {
offsetTime = endTime - nowTime;
timeObj = $('.end-time');
}
dateText = Number(data.startTime * 1000);
newDate = new Date(dateText);
newMonth = newDate.getMonth() + 1;
newDay = newDate.getDate();
newHour = newDate.getHours();
newMinus = newDate.getMinutes();
$('.notStart').find('.seckill-time-c').text(newMonth + '月' + newDay + '日' + newHour + ':' + newMinus);
seckillObj.startTick(timeObj, offsetTime);
},
error: function() {
// alert('err');
}
);
});
}
);
... ...