您现在的位置是:首页 > 教程 > ecshop商城教程ecshop商城教程
ecshop商品促销倒计时效果在首页显示代码实例
访卉2023-12-17 22:03:39ecshop商城教程已有人查阅
导读1、首先修改程序部分打开includes/lib_goods.php找到get_promote_goods()函数部分2、然后将 library/recommend_promotion.lbi全部替换为下面代码:
ecshop促销时间倒计时
1、首先修改程序部分打开includes/lib_goods.php找到get_promote_goods()函数部分在
1、首先修改程序部分打开includes/lib_goods.php找到get_promote_goods()函数部分在
$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
下面增加代码
$time = gmtime();
if ($time >= $row['promote_start_date'] && $time <= $row['promote_end_date'])
{
$goods[$idx]['gmt_end_time'] = local_date('M d, Y H:i:s',$row['promote_end_date']);
}
else
{
$goods[$idx]['gmt_end_time'] = 0;
}
2、然后将 library/recommend_promotion.lbi全部替换为下面代码:
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<!-- {if $promotion_goods} -->
<script >
var Tday = new Array();
var daysms = 24 * 60 * 60 * 1000
var hoursms = 60 * 60 * 1000
var Secondms = 60 * 1000
var microsecond = 1000
var DifferHour = -1
var DifferMinute = -1
var DifferSecond = -1
function clock(key)
{
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[key].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>秒"
if (DifferHour>0) {a=a}
else {a=''}
document.getElementByIdx_xx_x("leftTime"+key).innerHTML = a + b + c + d; //显示倒计时信息
}
</script>
<div id="sales" class="f_l clearfix">
<h1><a href="../search.php?intro=promotion"><img src="images/more.gif" /></a></h1>
<div class="clearfix goodBox">
<!--{foreach from=$promotion_goods key=key item=goods name="promotion_foreach"}-->
{if $smarty.foreach.promotion_foreach.index <= 3}
<div class="goodList">
<a href="{$goods.url}"><img src="{$goods.thumb}" border="0" alt="{$goods.name|escape:html}"/></a><br />
<p><a href="{$goods.url}" title="{$goods.name|escape:html}">{$goods.short_name|escape:html}</a></p>
{$lang.promote_price}<font class="f1">{$goods.promote_price}</font><br><font class="f4" id="leftTime{$key}">{$lang.please_waiting}</font>
</div>
{/if}
<script>
Tday[{$key}] = new Date("{$goods.gmt_end_time}");
window.setInterval(function()
{clock({$key});}, 1000);
</script>
<!--{/foreach}-->
</div>
</div>
<!-- {/if} -->
本文标签:
很赞哦! ()
相关文章
随机图文
-
ecshop后台通过ajax搜索
ecshop的搜索其实是功能十分强大的,但是ecshop搜索功能前台和后台还不大一样,前台主要是通过get方式,提交的url进行分页,而在ecshop的后台,则是接受表单的搜索条件,然后通过js发布到ajax -
ecshop用户中心收藏列表商品显示商品缩略图
ECSHOP用户中心收藏列表商品显示商品缩略图修改教程代码号ECSHOP视频教程也再不断的完善与跟进,期待大家的关注!希望在ECSHOP的道路上,代码号与您一路同行! -
ecshop完全清除版权信息的方法
完整去掉版权和后门的方法:去ECSHOP版权,去官方后门,完整版ECShop是一款B2C独立网店系统,适合企业及个人快速构建个性化网上商店。系统开源但不免费 -
ecshop收货人收货地址信息的省市区改成非必选项
今天为大家详细解说一下ECSHOP收货人收货地址信息的省市区改成非必选项代码号ECSHOP视频教程也再不断的完善与跟进,期待大家的关注!希望在ECSHOP的道路上
留言与评论 (共有 条评论) |