StaffController.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace pt\controllers;
  3. use bizHd\saas\services\StaffService;
  4. use common\components\jwt;
  5. use common\components\stringUtil;
  6. use common\components\util;
  7. use Yii;
  8. class StaffController extends BaseController
  9. {
  10. public $guestAccess = ['login'];
  11. public function actionLogin()
  12. {
  13. //登陆并拿到token ssh 2019.11.23
  14. $get = Yii::$app->request->get();
  15. $mobile = isset($get['mobile']) ? $get['mobile'] : 0;
  16. if (stringUtil::isMobile($mobile) == false) {
  17. util::fail('请填写正常的手机号');
  18. }
  19. $password = isset($get['password']) && !empty($get['password']) ? $get['password'] : '';
  20. if (empty($password)) {
  21. util::fail('请输入密码');
  22. }
  23. $staff = StaffService::getByCondition(['mobile' => $mobile]);
  24. if (password_verify($password, $staff['password']) == false) {
  25. util::fail('密码错误');
  26. }
  27. $staffId = $staff['id'];
  28. //获取token
  29. $token = jwt::getNewToken($staffId);
  30. util::success(['token' => $token]);
  31. }
  32. //登陆员工的详情 ssh 2019.12.26
  33. public function actionLoginDetail()
  34. {
  35. $detail = StaffService::getDetail($this->staffId);
  36. util::success($detail);
  37. }
  38. }