| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace wechat\modules\cp\controllers;
- use yii\web\Controller;
- class BaseController extends Controller
- {
- public $layout = false;
-
- /**
- * json 输出方法
- * @param int $code api code 码 0 失败 1 正常
- * @param array $data 输出信息
- * @param string $msg 提示语
- * @return Response
- */
- public function outJson($code = 0, $data = [], $msg = '')
- {
- $data = [
- 'code' => $code,
- 'message' => $msg,
- 'data' => $data,
- 'timestamp' => time(),
- ];
- return $this->asJson($data);
- }
- /**
- * 弹窗提醒
- * @param $message
- * @param string $url
- * @param bool $isAlert
- * @param string $title
- */
- public function alertMsg($message, $url='', $isAlert=true, $title='提示')
- {
- echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>',$title,'</title></head><body>';
- echo '<script type="text/javascript">';
- echo $isAlert?'alert("'.$message.'");':'';
- echo $url==''?'history.back();':'location.href="'.$url.'";';
- echo '</script>';
- echo '</body></html>';
- exit();
- }
- }
|