getRequest()->get(); $login = isset($request['login']) ? trim($request['login']) : ''; return $this->render('open', [ 'login' => $login, ]); } /** * 真实账户提交 * @return \yii\web\Response */ public function actionOpensave() { $model = new OpenForm(); if (Yii::$app->getRequest()->getIsPost()) { $data = Yii::$app->getRequest()->post(); $data['card0'] = UploadedFile::getInstanceByName('card0'); $data['card1'] = UploadedFile::getInstanceByName('card1'); $model->setAttributes($data); if ($model->open()) { return $this->asJson([ 'isSuccess' => true, 'msg' => '操作成功', ]); } else { return $this->asJson([ 'isSuccess' => false, 'msg' => Html::errorSummary($model, ['header' => '']), ]); } } return $this->asJson([ 'isSuccess' => false, 'msg' => 'invalid request', ]); } /** * 代理商(ib)开户页面 */ public function actionIbOpenIndex() { $this->layout = "pop.php"; $request = \Yii::$app->getRequest()->get(); $login = isset($request['login']) ? trim($request['login']) : ''; $member = new MemberApi(); $id = $member->getIdByLogin($login)['data']; $id = isset($id) ? intval($id) : ''; return $this->render('ib-open-index', [ 'login' => $login, 'id' => $id, ]); } /** * 代理商(ib)开户 * @return \yii\web\Response */ public function actionIbOpenSave() { $model = new IbOpenForm(); if (Yii::$app->getRequest()->getIsPost()) { $data = Yii::$app->getRequest()->post(); $data['card0'] = UploadedFile::getInstanceByName('card0'); $data['card1'] = UploadedFile::getInstanceByName('card1'); $model->bank_district = $data['bank_district']; $model->ref_id = $data['ref_id']; $model->setAttributes($data); if ($model->complete()) { return $this->asJson([ 'isSuccess' => true, 'msg' => '操作成功', ]); } else { return $this->asJson([ 'isSuccess' => false, 'msg' => Html::errorSummary($model, ['header' => '']), ]); } } return $this->asJson([ 'isSuccess' => false, 'msg' => 'invalid request', ]); } /** * 模拟账户申请界面 * @return string */ public function actionOpendemo() { return $this->render('opendemo'); } /** * 模拟账户提交 * @return \yii\web\Response */ public function actionOpendemosave() { $model = new OpenDemoForm(); if (Yii::$app->getRequest()->getIsPost()) { $data = Yii::$app->getRequest()->post(); $model->setAttributes($data); if ($model->openDemo()) { return $this->asJson([ 'isSuccess' => true, 'msg' => '账户:' . $model->getLogin() . ', 密码:' . $model->getPassword(), ]); } else { return $this->asJson([ 'isSuccess' => false, 'msg' => Html::errorSummary($model, ['header' => '']), ]); } } return $this->asJson([ 'isSuccess' => false, 'msg' => 'invalid request', ]); } /** * 登录界面 * @return string */ public function actionLogin() { return $this->renderPartial('login'); } /** * 登录验证函数 * @return \yii\web\Response */ public function actionLoginPost() { $model = new LoginForm(); if (Yii::$app->getRequest()->getIsPost()) { $model->setAttributes(Yii::$app->getRequest()->post()); $model->type = MemberIdentity::MEMBER_TYPE_USER; if ($model->login()) { return $this->asJson([ 'isSuccess' => true, ]); } } return $this->asJson([ 'isSuccess' => false, 'msg' => Html::errorSummary($model, ['header' => '']), ]); } /** * ibLogin页面 * @return string */ public function actionIblogin() { return $this->renderPartial('iblogin'); } /** * ibLogin验证 * @return \yii\web\Response */ public function actionIbloginPost() { $model = new LoginForm(); if (Yii::$app->getRequest()->getIsPost()) { $model->setAttributes(Yii::$app->getRequest()->post()); $model->type = MemberIdentity::MEMBER_TYPE_IB; if ($model->login()) { return $this->asJson([ 'isSuccess' => true, ]); } } return $this->asJson([ 'isSuccess' => false, 'msg' => Html::errorSummary($model, ['header' => '']), ]); } /** * 不同忘记密码页面 * @return string|\yii\web\Response */ public function actionPwd() { $data = Yii::$app->getRequest()->get(); $t = isset($data['type']) ? $data['type'] : ''; if ($t == 1) { return $this->renderPartial('pwd-t-1'); } elseif ($t == 2) { return $this->renderPartial('pwd-t-2'); } else { return $this->asJson([ 'isSuccess' => false, ]); } } /** * 发送邮件 * @return \yii\web\Response */ public function actionPwd1() { $pwdForm = new PwdForm(); if (Yii::$app->getRequest()->getIsPost()) { $pwdForm->setAttributes(Yii::$app->getRequest()->post()); if ($pwdForm->changePwd()) { return $this->asJson([ 'isSuccess' => true, ]); } } return $this->asJson([ 'isSuccess' => false, 'msg' => Html::errorSummary($pwdForm, ['header' => '']), ]); } /** * 修改密码页面 * @return string */ public function actionModifyPwd() { $request = Yii::$app->request; $username = $request->get('username'); $type = $request->get('type'); return $this->renderPartial('modify-pwd', [ 'username' => $username, 'type' => $type, ]); } /** * 修改密码验证 * @return \yii\web\Response */ public function actionModifyPwd1() { $pwdForm = new RePwdForm(); if (Yii::$app->getRequest()->getIsPost()) { $pwdForm->setAttributes(Yii::$app->getRequest()->post()); if ($pwdForm->modifyPwd1()) { return $this->asJson([ 'isSuccess' => true, ]); } } return $this->asJson([ 'isSuccess' => false, 'msg' => Html::errorSummary($pwdForm, ['header' => '']), ]); } /** * 登出 */ public function actionLogout() { $redirectAction = 'login'; $referrer = Yii::$app->request->referrer; if ($referrer) { $urlInfo = parse_url($referrer); if (!empty($urlInfo['path'])) { if (strpos($urlInfo['path'], '/ib') === 0) { Yii::$app->set('user', Yii::$app->get('userIb')); $redirectAction = 'iblogin'; } } } Yii::$app->user->logout(false); $this->redirect([$redirectAction]); } /** * 检测邮箱是否已注册 * @return \yii\web\Response */ public function actionCheckemailexist() { $email = trim(Yii::$app->getRequest()->get('email')); if ($email == '') { return $this->asJson(false); } $api = new MemberApi(); $result = $api->checkEmailExist($email); if ($result['code'] == 1) { return $this->asJson(true); } else { return $this->asJson(false); } } /** * 检测身份证是否已注册 * @return \yii\web\Response */ public function actionCheckidnoexist() { $idNo = trim(Yii::$app->getRequest()->get('id_card')); if ($idNo == '') { return $this->asJson(false); } $api = new MemberApi(); $result = $api->checkIdNoExist($idNo); if ($result['code'] == 1) { return $this->asJson(true); } else { return $this->asJson(false); } } /** * 发送验证码 * @return \yii\web\Response */ public function actionSendsms() { $mobile = trim(Yii::$app->getRequest()->post('mobile')); if ($mobile == '') { return $this->asJson([ 'isSuccess' => false, 'msg' => '请输入手机号码', ]); } $api = new SmsApi(); $result = $api->sendCode($mobile); if ($result['code'] == 0) { return $this->asJson([ 'isSuccess' => false, 'msg' => '太频繁,稍后', ]); } return $this->asJson([ 'isSuccess' => true, 'msg' => '发送成功', ]); } /** * 发送验证码 * @return \yii\web\Response */ public function actionSendmail() { $email= trim(Yii::$app->getRequest()->post('email')); if ($email == '') { return $this->asJson([ 'isSuccess' => false, 'msg' => '请输入电子邮箱', ]); } $api = new MemberApi(); $result = $api->checkEmailExist($email); if ($result['code'] == 0) { return $this->asJson([ 'isSuccess' => false, 'msg' => '邮箱已存在', ]); } $api = new MailApi(); $result = $api->sendMailCode($email); if ($result['code'] == 0) { return $this->asJson([ 'isSuccess' => false, 'msg' => '太频繁,稍后', //'msg' => $result['message'], ]); } return $this->asJson([ 'isSuccess' => true, 'msg' => '发送成功', ]); } /** * 模拟账户申请 用户协议 * @return string */ public function actionAgreement() { return $this->render('agreement'); } }