function index()
 {
     if ($this->setting['display_b2c_ad'] == 1) {
         //动态广告系统
         $miao_api = $this->miao_client();
         //获取59秒api设置信息
         $adv_data = $miao_api->AdsGet('', '468x60');
         $ad_rel = $adv_data['ads']['ad'];
         $ad_rel = getRandArray($ad_rel);
         if (count($ad_rel) > 0) {
             $this->assign('ad_rel', $ad_rel);
         }
     }
     $album_cate_mod = D('album_cate');
     $cid = isset($_GET['cid']) && intval($_GET['cid']) ? intval($_GET['cid']) : 0;
     $album_cate = $album_cate_mod->field('id,title')->where("status=1")->order("sort_order ASC")->select();
     $this->assign('album_cate', $album_cate);
     if (is_null($_REQUEST['cid'])) {
         $where = 'recommend=1';
         $this->assign('cid', -1);
     } else {
         $where = "cid={$cid}";
         $this->assign('cid', $cid);
     }
     //seo信息
     $this->album_seo($_GET['cid'], null, null, 1);
     $where .= " and status=1";
     $this->get_album_list($where, 6);
 }
 function index()
 {
     //分类数据
     $focus_mod = D('focus');
     if (S('index_group_cates')) {
         $index_group_cates = S('index_group_cates');
     } else {
         $index_group_cates = $this->get_index_group_cates();
         S('index_group_cates', $index_group_cates, C('INDEX_GROUP_CATES'));
     }
     $this->assign('index_group_cates', $index_group_cates);
     //热门活动
     $article_mod = M('article');
     //头条
     $top_actives = $article_mod->cache('TOP_ACTIVES', C('TOP_ACTIVES'))->where('is_best=1')->order('add_time DESC')->find();
     $this->assign('top_actives', $top_actives);
     //列表
     $hot_actives = $article_mod->cache('HOT_ACTIVES', C('TOP_ACTIVES'))->where('is_hot=1')->limit('1,5')->order('is_hot DESC,add_time DESC')->select();
     $this->assign('hot_actives', $hot_actives);
     //轮播器
     $ad_list = $focus_mod->where('cate_id=1 AND status=1')->order('ordid DESC')->select();
     $this->assign('ad_list', $ad_list);
     $this->assign('seo', $this->seo);
     //调取最新喜欢的数据
     if (S('index_lately_like')) {
         $lately_like = S('index_lately_like');
     } else {
         $lately_like = $this->lately_like();
         S('index_lately_like', $lately_like, '180');
         //缓存3分钟
     }
     $this->assign('lately_like', $lately_like);
     //获取返现商家信息
     if (S('index_rec_seller')) {
         $rec_seller = S('index_rec_seller');
     } else {
         $rec_seller = $this->rec_seller();
         S('index_rec_seller', $rec_seller, '300');
         //缓存5分钟
     }
     if (count($rec_seller) <= 0) {
         $rec_seller = '';
     }
     if ($this->setting['display_b2c_ad'] == 1) {
         //动态广告系统
         $miao_api = $this->miao_client();
         //获取59秒api设置信息
         $adv_data = $miao_api->AdsGet('', '468x60');
         $ad_rel = $adv_data['ads']['ad'];
         $ad_rel = getRandArray($ad_rel);
         //print_r($ad_rel);
         if (count($ad_rel) > 0) {
             $this->assign('ad_rel', $ad_rel);
         }
     }
     $this->assign('rec_seller', $rec_seller);
     //推荐商家
     $this->display();
 }
 public function index()
 {
     $miao_api = $this->miao_client();
     //获取59秒api设置信息
     if ($this->setting['display_b2c_ad'] == 1) {
         //动态广告系统
         //$miao_api = $this->miao_client();   //获取59秒api设置信息
         $adv_data = $miao_api->AdsGet('', '468x60');
         $ad_rel = $adv_data['ads']['ad'];
         $ad_rel = getRandArray($ad_rel);
         if (count($ad_rel) > 0) {
             $this->assign('ad_rel', $ad_rel);
         }
     }
     $page_size = 18;
     if (isset($_GET['p'])) {
         $p = $_GET['p'];
     }
     if (!$p || is_null($p)) {
         $p = 1;
     }
     $data = $miao_api->ListPromosListGet(null, null, '', $p, $page_size);
     $total_results = $data['total_results'];
     //总记录
     $promos = $data['promos']['promo'];
     $p_array = array();
     if (is_array($promos)) {
         foreach ($promos as $v) {
             $v['seller_url'] = base64_encode(urlencode($v['seller_url']));
             $p_array[] = $v;
         }
     }
     import("ORG.Util.Page");
     $count = $total_results;
     $p = new Page($count, $page_size);
     $page = $p->show();
     $this->assign('page', $page);
     $this->assign('promos', $p_array);
     //print_r($promos);
     $promo_parent = $miao_api->ListPromoCats();
     $promo_parent = $promo_parent['promo_cats']['promo_cat'];
     $this->assign('promo_cate', $promo_parent);
     //分类
     //获取seo
     $this->nav_seo('promo', 'nav', 3);
     $this->display();
 }
 public function index()
 {
     if ($this->setting['display_b2c_ad'] == 1) {
         //动态广告系统
         $miao_api = $this->miao_client();
         //获取59秒api设置信息
         $adv_data = $miao_api->AdsGet('', '468x60');
         if (count($adv_data) > 0) {
             $ad_rel = $adv_data['ads']['ad'];
             $ad_rel = getRandArray($ad_rel);
             if (count($ad_rel) > 0) {
                 $this->assign('ad_rel', $ad_rel);
             }
         }
     }
     $cid = isset($_GET['cid']) && intval($_GET['cid']) ? intval($_GET['cid']) : 0;
     $items_mod = D('items');
     $items_cate_mod = D('items_cate');
     import("ORG.Util.Page");
     $sql_where = "1=1 AND status=1";
     $cate_res = $this->items_cate_mod->field('id,pid')->where("id={$cid}")->find();
     $cate_res['level'] = 0;
     if (intval($cate_res['pid']) != 0) {
         $cate_res = $this->items_cate_mod->field('id,pid')->where("id=" . $cate_res['pid'])->find();
         //父类
         $cate_res['level'] = 1;
         if (intval($cate_res['pid']) != 0) {
             $cate_res = $this->items_cate_mod->field('id,pid')->where("id=" . $cate_res['pid'])->find();
             $cate_res['level'] = 2;
         }
     }
     //分类列表
     $res = get_items_cate_list($cate_res['id'], $cate_res['level'], 0, 'collect_miao');
     $this->assign('cate_list', $res['list']);
     S("cate_list{$cid}", $res['list']);
     //print_r($res['list']);
     if ($res['sort_list'][$cid]['level'] >= 2) {
         $sql_where .= " AND cid IN (" . $cid . ")";
     } else {
         foreach ($res['sort_list'] as $key => $val) {
             $ids[] = $val['id'];
         }
         $sql_where .= " AND cid IN (" . implode(',', $ids) . ")";
         //获取商品
     }
     if ($cid) {
         $cate_info = $items_cate_mod->field('pid,name,seo_title,seo_keys,seo_desc')->where('id=' . $cid)->find();
         if ('0' == $cate_info['pid']) {
             $pcid = $cid;
             $this->assign('pcate_info', $cate_info);
         } else {
             //暂时未发现在哪使用$scate = $items_cate_mod->where('pid=' . $cate_info['pid'])->select();
             $pcid = $cate_info['pid'];
             $pcate_info = $items_cate_mod->field('pid,name')->where('id=' . $cate_info['pid'])->find();
             $this->assign('pcate_info', $pcate_info);
             $this->assign('cate_info', $cate_info);
         }
         //暂时未发现在哪使用$this->assign('scate', $scate);
         $this->seo['seo_title'] = !empty($cate_info['seo_title']) ? $cate_info['seo_title'] : $cate_info['name'];
         $this->seo['seo_title'] = $this->seo['seo_title'] . ' - ' . $this->setting['site_name'];
         $this->seo['seo_keys'] = !empty($cate_info['seo_keys']) ? $cate_info['seo_keys'] : $cate_info['name'];
         !empty($cate_info['seo_desc']) && ($this->seo['seo_desc'] = $cate_info['seo_desc']);
     }
     $p = !empty($_GET['p']) ? intval($_GET['p']) : 1;
     $sp = !empty($_GET['sp']) ? intval($_GET['sp']) : 1;
     $sp > $this->setting['waterfall_sp'] && exit;
     $list_rows = $this->setting['waterfall_sp'] * $this->setting['waterfall_items_num'];
     $s_list_rows = $this->setting['waterfall_items_num'];
     $show_sp = 0;
     $count = $items_mod->where($sql_where)->count();
     $this->assign('count', $count);
     $count > $s_list_rows && ($show_sp = 1);
     $pager = new Page($count, $list_rows);
     $page = $pager->show_1();
     $first_row = $pager->firstRow + $s_list_rows * ($sp - 1);
     $sid = rand(0, 2);
     if ($sid == 1) {
         $order = 'sort_order ASC,sid DESC,id DESC';
     } else {
         $order = 'sort_order ASC,sid ASC,id DESC';
     }
     $items_list = $items_mod->relation(true)->where($sql_where)->limit($first_row . ',' . $s_list_rows)->order($order)->select();
     foreach ($items_list as $key => $val) {
         $items_list[$key]['three_comments'] = $this->user_comments_mod->where('pid=' . $val['id'] . ' and status=1')->order("add_time DESC")->limit("0,3")->relation(true)->select();
         //获取三条喜欢此宝贝的人
         $like['items_id'] = $val['id'];
         $items_list[$key]['likelist'] = $this->like_list_mod->where($like)->order('id desc')->limit(3)->select();
         $items_list[$key]['count'] = $this->like_list_mod->where($like)->count();
     }
     $this->assign('page', $page);
     $this->assign('p', $p);
     $this->assign('show_sp', $show_sp);
     $this->assign('sp', $sp);
     $this->assign('pcid', $pcid);
     $select_pid = $pcid;
     //设置选择状态
     //print_r($items_list);
     //获取最新推荐商品
     $this->assign('cid', $cid);
     $this->assign('items_list', $items_list);
     if ($pcid) {
         $cate_info = $items_cate_mod->field('id,pid')->where('id=' . $pcid)->find();
         if ('0' == $cate_info['pid']) {
             $pid_rel = $items_cate_mod->field('id')->where('pid=' . $pcid)->select();
             foreach ($pid_rel as $val) {
                 $cids[] = $val['id'];
             }
             $where = "pid IN (" . implode(',', $cids) . ") AND recommend=1 AND status=1";
             //获取商品
             $recommend_cate = $items_cate_mod->field('id,color,name')->where($where)->select();
         } else {
             //如果不是0 则获取他的pid
             $first_id_rel = $items_cate_mod->field('pid')->where('id=' . $pcid)->find();
             //获取一级分类的pid
             $pid_rel = $items_cate_mod->field('id')->where('pid=' . $first_id_rel['pid'])->select();
             $select_pid = $first_id_rel['pid'];
             //设置选择状态
             foreach ($pid_rel as $val) {
                 $cids[] = $val['id'];
             }
             $sql_where = "pid IN (" . implode(',', $cids) . ") AND recommend=1 AND status=1";
             //获取商品
             $recommend_cate = $items_cate_mod->field('id,color,name')->where($sql_where)->select();
         }
     }
     $this->assign('recommend_cate', $recommend_cate);
     $this->assign('select_pid', $select_pid);
     $this->nav_seo('cate', 'items_cate', $_GET['cid']);
     if ($this->isAjax() && $sp > 1) {
         //判断是否是ajax请求
         header('Content-Type:text/html; charset=utf-8');
         echo $this->fetch('public:goods_list');
     } else {
         $this->display();
     }
 }
 public function index()
 {
     if ($this->setting['display_b2c_ad'] == 1) {
         //动态广告系统
         $miao_api = $this->miao_client();
         //获取59秒api设置信息
         $adv_data = $miao_api->AdsGet('', '468x60');
         $ad_rel = $adv_data['ads']['ad'];
         $ad_rel = getRandArray($ad_rel);
         if (count($ad_rel) > 0) {
             $this->assign('ad_rel', $ad_rel);
         }
     }
     $seller_cate_mod = D('seller_cate');
     if (S('seller_cate_rel')) {
         $cate_rel = S('seller_cate_rel');
     } else {
         $cate_rel = $seller_cate_mod->where("status='1'")->order('sort asc,id asc')->select();
         S('seller_cate_rel', $cate_rel, '3600');
     }
     $cate_rel = $seller_cate_mod->where("status='1'")->order('sort asc,id asc')->select();
     //print_r($cate_rel);
     $this->assign('seller_cate', $cate_rel);
     //推荐返利商家
     $seller_list_mod = D('seller_list');
     if (S('seller_rec_seller')) {
         $rec_seller = S('seller_rec_seller');
     } else {
         $rec_seller = $seller_list_mod->field('id,click_url,name,net_logo,site_logo,cash_back_rate')->where("status='1' AND recommend='1'")->select();
         /**/
         $seler_arr = array();
         foreach ($rec_seller as $value) {
             $value['click_url'] = base64_encode(urlencode($value['click_url']));
             $seler_arr[] = $value;
         }
         $rec_seller = $seler_arr;
         S('seller_rec_seller', $rec_seller, '3600');
     }
     $this->assign('rec_seller', $rec_seller);
     //推荐商家
     $seller_list_cate_mod = D('seller_list_cate');
     //查询seller页面显示的商家
     if (S('seller_cate_list')) {
         $cate_list = S('seller_cate_list');
     } else {
         $cate_seller_rel = $seller_cate_mod->where("status='1' AND seller_status='1'")->order('sort asc,id asc')->select();
         $cate_list = array();
         foreach ($cate_seller_rel as $value) {
             $list_cate_id = $seller_list_cate_mod->field('list_id')->where("cate_id='{$value['id']}'")->select();
             $str = '';
             foreach ($list_cate_id as $v) {
                 $str .= '\'' . $v['list_id'] . '\',';
             }
             $str = substr($str, 0, -1);
             $list_rel = $seller_list_mod->field('id,click_url,name,net_logo,site_logo,cash_back_rate')->where("id IN ({$str}) AND status='1'")->order('sort asc,id asc')->limit('12')->select();
             $seler_arr = array();
             foreach ($list_rel as $v1) {
                 $v1['click_url'] = base64_encode(urlencode($v1['click_url']));
                 $seler_arr[] = $v1;
             }
             $cate_list[] = array('cate_name' => $value[name], 'cate_id' => $value[id], 'seller_list' => $seler_arr);
         }
         S('seller_cate_list', $cate_list, '3600');
     }
     $this->assign('cate_list', $cate_list);
     //推荐商家
     //获取seo信息
     $this->nav_seo('seller', 'nav', 4);
     $this->display();
 }