Authored by 陈轩

save

... ... @@ -65,10 +65,20 @@ let _helpers = {
*/
const index = (req, res, next) => {
let headerData = headerModel.setNav({
navTitle: '秒杀活动',
navBtn: true,
}),
result = {},
navTitle: '秒杀活动',
navBtn: true,
});
if (!req.xhr) {
return res.render('seckill', {
title: '秒杀活动',
pageHeader: headerData,
pageFooter: true,
width750: true,
});
}
let result = {},
hbsHelper = {
helpers: _helpers
};
... ... @@ -152,13 +162,7 @@ const index = (req, res, next) => {
result.products = _productAddFlag(resultProducts.data, req.yoho.isApp);
// console.log(result);
res.render('seckill', Object.assign({
title: '秒杀活动',
pageHeader: headerData,
pageFooter: true,
width750: true,
times: 12
}, result, hbsHelper));
res.json(result);
});
});
};
... ...
... ... @@ -16,15 +16,15 @@ module.exports = {
siteUrl: '//m.yohobuy.com',
assetUrl: '//localhost:5001',
domains: {
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
liveApi: 'http://api.live.yoho.cn/',
singleApi: 'http://single.yoho.cn/'
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// liveApi: 'http://api.live.yoho.cn/',
// singleApi: 'http://single.yoho.cn/'
// api: 'http://api-test1.yohops.com:9999/',
// service: 'http://service-test1.yohops.com:9999/',
// liveApi: 'http://testapi.live.yohops.com:9999/',
// singleApi: 'http://api-test1.yohops.com:9999/'
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test1.yohops.com:9999/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test1.yohops.com:9999/'
},
subDomains: {
host: '.m.yohobuy.com',
... ...
<div class="seckill-list yoho-page {{#if error}}seckill-list-error{{/if}}">
{{#unless error}}
{{> ./nav}}
<div class="product-list">
{{# products}}
{{> ./roduct}}
{{/products}}
</div>
{{else}}
<div class="seckill-error">{{error}}</div>
{{/unless}}
<section class="tips">
<h5>秒杀活动说明</h5>
<ol>
<li>秒杀商品限活动开始后,在详情页抢购,提前加入购物车无效</li>
<li>秒杀数量有限,抢完即止</li>
<li>活动最终解释权归YOHO!BUY有货所有</li>
</ol>
</section>
</div>
... ...
<nav class="nav-list">
<ul class="nav-ul hide">
{{# activitys}}
<li class="time-item {{# if @last}}last{{/if}} {{# if focus}}focus{{/if}} {{statusClass this}}">
<input type="hidden" name="" class="date" value="{{startTime}}">
<input type="hidden" name="" class="activityId" value="{{activityId}}">
<div class="normal">
<p class="time">{{time}}</p>
<p class="status tip-over">已开抢</p>
<p class="status tip-now">抢购中</p>
<p class="status tip-wait">即将开抢</p>
</div>
<div class="selected">
<p class="time">
<span>{{time}}</span>
<span class="status tip-over">已开抢</span>
<span class="status tip-now">抢购中</span>
<span class="status tip-wait">即将开抢</span>
</p>
<div class="status info-over">
<p>还有商品可以继续抢购</p>
</div>
<div class="status info-now">
<div class="last-info">
<p class="status tip-over">已开抢</p>
<p class="status tip-now">抢购中</p>
<p class="status tip-wait">即将开抢</p>
</div>
<div class="last-count-down">
<p class="countdown">剩余:<i class="tick hour">00</i><i class="tick minute">00</i><i class="tick second">00</i></p>
</div>
</div>
<div class="status info-wait">
<p class="countdown">距开抢:<i class="tick hour">00</i><i class="tick minute">00</i><i class="tick second">00</i></p>
</div>
</div>
</li>
{{/activitys}}
</ul>
</nav>
\ No newline at end of file
... ...
{{# products}}
{{> ./product}}
{{/products}}
\ No newline at end of file
... ...
<div class="item" data-activity="{{activityId}}" data-skn="{{productSkn}}">
<div class="item-img">
<img class="lazy" data-original="{{image defaultImages 235 314}}" alt="">
</div>
<div class="item-info">
<div class="item-title">
{{productName}}
</div>
{{# if wait}}
<div class="item-price">
<ins>¥{{secKillPrice}}</ins><del>¥{{marketPrice}}</del>
</div>
{{/if}}
<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>
{{else}}
<div class="item-price">
<ins>¥{{secKillPrice}}</ins><del>¥{{marketPrice}}</del>
</div>
{{/if}}
<div class="item-button">
{{#if over}}
<span class="old-price">还可以原价购买</span>
<a href='/product/show_{{{productSkn}}}{{#if @root.isApp}}?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"{{productSkn}}"}}{{/if}}' class="btn btn-over">已抢光</a>
{{else if wait}}
{{#if @root.isApp}}
<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' class="btn btn-buy">即将开抢</a>
{{/if}}
{{else}}
<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}}}{{#if @root.isApp}}?openby:yohobuy={"action":"go.productDetail","params":{"product_skn":"{{productSkn}}"}}{{/if}}'></a>
</div>
\ No newline at end of file
... ...
... ... @@ -17,6 +17,8 @@ var seckillObj = {};
lazyload('img.lazy');
seckillObj = {
$productList: null, // DOMContentLoaded的时候 赋值,即init
pageTemplate: require('product/seckill/index.hbs'),
listTemplate: require('product/product-list.hbs'),
el: {
// doms
... ... @@ -36,25 +38,29 @@ seckillObj = {
* [初始化界面]
*/
init: function() {
var $el = this.el, that = this;
var focus = $el.$navUl.find('>li.focus');
this.pageLoad()
.then(function() {
console.log('hi')
var $el = this.el, that = this;
var focus = $el.$navUl.find('>li.focus');
this.$productList = $('.product-list');
$el.$navUl.find('>li').click(function() {
that.selectTime(this);
});
this.$productList = $('.product-list');
$el.$navUl.find('>li').click(function() {
that.selectTime(this);
});
$(window).resize(function() {
that.initNav();
});
$(window).resize(function() {
that.initNav();
});
that.initNav();
that.initNav();
if (focus.length && (focus.hasClass('now') || focus.hasClass('wait'))) {
that.initTick($el.$navUl.find('>li.focus'));
}
if (focus.length && (focus.hasClass('now') || focus.hasClass('wait'))) {
that.initTick($el.$navUl.find('>li.focus'));
}
this.bindEvents();
this.bindEvents();
});
},
/**
... ... @@ -344,6 +350,20 @@ seckillObj = {
yoho.invokeMethod(action, params, onsuccess, function() {
tip.show(failTip);
});
},
pageLoad: function() {
loading.show();
return $.get('/product/seckill')
.done(function(result) {
console.log(result);
})
.error(function() {
console.log('TODO');
})
.always(function() {
loading.hide();
});
}
};
... ...