Beispiel #1
0
 protected function ajaxSuccess($data = null, $status = 1000, $msg = null)
 {
     if (!is_array($data)) {
         $msg = $data;
     }
     \Think\RestTool::instance()->success($data, $status, $msg);
 }
 /**
  * 后台用户登录
  */
 public function login($username = null, $password = null, $verify = null)
 {
     if (IS_POST) {
         //登录验证
         /* 检测验证码 */
         /*if(!check_verify($verify)){
               \Think\RestTool::instance()->error('验证码输入错误!');
           }*/
         $type = I('post.type');
         if (empty($username) || empty($password)) {
             \Think\RestTool::instance()->error('用户名和密码都不能为空!');
         }
         /* 调用UC登录接口登录 */
         $user = new UserApi();
         $userInfo = $user->login($username, $password, $type, true);
         if ($userInfo['status'] == 'ok') {
             $is_forver = true;
             $user->setUserCache($userInfo['msg'], $is_forver);
             //设置用户缓存
             \Think\RestTool::instance()->success(array(), 1000, '登陆成功!');
         } else {
             \Think\RestTool::instance()->error($userInfo['msg']);
         }
     } else {
         if (is_login()) {
             $this->redirect('Index/index');
         } else {
             /* 读取数据库中的配置 */
             $config = S('DB_CONFIG_DATA');
             if (!$config) {
                 $config = D('Config')->lists();
                 S('DB_CONFIG_DATA', $config);
             }
             C($config);
             //添加配置
             $this->display();
         }
     }
 }