1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2018/2/26/026
- * Time: 15:48
- */
- namespace frontend\base;
- use Yii;
- use yii\web\Response;
- class ToJson
- {
- public static function JsonData($data,$count = 0)
- {
- Yii::$app->response->format=Response::FORMAT_JSON;
- $list['rows'] = !empty($data) ? $data : [] ;
- $list['total'] = $count;
- return $list;
- }
- /*
- * code 返回状态码 100=失败 200=成功
- * msg 返回信息
- * data 返回数据 格式 array
- * */
- public static function JsonCode($code,$msg = '',$data = null)
- {
- Yii::$app->response->format=Response::FORMAT_JSON;
- $list['code'] = $code;
- $list['msg'] = $msg;
- $list['data'] = $data;
- return $list;
- }
- }
|