common.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. var browser = {
  2. versions: function() {
  3. var u = navigator.userAgent, app = navigator.appVersion;
  4. return {
  5. trident: u.indexOf('Trident') > -1,
  6. presto: u.indexOf('Presto') > -1,
  7. webKit: u.indexOf('AppleWebKit') > -1,
  8. gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,
  9. mobile: !!u.match(/AppleWebKit.*Mobile.*/),
  10. ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
  11. android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1,
  12. iPhone: u.indexOf('iPhone') > -1,
  13. iPad: u.indexOf('iPad') > -1,
  14. webApp: u.indexOf('Safari') == -1,
  15. weixin: u.indexOf('MicroMessenger') > -1,
  16. qq: u.match(/\sQQ/i) == " qq"
  17. };
  18. }(),
  19. language:(navigator.browserLanguage || navigator.language).toLowerCase()
  20. }
  21. if (browser.versions.mobile || browser.versions.android || browser.versions.ios) {
  22. location.href = '/m' + location.pathname + location.search
  23. }
  24. function backTop() {
  25. var currentScroll = document.documentElement.scrollTop || document.body.scrollTop
  26. if (currentScroll > 0) {
  27. window.requestAnimationFrame(this.backTop)
  28. window.scrollTo(0, currentScroll - (currentScroll / 5))
  29. }
  30. };
  31. $(function() {
  32. var url = 'api.jgkjapp.com'
  33. if (location.host.indexOf('guanwang.llvip.info') >= 0) {
  34. url = 'api.llvip.info'
  35. }
  36. $.post('https://'+url+'/CenterOne/tip/get_ad', {type: 1}, function(data) {
  37. if (data.code === 200) {
  38. var adInfo = data.data
  39. var str = ''
  40. var bgStr = ''
  41. var imgStr = ''
  42. if (adInfo.is_use === '1') {
  43. if (adInfo.tip_bg_status === '1' && adInfo.tip_bg) {
  44. bgStr = 'background-image: '+'url('+adInfo.tip_bg+')'
  45. } else {
  46. bgStr = 'background-color: '+ adInfo.tip_background
  47. }
  48. if (adInfo.tip_qr_code1_status === '1') {
  49. imgStr += '<div class="tip-img-wrap"><img class="tip-qrcode" src="'+adInfo.tip_qr_code1+'" alt=""><img class="tip-qrcode-pop" src="'+adInfo.tip_qr_code1+'" alt=""></div>'
  50. }
  51. if (adInfo.tip_qr_code2_status === '1') {
  52. imgStr += '<div class="tip-img-wrap"><img class="tip-qrcode" src="'+adInfo.tip_qr_code2+'" alt=""><img class="tip-qrcode-pop" src="'+adInfo.tip_qr_code2+'" alt=""></div>'
  53. }
  54. str += '<div class="notice" style="'+bgStr+'">' +
  55. '<p style="font-size: '+adInfo.tip_font_size+'px;color: '+adInfo.tip_font_color+'">'+adInfo.tip_content+'</p>' +
  56. '<div class="notice-right">' +
  57. '<a href="'+adInfo.tip_btn_url+'" target="blank"><button style="background: '+adInfo.tip_btn_color+';color: '+adInfo.tip_btn_font_color+'">'+adInfo.tip_btn_test+'</button></a>' +
  58. imgStr +
  59. '</div>' +
  60. '</div>'
  61. $('#notice').append(str)
  62. $('.float-headers').css('top', '80px')
  63. }
  64. }
  65. })
  66. })