...
|
...
|
@@ -9,13 +9,66 @@ var tableOperation = { |
|
|
$body: $('.table.table-body'),
|
|
|
removeBody: function() {
|
|
|
this.$body = $('.table.table-body');
|
|
|
this.$body.remove();
|
|
|
},
|
|
|
appendBody: function(htmlStr) {
|
|
|
this.$body.remove();
|
|
|
$(htmlStr).appendTo(this.$header);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
var countDown = {
|
|
|
count: null,
|
|
|
intervalTimer: null,
|
|
|
intervalValue: 60000,
|
|
|
$element: null,
|
|
|
selector: '.left-time',
|
|
|
setTime: function() {
|
|
|
var that = this;
|
|
|
|
|
|
this.$element.each(function(index, item) {
|
|
|
var $item = $(item);
|
|
|
var leftTime = $item.data('left');
|
|
|
|
|
|
$item.text(that.convertLeftTime(leftTime - that.count * 60));
|
|
|
});
|
|
|
this.count += 1;
|
|
|
},
|
|
|
convertLeftTime: function(src) {
|
|
|
var min = parseInt(src / 60, 10) % 60;
|
|
|
var hour = parseInt(src / 3600, 10);
|
|
|
var timeStr = min + '分钟';
|
|
|
|
|
|
if (src <= 0) {
|
|
|
timeStr = '已失效';
|
|
|
return timeStr;
|
|
|
}
|
|
|
|
|
|
if (hour > 0) {
|
|
|
timeStr = hour + '小时' + timeStr;
|
|
|
}
|
|
|
|
|
|
timeStr = '剩余' + timeStr;
|
|
|
|
|
|
return timeStr;
|
|
|
},
|
|
|
getLeftTime: function() {
|
|
|
var that = this;
|
|
|
|
|
|
if (this.$element.length) {
|
|
|
this.setTime();
|
|
|
this.intervalTimer = setInterval(this.setTime.bind(that), that.intervalValue);
|
|
|
}
|
|
|
},
|
|
|
start: function() {
|
|
|
this.count = 0;
|
|
|
this.$element = $(this.selector);
|
|
|
if (this.intervalTimer) {
|
|
|
clearInterval(this.intervalTimer);
|
|
|
}
|
|
|
this.getLeftTime();
|
|
|
}
|
|
|
};
|
|
|
|
|
|
require('./me');
|
|
|
|
|
|
function getOrderList(type, page) {
|
...
|
...
|
@@ -30,6 +83,7 @@ function getOrderList(type, page) { |
|
|
}).done(function(res) {
|
|
|
tableOperation.appendBody(res);
|
|
|
bindPaginationClick(); // eslint-disable-line
|
|
|
countDown.start();
|
|
|
}).fail(function(err) {
|
|
|
console.log(err);
|
|
|
});
|
...
|
...
|
@@ -49,6 +103,10 @@ function getQueryString() { |
|
|
return query;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function bindPaginationClick() {
|
|
|
$('.blk-pagination li').off('click').on('click', function(e) {
|
|
|
var $this = $(this);
|
...
|
...
|
@@ -60,6 +118,7 @@ function bindPaginationClick() { |
|
|
if (!$this.hasClass('active')) {
|
|
|
$('.blk-pagination li.active').removeClass('active');
|
|
|
$this.addClass('active');
|
|
|
$(window).scrollTop(0);
|
|
|
|
|
|
getOrderList(type, page);
|
|
|
}
|
...
|
...
|
@@ -69,11 +128,14 @@ function bindPaginationClick() { |
|
|
|
|
|
$('.tabs li').on('click', function() {
|
|
|
var $this = $(this);
|
|
|
var $searchBar = $('.search-bar');
|
|
|
|
|
|
var typeMap = {
|
|
|
all: 1,
|
|
|
paying: 2,
|
|
|
delivering: 3
|
|
|
};
|
|
|
|
|
|
var type = typeMap[$this.data('type')];
|
|
|
var page = getQueryString().page;
|
|
|
|
...
|
...
|
@@ -81,6 +143,12 @@ $('.tabs li').on('click', function() { |
|
|
$('.tabs li.active').removeClass('active');
|
|
|
$this.addClass('active');
|
|
|
|
|
|
if (type !== 1) {
|
|
|
$searchBar.addClass('vhide');
|
|
|
} else {
|
|
|
$searchBar.removeClass('vhide');
|
|
|
}
|
|
|
|
|
|
getOrderList(type, page);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -88,3 +156,4 @@ $('.tabs li').on('click', function() { |
|
|
|
|
|
|
|
|
bindPaginationClick();
|
|
|
countDown.start(); |
...
|
...
|
|