ctms/pms-admin/controllers/CityController.php
2025-04-10 23:19:13 +08:00

55 lines
1.3 KiB
PHP
Executable File

<?php
/**
* @Author: fm453
* @Date: 2018-08-17 19:39:41
* @Last Modified by: fm453
* @Last Modified time: 2021-04-28 17:20:59
* @Email: fm453@lukegzs.com
*/
namespace backend\controllers;
use Yii;
use yii\data\Pagination;
use yii\helpers\Url;
// use backend\models\Citys;
class CityController extends \yii\web\Controller
{
//替代常规的_construct 析构函数;其他方法调用前执行
public function init()
{
parent::init();
$session = Yii::$app->session;
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
$session->set('pid',(int)$_GET['pid']);
}
$pid = $session->get('pid');
if(!$pid){
$url = Url::toRoute('/index/index');
return $this->redirect($url);
}
}
//主界面
public function actionIndex()
{
return $this->render('../layouts/dev',[]);
}
public function actionSelect()
{
$citys = Yii::$app->params['citys'];
$pager = new Pagination(['totalCount' =>count($citys), 'pageSize' => '20']);
$callback = isset($_GET['callback']) ? $_GET['callback'] : 'city';
$search=[];
return $this->render('select',[
'citys'=>$citys,
'pager' => $pager,
'search'=>$search,
'callback'=>$callback
]);
}
}