ecshop首页推荐的分类也能倒计时
2009-11-16 09:32 来源:www.chinab4c.com 作者:ecshop专家
1:cat_goods.lbi中修改成以下
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<div class="box">
<div class="box_1">
<h3><span><a href="{$goods_cat.url}" class="f6">{$goods_cat.name|escape:html}</a></span></h3>
<div class="centerPadd">
<div class="clearfix goodsBox" style="border:none;">
<script>
var DifferHour = -1
var DifferMinute = -1
var DifferSecond = -1
var daysms = 24 * 60 * 60 * 1000
var hoursms = 60 * 60 * 1000
var Secondms = 60 * 1000
var microsecond = 1000
<!--{foreach from=$cat_goods item=goods key = key}-->
{if $goods.promote_end_date}
var Tday{$goods.id} = new Date("{$goods.promote_end_date}");//循环出结束时间
{/if}
{/foreach}
</script>
<!--{foreach from=$cat_goods item=goods key=key}-->
{if $goods.promote_end_date}
<script>
function clock{$goods.id}()//动态生成数组
{
var time = new Date()
var hour = time.getHours()
var minute = time.getMinutes()
var second = time.getSeconds()
var timevalue = ""+((hour > 12) ? hour-12:hour)
timevalue +=((minute < 10) ? ":0":":")+minute
timevalue +=((second < 10) ? ":0":":")+second
timevalue +=((hour >12 ) ? " PM":" AM")
var convertHour = DifferHour
var convertMinute = DifferMinute
var convertSecond = DifferSecond
var Diffms = Tday{$goods.id}.getTime() - time.getTime()
DifferHour = Math.floor(Diffms / daysms)
Diffms -= DifferHour * daysms
DifferMinute = Math.floor(Diffms / hoursms)
Diffms -= DifferMinute * hoursms
DifferSecond = Math.floor(Diffms / Secondms)
Diffms -= DifferSecond * Secondms
var dSecs = Math.floor(Diffms / microsecond)
if(convertHour != DifferHour) a="<font color=red>"+DifferHour+"</font>天";
if(convertMinute != DifferMinute) b="<font color=red>"+DifferMinute+"</font>时";
if(convertSecond != DifferSecond) c="<font color=red>"+DifferSecond+"</font>分"
d="<font color=red>"+dSecs+"</font>秒"
document.getElementById("leftTime{$goods.id}").innerHTML = "剩余:"+a + b + c + d;
setTimeout("clock{$goods.id}()",1000)
}
</script>
{/if}
<div class="goodsItem">
<a href="{$goods.url}"><img src="{$goods.thumb}" alt="{$goods.name|escape:html}" class="goodsimg" /></a><br />
<p><a href="{$goods.url}" title="{$goods.name|escape:html}">{$goods.short_name|escape:html}</a>
<br>{if $goods.promote_end_date}<div id="leftTime{$goods.id}">数据加载..</div>{/if}</p>
<!-- {if $goods.promote_price neq ""} -->
<font class="shop_s">{$goods.promote_price}</font>
<!-- {else}-->
<font class="shop_s">{$goods.shop_price}</font>
<!--{/if}-->
</div>
<!--{/foreach}-->
</div>
</div>
</div>
</div>
<div class="blank5"></div>
<script>
{foreach from=$cat_goods item=goods key=key}
{if $goods.promote_end_date}
clock{$goods.id}()
{/if}
{/foreach}
</script>
2:includes/lib_goods.php
assign_cat_goods()函数中
sql语句中增加g.promote_end_date,
数组中增加
$goods[$idx]['promote_end_date'] = local_date('Y/m/d H:i',$row['promote_end_date']);
最近更新
常用插件
- ecshop二次开发打印采购单
在ecshop电子商务系统的开发和使用过程中,我们常常要统计订单的信息...
- ecshop留言板改进
ecshop留言板 改进,这个插件主要是为了改进ecshop留言板功能插件,我们可...
- ecshop后台商品列表编辑属
ecshop后台商品列表编辑属性规格,这个功能十分重要,当我们在后台,录...
- ecshop整合招商银行php支付
最近有个朋友,他是用ecshop的。为了和招商银行合作,必须开发出基于...
- ecshop退款插件2.7.1utf版
ecshop退款插件2.7.1utf版重要可以通过会员中心,会员在收到货之后,发现...