| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426 |
- <?php
- namespace backend\controllers;
- use backend\models\forms\CompleteMaterialForm;
- use backend\models\forms\IbOpenForm;
- use backend\models\forms\LoginForm;
- use backend\models\forms\OpenDemoForm;
- use backend\models\forms\OpenForm;
- use backend\models\forms\PwdForm;
- use backend\models\forms\RePwdForm;
- use backend\models\MailApi;
- use backend\models\MemberApi;
- use backend\models\SmsApi;
- use Yii;
- use yii\helpers\Html;
- use yii\web\Controller;
- use yii\web\UploadedFile;
- use backend\models\MemberIdentity;
- class AccountController extends Controller
- {
- public $enableCsrfValidation = false;
- /**
- * 真实账户申请界面
- * @return string
- */
- public function actionOpen()
- {
- $request = \Yii::$app->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');
- //var_dump($data);die;
- $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' => '太频繁,稍后',
- ]);
- }
- return $this->asJson([
- 'isSuccess' => true,
- 'msg' => '发送成功',
- ]);
- }
- /**
- * 模拟账户申请 用户协议
- * @return string
- */
- public function actionAgreement()
- {
- return $this->render('agreement');
- }
- }
|