Esempio n. 1
0
 public function newslist()
 {
     //SEO
     $ident = "News";
     $idents = $this->seo($ident);
     $this->assign("title", $idents['title']);
     $this->assign("keywords", $idents['keywords']);
     $this->assign("description", $idents['description']);
     $cat = I('get.cat');
     $NewsModel = M('news_contents');
     $NewsCat = M('news_cat');
     $newscat = $NewsCat->where(array('is_show' => 1))->order('id ASC')->select();
     $cats = array();
     foreach ($newscat as $k => $v) {
         $cats[$k] = $v['id'];
         $map['cat_id'] = array('eq', $v['id']);
         $map['is_show'] = array('eq', 1);
         $newscat[$k]['amount'] = $NewsModel->where($map)->count();
     }
     $newsrank = $NewsModel->field('id,title,thumbnail,description')->where(array('is_show' => 1))->order('clicktimes DESC')->limit(3)->select();
     $this->assign('newsrank', $newsrank);
     $mapnews = array();
     if ($cat) {
         if (in_array($cat, $cats)) {
             $cat_name = $NewsCat->where(array('id' => $cat))->getField('cat_name');
             $this->assign('cat_name', $cat_name);
             $mapnews['cat_id'] = array('eq', $cat);
         } else {
             $this->display('Public:404');
             exit;
         }
     }
     $mapnews['is_show'] = array('eq', 1);
     $count = $NewsModel->where($mapnews)->count();
     // 查询满足要求的总记录数
     $Page = new \Think\MyPage($count, 4);
     $show = $Page->show();
     $news = $NewsModel->field('id,title,create_time,thumbnail,description,clicktimes,author')->where($mapnews)->order('create_time DESC')->limit($Page->firstRow . ',' . $Page->listRows)->select();
     $this->assign('news', $news);
     $this->assign('page', $show);
     // 赋值分页输出
     $this->assign('newscat', $newscat);
     $this->display();
 }
Esempio n. 2
0
 public function blogList()
 {
     //SEO
     $ident = "Blog";
     $idents = $this->seo($ident);
     $this->assign("title", $idents['title']);
     $this->assign("keywords", $idents['keywords']);
     $this->assign("description", $idents['description']);
     $BlogModel = M('blog');
     $mapblog['a.is_show'] = array('eq', 1);
     $count = $BlogModel->alias('a')->where($mapblog)->count();
     $Page = new \Think\MyPage($count, 6);
     $show = $Page->show();
     $blogs = $BlogModel->alias('a')->field('a.id,a.type,a.title,a.create_time,a.description,a.clicktimes,a.author,b.images,b.video')->join('LEFT JOIN im_blog_album b ON a.id=b.blog_id')->where($mapblog)->limit($Page->firstRow . ',' . $Page->listRows)->group('a.id')->order('create_time DESC')->select();
     $blogrank = $BlogModel->field('id,title,list_image,description')->where(array('is_show' => 1))->order('clicktimes DESC')->limit(3)->select();
     $this->assign('blogrank', $blogrank);
     $this->assign('blogs', $blogs);
     $this->assign('page', $show);
     $this->display();
 }
Esempio n. 3
0
 public function promoteList()
 {
     //SEO
     $ident = "promoteList";
     $idents = $this->seo($ident);
     $this->assign('productactive', 'active');
     $this->assign("title", $idents['title']);
     $this->assign("keywords", $idents['keywords']);
     $this->assign("description", $idents['description']);
     if (C('ad5')) {
         // 列表页广告
         $modelAdv = M('advs');
         $getListLeftAdv = $modelAdv->field('product_id,is_connect, thumbnail')->where("position_id = '13'")->find();
         $getListRightAdv = $modelAdv->field('product_id,is_connect, thumbnail')->where("position_id = '14'")->find();
         $this->assign('leftAdv', $getListLeftAdv);
         $this->assign('rightAdv', $getListRightAdv);
     }
     $order = "update_time DESC, id DESC";
     if (isset($_GET['by'])) {
         switch ($_GET['by']) {
             case 'all':
                 break;
             case 'time':
                 $order = "add_time DESC";
                 break;
             case 'priceup':
                 $order = "promote_price ASC";
                 break;
             case 'pricedown':
                 $order = "promote_price DESC";
                 break;
             case 'new':
                 $where['is_new'] = 1;
                 break;
         }
     }
     $modelProduct = M('product');
     $where['a.is_on_sale'] = 1;
     $where['a.recycle'] = 0;
     $where['a.is_promote'] = 1;
     $where['b.status'] = 5;
     $getPageCount = $modelProduct->alias('a')->join('LEFT JOIN im_promote b ON a.id = b.product_id')->where($where)->count();
     $getPageSize = 16;
     // 分页处理
     $page = new \Think\MyPage($getPageCount, $getPageSize);
     $productRes = $modelProduct->alias('a')->field('a.id,a.cat_id,a.pro_name,a.pro_subname,a.market_price,a.promote_price,a.list_image,a.is_new,a.is_promote,b.status,b.rate,b.start_time,b.end_time')->join('LEFT JOIN im_promote b ON a.id = b.product_id')->where($where)->order($order)->limit($page->firstRow, $page->listRows)->select();
     $time = array();
     foreach ($productRes as $k => $v) {
         $now = time();
         if ($v['end_time'] > $now) {
             $time[$v['id']] = $v['end_time'] - $now;
         }
         if ($v['start_time'] > $now) {
             $time[$v['id']] = 0;
         }
         if ($v['end_time'] <= $now) {
             $data['is_promote'] = 0;
             $modelProduct->where(array('id' => $v['id']))->save($data);
             unset($productRes[$k]);
         }
     }
     $time = json_encode($time);
     // dump($productRes);
     // dump($time);
     // die;
     $pageShow = $page->show();
     $this->assign('time', $time);
     $this->assign('page', $pageShow);
     $this->assign('productList', $productRes);
     $this->display();
 }
Esempio n. 4
0
 public function completeOrder()
 {
     //SEO
     $ident = "order";
     $idents = $this->seo($ident);
     $this->assign("title", $idents['title']);
     $this->assign("keywords", $idents['keywords']);
     $this->assign("description", $idents['description']);
     $db = M("orders");
     $order = M("order_products");
     $order_detail = M('products_attr');
     $product = M("product");
     $user_id = $_SESSION['user']['userid'];
     $map['order_status'] = array("eq", "4");
     $map['user_id'] = array("eq", $user_id);
     $count = $db->where($map)->count();
     $page = new \Think\MyPage($count, 3);
     $show = $page->show();
     $orderlist = $db->where($map)->order("order_date desc")->limit($page->firstRow . ',' . $page->listRows)->select();
     foreach ($orderlist as &$v) {
         $v['list'] = $order->where("order_id = " . $v['id'])->select();
         foreach ($v['list'] as &$vo) {
             //取商品的信息
             $vo['prolist'] = $product->field('pro_name,id,list_image')->where("id = " . $vo['product_id'])->find();
             //取赠品的信息
             if ($vo['gift_id']) {
                 $vo['prolist']['gift'] = $product->field('pro_name,id,list_image')->where('id = ' . $vo['gift_id'])->find();
             }
         }
         //dump($v['list']);
     }
     // dump($orderlist);
     $this->assign("page", $show);
     $this->assign("orderlist", $orderlist);
     $this->display();
 }
Esempio n. 5
0
 public function applyProduct()
 {
     //SEO
     $ident = "service";
     $idents = $this->seo($ident);
     $this->assign("title", $idents['title']);
     $this->assign("keywords", $idents['keywords']);
     $this->assign("description", $idents['description']);
     $order = M("orders");
     $order_product = M("order_products");
     $product = M("product");
     $sale = M("sale_service");
     $user_id = $_SESSION['user']['userid'];
     $map['user_id'] = array("eq", $user_id);
     $map['order_status'] = array("eq", 4);
     if ($user_id) {
         $count = $order->where($map)->count();
         $page = new \Think\MyPage($count, 6);
         $show = $page->show();
         $orderlist = $order->where($map)->order("order_date desc")->limit($page->firstRow . ',' . $page->listRows)->select();
         foreach ($orderlist as &$v) {
             $v['list'] = $order_product->where("order_id = " . $v['id'])->select();
             foreach ($v['list'] as &$vo) {
                 //取商品的信息
                 $vo['prolist'] = $product->field('pro_name,id,list_image')->where("id = " . $vo['product_id'])->find();
                 $sales = $sale->where("pro_id = " . $vo['product_id'] . " and order_id = " . $v['id'])->find();
                 if ($sale) {
                     $vo['sale'] = $sales;
                 }
             }
             //dump($v['list']);
         }
         // dump($orderlist);
     }
     $this->assign("page", $show);
     $this->assign("orderlist", $orderlist);
     $this->display();
 }