在 js 中写这个来判断

    1. window.onload = function() {
    2. $(function() {
    3. //判断手机环境
    4. var u = navigator.userAgent, app = navigator.appVersion;
    5. var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
    6. var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    7. var isiosapp = u.indexOf('Safari') == -1 && u.indexOf('Language') == -1 && u.indexOf('MicroMessenger') == -1;
    8. var isanapp = u.indexOf('igetapp') > -1;
    9. function is_weixn(){
    10. var ua = navigator.userAgent.toLowerCase();
    11. if(ua.match(/MicroMessenger/i)=="micromessenger"){
    12. return true;
    13. } else {
    14. return false;
    15. };
    16. };
    17. //图片懒加载
    18. $('.lazyload').lazyload();
    19. if(isiOS && !isiosapp && !is_weixn()) {
    20. //IOS LIU IOS 的操作
    21. $('.btn').click(function(){
    22. window.location.href = 'http://ttts.besttoptoday.com/pay/hyzfZc?ucid=BZSFSLHQIH';
    23. })
    24. } else if(isAndroid && !isanapp && !is_weixn()) {
    25. //android liu
    26. $('.btn').click(function(){
    27. window.location.href = 'http://ttts.besttoptoday.com/pay/hyzfZc?ucid=BZSFSLHQIH';
    28. })
    29. } else if(is_weixn()) {
    30. //weixin
    31. $('.btn').click(function(){
    32. window.location.href = 'http://ttts.besttoptoday.com/pay/hyzfZc?ucid=BZSFSLHQIH';
    33. })
    34. } else if(isiOS && isiosapp && !is_weixn()) {
    35. // ios app
    36. $('.btn').hide();
    37. } else if(isAndroid && isanapp && !is_weixn()) {
    38. //android app
    39. $('.btn').hide();
    40. /* $('.read_btn').click(function(){
    41. window.local_obj.runOnAndroidJS_SpecialColum('134');
    42. }) */
    43. }
    44. if(isAndroid && isanapp){
    45. function toptodayandroid(top){
    46. var bb = top;
    47. $(".bbh_p").text(bb);
    48. if(bb>=43){
    49. var bt = document.title;
    50. var fb = document.getElementById('shortTitle').innerText;
    51. var pic = document.getElementById('picture').src;
    52. function chc(){
    53. window.local_obj.getShareInfo(bt,fb,pic);
    54. };
    55. chc();
    56. };
    57. };
    58. }
    59. if(isiOS && screen.height >= 812 && isiosapp && !is_weixn()){
    60. //iphone x app
    61. $('.wrap').css("margin-top","84px"); // iphone x 的最上面会被遮盖
    62. var oMeta = document.createElement('meta');
    63. oMeta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no,viewport-fit=cover';
    64. oMeta.name = 'viewport';
    65. document.getElementsByTagName('head')[0].appendChild(oMeta);
    66. };
    67. // 小手机适配
    68. if ((screen.width <= 340 && !is_weixn())||(screen.width <= 340 && !is_weixn())) {
    69. //iphone 5 app
    70. var oMeta = document.createElement('meta');
    71. oMeta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no,viewport-fit=cover';
    72. oMeta.name = 'viewport';
    73. document.getElementsByTagName('head')[0].appendChild(oMeta);
    74. $(".content").css({marginTop: '4%'})
    75. $(".rule").css({paddingBottom: '0'})
    76. $(".iddv").css({position: 'relative', bottom: '0', marginTop: '10%' })
    77. $(".btn").css({position: 'relative', bottom: '0', marginTop: '3%'})
    78. };
    79. })
    80. }