<?php 
/**
*	前端引入
*/
class frontClassAction extends ActionNot
{
	
	public $agentrs;
	
	private function getInshow()
	{
		$key = $this->get('key');
		if(!$key)return returnerror('引入客服“'.TITLE.'”key不能为空');
		$ars = m('agent')->getone("`agentkey`='$key' and `status`=1");
		if(!$ars)return returnerror('引入客服“'.TITLE.'”key不存在');
		$this->agentrs = $ars;
		return returnsuccess();
	}
	
	public function defaultAction()
	{
		$barr = $this->getInshow();
		$msg  = '';
		if($barr['success']){
			$this->showfrontscript();
		}else{
			$msg = $barr['msg'];
		}
		$this->assign('showmsg', $msg);
	}
	private function showfrontscript(){
		$this->assign('agentrs', $this->agentrs);
	}
	
	
	/**
	*	客户咨询窗口
	*/
	public function chatAction()
	{
		$barr = $this->getInshow();
		$lang = $this->get('lang','zh-CN');
		if(!$barr['success'])return $barr['msg'];
		$this->assign('agentrs', $this->agentrs);
		$this->assign('lang', $lang);
	}
}