예제 #1
0
 public function actionOff()
 {
     Utils::ensureOpenId();
     $request = wanhunet::$app->request;
     if ($request->isPost) {
         if (($model = MemberOther::findOne(['row' => $request->post('open_id'), 'table' => MemberOther::TABLE_WECHAT])) !== null) {
             /** @var MemberOther $model */
             $model->row = '';
             $model->save();
         }
         wanhunet::$app->user->logout();
         return $this->goBack(['info' => "解绑成功"], Url::to(['site/signin']));
     }
     return $this->view('off');
 }
예제 #2
0
 public function actionEnter()
 {
     Utils::ensureOpenId();
     if (wanhunet::$app->user->isGuest) {
         if (($openId = wanhunet::$app->request->get('open_id')) !== null && ($model = MemberOther::findOne(['row' => $openId, 'table' => MemberOther::TABLE_WECHAT])) !== null) {
             /** @var MemberOther $model */
             if (Yii::$app->user->login($model->member, 3600 * 24 * 30)) {
                 return $this->redirect(Url::to(['main']));
             }
         }
         return $this->redirect(Url::to(['signin']));
     } else {
         return $this->redirect(Url::to(['signin']));
     }
 }
예제 #3
0
 public function acShare()
 {
     $errorAuth = '';
     if (wanhunet::$app->user->isGuest) {
         Utils::ensureOpenId();
         $url = wanhunet::$app->urlManager->createAbsoluteUrl(['share/index']);
         $errorAuth = '您未绑定微信账号';
         if (($openId = wanhunet::$app->request->get('open_id')) !== null && ($model = MemberOther::findOne(['row' => $openId, 'table' => MemberOther::TABLE_WECHAT])) !== null) {
             /** @var MemberOther $model */
             if (\Yii::$app->user->login($model->member, 3600 * 24 * 30)) {
                 $url = wanhunet::$app->urlManager->createAbsoluteUrl(['share/index/' . wanhunet::app()->member->invitation]);
                 $errorAuth = '';
             }
         }
     } else {
         $url = wanhunet::$app->urlManager->createAbsoluteUrl(['share/index/' . wanhunet::app()->member->invitation]);
     }
     $url = wanhunet::app()->wechat->getOauth2AuthorizeUrl($url, 'authorize', 'snsapi_userinfo');
     if (wanhunet::$app->request->get('qrcode', null) !== null) {
         Utils::qrcode(urldecode(wanhunet::$app->request->get('qrcode', urlencode($url))));
     }
     return $this->view('share', ['url' => $url, 'errorAuth' => $errorAuth]);
 }