實現前後臺同步倒計時

2021-09-11 07:12:18 字數 2325 閱讀 1421

web:首先定義全域性變數,建立hashmap存放值

hashmapmapcountdown=new hashmap();

int hour;//時

int minute;//分

int second;//秒

倒計時方法,獲取限時競價時間,將時間分割成時分秒,賦值給三個全域性變數,通過while()迴圈實現倒計時

/**

* 拍賣開始,進入限時競價時間,倒計時

* 將倒計時值傳入mapcountdown中

* 後台-拍賣管理-拍賣大廳

mapcountdown.put(integer.parseint(id), h+hour+"小時"+m+minute+"分鐘"+s+second+"秒");

//strcountdown=h+hour+"小時"+m+minute+"分鐘"+s+second+"秒";

"countdown"+id, h+hour+"小時"+m+minute+"分鐘"+s+second+"秒");

thread.sleep(1000);

}}else

if(minute<10)

if(second<10)

mapcountdown.put(integer.parseint(id), h+hour+"小時"+m+minute+"分鐘"+s+second+"秒");

//strcountdown=h+hour+"小時"+m+minute+"分鐘"+s+second+"秒";

"countdown"+id, h+hour+"小時"+m+minute+"分鐘"+s+second+"秒");

thread.sleep(1000);

}}else

if(minute<10)

if(second<10)

mapcountdown.put(integer.parseint(id), h+hour+"小時"+m+minute+"分鐘"+s+second+"秒");

//strcountdown=h+hour+"小時"+m+minute+"分鐘"+s+second+"秒";

"countdown"+id, h+hour+"小時"+m+minute+"分鐘"+s+second+"秒");

if(hour==0&&minute==0&&second==0)

thread.sleep(1000);

}}else

}} pw.write("");

}

獲取倒計時值,返回介面

/**

* 根據拍賣id獲取mapcountdown中值

* 限時競價倒計時時間

* 前後臺—拍賣大廳

在js中建立乙個計時器setinterval()獲取web層mapcountdown中的值

js:前台獲取倒計時的值

//倒計時 獲取限時競價時間

var timer;

function getsessionvalue()/auctioncontroller/getsessionvalue.do",,function(data)else if(data=="暫停中...")elseelse}}

});},500);

}

後台獲取倒計時的值

//倒計時

var timer;

function getsessionvalue()/auctioncontroller/getsessionvalue.do",,function(data)else if(data=="暫停中...")else}//

});},500);

}

效果:

倒計時 心跳倒計時

我從悶熱的午後醒來,可還是頭痛得厲害,睡意再次湧上心頭,我告訴自己不能再昏睡下去,於是決定出門去清醒一下。現在的天氣雖說有些燥熱,但是陰涼處還是比較涼爽,我慢慢地走,接著慢跑了起來,夕陽散發著最後一縷餘暉。我邊看著眼前的城市邊際的美景邊深呼吸著,隨著耳機裡傳來的 律動著。突然有個聲音從我腦海裡響起,...

js倒計時,秒倒計時,天倒計時

html 1 html 2 距某某開幕式還有 天 html html html id timer style color red 這次利用系統時間自校驗倒計時,無需手工調校使得倒計時更為精確,及詳細注釋如下 id clock 00 01 11 00 id startb type button val...

JQuery實現倒計時

以下是要實現的效果 當條件滿足時,出彈窗,3秒後自動跳轉指定頁面 姓名 type text name name cwid type text name cwid class submit nclick submit 註冊 class tishi hide 恭喜您,身份驗證成功倒計時 id time ...