You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
499 lines
19 KiB
499 lines
19 KiB
<?php
|
|
|
|
/**
|
|
* 获取AJAX内容
|
|
* $Author: wangzhentao $
|
|
*/
|
|
|
|
define('IN_ECS', true);
|
|
|
|
require(dirname(__FILE__) . '/includes/init.php');
|
|
|
|
if ((DEBUG_MODE & 2) != 2)
|
|
{
|
|
$smarty->caching = true;
|
|
}
|
|
|
|
require(ROOT_PATH . '/includes/lib_area.php'); //ecmoban模板堂 --zhuo
|
|
require(ROOT_PATH . '/includes/cls_json.php');
|
|
require(ROOT_PATH . '/includes/lib_clips.php');
|
|
include_once(ROOT_PATH . 'includes/lib_transaction.php');
|
|
require_once(ROOT_PATH . 'includes/lib_ecmoban.php');
|
|
require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/user.php');
|
|
|
|
assign_template();
|
|
/*------------------------------------------------------ */
|
|
//-- INPUT
|
|
/*------------------------------------------------------ */
|
|
|
|
//ecmoban模板堂 --zhuo start
|
|
|
|
$area_info = get_area_info($province_id);
|
|
|
|
$where = "regionId = '$province_id'";
|
|
$date = array('parent_id');
|
|
$region_id = get_table_date('region_warehouse', $where, $date, 2);
|
|
//ecmoban模板堂 --zhuo end
|
|
|
|
$act=!empty($_REQUEST['act'])?trim($_REQUEST['act']):'';
|
|
$tpl=!empty($_REQUEST['tpl'])?trim($_REQUEST['tpl']):1; //by wu
|
|
$smarty->assign('tpl',$tpl); //by wu
|
|
|
|
if($act=='get_content')
|
|
{
|
|
|
|
$result = array('error' => 0, 'message' => '', 'content' => '');
|
|
$json = new JSON;
|
|
$data_type=!empty($_POST['data_type'])?trim($_POST['data_type']):'';
|
|
switch($data_type)
|
|
{
|
|
case 'cart_list':
|
|
$cart_info=insert_cart_info(2);
|
|
$result['cart_num']=$cart_info['number'];
|
|
$GLOBALS['smarty']->assign('cart_info',$cart_info);
|
|
$result['content'] = $GLOBALS['smarty']->fetch('library/right_float_cart_info.lbi');
|
|
break;
|
|
case 'mpbtn_total':
|
|
$user_info = get_user_default($_SESSION['user_id']);
|
|
$bonus = get_user_bouns_new_list($_SESSION['user_id'], $page, 0, 'bouns_available_gotoPage', 0, 7);//可用红包
|
|
if($user_info)
|
|
{
|
|
foreach($bonus['available_list'] as $key=>$val)
|
|
{
|
|
$bonus['available_list'][$key]['use_startdate']=substr($val['use_startdate'],0,10);
|
|
$bonus['available_list'][$key]['use_enddate']=substr($val['use_enddate'],0,10);
|
|
}
|
|
$user_info['bouns_list']=$bonus['available_list'];
|
|
$user_info['bouns_num']=count($bonus['available_list']);
|
|
}
|
|
$GLOBALS['smarty']->assign('user_info',$user_info);
|
|
$result['content'] = $GLOBALS['smarty']->fetch('library/right_float_total_info.lbi');
|
|
break;
|
|
case 'mpbtn_history':
|
|
$history_info=insert_history_info(10);
|
|
$GLOBALS['smarty']->assign('history_info',$history_info);
|
|
$result['content'] = $GLOBALS['smarty']->fetch('library/right_float_histroy_info.lbi');
|
|
break;
|
|
case 'mpbtn_collection':
|
|
$operat=!empty($_POST['type'])?trim($_POST['type']):'';
|
|
$collect_id=!empty($_POST['collection_id'])?intval($_POST['collection_id']):0;
|
|
|
|
if(!empty($operat)&&$operat=='del'&&$collect_id>0)
|
|
{
|
|
$GLOBALS['db']->query('DELETE FROM ' .$GLOBALS['ecs']->table('collect_goods'). " WHERE rec_id='$collect_id' AND user_id ='".$_SESSION['user_id']."'" );
|
|
}
|
|
$collection_goods = get_collection_goods($_SESSION['user_id'], 10, 1, 'collection_goods_gotoPage');
|
|
$smarty->assign('goods_list', $collection_goods['goods_list']);
|
|
$collection_store = get_collection_store($_SESSION['user_id'], 5, 1, 'collection_store_gotoPage');
|
|
$smarty->assign('store_list', $collection_store['store_list']);
|
|
$result['content'] = $GLOBALS['smarty']->fetch('library/right_float_collection_info.lbi');
|
|
break;
|
|
case 'mpbtn_order':
|
|
$order_list = get_user_orders($_SESSION['user_id'], 5, 1, 0,'','',0,5);
|
|
|
|
$smarty->assign('order_list', $order_list['order_list']);
|
|
$result['content'] = $GLOBALS['smarty']->fetch('library/right_float_order_info.lbi');
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
die($json->encode($result));
|
|
}
|
|
elseif($act=='get_login_dialog')
|
|
{
|
|
require_once(ROOT_PATH . 'languages/' .$_CFG['lang']. '/user.php');
|
|
$result = array('error' => 0, 'message' => '', 'content' => '');
|
|
$back_act=!empty($_POST['back_act'])?trim($_POST['back_act']):'';
|
|
$json = new JSON;
|
|
/* 验证码相关设置 */
|
|
if ((intval($_CFG['captcha'])) && gd_version() > 0)
|
|
{
|
|
$smarty->assign('enabled_captcha', 1);
|
|
$smarty->assign('rand', mt_rand());
|
|
}
|
|
|
|
$smarty->assign('back_act',$back_act);
|
|
$smarty->assign('user_lang',$_LANG);
|
|
$result['content'] = $GLOBALS['smarty']->fetch('library/login_dialog_body.lbi');
|
|
die($json->encode($result));
|
|
}
|
|
//获得顶级分类页面楼层
|
|
elseif($act=='get_cat_top_list'&&$tpl==1)
|
|
{
|
|
$region_id = isset($_REQUEST['region_id'])?intval($_REQUEST['region_id']):0;
|
|
$area_id = isset($_REQUEST['area_id'])?intval($_REQUEST['area_id']):0;
|
|
$cat_id=!empty($_REQUEST['cat_id'])?intval($_REQUEST['cat_id']):0;
|
|
$prent_id=!empty($_REQUEST['prent_id'])?intval($_REQUEST['prent_id']):0;
|
|
$rome_key=intval($_REQUEST['rome_key'])+1;
|
|
$result = array('error' => 0,'content' => '');
|
|
$json = new JSON;
|
|
|
|
if($cat_id>0)
|
|
{
|
|
//将数据写入缓存文件 by wang
|
|
if($categories_child = read_static_cache('cat_top_cache'.$prent_id))
|
|
{
|
|
$one_cate_child = $categories_child[$cat_id];
|
|
}
|
|
else
|
|
{
|
|
$categories_child = get_parent_cat_tree($prent_id);
|
|
$one_cate_child = $categories_child[$cat_id];
|
|
}
|
|
|
|
//获取分类的品牌和商品
|
|
if($one_cate_child)
|
|
{
|
|
$one_cate_child['brands'] = get_brands($cat_id, 'brand', 10);
|
|
foreach($one_cate_child['cat_id'] as $k=>$v)
|
|
{
|
|
$child_children = get_children($v['id']);
|
|
$childcate_goods_list=get_category_recommend_goods('best',$child_children, 0, 0, 0, '', $region_id, $area_id, 10);
|
|
if($childcate_goods_list)
|
|
{
|
|
$one_cate_child['cat_id'][$k]['goods_list']=$childcate_goods_list;
|
|
}
|
|
}
|
|
|
|
for($i=1;$i<=$_CFG['auction_ad'];$i++){
|
|
$cat_top_floor_ad .= "'cat_top_floor_ad".$i.","; //首页楼层左侧广告图
|
|
}
|
|
|
|
//楼层广告
|
|
$floor_ad_arr=array("ad_arr"=>$cat_top_floor_ad,"id"=>$cat_id);
|
|
$cat_top_floor_ad = insert_get_adv_child($floor_ad_arr);
|
|
|
|
//楼层底部广告
|
|
$smarty->assign('rome_number',$rome_key);
|
|
$smarty->assign('cat_top_floor_ad',$cat_top_floor_ad);
|
|
$smarty->assign('one_cate_child',$one_cate_child);
|
|
$result['content'] = html_entity_decode($smarty->fetch('library/load_category_top.lbi'));
|
|
}
|
|
else
|
|
{
|
|
$result['error']=1;
|
|
}
|
|
|
|
}
|
|
|
|
$result['cat_id'] = $cat_id;
|
|
$result['rome_key'] = $rome_key;
|
|
|
|
die($json->encode($result));
|
|
}
|
|
//获得首页页面楼层
|
|
elseif($act=='get_index_goods_cat')
|
|
{
|
|
$rome_key=intval($_REQUEST['rome_key']);
|
|
$result = array('error' => 0,'content' => '','maxindex'=>0);
|
|
$json = new JSON;
|
|
|
|
//将数据写入缓存文件 by wang
|
|
if(!read_static_cache('index_goods_cat_cache'))
|
|
{
|
|
$sql = 'SELECT filename,region,theme,id, number, type, sort_order FROM ' . $GLOBALS['ecs']->table('template') .
|
|
" WHERE filename = 'index' AND type =1 AND theme='" . $GLOBALS['_CFG']['template'] . "' order by sort_order asc";
|
|
$template = $GLOBALS['db']->getAll($sql);
|
|
write_static_cache('index_goods_cat_cache',$template);
|
|
}
|
|
else
|
|
{
|
|
$template=read_static_cache('index_goods_cat_cache');
|
|
}
|
|
if($rome_key<=count($template)-1)
|
|
{
|
|
$row=$template[$rome_key];
|
|
|
|
//获取楼层设置内容
|
|
$brand_ids=insert_get_floor_content($row);
|
|
$brands_theme2 = get_floor_brand($brand_ids);
|
|
$brands_theme2=get_brands_theme2($brands_theme2);
|
|
|
|
$smarty->assign('brands_theme2',$brands_theme2);
|
|
|
|
if(!read_static_cache('index_goods_cat'.$rome_key))
|
|
{
|
|
$goods_cat=assign_cat_goods($row['id'], $row['number'], 'web', '', 'cat', $region_id,$area_info['region_id'], $row['sort_order']);
|
|
write_static_cache('index_goods_cat'.$rome_key,$goods_cat);
|
|
|
|
}
|
|
else
|
|
{
|
|
$goods_cat=read_static_cache('index_goods_cat'.$rome_key);
|
|
}
|
|
if($goods_cat)
|
|
{
|
|
//广告
|
|
$get_adv=insert_get_adv(array('logo_name'=>$goods_cat['floor_banner']));
|
|
$smarty->assign('get_adv',$get_adv);
|
|
$cat_goods_banner='';
|
|
$cat_goods_hot='';
|
|
/**小图 start**/
|
|
for($i=1;$i<=$_CFG['auction_ad'];$i++){
|
|
$cat_goods_banner .= "'cat_goods_banner".$i.","; //首页楼层轮播图
|
|
$cat_goods_hot .= "'cat_goods_hot".$i.","; //首页楼层轮播图
|
|
}
|
|
$cat_goods_banner=insert_get_adv_child(array('ad_arr'=>$cat_goods_banner,'id'=>$goods_cat['id'],"warehouse_id"=>$region_id,"area_id"=>$area_info['region_id']));
|
|
$cat_goods_hot=insert_get_adv_child(array('ad_arr'=>$cat_goods_hot,'id'=>$goods_cat['id'],"warehouse_id"=>$region_id,"area_id"=>$area_info['region_id']));
|
|
$smarty->assign('cat_goods_banner',$cat_goods_banner);
|
|
$smarty->assign('cat_goods_hot',$cat_goods_hot);
|
|
$smarty->assign('goods_cat',$goods_cat);
|
|
$result['content']=html_entity_decode($smarty->fetch('library/load_cat_goods.lbi'));
|
|
}
|
|
else
|
|
{
|
|
$result['error']=1;
|
|
}
|
|
if($rome_key==count($template)-1)
|
|
{
|
|
$result['maxindex']=1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$result['error']=1;
|
|
}
|
|
|
|
die($json->encode($result));
|
|
}
|
|
elseif($act=='getCategotyParentTree'){
|
|
$cat_id = isset($_REQUEST['cat_id']) ? intval($_REQUEST['cat_id']) : 0;
|
|
|
|
$result = array('error' => 0,'content' => '');
|
|
$json = new JSON;
|
|
|
|
$file = "parent_style_brands" . $cat_id;
|
|
$brands = read_static_cache($file);
|
|
|
|
//将数据写入缓存文件 by wang
|
|
if($brands === false)
|
|
{
|
|
$brands = get_brands($cat_id);
|
|
write_static_cache($file, $brands);
|
|
}
|
|
|
|
$smarty->assign('brands', $brands);
|
|
|
|
$result['cat_id'] = $cat_id;
|
|
$result['brands_content'] = $GLOBALS['smarty']->fetch('library/category_parent_brands.lbi');
|
|
|
|
die($json->encode($result));
|
|
}
|
|
|
|
//获得顶级分类页面楼层(模板2)
|
|
elseif($act=='get_cat_top_list'&&$tpl==2)
|
|
{
|
|
$region_id = isset($_REQUEST['region_id'])?intval($_REQUEST['region_id']):0;
|
|
$area_id = isset($_REQUEST['area_id'])?intval($_REQUEST['area_id']):0;
|
|
$cat_id=!empty($_REQUEST['cat_id'])?intval($_REQUEST['cat_id']):0;
|
|
$prent_id=!empty($_REQUEST['prent_id'])?intval($_REQUEST['prent_id']):0;
|
|
$rome_key=intval($_REQUEST['rome_key'])+1;
|
|
$result = array('error' => 0,'content' => '');
|
|
$json = new JSON;
|
|
if($cat_id>0)
|
|
{
|
|
//将数据写入缓存文件 by wang
|
|
if($categories_child = read_static_cache('cat_top_cache'.$prent_id))
|
|
{
|
|
$one_cate_child = $categories_child[$cat_id];
|
|
}
|
|
else
|
|
{
|
|
$categories_child = get_parent_cat_tree($prent_id);
|
|
$one_cate_child = $categories_child[$cat_id];
|
|
}
|
|
|
|
//获取分类的品牌和商品
|
|
if($one_cate_child)
|
|
{
|
|
$one_cate_child['brands'] = get_brands($cat_id, 'brand', 10);
|
|
foreach($one_cate_child['cat_id'] as $k=>$v)
|
|
{
|
|
$child_children = get_children($v['id']);
|
|
$childcate_goods_list=get_category_recommend_goods('best',$child_children, 0, 0, 0, '', $region_id, $area_id, 10);
|
|
|
|
if($childcate_goods_list)
|
|
{
|
|
$one_cate_child['cat_id'][$k]['goods_list']=$childcate_goods_list;
|
|
}
|
|
}
|
|
|
|
//热销商品
|
|
$childcate_goods_hot=get_category_recommend_goods('hot',get_children($cat_id), 0, 0, 0, '', $region_id, $area_id, 1);
|
|
$one_cate_child['goods_hot']=$childcate_goods_hot;
|
|
|
|
for($i=1;$i<=$_CFG['auction_ad'];$i++){
|
|
$top_style_elec_left .= "'top_style_elec_left".$i.","; //首页楼层左侧广告图
|
|
}
|
|
|
|
//楼层广告(left)
|
|
$floor_ad_arr=array("ad_arr"=>$top_style_elec_left,"id"=>$cat_id);
|
|
$top_style_elec_left = insert_get_adv_child($floor_ad_arr);
|
|
|
|
//楼层广告(row)
|
|
$top_style_elec_row = "'top_style_elec_row,";
|
|
$floor_ad_arr=array("ad_arr"=>$top_style_elec_row,"id"=>$cat_id);
|
|
$top_style_elec_row = insert_get_adv_child($floor_ad_arr);
|
|
|
|
$class_num=array('on','','last');
|
|
|
|
//楼层底部广告
|
|
$smarty->assign('class_num',$class_num);
|
|
$smarty->assign('rome_number',$rome_key);
|
|
$smarty->assign('top_style_elec_left',$top_style_elec_left);
|
|
$smarty->assign('top_style_elec_row',$top_style_elec_row);
|
|
$smarty->assign('one_cate_child',$one_cate_child);
|
|
$result['content'] = html_entity_decode($smarty->fetch('library/load_category_top.lbi'));
|
|
}
|
|
else
|
|
{
|
|
$result['error']=1;
|
|
}
|
|
|
|
}
|
|
|
|
$result['cat_id'] = $cat_id;
|
|
$result['rome_key'] = $rome_key;
|
|
|
|
die($json->encode($result));
|
|
}
|
|
|
|
//获得顶级分类页面楼层(模板3)
|
|
elseif($act=='get_cat_top_list'&&$tpl==3)
|
|
{
|
|
$region_id = isset($_REQUEST['region_id'])?intval($_REQUEST['region_id']):0;
|
|
$area_id = isset($_REQUEST['area_id'])?intval($_REQUEST['area_id']):0;
|
|
$cat_id=!empty($_REQUEST['cat_id'])?intval($_REQUEST['cat_id']):0;
|
|
$prent_id=!empty($_REQUEST['prent_id'])?intval($_REQUEST['prent_id']):0;
|
|
$rome_key=intval($_REQUEST['rome_key'])+1;
|
|
$result = array('error' => 0,'content' => '');
|
|
$json = new JSON;
|
|
if($cat_id>0)
|
|
{
|
|
//将数据写入缓存文件 by wang
|
|
if($categories_child = read_static_cache('cat_top_cache'.$prent_id))
|
|
{
|
|
$one_cate_child = $categories_child[$cat_id];
|
|
}
|
|
else
|
|
{
|
|
$categories_child = get_parent_cat_tree($prent_id);
|
|
$one_cate_child = $categories_child[$cat_id];
|
|
}
|
|
|
|
//获取分类的品牌和商品
|
|
if($one_cate_child)
|
|
{
|
|
$one_cate_child['brands'] = get_brands($cat_id, 'brand', 10);
|
|
foreach($one_cate_child['cat_id'] as $k=>$v)
|
|
{
|
|
$child_children = get_children($v['id']);
|
|
$childcate_goods_list=get_category_recommend_goods('best',$child_children, 0, 0, 0, '', $region_id, $area_id, 10);
|
|
//$childcate_goods_hot=get_category_recommend_goods('hot',$child_children, 0, 0, 0, '', $region_id, $area_id, 10);
|
|
if($childcate_goods_list)
|
|
{
|
|
$one_cate_child['cat_id'][$k]['goods_list']=$childcate_goods_list;
|
|
}
|
|
/*if($childcate_goods_hot)
|
|
{
|
|
$one_cate_child['cat_id'][$k]['goods_hot']=$childcate_goods_hot;
|
|
}*/
|
|
}
|
|
|
|
//热销商品
|
|
$childcate_goods_hot=get_category_recommend_goods('hot',get_children($cat_id), 0, 0, 0, '', $region_id, $area_id, 4);
|
|
$one_cate_child['goods_hot']=$childcate_goods_hot;
|
|
|
|
for($i=1;$i<=$_CFG['auction_ad'];$i++){
|
|
$top_style_food_left .= "'top_style_food_left".$i.","; //首页楼层左侧广告图
|
|
}
|
|
|
|
//楼层广告(left)
|
|
$floor_ad_arr=array("ad_arr"=>$top_style_food_left,"id"=>$cat_id);
|
|
$top_style_food_left = insert_get_adv_child($floor_ad_arr);
|
|
|
|
//楼层广告(row)
|
|
$top_style_food_row = "'top_style_food_row,";
|
|
$floor_ad_arr=array("ad_arr"=>$top_style_food_row,"id"=>$cat_id);
|
|
$top_style_food_row = insert_get_adv_child($floor_ad_arr);
|
|
|
|
$class_num=array('on','','last');
|
|
|
|
//楼层底部广告
|
|
$smarty->assign('class_num',$class_num);
|
|
$smarty->assign('rome_number',$rome_key);
|
|
$smarty->assign('top_style_food_left',$top_style_food_left);
|
|
$smarty->assign('top_style_food_row',$top_style_food_row);
|
|
$smarty->assign('one_cate_child',$one_cate_child);
|
|
$result['content'] = html_entity_decode($smarty->fetch('library/load_category_top.lbi'));
|
|
}
|
|
else
|
|
{
|
|
$result['error']=1;
|
|
}
|
|
|
|
}
|
|
|
|
$result['cat_id'] = $cat_id;
|
|
$result['rome_key'] = $rome_key;
|
|
|
|
die($json->encode($result));
|
|
}
|
|
|
|
//换一组 by wu
|
|
//type 1:随便看看 2:品牌 3:分类商品
|
|
elseif($act='changeShow')
|
|
{
|
|
$type = empty($_REQUEST['type']) ? 0 : intval($_REQUEST['type']);
|
|
$tpl = empty($_REQUEST['tpl']) ? 0 : intval($_REQUEST['tpl']);
|
|
$region_id = isset($_REQUEST['region_id'])?intval($_REQUEST['region_id']):0;
|
|
$area_id = isset($_REQUEST['area_id'])?intval($_REQUEST['area_id']):0;
|
|
$cat_id=!empty($_REQUEST['cat_id'])?intval($_REQUEST['cat_id']):0;
|
|
$prent_id=!empty($_REQUEST['prent_id'])?intval($_REQUEST['prent_id']):0;
|
|
$rome_key=intval($_REQUEST['rome_key'])+1;
|
|
|
|
$smarty->assign('type', $type); //输出类型
|
|
$smarty->assign('tpl', $tpl); //输出模板
|
|
|
|
$result = array('error' => 0,'content' => '');
|
|
$json = new JSON;
|
|
|
|
if($type==1)
|
|
{
|
|
$child_children = get_children($cat_id);
|
|
$havealook=get_category_recommend_goods('rand',$child_children, 0, 0, 0, '', $region_id, $area_id, 6);
|
|
//$havealook=get_goods_havealook(6);
|
|
$smarty->assign('havealook', $havealook);
|
|
$result['page']=$GLOBALS['smarty']->fetch('library/have_a_look.lbi');
|
|
}
|
|
|
|
elseif($type==3)
|
|
{
|
|
if($cat_id>0)
|
|
{
|
|
if($tpl==2)
|
|
{
|
|
$child_children = get_children($cat_id);
|
|
$goods_list=get_category_recommend_goods('rand',$child_children, 0, 0, 0, '', $region_id, $area_id, 8);
|
|
$smarty->assign('goods_list',$goods_list);
|
|
$result['page'] = html_entity_decode($smarty->fetch('library/cat_goods_change.lbi'));
|
|
}
|
|
elseif($tpl==3)
|
|
{
|
|
$child_children = get_children($cat_id);
|
|
$goods_list=get_category_recommend_goods('rand',$child_children, 0, 0, 0, '', $region_id, $area_id, 6);
|
|
$smarty->assign('goods_list',$goods_list);
|
|
$result['page'] = html_entity_decode($smarty->fetch('library/cat_goods_change.lbi'));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$result['error']=1;
|
|
}
|
|
}
|
|
|
|
die($json->encode($result));
|
|
}
|
|
|
|
?>
|