<?php
// +----------------------------------------------------------------------
// | WindSNS 、微版本 :国内领先企业级社交开源SNS框架系统
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2028 http://windsns.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 常州微诺信息科技有限公司 http://www.weinuo.net
// +----------------------------------------------------------------------
// | E-mail: open@weinuo.net
// +----------------------------------------------------------------------
// | 微信客服: weinuogroup
// +----------------------------------------------------------------------
namespace app\index\controller;
use app\common\controller\Frontend;
use think\Config;
use think\Hook;
use think\Db;
use think\Request;

class Article extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';
	/**
	 * 协议
	 * @author   常州微诺信息科技有限公司
	 * @blog     http://www.weinuo.net
	 * @version  0.0.1
	 * @datetime 2020-03-03
	 */
    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(20); //资讯列表
        $page = $articlelists->render();
    	$this->assign('articlelists', $articlelists);
        $this->assign('page', $page);
        $hotarticlelists = Db::name('article')-> where(['article_state'=>1,'article_hot'=>2])-> order('articleid', 'desc')->paginate(10); //资讯列表
        $page = $hotarticlelists->render();
    	$this->assign('hotarticlelists', $hotarticlelists);
        return $this->view->fetch('windsns_index');
    }
	/**
	 * 协议
	 * @author   常州微诺信息科技有限公司
	 * @blog     http://www.weinuo.net
	 * @version  0.0.1
	 * @datetime 2020-03-03
	 */
    public function read()
    {
        $getarticletypeid  =  input('get.worldtype');
    	$getarticleid  =  input('get.articleid'); 
    	$sqtypeid   = Db::name('article_type')->where(['article_typeid'=>$getarticletypeid])->find();//查询该栏目类型ID是否存在
    	$sqarticleid = Db::name('article')->where(['articleid'=>$getarticleid])->find();//查询该文章ID是否存在
    	$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');
			}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');
			}
      
    }

	/**
	 * 协议
	 * @author   常州微诺信息科技有限公司
	 * @blog     http://www.weinuo.net
	 * @version  0.0.1
	 * @datetime 2020-03-03
	 */
}
