-
- <!--主体内容右边-->
- <div class="gs_right">
- <div class="rit_1">
- <span class="rit_title"> <b>限时抢购</b><span id="tab_right_promo" style="margin-left: 5px; float: left; display: inline;"><a class="sel_promo_date" id="right_promo_1" onclick="swi_tab("right_promo","sel_promo_date",1,3)" target="_self" href="javascript:;">06.02</a></span></span>
- <ul class="qg_ul" id="right_promo_3_1">
- <!-- {if $index_promote_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.getElementById("leftTime"+key).innerHTML = a + b + c + d; //显示倒计时信息
- }
- </script>
- <!--{foreach from=$index_promote_goods key=key item=goods name="promotion_foreach"}-->
- {if $smarty.foreach.promotion_foreach.index <= 5}
- <li class="no_border"><span class="date"><font id="leftTime{$key}">{$lang.please_waiting}</font></span>
- <a title="{$goods.name|escape:html}" target="_blank" href="{$goods.url}"><img src="{$goods.thumb}">{$goods.short_name|escape:html}</a>
- <em><span>市场价:</span><b class="hui">{$goods.shop_price}</b></em>
- <em><span> 抢购价:</span><b class="red">{$goods.promote_price}</b></em>
- <em><span>立省:</span><b class="green">{$goods.sy}</b></em>
- </li>
- {/if}
- <script>
- Tday[{$key}] = new Date("{$goods.gmt_end_time}");
- window.setInterval(function()
- {clock({$key});}, 1000);
- </script>
- <!--{/foreach}-->
- <!--{/if}-->
- </ul>
- </div><!--抢购-->
复制代码
在lib_goods.php
- /**
- * 首页促销倒计时商品
- *
- * @access public
- * @return array
- */
- function index_promote_goods($cats = '')
- {
- $time = gmtime();
- $order_type = $GLOBALS['_CFG']['recommend_order'];
- /* 取得促销lbi的数量** */
- $num = get_library_number("recommend_promotion");
- $sql = 'SELECT g.goods_id, g.goods_name, 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]['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']);
- $goods[$idx]['sy'] =price_format(ceil($row['shop_price']-$row['promote_price']));
- /* 促销时间倒计时 */
- $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;
- }
- }
- return $goods;
- }
复制代码
如果不懂得,可以去QQ群咨询群号:129370737 |