超简单可用仿京东商城 限时抢购多个促销商品倒计时特

原文地址:http://bbs.ecshop.com/viewthread.php?tid=115004&page=1

 

无奈做好事真难,删除图个安心
各位看官请考虑下我免费制作这个效果,并且好心写出教程,无奈网上小人总会以各种方式来说你做得不够,
本人不是来教基础知识的,连基本的模板选择都不会我怎么去教他们做这些功能,反而不教这些基础知识成为了我共享这个功能点的不对的地方。
喜欢这个特效的朋友,可以去下载站点查看:
http://www.belary.com/rpg

需要的朋友我只提供程序包,安装方法不再赘述了。


===重新更新帖子里,把以前的删掉了====

安装方法如下:
1. myget_promote_goods()这个函数拷贝到includes/lib_goods.php中



function myget_promote_goods($cats = '')
{
    $time = gmtime();
    $order_type = $GLOBALS['_CFG']['recommend_order'];
   
    $num = get_library_number("recommend_promotion");
    $sql = 'SELECT g.goods_id, g.goods_name, g.goods_number,g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, ' .
                "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, ".
                "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, b.brand_name, " .
                "g.is_best, g.is_new, g.is_hot, g.is_promote, RAND() AS rnd " .
            'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
            'LEFT JOIN ' . $GLOBALS['ecs']->table('brand') . ' AS b ON b.brand_id = g.brand_id ' .
            "LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
                "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
            'WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ' .
            " AND g.is_promote = 1 AND promote_start_date <= '$time' AND promote_end_date >= '$time' ";
    $sql .= $order_type == 0 ? ' ORDER BY g.sort_order, g.last_update DESC' : ' ORDER BY rnd';
    $sql .= " LIMIT $num ";
    $result = $GLOBALS['db']->getAll($sql);
    $goods = array();
    foreach ($result AS $idx => $row)
    {
        if ($row['promote_price'] > 0)
        {
            $promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
            $goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : '';
        }
        else
        {
            $goods[$idx]['promote_price'] = '';
        }
        $goods[$idx]['id']           = $row['goods_id'];
        $goods[$idx]['name']         = $row['goods_name'];
  $goods[$idx]['num']         = $row['goods_number'];
        $goods[$idx]['brief']        = $row['goods_brief'];
        $goods[$idx]['brand_name']   = $row['brand_name'];
        $goods[$idx]['goods_style_name']   = add_style($row['goods_name'],$row['goods_name_style']);
        $goods[$idx]['short_name']   = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
        $goods[$idx]['short_style_name']   = add_style($goods[$idx]['short_name'],$row['goods_name_style']);
        $goods[$idx]['market_price'] = price_format($row['market_price']);
        $goods[$idx]['shop_price']   = price_format($row['shop_price']);
        $goods[$idx]['thumb']        = get_image_path($row['goods_id'], $row['goods_thumb'], true);
        $goods[$idx]['goods_img']    = get_image_path($row['goods_id'], $row['goods_img']);
        $goods[$idx]['url']          = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
  //设置时间
  if ($time >= $row['promote_start_date'] && $time <= $row['promote_end_date'])
        {
   $goods[$idx]['gmt_end_time'] = $row['promote_end_date'];
        }
        else
        {
   $goods[$idx]['gmt_end_time']  =  0;
        }
    }
    return $goods;
}

复制代码
2. 新建一个文本文档名称为countdown_promote.lbi 保存到library 文件 目录下内如如下:



限时抢购




{$lang.please_waiting}






3.在你需要显示倒计时的地方引用countdown_promote.lbi即可。 如下:

并且在index.php中对模板变量进行赋值

  1. $smarty->assign('cats_promote_goods', myget_promote_goods($cat_id)); // 调用栏目限时抢购商品
复制代码


4. 再次说明下,这个代码例子是基于我的模板上的每个模板的样式不同,需要自行调整。

转载于:https://www.cnblogs.com/yeye518/archive/2010/08/18/2231671.html

你可能感兴趣的:(超简单可用仿京东商城 限时抢购多个促销商品倒计时特)