public function apply($license = 0)
 {
     //添加申请
     $group_id = get_user_auth_group();
     $d_apply = D('Apply');
     if (IS_POST) {
         //已认证用户访问此处提示正在认证或者认证成功
         if (in_array($group_id, array(2, 4))) {
             //已经认证成功
             $this->ajaxReturnHandle(1, '您已经认证成功');
         } else {
             //取出未禁用的申请
             $res = $d_apply->where(array('uid' => $this->mid, 'status' => array('neq', -1)))->find();
             $data['license'] = intval($license);
             $data['uid'] = $this->mid;
             $data['createtime'] = time();
             $data['status'] = 2;
             if ($group_id == 1) {
                 $to_auth = 2;
             } elseif ($group_id == 3) {
                 $to_auth = 4;
             }
             $data['to_auth'] = $to_auth;
             if (!$res) {
                 //表示未申请,新增一条申请记录
                 $res = $d_apply->add($data);
                 if ($res) {
                     $this->ajaxReturnHandle(1, '您已经成功提交申请,请等待审核');
                 } else {
                     $this->ajaxReturnHandle(0, '提交认证失败');
                 }
             } else {
                 if ($res['status'] == 2) {
                     //表示待审核,提示待审核
                     $this->ajaxReturnHandle(0, '正在审核中');
                 } else {
                     if ($res['status'] == 0) {
                         //表示拒绝审核,修改审核资料,若修改成功,将状态改为2,即为待审核
                         $data['status'] = 2;
                         $res = $d_apply->where(array('uid' => $this->mid))->save($data);
                         if ($res) {
                             $this->ajaxReturnHandle(1, '重新提交申请成功,请等待审核');
                         } else {
                             $this->ajaxReturnHandle(0, '重新提交申请失败');
                         }
                     }
                 }
             }
         }
     } else {
         //展示页面
         /*
          * 获得当前用户的身份信息,个人还是机构,若已认证,提示恭喜,若未认证,展示申请页面
          * 根据 group_id 在视图中控制样式
          */
         $this->_setTab('apply');
         $apply = $d_apply->alias('a')->where(array('a.uid' => $this->mid, 'a.status' => array('neq', -1)))->field('b.identity,a.status,a.license')->join('__BROKER__ b on a.uid = b.uid', 'left')->find();
         $identity_table = array(1 => '经纪人', 2 => '中介', 3 => '楼盘');
         $apply['shenfen'] = $identity_table[$apply['identity']];
         $this->assign('group_id', $group_id);
         $this->assign('apply', $apply);
         $this->display();
     }
 }
 protected function user_info()
 {
     $user_info = query_user(array('avatar128', 'nickname', 'uid', 'mobile'));
     $user_info['auth_role'] = get_user_auth_group();
     $this->assign('user_info', $user_info);
 }