给自己的网站添加在线客服代码

如本站右下角的演示,是从jq22拿过用来的,但是源码不完整,而且有很多缺陷,现在完善修复一下,放出来给大家

html代码,请自行修改头像链接:

  1. <div class="livechat-girl animated"> <img class="girl" src="头像的链接">
  2. <div class="livechat-hint rd-notice-tooltip rd-notice-type-success rd-notice-position-left single-line show_hint">
  3. <div class="rd-notice-content">嘿,我来帮您!</div>
  4. </div>
  5. <div class="animated-circles">
  6. <div class="circle c-1"></div>
  7. <div class="circle c-2"></div>
  8. <div class="circle c-3"></div>
  9. </div>
  10. </div>

2018-01-14-13-30-11.png

附上js代码

上面部分是判断是否手机移动端,下面是判断后,针对移动设备点击后跳转到相对应的客服链接

  1. <script>
  2. jQuery( function ( $ ) {
  3. var isMobile = {
  4. Android : function() {
  5. return navigator.userAgent.match(/Android/i) ? true : false;
  6. },
  7. BlackBerry : function() {
  8. return navigator.userAgent.match(/BlackBerry/i) ? true : false;
  9. },
  10. iOS : function() {
  11. return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
  12. },
  13. Windows : function() {
  14. return navigator.userAgent.match(/IEMobile/i) ? true : false;
  15. },
  16. any : function() {
  17. return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
  18. }
  19. };
  20. setInterval(function(){
  21. if($(".animated-circles").hasClass("animated")){
  22. $(".animated-circles").removeClass("animated");
  23. }else{
  24. $(".animated-circles").addClass('animated');
  25. }
  26. },3000);
  27. var wait = setInterval(function(){
  28. $(".livechat-hint").removeClass("show_hint").addClass("hide_hint");
  29. clearInterval(wait);
  30. },4500);
  31. $(".livechat-girl").hover(function(){
  32. clearInterval(wait);
  33. $(".livechat-hint").removeClass("hide_hint").addClass("show_hint");
  34. },function(){
  35. $(".livechat-hint").removeClass("show_hint").addClass("hide_hint");
  36. }).click(function(){
  37. if(isMobile.any()){
  38. window.location.href = 'mqqwpa://im/chat?chat_type=wpa&uin=872872015&version=1&src_type=web&web_src=oicqzone.com';
  39. }else{
  40. window.location.href = 'http://wpa.qq.com/msgrd?v=3&uin=872872015&site=qq&menu=yes';
  41. }
  42. });
  43. } );
  44. </script>

样式代码:

  1. @keyframes scaleToggleOne { 0 {
  2. transform:scale(1);
  3. -webkit-transform:scale(1)
  4. }
  5. 50% {
  6. transform:scale(2);
  7. -webkit-transform:scale(2)
  8. }
  9. 100% {
  10. transform:scale(1);
  11. -webkit-transform:scale(1)
  12. }
  13. }
  14. @keyframes scaleToggleTwo { 0 {
  15. transform:scale(1);
  16. -webkit-transform:scale(1)
  17. }
  18. 20% {
  19. transform:scale(1);
  20. -webkit-transform:scale(1)
  21. }
  22. 60% {
  23. transform:scale(2);
  24. -webkit-transform:scale(2)
  25. }
  26. 100% {
  27. transform:scale(1);
  28. -webkit-transform:scale(1)
  29. }
  30. }
  31. @keyframes scaleToggleThree { 0 {
  32. transform:scale(1);
  33. -webkit-transform:scale(1)
  34. }
  35. 33% {
  36. transform:scale(1);
  37. -webkit-transform:scale(1)
  38. }
  39. 66% {
  40. transform:scale(2);
  41. -webkit-transform:scale(2)
  42. }
  43. 100% {
  44. transform:scale(1);
  45. -webkit-transform:scale(1)
  46. }
  47. }
  48. .animated { -webkit-animation-duration: .5s; animation-duration: .5s; -webkit-animation-fill-mode: both; animation-fill-mode: both }
  49. .livechat-girl { width: 60px; height: 60px; border-radius: 50%; position: fixed; bottom: 5px; right: 40px; opacity: 0; -webkit-box-shadow: 0 5px 10px 0 rgba(35,50,56,.3); box-shadow: 0 5px 10px 0 rgba(35,50,56,.3); z-index: 700; transform: translateY(0); -webkit-transform: translateY(0); -ms-transform: translateY(0); cursor: pointer; -webkit-transition: all 1s cubic-bezier(.86, 0, .07, 1); transition: all 1s cubic-bezier(.86, 0, .07, 1) }
  50. .livechat-girl:focus { outline: 0 }
  51. .livechat-girl.animated { opacity: 1; transform: translateY(-40px); -webkit-transform: translateY(-40px); -ms-transform: translateY(-40px) }
  52. .livechat-girl:after { content: ''; width: 12px; height: 12px; border-radius: 50%; background-image: linear-gradient(to bottom, #26c7fc, #26c7fc); position: absolute; right: 1px; top: 1px; z-index: 50 }
  53. .livechat-girl .girl { position: absolute; top: 0; left: 0; width: 100%; height: auto; z-index: 50;border-radius: 50%; }
  54. .livechat-girl .animated-circles .circle { background: rgba(38,199,252,.25); width: 60px; height: 60px; border-radius: 50%; position: absolute; z-index: 49; transform: scale(1); -webkit-transform: scale(1) }
  55. .livechat-girl .animated-circles.animated .c-1 { animation: 2s scaleToggleOne cubic-bezier(.25, .46, .45, .94) forwards }
  56. .livechat-girl .animated-circles.animated .c-2 { animation: 2.5s scaleToggleTwo cubic-bezier(.25, .46, .45, .94) forwards }
  57. .livechat-girl .animated-circles.animated .c-3 { animation: 3s scaleToggleThree cubic-bezier(.25, .46, .45, .94) forwards }
  58. .livechat-girl.animation-stopped .circle { opacity: 0!important }
  59. .livechat-girl.animation-stopped .circle { opacity: 0!important }
  60. .livechat-girl .livechat-hint { position: absolute; right: 40px; top: 50%; margin-top: -20px; opacity: 0; z-index: 0; -webkit-transition: all .3s cubic-bezier(.86, 0, .07, 1); transition: all .3s cubic-bezier(.86, 0, .07, 1) }
  61. .livechat-girl .livechat-hint.show_hint { -webkit-transform: translateX(-40px); transform: translateX(-40px); opacity: 1 }
  62. .livechat-girl .livechat-hint.hide_hint { opacity: 0; -webkit-transform: translateX(0); transform: translateX(0) }
  63. .livechat-girl .livechat-hint.rd-notice-tooltip { max-width: 1296px!important }
  64. .livechat-girl .livechat-hint.rd-notice-tooltip .rd-notice-content { width: auto; overflow: hidden; text-overflow: ellipsis }
  65. @media only screen and (max-width:1599px) {
  66. .livechat-girl .livechat-hint.rd-notice-tooltip { max-width: 1060px!important }
  67. }
  68. @media only screen and (max-width:1309px) {
  69. .livechat-girl .livechat-hint.rd-notice-tooltip { max-width: 984px!important }
  70. }
  71. @media only screen and (max-width:1124px) {
  72. .livechat-girl .livechat-hint.rd-notice-tooltip { max-width: 600px!important }
  73. }
  74. .rd-notice-tooltip { -webkit-box-shadow: 0 2px 2px rgba(0,0,0,.2); box-shadow: 0 2px 2px rgba(0,0,0,.2); font-size: 14px; border-radius: 3px; line-height: 1.25; position: absolute; z-index: 65; max-width: 350px; opacity: 1 }
  75. .rd-notice-tooltip:after { position: absolute; display: block; content: ''; height: 20px; width: 20px; -webkit-box-shadow: none; box-shadow: none; -webkit-transform: rotate(-45deg); -moz-transform: rotate(-45deg); -ms-transform: rotate(-45deg); -o-transform: rotate(-45deg); transform: rotate(-45deg); -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; z-index: 50 }
  76. .rd-notice-tooltip .rd-notice-content { background: 0; border-radius: 3px; width: 100%; color: #fff; position: relative; z-index: 60; padding: 20px; font-weight: 400; line-height: 1.45 }
  77. .rd-notice-type-success { background-color: #26c7fc; -webkit-box-shadow: 0 5px 10px 0 rgba(38,199,252,.2); box-shadow: 0 5px 10px 0 rgba(38,199,252,.2) }
  78. .rd-notice-type-success .rd-notice-content { background-color: #26c7fc }
  79. .rd-notice-type-success:after { background-color: #26c7fc; -webkit-box-shadow: 0 5px 10px 0 rgba(38,199,252,.2); box-shadow: 0 5px 10px 0 rgba(38,199,252,.2) }
  80. .rd-notice-position-left { margin-left: -20px }
  81. .rd-notice-position-left:after { right: -6px; top: 50%; margin-top: -10px }
  82. .rd-notice-tooltip.single-line .rd-notice-content { height: 40px; padding: 0 20px; line-height: 40px; white-space: nowrap }

把上面的代码放到相对应的位置就可以了,如果是使用自媒体博客Spimes主题的话

分别丢到代码框里面即可

224103313.png

文章由官网发布,如若转载,请注明出处:https://www.veimoz.com/130
5 条评论
7.9k

发表评论

已有 5 条评论

  1. 咪叽数码     Win 10 /    Chrome
    2020-12-30 23:02

    window.open("http://。。。");
    新建窗口打开比较好。。。

    1. AKERS     Win 10 /    Chrome
      2021-03-24 23:18

      @咪叽数码

      手机跳转不了呀

      1. AKERS     Win 10 /    Chrome
        2021-03-25 00:42

        @AKERS

        能跳转了,估计是缓存 判断失误 哈哈哈 这玩意儿没法撤回 尴尬

  2. 大师兄     Win 10 /    Chrome
    2020-04-15 17:20

    :玫瑰::玫瑰:漂亮

  3. 成人之美     Win 10 /    QQ浏览器
    2020-04-15 00:07

    不错,拿走了。

!