我正在asp.net的拍卖网站上工作。当我们点击每个批次的增量出价按钮时,如果计时器中的时间少于3分钟,那么批次时间会延长3分钟,但每个批次的计时器会在几秒钟内失配,而我的客户不希望这样。
这是调用JS函数来扩展批次的时间:
eval('timer' + auctionLotId).cdtime('timer' + auctionLotId + "', '" + auctioncurrtime + "', '" + auctionendtimer + "', " + auctionLotId);
这是用于更新计时器的JS文件:
function cdtime(container, currentTime, targetdate, AuctionLotID) {
if (!document.getElementById || !document.getElementById(container))
return;
this.container = document.getElementById(container);
this.auctionLotID = AuctionLotID;
var now = new Date();
//this.currentTime = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds());
//this.currentTime = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
this.currentTime = new Date(currentTime);
this.targetdate = new Date(targetdate);
this.currentTime.setSeconds(this.currentTime.getSeconds() - 1);
//alert('currentTime: ' + this.currentTime);
//this.targetdate = new Date(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
this.timesup = false;
this.updateTime();
}
cdtime.prototype.resetTimer = function (newdate) {
var thisobj = this;
this.targetdate = new Date(newdate);
this.extended = 1;
this.timesup = false;
//this.updateTime();
}
cdtime.prototype.updateTime = function () {
//alert(this.currentTime);
var thisobj = this;
this.currentTime.setSeconds(this.currentTime.getSeconds() + 1);
this.tim = setTimeout(function () { thisobj.updateTime() }, 1000); //update time every second
//timer = setTimeout(updatetimer, 1000);
}