...
|
...
|
@@ -11,23 +11,7 @@ var $ = require('yoho-jquery'), |
|
|
lazyload = require('yoho-jquery-lazyload'),
|
|
|
tip = require('plugin/tip');
|
|
|
|
|
|
|
|
|
var _helpers = {
|
|
|
statusClass: function(nav) {
|
|
|
if (nav.over) {
|
|
|
return 'over';
|
|
|
} else if (nav.now) {
|
|
|
return 'now';
|
|
|
} else if (nav.wait) {
|
|
|
return 'wait';
|
|
|
} else {
|
|
|
return '';
|
|
|
}
|
|
|
},
|
|
|
readaleTime: function(unixStamp) {
|
|
|
return moment.unix(unixStamp).format('MM月DD日 HH:mm');
|
|
|
}
|
|
|
};
|
|
|
window.$ = $;
|
|
|
|
|
|
var seckillObj = {};
|
|
|
|
...
|
...
|
@@ -39,50 +23,56 @@ seckillObj = { |
|
|
pageTemplate: require('template/product/seckill/index.hbs'),
|
|
|
listTemplate: require('template/product/seckill/product-list.hbs'),
|
|
|
|
|
|
el: {
|
|
|
// doms
|
|
|
$navUl: $('.nav-ul'),
|
|
|
$navList: $('.nav-list'),
|
|
|
|
|
|
// 变量
|
|
|
times: $('.nav-ul>li').length,
|
|
|
startX: 0,
|
|
|
timeWidth: 0,
|
|
|
focusTimeWidth: 0,
|
|
|
iScroll: null,
|
|
|
currentTick: null
|
|
|
},
|
|
|
el: {},
|
|
|
|
|
|
/**
|
|
|
* [初始化界面]
|
|
|
*/
|
|
|
init: function() {
|
|
|
var self = this;
|
|
|
this.$container = $('.seckill-list');
|
|
|
this.pageLoad()
|
|
|
.then(function() {
|
|
|
console.log('hi')
|
|
|
var $el = this.el, that = this;
|
|
|
self.domInit();
|
|
|
})
|
|
|
.then(function() {
|
|
|
var $el = self.el;
|
|
|
var focus = $el.$navUl.find('>li.focus');
|
|
|
|
|
|
this.$productList = $('.product-list');
|
|
|
self.$productList = $('.product-list');
|
|
|
$el.$navUl.find('>li').click(function() {
|
|
|
that.selectTime(this);
|
|
|
self.selectTime(self);
|
|
|
});
|
|
|
|
|
|
$(window).resize(function() {
|
|
|
that.initNav();
|
|
|
self.initNav();
|
|
|
});
|
|
|
|
|
|
that.initNav();
|
|
|
self.initNav();
|
|
|
|
|
|
if (focus.length && (focus.hasClass('now') || focus.hasClass('wait'))) {
|
|
|
that.initTick($el.$navUl.find('>li.focus'));
|
|
|
self.initTick($el.$navUl.find('>li.focus'));
|
|
|
}
|
|
|
|
|
|
this.bindEvents();
|
|
|
self.bindEvents();
|
|
|
});
|
|
|
},
|
|
|
|
|
|
domInit: function() {
|
|
|
this.el = {
|
|
|
// doms
|
|
|
$navUl: $('.nav-ul'),
|
|
|
$navList: $('.nav-list'),
|
|
|
|
|
|
// 变量
|
|
|
times: $('.nav-ul>li').length,
|
|
|
startX: 0,
|
|
|
timeWidth: 0,
|
|
|
focusTimeWidth: 0,
|
|
|
iScroll: null,
|
|
|
currentTick: null
|
|
|
};
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* [初始化时间段]
|
|
|
*/
|
...
|
...
|
@@ -224,18 +214,17 @@ seckillObj = { |
|
|
* [异步加载商品列表]
|
|
|
*/
|
|
|
refreshProductList: function(activityId) {
|
|
|
var url = yoho.isApp ?
|
|
|
'/product/seckill/get-product-list?app_version=1' :
|
|
|
'/product/seckill/get-product-list';
|
|
|
|
|
|
loading.show();
|
|
|
$.ajax({
|
|
|
url: '/product/seckill/get-product-list',
|
|
|
url: url,
|
|
|
data: {
|
|
|
uid: yoho.isLogin(), // only app use;
|
|
|
activityId: activityId
|
|
|
},
|
|
|
beforeSend: function(jqXhr, config) {
|
|
|
if (yoho.isApp) {
|
|
|
config.url += '&app_version=1';
|
|
|
}
|
|
|
},
|
|
|
success: function(data) {
|
|
|
$('.product-list').html(data);
|
|
|
lazyload('img.lazy');
|
...
|
...
|
@@ -384,7 +373,7 @@ seckillObj = { |
|
|
return $.get('/product/seckill')
|
|
|
.done(function(result) {
|
|
|
self.$container.html(
|
|
|
self.pageTemplate($.extend(result, _helpers, {
|
|
|
self.pageTemplate($.extend(result, {
|
|
|
isApp: yoho.isApp
|
|
|
}))
|
|
|
);
|
...
|
...
|
|