Пример #1
0
$category = array_sort($category, 'count', 'desc');
//最多取8个分类的商品,并且每个分类下的产品数量要大于4
$step = count($category) < 8 ? count($category) : 8;
$category = array_slice($category, 0, $step);
$catids = "";
foreach ($category as $key => $value) {
    if ($value['count'] > 4) {
        $catids .= $value['category_id'] . ',';
    }
}
$category = Sp_Taobao_Goods::getItemcats($catids);
if (!is_array(@$category[0])) {
    $cat[] = $category;
    $category = $cat;
}
//取每个分类的商品
foreach ($category as $key => $value) {
    $goods = Sp_Taobao_Goods::getShopItems($nick, $value['cid'], 1, 40);
    //从40个商品中随机取8个
    shuffle($goods['item_search']['items']['item']);
    $goods['item_search']['items']['item'] = array_slice($goods['item_search']['items']['item'], 0, 8);
    $category[$key]['items'] = $goods['item_search']['items']['item'];
}
$shop["shop"] = array('items' => $category, 'info' => $shop_info['shop']);
//print_r($shop);
Config::load($shop);
$sp_view->setConfig(Config::get());
$sp_view->addStyle('shop.css');
$sp_view->setTitle(strip_tags($shop_info['shop']['title']));
//print_r($sp_view);
$sp_view->display("shop.html");
Пример #2
0
    $goods_detail = Sp_Taobao_Goods::getItemDetail($num_iid);
    //淘宝客点击url
    $url = Sp_Taobao_Taobaoke::getItemConvert($num_iid, Config::get('taoke.pid_short'));
    $cid = $goods_detail["item"]['cid'];
    $props = $goods_detail["item"]['props'];
    //商品属性
    $props = Sp_Taobao_Goods::getItemPropValues($cid, $props);
    //商品分类信息
    $catgory = Sp_Taobao_Goods::getItemcats($cid);
    //当前分类的推荐商品
    $cat_goods = Sp_Taobao_Goods::getCategoryItems($cid, 40, Config::get('taoke.pid_short'));
    //从40个商品中随机取8个
    shuffle($cat_goods['taobaoke_items']['taobaoke_item']);
    $cat_goods['taobaoke_items']['taobaoke_item'] = array_slice($cat_goods['taobaoke_items']['taobaoke_item'], 0, 8);
    //商品的评价信息
    $rates = Sp_Taobao_Goods::getItemsTraderates($goods_detail['item']['num_iid'], $goods_detail['item']['nick']);
    if ($rates['total_results'] > 0) {
        $rates = $rates['trade_rates']['trade_rate'];
    } else {
        $rates = null;
    }
    $goods["goods"] = array("item" => $goods_detail['item'], "cat_items" => $cat_goods['taobaoke_items']['taobaoke_item'], "taobaoke" => $url["taobaoke_items"]["taobaoke_item"], "props" => $props, "category" => $catgory, "rates" => $rates);
    Config::load($goods);
    $sp_view->setConfig(Config::get());
    $sp_view->addStyle('goods.css');
    $sp_view->setTitle($goods_detail['item']['title']);
    $sp_view->caching = true;
    $sp_view->cache_lifetime = 86400;
    $sp_view->cache_id = $cache_id;
}
$sp_view->display("goods.html", $cache_id);
Пример #3
0
$a['sales'] = Config::get('huodongarray');
print_r($a);
//$new_file = DATA_CURRENT . 'index_temp.php';
$new_file = DATA_CURRENT . 'index_hot_sales.php';
file_put_contents($new_file, '<?php return ' . var_export($a, true) . ';');

die();
*/
//装载页面数据
Config::load(DATA_CURRENT . 'index_hot_categores.php');
Config::load(DATA_CURRENT . 'index_hot_focus.php');
Config::load(DATA_CURRENT . 'index_hot_brands.php');
Config::load(DATA_CURRENT . 'index_hot_sales.php');
Config::load(DATA_CURRENT . 'index_categores.php');
//TODO 改为从数据文件中读取默认值
foreach (Config::get('index_categores') as $key => $category) {
    $goods = Sp_Taobao_Goods::getCategoryItems($category['catid'], 40, Config::get('taoke.pid_short'));
    //从40个商品中随机取8个
    shuffle($goods['taobaoke_items']['taobaoke_item']);
    $goods['taobaoke_items']['taobaoke_item'] = array_slice($goods['taobaoke_items']['taobaoke_item'], 0, 8);
    $category = array_merge($category, $goods);
    Config::set('index_categores.' . $key, $category);
}
$sp_view = new Sp_View('utf-8');
$sp_view->addStyle('index.css');
//$sp_view->setTitle("测试");
$sp_view->setConfig(Config::get());
$sp_view->display("index.html");
//$url = "http://more.handlino.com/sentences.json?n=10&corpus=";
//$result = file_get_contents($url);
//print_r(json_decode($result));
Пример #4
0
            $url_format = "list.php?catid={$cid}&sortnum={$sort}&sp={$start_price}&ep={$end_price}&page=%d";
        }
    }
    /*
    Array ( [catid] => 1801 [sortnum] => 0 [sp] => 1 [ep] => 10000 [sq] => w!bEpA [page] => 2 ) 
    */
    //如果cid为0,不返回类目信息
    $parent_cats = null;
    $current_cats = null;
    if ($cid != 0) {
        $parent_cats = Sp_Taobao_Goods::getItemParentCats($cid);
        $current_cats = Sp_Taobao_Goods::getItemcats($cid);
        //print_r($parent_cats);
    }
    $params = array('keyword' => $keyword, 'page_no' => $page_no);
    $goods = Sp_Taobao_Goods::getCategoryItems($cid, $page_size, Config::get('taoke.pid_short'), $params);
    if ($goods) {
        $pager = new Sp_Pager($goods['total_results'], $page_no, $page_size, $url_format);
        $goods = $goods['taobaoke_items']['taobaoke_item'];
    }
    $list['list'] = array('categores' => $parent_cats, 'curr_cat' => $current_cats, 'goods' => $goods, 'keyword' => $keyword, 'pager' => isset($pager) ? $pager : null);
    Config::load($list);
    //print_r(Config::get());
    $sp_view->addStyle('list.css');
    $sp_view->addStyle('pager.css');
    $sp_view->setConfig(Config::get());
    $sp_view->caching = false;
    //$sp_view->cache_lifetime = 86400;
    //$sp_view->cache_id = $cache_id;
}
$sp_view->display("list.html", $cache_id);