| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace pt\controllers;
- use bizHd\saas\services\StaffService;
- use common\components\jwt;
- use common\components\stringUtil;
- use common\components\util;
- use Yii;
- class StaffController extends BaseController
- {
- public $guestAccess = ['login'];
- public function actionLogin()
- {
- //登陆并拿到token ssh 2019.11.23
- $get = Yii::$app->request->get();
- $mobile = isset($get['mobile']) ? $get['mobile'] : 0;
- if (stringUtil::isMobile($mobile) == false) {
- util::fail('请填写正常的手机号');
- }
- $password = isset($get['password']) && !empty($get['password']) ? $get['password'] : '';
- if (empty($password)) {
- util::fail('请输入密码');
- }
- $staff = StaffService::getByCondition(['mobile' => $mobile]);
- if (password_verify($password, $staff['password']) == false) {
- util::fail('密码错误');
- }
- $staffId = $staff['id'];
- //获取token
- $token = jwt::getNewToken($staffId);
- util::success(['token' => $token]);
- }
- //登陆员工的详情 ssh 2019.12.26
- public function actionLoginDetail()
- {
- $detail = StaffService::getDetail($this->staffId);
- util::success($detail);
- }
- }
|