生命不息,奋斗不止/创造价值-传递价值-获得价值
所谓迷茫,就是才华配不上梦想 每一个让你难堪的现在,都有一个不够努力的曾经

让你的ecshop首页的特价商品也跟京东360一样拥有倒计时功能

怎样让ECSHOP显示拍卖倒计时?  怎样在ECSHOP首页显示拍卖商品倒计时?   如何把在首页拍卖商品列表显示倒计时,   京东商城促销倒计时修改方案,   希望拍卖商品加个开始前的倒计时,   限时抢购 怎么做毫秒倒计时

废话就不多说了,下面进入正题:

1
(ecshop倒计时)

Step 1:

上传 images和library文件夹的文件到对应的目录,首页最终的实现效果如图:
背景图图片大家可以自己做放到images里,本篇ecshop开发之首页特价商品倒计时模块用到的library代码我会在最后给大家写出。

在 /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;
       }

在你ecshop模板的css文件中增加相应的css属性

Step2:设置方法:
A、后台设置促销促销商品,这个系统默认的设置就行,
B、设置促销显示模块,如果你没有修改此文件的话就直接覆盖目录里面的libs.xml文件;代码如下:
第1行代码改为:

<?xml version=”1.0″ encoding=”gb2312″ ?>

因为桃缘成人用品商城用的gb2312编码。其他代码复制http://www.taoyuan99.com/就可以了。

如果你以前修改过性用品模板,那么就在:
<file name=”index.dwt”> 
<region name=”左边区域”>   
<lib>cart</lib>  


后面增加:
<lib>recommend_promotion</lib> 

          
最后的代码就是:
<file name=”index.dwt”>  
<region name=”左边区域”>    
<lib>cart</lib>  <lib>recommend_promotion</lib>   
<lib>brands</lib>,
Step2:在ecshop后台模板中设置显示位置和数量。

此修改的显示在左右2边数量为2个商品,可以根据自己需要修改下css和显示的位置。

.f4_c{color:#316103; font-weight:600; font-size:16px; text-decoration:underline;}
.f4_t{color:#328225;}
.f7{color:#b93035;}

  #sales{width:204px;
  }
  #sales .goodBox{margin:10px 0px 10px 10px; _margin-left:5px;}           
    #sales .goodBox .goodList p{text-align: center; color:#3f3f3f;}
    #sales .goodBox .goodList p a{color:#0e6c02; text-decoration:none;}
  #sales .goodBox .goodList p a:hover{color:#ff6600; text-decoration:none;}
  #sales .goodList{width:160px; margin:0px 14px 15px 14px;}
  #sales .goodList img{ width:100px; height:100px;margin-bottom:6px; margin-top:5px; text-align:center; margin-left:25px;
  }
  #sales .goodList p{ margin-top:3px; text-align:center;}

桃缘情趣用品商城的library文件代码如下:
<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 class=f4_c><strong>”+DifferHour+”</strong></font>天”;
  if(convertMinute != DifferMinute) b=”<font class=f4_c><strong>”+DifferMinute+”</strong></font>时”;
  if(convertSecond != DifferSecond) c=”<font class=f4_c><strong>”+DifferSecond+”</strong></font>分”
    d=”<font class=f4_c><strong>”+dSecs+”</strong></font>秒”
    if (DifferHour>0) {a=a}
    else {a=”}
  document.getElementByIdx_x(“leftTime”+key).innerHTML = a + b + c + d; //显示倒计时信息

                            </script>
<div id=”sales” style=”background:url(images/xstjbg.gif) no-repeat; width:204px; height:455px; margin-left:6px;”>
      <div style=” margin-top:60px;”>
        <!–{foreach from=$promotion_goods key=key item=goods name=”promotion_foreach”}–>
        {if $smarty.foreach.promotion_foreach.index <= 3}
          <div>
    <font size=”2″>剩余</font><font class=”f4_t” id=”leftTime{$key}”>{$lang.please_waiting}</font>
          <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>
       <font>
          <!– {if $goods.market_price neq “”} –>              
         <font style=”color:#727171; font-size:12px;”>市场价:{$goods.market_price}</font><b><font style=”color:#727171; font-size:12px;”></font></b>
   <!– {else}–>
         {$goods.market_price}
         <!–{/if}–>                                                           
          </font><br />
          昆明成人用品网价:<font class=”f7″>{$goods.promote_price}</font><br>                    
        </div>
        {/if}
<script>
Tday[{$key}] = new Date(“{$goods.gmt_end_time}”);        

window.setInterval(function()    
{clock({$key});}, 1000);    
</script>                                       
        <!–{/foreach}–>
      </div>
     </div>
   
<!– {/if} –>

赞(0)
未经允许不得转载:jack361博客 » 让你的ecshop首页的特价商品也跟京东360一样拥有倒计时功能

评论 抢沙发

评论前必须登录!

 

如果你爱我或恨我,请↓

联系我