/** * Displays homepage. * * @return mixed */ public function actionIndex() { $info = ZCommonSessionFun::get_user_session(); ZCommonFun::print_r_debug($info); exit; return $this->render('index'); }
/** * Updates an existing UserProfile model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionBind() { if (ZCommonSessionFun::get_user_id() < 1) { $url = Yii::$app->urlManager->createUrl([ZCommonSessionFun::urlLoginUserStr]); return $this->redirect($url); } $this->view->title = '个人设置'; $this->layout = false; $condition['uid'] = ZCommonSessionFun::get_user_id(); $model = $model = UserProfile::findOne($condition); if (!$model) { $model = new UserProfile(); } $model->uid = ZCommonSessionFun::get_user_id(); $model->birthday = $model->birthday ? date('Y-m-d', strtotime($model->birthday)) : ''; $load = $model->load(Yii::$app->request->post()); if ($load && $model->save()) { $userInfo = ZCommonSessionFun::get_user_session(); $userInfo['profile'] = $model->attributes; $userInfo['nickname'] = $model->nickname; $userInfo['head_image'] = $model->head_image; $userInfo['intro'] = $model->intro; ZCommonSessionFun::set_user_session($userInfo); return $this->redirect(['bind']); } else { return $this->render('_form', ['model' => $model]); } }
/** * 初始化 * @see \yii\base\Object::init() */ public function init() { parent::init(); $sessionUser = ZCommonSessionFun::get_user_session(); //没有设置用户信息 if (ZCommonSessionFun::get_user_id() > 0 && !isset($sessionUser['is_set_profile'])) { $sessionUser['is_set_profile'] = true; $model_UserProfile = new UserProfile(); $condition['uid'] = ZCommonSessionFun::get_user_id(); if ($model_UserProfile = $model_UserProfile->findOne($condition)) { $sessionUser['head_image'] = $model_UserProfile->getHeadImage0(); $sessionUser['nickname'] = $model_UserProfile->getNickname0(); $sessionUser['intro'] = $model_UserProfile->getIntro0(); ZCommonSessionFun::set_user_session($sessionUser); } } }
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use common\models\UserProfile; use common\z\ZCommonSessionFun; use common\z\ZCommonFun; use common\z\ZController; use common\models\OauthBind; /* @var $this yii\web\View */ /* @var $model common\models\UserProfile */ /* @var $form yii\widgets\ActiveForm */ $this->title = ZController::$site_name . '账号绑定'; echo $this->renderFile(__DIR__ . '/../layouts/head.php'); $sessionUser = ZCommonSessionFun::get_user_session(); $const_BindList = OauthBind::constBindList(); $model_OauthBind = new OauthBind(); $uid = ZCommonSessionFun::get_user_id(); $user_BindList = $model_OauthBind->getUserBindList($uid); // ZCommonFun::print_r_debug($user_BindList); // $user_BindList = ZCommonFun::listData($user_BindList, 'id', 'type'); // ZCommonFun::print_r_debug($user_BindList); ?> <link href="./bag-test/bootstrap/bootstrap.min.css" rel="stylesheet" media="screen"> <link href="./bag-test/bootstrap/datetimepicker.css" rel="stylesheet" media="screen"> <style> div.notice { margin: 0;