public function actionInvitation() { if (\yii::$app->user->isGuest) { $this->redirect(['site/login']); } $model = UcenterMember::find()->where('id=' . Yii::$app->user->id)->one(); $uid = yii::$app->user->id; $invitation_code = UcenterMember::findIdentity($uid)->invitation_code; //被邀请记录(分页) $query = member::getInvite($uid); $pages = new Pagination(['totalCount' => $query->count(), 'pageSize' => 4]); $invitation_log = $query->offset($pages->offset)->limit($pages->limit)->orderBy('id DESC')->all(); $infos_rar = $this->Ucenter(); //用户数据包 return $this->render('invitation', compact("infos_rar", "invitation_code", "model", "invitation_log", "pages")); }
public function actionGindex() { Utils::ensureOpenId(); $openId = Yii::$app->request->get('open_id'); if (($usermodel = UcenterMember::findOne(['openid' => $openId])) !== null) { Yii::$app->user->login($usermodel); } elseif (empty(Yii::$app->user->id)) { return $this->redirect(['site/signin']); } $uid = yii::$app->user->id; $gold = Gold::find()->select('uid,sum(money) as smoney')->where(['uid' => $uid])->asArray()->one(); $allgold = Gold::find()->select('uid,rid,sum(money) as smoney')->where(['uid' => $uid])->asArray()->groupBy('rid')->all(); $invitation_code = UcenterMember::findIdentity($uid)->invitation_code; $goldincome = Income::find()->select('member_id,sum(goldincome) as sincome')->where(['member_id' => $uid])->asArray()->one(); $jssdk = new Jssdk('wx32814d588c44c17c', '23b0f218574551f18db1dc991dbee87f'); $signpack = $jssdk->getSignPackage(); return $this->view('gindex', compact('gold', 'allgold', 'goldincome', 'invitation_code', 'signpack')); }
public function actionInvitation() { if (\yii::$app->user->isGuest) { $this->redirect(['site/login']); } $uid = yii::$app->user->id; $invitation_code = UcenterMember::findIdentity($uid)->invitation_code; $infos_rar = $this->Ucenter(); //用户数据包 return $this->render('invitation', compact("infos_rar", "invitation_code")); }
public function actionSetting() { if (\yii::$app->user->isGuest) { $this->redirect(['site/login']); } $uid = yii::$app->user->id; $is_Authentic = member::isAuthentic($uid); $model = UcenterMember::find()->where("id=" . $uid)->one(); if (isset($_POST['prepassword']) && isset($_POST['newpassword']) && isset($_POST['repeatpassword'])) { $_model = UcenterMember::findIdentity($uid); if (!yii::$app->security->validatePassword($_POST['prepassword'], $_model->password_hash)) { echo '原始密码错误'; exit; } elseif ($_POST['newpassword'] == $_POST['repeatpassword']) { $_model->password_hash = Yii::$app->security->generatePasswordHash($_POST['newpassword']); $app_pwd = md5(sha1($_POST['newpassword']) . time()); $_model->app_pwd = $app_pwd; $_model->save(false); echo '密码修改成功'; exit; } else { echo '两次密码不一致'; exit; } } if (isset($_POST['realname']) && isset($_POST['idcard'])) { $realname = $_POST['realname']; $idcard = $_POST['idcard']; try { $idcard_result = Port::baiduIdentity($idcard); if (!$idcard) { echo '身份认号不匹配,请核对后重新输入'; exit; } } catch (ErrorException $e) { echo '认证失败'; exit; } try { $result = member::authentication($uid, $realname, $idcard); if ($result) { echo '身份认证成功'; exit; } } catch (ErrorException $e) { echo $e->getMessage(); exit; } } if (isset($_POST['UcenterMember']['person_face'])) { $model->person_face = UploadedFile::getInstance($model, 'person_face'); if ($model->person_face) { if ($model->validate()) { $old_face = UcenterMember::findOne(['id' => $uid])->person_face; //旧头像 $init_face = Setting::findOne(['code' => 'img'])->value; //初始头像 $Name = mt_rand(1100, 9900) . time() . '.' . $model->person_face->extension; $model->person_face->saveAs('upload/' . $Name); //保存头像名到数据表 $model->person_face = $Name; if ($model->update()) { //若不是初始头像,删除旧头像。 if ($old_face != $init_face) { @unlink('../web/upload/' . $old_face); } header("Content-type: text/html; charset=utf-8"); echo '<script>alert("头像修改完成~");</script>'; } } } } $infos_rar = $this->Ucenter(); //用户数据包 return $this->render('setting', compact("infos_rar", "model", "model_password", "is_Authentic")); }
public function actionGold() { $uid = yii::$app->user->id; $invitation_code = UcenterMember::findIdentity($uid)->invitation_code; return $this->view('gold', compact('invitation_code')); }