判断分享是不是微信

// 检查是否是微信分享

function isWeixin(){
  var ua = navigator.userAgent.toLowerCase();  //获取用户端信息
  if(ua.indexOf('micromessenger')>0){  //检测特殊字符串"micromessenger"的位置
    return true;
  }else{
    return false;
  }
}

function isShowWeiXin(){
  if(isWeixin()){
    document.getElementById('mcover').style.display='block';  //如果是微信,则显示微信遮罩层
   }else{
    var url = "http://common.culihui.com/extImage/download/pro/android_clh_portal.apk";
    statistics(url);
  }
}

function isIphone(){
  if(isWeixin()){
    document.getElementById('mcover').style.display='block';
  }else{
    var url = "https://itunes.apple.com/cn/app/cu-li-hui/id988262340?mt=8";
  statistics(url);
}
}

function GetQueryString(name){
  var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
  var r = window.location.search.substr(1).match(reg);
  if(r!=null){
    return unescape(r[2]);
  } else{
    return null;
  }
}

function statistics(url){
  var equipment = GetQueryString("equipment");
  var source = GetQueryString("source");
  $.ajax({
    url: "statistics.jhtml",
    type: "GET",
    data: {equipment: equipment, source: source},
    success: function() {
    window.location.href = url;
  },
  error: function(){
    return;
  }
  });
}

posted @ 2016-06-30 15:59  #料  阅读(390)  评论(0编辑  收藏  举报