首页调用团购购买数量剩余时间【已解决】
2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家
此方法是参照网络上的修改方法,我也试了很多遍,一直都还是不行,处于:“请稍等,正在载入中…”现研究了好一会儿终于能够正常显示剩余时间,特把解决方法晒出来,帮助有着同样问题无处寻觅答案的童鞋们: 首先修改index.php中的代码: /** * 获得最新的团购活动 * * @accessprivate * @returnarray */ function index_get_group_buy() { $time = gmtime(); $limit = get_library_number('group_buy', 'index'); $group_buy_list = array(); if ($limit > 0) { $sql = 'SELECT gb.act_id AS group_buy_id, gb.goods_id, gb.ext_info, gb.goods_name, g.goods_thumb, g.goods_img,gb.end_time ' . 'FROM ' . $GLOBALS['ecs']->table('goods_activity') . ' AS gb, ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "WHERE gb.act_type = '" . GAT_GROUP_BUY . "' " . "AND g.goods_id = gb.goods_id " . "AND gb.start_time <= '" . $time . "' " . "AND gb.end_time >= '" . $time . "' " . "AND g.is_delete = 0 " . "ORDER BY gb.act_id DESC " . "LIMIT $limit" ; $res = $GLOBALS['db']->query($sql); while ($row = $GLOBALS['db']->fetchRow($res)) { $row['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $row['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $ext_info = unserialize($row['ext_info']); $stat = group_buy_stat($row['group_buy_id'], $ext_info['deposit']); $price_ladder = $ext_info['price_ladder']; if (!is_array($price_ladder) || empty($price_ladder)) { $row['last_price'] = price_format(0); } else { foreach ($price_ladder AS $amount_price) { $price_ladder[$amount_price['amount']] = $amount_price['price']; } } ksort($price_ladder); //$smarty->assign('now_time',gmtime());// 当前系统时间 $row['gmt_now_date']= $group_buy['end_date'];// 当前时间 //$row['gmt_now_date'] = format_time($row['end_date']);// 当前时间 $row['gmt_end_date'] = $row['end_time'];// 结束时间 $row['vn'] = $stat['valid_goods'];//调用团购信息产品购买人数 $row['last_price'] = price_format(end($price_ladder)); $row['url'] = build_uri('group_buy', array('gbid' => $row['group_buy_id'])); $row['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $row['short_style_name'] = add_style($row['short_name'],''); $group_buy_list[] = $row; } } return $group_buy_list; } library/group_buy.lbi 注意这里:原版的lefttime.js是定义的单个ID <font id="leftTime" class="f1">这里循环了,ID重复一定报错。 这里怎么解决呢?你可以自己从JS文件夹里新复制一个lefttime.js这里我命名为:lefttime1.js;调用:<script type="text/javascript" src="js/lefttime1.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=gbk"> <script type="text/javascript" src="js/lefttime.js"></script> <!-- {if $group_buy_goods} --> <div class="box" style="border:1px solid #e2e2e2; width:198px;"> <h3><span>{$lang.group_buy_goods}</span></h3> <div class="box_1" style="border:none;"> <div class="boxCenterList clearfix"> <!--{foreach from=$group_buy_goods item=goods}--> <ul class="clearfix" style="position:relative;"> <li class="goodsimg" style="width:190px; height:190px; margin:0px;"><a style=" margin:0px;width:190px; height:190px;" href="{$goods.url}"><img src="{$goods.thumb}" alt="{$goods.goods_name|escape:html}" class="goodsimg" style=" margin:0;width:190px; height:190px;" /></a></li> <li style="text-align:center; width:200px; overflow:hidden; font-size:14px; font-weight:bold;"><a href="{$goods.url}" title="{$goods.goods_name|escape:html}">{$goods.short_style_name|escape:html}</a></li> <li style="width:100%;"><font class="shop_s">{$goods.last_price}</font></li> <div class="index_group">售出 <strong>{$goods.vn}</strong> 件</div> 剩余时间:<span id="leftTime">结束时间:{$goods.gmt_end_date}</span> </ul> <!--{/foreach}--> </div> </div> </div> <div class="blank"></div> <!-- {/if} --> <script type="text/javascript"> var gmt_end_time = "{$goods.gmt_end_date|default:0}"; {foreach from=$lang.goods_js item=item key=key} var {$key} = "{$item}"; {/foreach} var now_time = "{$goods.gmt_now_date|default:0}"; <!-- {literal} --> onload = function() { try { onload_leftTime(); } catch (e) {} } <!-- {/literal} --> </script> |
最近更新
常用插件
- ecshop2.7.1打印发货单插件
ecshop2.7.1打印发货单插件介绍:ecshop2.7.1和以前的ecshop版本不一样,ecs...
- ecshop商品分类名称增加样
ecshop插件介绍:本插件可以方便在后台管理,为ecshop商品分类名称增加样...
- ecshop二次商品订购人信息
ecshop二次商品订购人信息填写插件,有时候给朋友送花,或者是送礼品的...
- ecshop二次开发详细页面生
插件介绍: ECSHOP系统,在很多时候,很多商品没有人购买,不但购买的人...
- ecshop分类批量扩展插件
ecshop分类批量扩展插件,这个插件是ecshop插件里面比较核心的插件。我们...
ecshop热门问答
ecshop热门资料
ecshop亮点
ecshop商品相册
ecshop过来人
ecshop留言本
ecshop邮件服务器设置
ecshop外包网站维护
ecshop一号店分类首页
ecshop新装
dedecms文章统计
ecshop分类图片
ecshop缺省
ecshop人人
ecshop分库存
安装失败
zencart销售数量
ecshop工具栏
ecshop单位
ecshop长沙做网站
https502
ecshopbuild
ecshop首页添加文章
ecshopNot
ecshop用品
mongodb
ecshop批量图片本地化
ecshop相框
ecshop图片处理
ecshop级数
ecshop学长
ecshop购物车