Base.php
2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* tpshop
* ============================================================================
* * 版权所有 2015-2027 深圳搜豹网络科技有限公司,并保留所有权利。
* 网站地址: http://www.tp-shop.cn
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
* 不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* $Author: IT宇宙人 2015-08-10 $
*/
namespace app\home\controller;
use think\Controller;
use think\Db;
use think\response\Json;
use think\Session;
class Base extends Controller {
public $session_id;
public $cateTrre = array();
/*
* 初始化操作
*/
public function _initialize() {
Session::start();
$this->session_id = session_id(); // 当前的 session_id
define('SESSION_ID',$this->session_id); //将当前的session_id保存为常量,供其它方法调用
// 判断当前用户是否手机
if(isMobile())
cookie('is_mobile','1',3600);
else
cookie('is_mobile','0',3600);
$this->request->isAjax() ? define('IS_AJAX',true) : define('IS_AJAX',false); //
($this->request->method() == 'GET') ? define('IS_GET',true) : define('IS_GET',false); //
($this->request->method() == 'POST') ? define('IS_POST',true) : define('IS_POST',false); //
define('MODULE_NAME',$this->request->module()); // 当前模块名称是
define('CONTROLLER_NAME',$this->request->controller()); // 当前控制器名称
define('ACTION_NAME',$this->request->action()); // 当前操作名称是
$this->public_assign();
}
/**
* 保存公告变量到 smarty中 比如 导航
*/
public function public_assign()
{
$tpshop_config = array();
$tp_config = M('config')->cache(true,TPSHOP_CACHE_TIME)->select();
$this->assign('tpshop_config', $tpshop_config);
}
/*
*
*/
public function ajaxReturn($data){
exit(json_encode($data));
}
}