StaffController.php 1.1 KB

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