欢迎来到亿搜云建站平台,全网营销云系统加盟中心!

海量企业网站模板 · 任您选择

美出特色,精出品质,一切为了企业更好的营销

您现在的位置:首页 > 帮助中心 > 建站帮助 > 基础知识 > 手机端使用QQ临时会话的代码

手机端使用QQ临时会话的代码

2016/3/1 16:41:10 点击:264

QQ临时会话在网页中加一行代码就可以了,那么在手机中如何来添加呢,今天我们就一起来看一个例子,具体的细节如下所示.

function qqcao(){

 var type = undefined;
 var param = "";
 var sid = 2;
 var rawuin = 'qq号码';
 var qsig = "undefined";
 var QQApi = {
  openURL: function(url){
   var i = document.createElement('iframe');
   i.style.display = 'none';
   i.onload = function() { i.parentNode.removeChild(i); };
   i.src = url;
   document.body.appendChild(i);
    
   var returnValue = QQApi.__RETURN_VALUE;
   QQApi.__RETURN_VALUE = undefined;
   return returnValue;
  },
  isAppInstalled: function(scheme) {
   var parameters = {'scheme':scheme};
   var r = QQApi.openURL('jsbridge://app/isInstalled_?p=' + encodeURIComponent(JSON.stringify(parameters)));
   return r ? r.result : null;
  },
  isQQWebView: function(){
   return QQApi.isAppInstalled('mqq') == true;
  },
  __RETURN_VALUE: undefined
 };
 var usa=navigator.userAgent;
 var p;
 var mobile_q_jump = {
  android:"https://play.google.com/store/apps/details?id=com.tencent.mobileqq",
  ios:"itms-apps://itunes.apple.com/cn/app/qq-2011/id444934666?mt=8",
  winphone:"http://www.windowsphone.com/zh-cn/store/app/qq/b45f0a5f-13d8-422b-9be5-c750af531762",
  pc:"http://mobile.qq.com/index.html"
 };
 var isMQ = 0;
 if(typeof type == "undefined") type = 1;
 if(usa.indexOf("Android")>-1){
  p = "android";
 }
 else if(usa.indexOf("iPhone")>-1 || usa.indexOf("iPad")>-1 || usa.indexOf("iPod")>-1){
  p = "ios";
 }
 else if(usa.indexOf("Windows Phone") > -1 || usa.indexOf("WPDesktop") > -1){
  p = "winphone";
 }
 else {
  p = "pc";
 }
 if(p == "ios"){
  //防止循环
  if(history.pushState)
   history.pushState({},"t","#");
  isMQ = QQApi.isQQWebView();
  if (!isMQ){ 
   var sc = document.createElement("script");
   sc.src = "http://__.qq.com/api/qqapi.js";
   sc.onload = function(){
    if(window['iOSQQApi']){
     isMQ =iOSQQApi.device.isMobileQQ(); 
    }
   };
   document.body.appendChild(sc);
  }
 }
 else if(p == "pc" && qsig != "undefined"){
  window.open(qsig,"_self");
 }
 if(type == 1){//手Q
  var isSuccess = true;
  var f = document.createElement("iframe");
  f.style.display = "none";
  document.body.appendChild(f);
  f.onload = function(){
   isSuccess = false;
  };
  if(p == "ios" && sid == 1){
   f.src = "mqqapi://card/show_pslcard?src_type=internal&version=1&uin="+ rawuin +"&card_type=person&source=qrcode";
  }
  if(p == "ios" && sid == 2){//ios并且为群名片
   f.src = "mqqapi://card/show_pslcard?src_type=internal&version=1&uin="+ rawuin +"&card_type=person&source=qrcode";
  }
  else if(p != "pc"){
   var url = window.location.href.split("&");
   f.src = "mqqopensdkapi://bizAgent/qm/qr?url=" + encodeURIComponent(url[0]);
  }
  if(p == "android" && sid == 1){
   f.src = "mqqapi://card/show_pslcard?src_type=internal&version=1&uin="+ rawuin +"&card_type=person&source=qrcode";
  }
  if(p == "android" && sid == 2){//ios并且为群名片
   f.src = "mqqapi://card/show_pslcard?src_type=internal&version=1&uin="+ rawuin +"&card_type=person&source=qrcode";
  }
  var now = Date.now();
  setTimeout( function(){
   if((p == "ios" && !isMQ && Date.now() - now < 2000) || (p == "android" && !isSuccess) || ((p == "winphone" && Date.now() - now < 2000))){
    var jumpUrl = mobile_q_jump[p]; 
    if(jumpUrl) window.open(jumpUrl,"_self");
   }
  } , 1500);
  
 }
}


//pc

tencent://Message/?Uin=QQ号码&websiteName=www.cn-mcn.com&Menu=yes

//带图片 pc
<a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=QQ号码&site=qq&menu=yes"><img border="0" src="http://wpa.qq.com/pa?p=2:QQ号码:41" alt="点击这里给我发消息" title="点击这里给我发消息"/></a>


声明:免责声明:本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,也不承认相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,请发送邮件至:40819446@qq.com进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。本站原创内容未经允许不得转载。

标签:

全部
×

成为 亿搜云平台 代理商!

关注

微信
关注

微信扫一扫
获取最新优惠信息

亿搜云平台公众号

客服

联系
客服

很高兴为您服务
尊敬的用户,欢迎您咨询,我们为新用户准备了优惠好礼。 咨询客服

联系客服:

在线QQ: 40819446

客服电话: 15250286283

售前咨询 售后服务
在线交谈 智能小云

工作时间:

周一至周五: 09:00 - 17:00

WAP

手机
访问

移动端访问
手机上也能选模板

亿搜云平台手机端