Chat.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. class Chat {
  3. public static function getChatHtml() {
  4. $web_html = '';
  5. $avatar = get_member_avatar(session('avatar'));
  6. $store_avatar = get_store_logo(session('store_avatar'));
  7. $app_url = BASE_SITE_URL;
  8. $chat_url = CHAT_SITE_URL;
  9. $node_url = config('ds_config.instant_message_gateway_url');
  10. $shop_url = HOME_SITE_URL;
  11. $goods_id = intval(input('goods_id'));
  12. $member_id = session('member_id');
  13. $member_name = session('member_name');
  14. $store_id = session('store_id');
  15. $store_name = session('store_name');
  16. $seller_id = session('seller_id');
  17. $seller_name = session('seller_name');
  18. $seller_is_admin = session('seller_is_admin');
  19. $seller_smt_limits = session('seller_smt_limits');
  20. $controller = request()->controller();
  21. $action = request()->action();
  22. $web_html = <<<EOT
  23. <link href="{$chat_url}/css/chat.css" rel="stylesheet" type="text/css">
  24. <div style="clear: both;"></div>
  25. <div id="web_chat_dialog" style="display: none;float:right;"></div>
  26. <script type="text/javascript">
  27. var APP_SITE_URL = '{$app_url}';
  28. var CHAT_SITE_URL = '{$chat_url}';
  29. var HOME_SITE_URL = '{$shop_url}';
  30. var connect_url = "{$node_url}";
  31. var layout ="{$controller}";
  32. var controller_act = "{$controller}_{$action}";
  33. var chat_goods_id = "{$goods_id}";
  34. var user = {};
  35. user['u_id'] = "{$member_id}";
  36. user['u_name'] = "{$member_name}";
  37. user['s_id'] = "{$store_id}";
  38. user['s_name'] = "{$store_name}";
  39. user['s_avatar'] = "{$store_avatar}";
  40. user['avatar'] = "{$avatar}";
  41. </script>
  42. EOT;
  43. $web_html .= '<link href="' . PLUGINS_SITE_ROOT . '/perfect-scrollbar.min.css" rel="stylesheet" type="text/css">';
  44. $web_html .= '<script type="text/javascript" src="' . PLUGINS_SITE_ROOT . '/perfect-scrollbar.min.js"></script>';
  45. $web_html .= '<script type="text/javascript" src="' . PLUGINS_SITE_ROOT . '/jquery.mousewheel.js"></script>';
  46. $web_html .= '<script type="text/javascript" src="' . PLUGINS_SITE_ROOT . '/jquery.charCount.js" charset="utf-8"></script>';
  47. $web_html .= '<script type="text/javascript" src="' . PLUGINS_SITE_ROOT . '/jquery.smilies.js" charset="utf-8"></script>';
  48. $web_html .= '<script type="text/javascript" src="' . BASE_SITE_ROOT . '/static/chat/js/user.js" charset="utf-8"></script>';
  49. //如果登录了卖家状态
  50. if ($seller_id) {
  51. $seller_smt_limits = '';
  52. if ($seller_smt_limits && is_array($seller_smt_limits)) {
  53. $seller_smt_limits = implode(',', $seller_smt_limits);
  54. }
  55. $web_html .= <<<EOT
  56. <script type="text/javascript">
  57. user['seller_id'] = "{$seller_id}";
  58. user['seller_name'] = "{$seller_name}";
  59. user['seller_is_admin'] = "{$seller_is_admin}";
  60. var smt_limits = "{$seller_smt_limits}";
  61. </script>
  62. EOT;
  63. }
  64. return $web_html;
  65. }
  66. }