chat = $chat; $this->io = $chat->io; $this->socket = $chat->socket; $this->nsp = $chat->nsp; $this->getter = $chat->getter; $this->chatService = $chat->chatService; $this->sender = $chat->sender; } public function on() { // 检测当前 auth 是否是客服 $this->register('check_identify', function ($data, $callback) { // 检查当前管理员登录状态 if (!$this->chatService->isLogin()) { throw new ShoproException('请先登录管理后台'); } $admin = $this->session('auth_user'); // 获取当前管理员的客服身份 $customerServices = $this->chatService->getCustomerServicesByAuth($admin['id'], $this->session('auth')); if (!$customerServices) { throw new ShoproException(''); // 您还不是客服,后台不提示,留空 } // 注册客服事件 $this->customerServiceOn(); $this->sender->successSocket($callback, '验证成功', [ 'customer_services' => $customerServices ]); }); } }