kefu.html 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <title>客服系统</title>
  2. <div class="layui-card layadmin-header">
  3. <div class="layui-breadcrumb" lay-filter="breadcrumb">
  4. <a lay-href="">主页</a>
  5. <a><cite>高级</cite></a>
  6. <a><cite>通讯系统</cite></a>
  7. <a><cite>客服系统</cite></a>
  8. </div>
  9. </div>
  10. <div class="layui-fluid">
  11. <div class="layui-row layui-col-space15">
  12. <div class="layui-col-md12">
  13. <div class="layui-card">
  14. <div class="layui-card-header">面板外的操作示例</div>
  15. <div class="layui-card-body">
  16. <div class="layui-btn-container LAY-senior-im-chat-demo">
  17. <button class="layui-btn" data-type="kefu1">在线客服一</button>
  18. <button class="layui-btn" data-type="kefu2">在线客服二</button>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. <script>
  26. layui.use(['admin', 'layim'], function(){
  27. var $ = layui.$
  28. ,admin = layui.admin
  29. ,element = layui.element
  30. ,router = layui.router();
  31. var layim = layui.layim;
  32. layim.config({
  33. init: {
  34. //配置客户信息
  35. mine: {
  36. "username": "访客" //我的昵称
  37. ,"id": "100000123" //我的ID
  38. ,"status": "online" //在线状态 online:在线、hide:隐身
  39. ,"remark": "在深邃的编码世界,做一枚轻盈的纸飞机" //我的签名
  40. ,"avatar": "//res.layui.com/images/fly/avatar/00.jpg" //我的头像
  41. }
  42. }
  43. //开启客服模式
  44. ,brief: true
  45. });
  46. var active = {
  47. kefu1: function(){
  48. layim.chat({
  49. name: '在线客服一' //名称
  50. ,type: 'kefu' //聊天类型
  51. ,avatar: '//tp1.sinaimg.cn/5619439268/180/40030060651/1' //头像
  52. ,id: 1111111 //定义唯一的id方便你处理信息
  53. })
  54. }
  55. ,kefu2: function(){
  56. layim.chat({
  57. name: '在线客服二' //名称
  58. ,type: 'kefu' //聊天类型
  59. ,avatar: '//tp1.sinaimg.cn/5619439268/180/40030060651/1' //头像
  60. ,id: 2222222 //定义唯一的id方便你处理信息
  61. });
  62. }
  63. }
  64. $('.LAY-senior-im-chat-demo .layui-btn').on('click', function(){
  65. var type = $(this).data('type');
  66. active[type] ? active[type].call(this) : '';
  67. });
  68. });
  69. </script>