The following is an example of a second-kill product:
1. template:
JS Code for countdown prompt
<MCE: Script Type = "text/JavaScript"> <! -- <Br/> var the_s = new array (); <br/> function $ (ID) {<br/> return document. getelementbyid (ID); <br/>}< br/> function view_time (the_s_index, objid) {<br/> If (the_s [the_s_index]> = 0) {<br/> var the_d = math. floor (the_s [the_s_index]/3600)/24) <br/> var the_h = math. floor (the_s [the_s_index]-the_d * 24*3600)/3600); <br/> var the_m = math. floor (the_s [the_s_index]-the_d x 24 * 3600-the_h * 3600)/60); <br/> var the_s = (_ S [the_s_index]-the_h * 3600) % 60; <br/> html = "Left"; <br/> // If (the_d! = 0) HTML + = the_d + "day"; <br/> If (the_d! = 0 | the_h! = 0) HTML + = '<SPAN class = "Hour">' + (the_h + (the_d * 24) + "</span> Hour "; <br/> If (the_d! = 0 | the_h! = 0 | the_m! = 0) HTML + = '<SPAN class = "Minute">' + the_m + "</span> points "; <br/> HTML + = '<SPAN class = "second">' + the_s + "</span> seconds"; <br/> $ (objid ). innerhtml = HTML; <br/> the_s [the_s_index] --; <br/>}else {<br/> $ (objid ). innerhtml = "ended"; <br/>}< br/> // --> </MCE: SCRIPT>
Because the second kill uses the server time, it cannot be displayed on a single page in the background using static mode. because there is no start time or end time in the mall of kingcms, I need to add two fields in the model management in the background:
Nstart varchar (20) not null,
Nfinish varchar (20) not null
<Tr> <TH> Start time </Th> <TD> {King: _ nstart/} </TD> </tr>
<Tr> <TH> end time </Th> <TD> {King: _ nfinish/} </TD> </tr>
I want to have a countdown prompt at the start time. Enable the dbquery module for query. If the current server time reaches the start time, there will be a countdown prompt.
<Div class = "item"> <br/> <p id = "limitad _ {King: Kid/}"> </P> <br/> {king: dbquery query = "select kid, k_nfinish, unix_timestamp (k_nstart) as k_cstart, unix_timestamp (k_nfinish) as k_cfinish from King _ shop where KID = (King: Kid /) "} </P> <p> <? Php <br/> date_default_timezone_set ("PRC"); <br/> // if the current time is greater than or equal to the activity start time <br/> If (Time () >={ king: k_cstart/} & time () <= {King: k_cfinish/}) {<br/> echo "<MCE: script language =/" javascript/"> <! -- <Br/> var startdate = new date ('". date ("Y/M/d h: I: s "). "'); var enddate = new date (' {King: k_nfinish replace = '-|/'/} '); the_s [{King: Kid/}] = (enddate. gettime ()-startdate. gettime ()/1000; setinterval (/"view_time ({King: Kid/}, 'limitad _ {King: Kid/} ')/", 1000 ); <br/> // --> </MCE: SCRIPT> "; <br/>}?> <Br/> {/King: dbquery} <br/> </div>
The following is a connection:
<A href = "{config: system. inSt/} portal/groupbuy. php? Action = secondbuy & pid = {King: Kid/} & cid = 1 "> purchase </a>