我看到一篇文章 我正在琢磨 大家一起来看看
index.php添加一下内容
if(!empty($channels['default']) && $channels['default'] != 'index.php') {
if(strpos($channels['default'], '?')) {
sheader(S_URL.'/'.$channels['default']);
exit();
} else {
include_once(S_ROOT.'./'.$channels['default']);
}
} else {
if(!empty($_SCONFIG['htmlindex'])) {
$_SHTML['action'] = 'index';
$_SGLOBAL['htmlfile'] = gethtmlfile($_SHTML);
ehtml('get', $_SCONFIG['htmlindextime']);
$_SCONFIG['debug'] = 0;
}
$title = $_SCONFIG['sitename'];
$keywords = $_SCONFIG['sitename'];
$description = $_SCONFIG['sitename'];
/*=========================================商城数据开始===============================================*/
//获取产品属性
function get_mall_spec($goods_id,$db){
$strSql="select * from ecm_goods_spec where goods_id=$goods_id limit 0,1";
$query=$db->query($strSql);
if ( $iteminfo = $db->fetch_array( $query ) ) {
$iteminfo['image']=get_thumb_img($iteminfo['default_image']);
return $iteminfo;
}
return null;
}
//获取缩略图路径
function get_thumb_img($d){
define('ECM_KEY','e169dd3a39dcae97e41bc71813b6de19');
$arr=array('file'=>$d,'width'=>120,'height'=>120);
$hash_path = md5( ECM_KEY.$arr['file'].$arr['width'].$arr['height'] );
$thumb_path = "http://127.0.0.1/shop/temp/thumb/".$hash_path[0].$hash_path[1]."/".$hash_path[2].$hash_path[3]."/".$hash_path.$arr['file'].".jpg";
return $thumb_path;
}
//最新的推荐图片产品
$strSql="select * from ecm_goods where is_mi_best=1 order by last_update desc limit 0,18";
$query = $_SGLOBAL['db']->query($strSql);
while ($item = $_SGLOBAL['db']->fetch_array($query)) {
$item['spec']=get_mall_spec($item['goods_id'],$_SGLOBAL['db']);
$item['jieshen']=$item['spec']['market_price']-$item['spec']['store_price'];
$mall_new[] = $item;
}
//最新的团购产品
$strSql="select * from ecm_goods_activity where act_type=1 order by end_time desc limit 0,10";
$query = $_SGLOBAL['db']->query($strSql);
while ($item = $_SGLOBAL['db']->fetch_array($query)) {
$item["end_time"]=date("y-m-d",$item["end_time"]);
$item['spec']=get_mall_spec($item['goods_id'],$_SGLOBAL['db']);
$arr=unserialize($item['ext_info']);
$item['price']=$arr['price'];
$item['jieshen']=$item['spec']['market_price']-$item['price'];
$mall_act[] = $item;
}
//热门分类
$strSql="select * from ecm_category order by goods_count desc limit 0,14";
$query = $_SGLOBAL['db']->query($strSql);
while ($item = $_SGLOBAL['db']->fetch_array($query)) {
$mall_category[] = $item;
}
//推荐商家
$strSql="select * from ecm_store where is_recommend=1 order by add_time desc limit 0,12";
$query = $_SGLOBAL['db']->query($strSql);
while ($item = $_SGLOBAL['db']->fetch_array($query)) {
$mall_store[] = $item;
}
/*=========================================商城数据结束===============================================*/ |