PassportController.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\alliance\controllers;
  8. use app\modules\alliance\controllers\BaseController;
  9. use app\modules\alliance\models\AuthLoginForm;
  10. use app\modules\alliance\models\LoginForm;
  11. use yii\base\BaseObject;
  12. class PassportController extends BaseController
  13. {
  14. /**
  15. * 平台小程序手机号登录(平台个人中心,店铺个人中心)
  16. */
  17. public function actionPlatformAuthPhone()
  18. {
  19. $form = new AuthLoginForm();
  20. $form->attributes = all_params();
  21. $form->store_id = get_store_id();
  22. return $this->asJson($form->platformPhoneAuth());
  23. }
  24. /**
  25. * 登录
  26. * @return \yii\web\Response
  27. * @throws \yii\base\Exception
  28. */
  29. public function actionLogin()
  30. {
  31. $form = new \app\modules\client\models\v1\LoginForm();
  32. $form->scenario = get_params('_platform') ?: post_params('_platform');
  33. $form->attributes = all_params();
  34. $form->store_id = get_store_id();
  35. return $this->asJson($form->login());
  36. }
  37. public function actionEditPassword()
  38. {
  39. $form = new AuthLoginForm();
  40. $form->attributes = all_params();
  41. $form->store_id = get_store_id();
  42. return $this->asJson($form->editPassword());
  43. }
  44. public function actionCode()
  45. {
  46. $form = new AuthLoginForm();
  47. $form->attributes = all_params();
  48. $form->store_id = get_store_id();
  49. return $this->asJson($form->code());
  50. }
  51. /**
  52. * 发送验证码
  53. * @return \yii\web\Response
  54. */
  55. public function actionSendCode()
  56. {
  57. $form = new LoginForm();
  58. $form->phone = post_params('phone');
  59. $form->store_id = get_store_id();
  60. if (trim(post_params('code_type')) == LoginForm::TYPE_VERIFY_CODE_LOGIN) {
  61. return $this->asJson($form->sendCode(LoginForm::CACHE_KEY_SMS_LOGIN));
  62. } else if (trim(post_params('code_type')) == LoginForm::TYPE_VERIFY_CODE_BIND) {
  63. return $this->asJson($form->sendCode(LoginForm::CACHE_KEY_BIND_PHONE));
  64. } else {
  65. return $this->asJson(['code' => 1, 'msg' => '参数不正确']);
  66. }
  67. }
  68. }