assign([ 'service_configuration' => $customer_service_configuration, 'service_url' => $service_url, 'kefu_token' => $kefu_token, 'userInfo' => json_encode($this->userInfo) ]); return $this->fetch(); } /** * 获取微信客服 */ public function get_service_list() { $where = UtilService::getMore([ ['mer_id', ''], ['page', 1], ['limit', 10] ]); $list = StoreService::get_weixin_service_list($where); return JsonService::successful($list); } /** * crmeb客服token */ public function get_kefu_token() { $kefu_token = SystemConfigService::get('kefu_token'); $data['kefu_token'] = $kefu_token; return JsonService::successful($data); } /**聊天 * @param Request $request * @return mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function service_ing(Request $request) { $params = Request::instance()->param(); $to_uid = $params['to_uid']; if (!isset($to_uid) || empty($to_uid)) $this->failed('未获取到接收用户信息!'); if ($this->uid == $to_uid) $this->failed('您不能进行自言自语!'); //发送用户信息 $now_user = StoreService::where(['uid' => $this->uid])->find(); if (!$now_user) $now_user = $this->userInfo; $this->assign('user', $now_user); //接收用户信息 $to_user = StoreService::where(['uid' => $to_uid])->find(); if (!$to_user) $to_user = User::getUserData($to_uid); if (!$to_user) $this->failed('未获取到接收用户信息!'); $this->assign(['to_user' => $to_user]); return $this->fetch(); } /**聊天记录 * @return mixed */ public function service_new() { return $this->fetch(); } }