Esempio n. 1
0
 /**
  * qq回调地址
  */
 public function actionCallbackQq()
 {
     $qq = new QQ();
     $access_token = $qq->qq_callback();
     $zhao_uid = ZCommonSessionFun::get_user_id();
     $zhao_uid = $zhao_uid > 0 ? $zhao_uid : '';
     //         ZCommonSessionFun::set_user_session($access_token);
     //         exit;
     $openid = $qq->get_openid();
     $qq = new QQ($access_token, $openid);
     $user_info = $qq->get_user_info();
     $openid = $openid;
     $bind_info['openid'] = $openid;
     $bind_info['nickname'] = $user_info['nickname'];
     $bind_info['headimgurl'] = $user_info['figureurl'];
     ZCommonSessionFun::set_session('bind_info', $bind_info);
     ZCommonSessionFun::set_session('bind', OauthBind::typeQQ);
     //微信登陆类型
     if (intval($zhao_uid) > 0) {
         return $this->redirect($this->bind_url);
     } else {
         ZCommonSessionFun::set_login_type(OauthBind::typeQQ);
     }
     return $this->redirect($this->bind_url);
     /* $model_User = new User();
        $return = $model_User->userBind('', '', $zhao_uid, $openid, OauthBind::typeQQ, $user_info['nickname'], $user_info['figureurl'],true);
        //绑定成功或者已经绑定
        if($return===0 || $return===1){
            $user = $model_User->operationData['user']->attributes;
            $user['nickname'] = $model_User->operationData['user_profile']->nickname;
            $user['head_image'] = $model_User->operationData['user_profile']->head_image;
            $user['openid'] = $openid;
            ZCommonSessionFun::set_user_session($user);
            //qq登录类型
            if(intval($zhao_uid)>0){
                $bind_url = ['user-profile/bind-list'];
                return $this->redirect($bind_url);
            }else{
                ZCommonSessionFun::set_login_type(OauthBind::typeQQ);
            }
            return $this->redirect([ZCommonSessionFun::urlMyStr]);
        } */
     ZCommonFun::print_r_debug($model_User->operationData);
     exit;
 }
Esempio n. 2
0
 /**
  * Lists all Survey models.
  *
  * @return mixed
  */
 public function actionIndex()
 {
     $this->view->title = '最新';
     if (isset($_GET['code'])) {
         $qq = new QQ();
         $qq->is_mobile = true;
         $access_token = $qq->qq_callback();
         $zhao_uid = ZCommonSessionFun::get_user_id();
         $zhao_uid = $zhao_uid > 0 ? $zhao_uid : '';
         // echo $zhao_uid;
         // ZCommonFun::print_r_debug($access_token);
         // exit;
         $openid = $qq->get_openid();
         $qq = new QQ($access_token, $openid);
         $user_info = $qq->get_user_info();
         $openid = $openid;
         $bind_info['openid'] = $openid;
         $bind_info['nickname'] = $user_info['nickname'];
         $bind_info['headimgurl'] = $user_info['figureurl'];
         ZCommonSessionFun::set_session('bind_info', $bind_info);
         ZCommonSessionFun::set_session('bind', OauthBind::typeQQ);
         //微信登陆类型
         if (intval($zhao_uid) > 0) {
             return $this->redirect($this->bind_url);
         } else {
             ZCommonSessionFun::set_login_type(OauthBind::typeQQ);
         }
         return $this->redirect($this->bind_url);
         /* $model_User = new User();
                     $return = $model_User->userBind('', '', $zhao_uid, $openid, OauthBind::typeQQ, $user_info['nickname'], $user_info['figureurl'], true);
                     // 绑定成功或者已经绑定
                     if ($return === 0 || $return === 1) {
                         $user = $model_User->operationData['user']->attributes;
                         $user['nickname'] = $model_User->operationData['user_profile']->nickname;
                         $user['head_image'] = $model_User->operationData['user_profile']->head_image;
                         $user['openid'] = $openid;
                         ZCommonSessionFun::set_user_session($user);
                         // qq登录类型
                         if (intval($zhao_uid) > 0) {
         
                             $bind_url = [
                                 'user-profile/bind-list'
                             ];
                             return $this->redirect($bind_url);
                         } else {
                             ZCommonSessionFun::set_login_type(OauthBind::typeQQ);
                         }
                         return $this->redirect([
                             ZCommonSessionFun::urlMyStr
                         ]);
                     } */
         ZCommonFun::print_r_debug($model_User->operationData);
         exit;
     }
     $sort = Yii::$app->request->get('sort', 0);
     $this->view->title = $sort > 0 ? '最新' : '最热';
     if ($sort < 1) {
         $this->view->title = ZController::$site_name . ' : 可以自己创建测试的网站';
     } else {
         $this->view->title = ZController::$site_name . ' : 最新';
     }
     $this->layout = false;
     $queryParams = Yii::$app->request->queryParams;
     $queryParams['SurverySearch']['is_publish'] = 1;
     if (isset($_POST['SurverySearch']['title'])) {
         $queryParams['SurverySearch']['title'] = $_POST['SurverySearch']['title'];
     }
     $search = false;
     if (isset($queryParams['SurverySearch']['title'])) {
         $search = $queryParams['SurverySearch']['title'];
     }
     $cache_key_arr = $queryParams;
     $cache_key_arr['sort'] = $sort;
     $cache_key = ZCache::array_to_key($cache_key_arr);
     $cache_data = Yii::$app->cache->get($cache_key);
     // echo 1,'<br/>';
     // 缓存存在,跳转到缓存label
     if ($cache_data) {
         goto cache;
     }
     // echo 2,'<br/>';
     $searchModel = new SurverySearch();
     $query = $searchModel->query($queryParams);
     $count = $query->count();
     // 分页
     $pagination = new Pagination();
     // 每页现实数量
     $pagination->pageSize = $this->pageSize;
     // 总数量
     $pagination->totalCount = $count;
     $offset = $pagination->getOffset();
     $limit = $pagination->getLimit();
     $query->offset($offset);
     $query->limit($limit);
     $op_name = '';
     // 最新
     if ($sort > 0) {
         $query->orderBy(['created' => SORT_DESC]);
         $op_name = '最新';
     } else {
         $op_name = '最热';
         $query->orderBy(['answer_count' => SORT_DESC]);
     }
     $a_models = $query->all();
     $pageCount = $pagination->getPageCount();
     $page = Yii::$app->request->get('page', 0);
     $model_SurveyOperation = new SurveyOperation();
     $models_SurveyOperation = $model_SurveyOperation->getIsTop();
     // 要缓存的数据
     $cache_data = ['models_SurveyOperation' => $models_SurveyOperation, 'searchModel' => $searchModel, 'a_models' => $a_models, 'pagination' => $pagination, 'sort' => $sort, 'op_name' => $op_name, 'search' => $search];
     Yii::$app->cache->set($cache_key, $cache_data, ZCache::HOME_PAGE_TIMEOUT);
     cache:
     // echo 3,'<br/>';
     // exit;
     // echo $pageCount,'=',$page+1;
     // ZCommonFun::print_r_debug($pagination);
     return $this->render('index2', $cache_data);
 }