示例#1
0
 public function actionSafety()
 {
     $userBaseInfo = new UserBaseInfo();
     $address = new Address();
     $userTB = new UserThirdPartyLogin();
     $this->layout = 'uc';
     if (!$userBaseInfo->islogin()) {
         return $this->redirect(array('user/login'));
     } else {
         // 获取用户密码信息
         // $cookie = Yii::$app->getRequest()->cookies;
         // $cookieId = $cookie[UserBaseInfo::COOKIE_KEY_ID]->value;
         $session = Yii::$app->session[UserBaseInfo::SESSION_KEY_USER];
         $userId = isset($session['id']) && $session['id'] ? $session['id'] : 0;
         $inforMation = $userBaseInfo->getUserById($userId);
         $addr = $address->getAddress($userId);
         $thirds = $userTB->getBindByUser($userId, UserThirdPartyLogin::BIND_WEB_CHANNEL) ? $userTB->getBindByUser($userId, UserThirdPartyLogin::BIND_WEB_CHANNEL) : [];
         foreach ($thirds as $key => $value) {
             $thirds[$key]['type'] = strtoupper($thirds[$key]['type']);
         }
         $level = 0;
         $item = 5;
         if ($thirds) {
             $level += count($thirds) * 10;
             $item -= count($thirds);
         }
         if ($inforMation['mobile']) {
             $level += 40;
             $item -= 1;
         }
         if ($inforMation['email']) {
             $level += 30;
             $item -= 1;
         }
         $inforMation['level'] = $level;
         $inforMation['item'] = $item;
         $inforMation['addrNum'] = count($addr);
         $inforMation['thirds'] = arrayColumn($thirds, 'type');
         return $this->render('safety', $inforMation);
     }
 }