<?php
// +----------------------------------------------------------------------
// | 微版本 [ windsns框架系统]
// +----------------------------------------------------------------------
// | Copyright (c) 2010~2028 http://www.windsns.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.weinuo.net ) 常州微诺信息科技有限公司 ● 微版本开发团队
// +----------------------------------------------------------------------
// | Author: liu21st <3339882530@qq.com>
// +----------------------------------------------------------------------
// | frame: windsns框架；版权所有，侵权必究！
// +----------------------------------------------------------------------
namespace app\m\controller;

use app\common\controller\Frontend;
use think\Hook;
use think\Db;
use think\Request;
class Article extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {
    	$this->view->assign('title', __('文章'));
    	
    	$articlelists = Db::name('article')->alias('a')->join('ws_article_type w','a.article_type = w.article_typeid')-> where(['article_state'=>1])-> order('articleid', 'desc')->paginate(100000); //资讯列表
        $page = $articlelists->render();
    	$this->assign('articlelists', $articlelists);
        $this->assign('page', $page);

        return $this->view->fetch();
    }







 public function read()
    {
    
        $getarticletypeid  =  input('get.worldtype'); 
    	$getarticleid  =  input('get.articleid'); 
    	
    	$sqtypeid   = Db::name('article_type')->where(['article_typeid'=>$getarticletypeid])->find();
    	$sqarticleid = Db::name('article')->where(['articleid'=>$getarticleid])->find();
    	$sqinfosid = Db::name('article')->where(['articleid'=>$getarticleid,'article_type'=>$getarticletypeid])->find();
    	$worldnames =  $sqinfosid['article_little'];
    	$this->view->assign('title', __($worldnames));
        $hotarticlelists = Db::name('article')-> where(['article_state'=>1,'article_hot'=>2])-> order('articleid', 'desc')->paginate(10); 
        $page = $hotarticlelists->render();
    	$this->assign('hotarticlelists', $hotarticlelists);

    	
    	if(!$sqtypeid){
			 return $this->view->fetch('errors_noarticletype');
			 exit;
			}elseif(!$sqarticleid){
				 return $this->view->fetch('errors_noarticleinfos');
				 exit;
			}elseif(!$sqinfosid){
				
				return $this->view->fetch('errors_noarticleinfos');
			 
			 exit;
				
				
			}else{
				
				$sqlliulan = Db::name('article')->where('articleid',$getarticleid)->setInc('article_number', 1);//浏览次数+1
		
			    $windsns_articleinfos = Db::name('article')->where(['articleid'=>$getarticleid,'article_type'=>$getarticletypeid])->select();//打印这个模板产品的信息--- phpwind模板
                $this->assign('windsns_articleinfos', $windsns_articleinfos);
				 return $this->view->fetch('windsns_article');
			}
    	

      
    }



}
